From f9001779751f83dc8a10e478bfecb4d8dd5f964c Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Sun, 22 May 2011 11:11:40 +0100 Subject: [PATCH] Wordpress 3.1 Signed-off-by: Edward Z. Yang --- license.txt | 9 +- readme.html | 14 +- wp-activate.php | 8 +- wp-admin/admin-ajax.php | 494 +- wp-admin/admin-header.php | 61 +- wp-admin/admin.php | 58 +- wp-admin/comment.php | 17 +- wp-admin/css/colors-classic-rtl.css | 2 +- wp-admin/css/colors-classic-rtl.dev.css | 29 +- wp-admin/css/colors-classic.css | 2 +- wp-admin/css/colors-classic.dev.css | 431 +- wp-admin/css/colors-fresh.css | 2 +- wp-admin/css/colors-fresh.dev.css | 76 +- wp-admin/css/dashboard-rtl.css | 2 +- wp-admin/css/dashboard-rtl.dev.css | 3 - wp-admin/css/dashboard.css | 2 +- wp-admin/css/dashboard.dev.css | 10 +- wp-admin/css/global.css | 2 +- wp-admin/css/global.dev.css | 42 +- wp-admin/css/ie.css | 2 +- wp-admin/css/ie.dev.css | 3 +- wp-admin/css/install.css | 2 +- wp-admin/css/install.dev.css | 1 + wp-admin/css/login.css | 2 +- wp-admin/css/login.dev.css | 16 +- wp-admin/css/media.css | 2 +- wp-admin/css/media.dev.css | 4 +- wp-admin/css/ms.css | 2 +- wp-admin/css/ms.dev.css | 23 +- wp-admin/css/nav-menu.css | 2 +- wp-admin/css/nav-menu.dev.css | 24 +- wp-admin/css/plugin-install.css | 2 +- wp-admin/css/plugin-install.dev.css | 5 - wp-admin/css/press-this.css | 2 +- wp-admin/css/press-this.dev.css | 10 +- wp-admin/css/theme-editor.css | 2 +- wp-admin/css/theme-editor.dev.css | 8 + wp-admin/css/theme-install-rtl.css | 1 + wp-admin/css/theme-install-rtl.dev.css | 41 + wp-admin/css/theme-install.css | 2 +- wp-admin/css/theme-install.dev.css | 12 +- wp-admin/css/widgets-rtl.css | 2 +- wp-admin/css/widgets-rtl.dev.css | 4 + wp-admin/css/wp-admin-rtl.css | 2 +- wp-admin/css/wp-admin-rtl.dev.css | 86 +- wp-admin/css/wp-admin.css | 2 +- wp-admin/css/wp-admin.dev.css | 4246 ++++++++++------- wp-admin/custom-background.php | 12 +- wp-admin/custom-header.php | 30 +- wp-admin/edit-attachment-rows.php | 239 - wp-admin/edit-comments.php | 418 +- wp-admin/edit-form-advanced.php | 35 +- wp-admin/edit-form-comment.php | 2 +- wp-admin/edit-link-categories.php | 237 - wp-admin/edit-link-category-form.php | 92 - wp-admin/edit-link-form.php | 2 + wp-admin/edit-post-rows.php | 34 - wp-admin/edit-tag-form.php | 19 +- wp-admin/edit-tags.php | 303 +- wp-admin/edit.php | 357 +- wp-admin/export.php | 259 +- wp-admin/images/blue-grad.png | Bin 160 -> 337 bytes wp-admin/images/button-grad-active-vs.png | Bin 152 -> 0 bytes wp-admin/images/button-grad-vs.png | Bin 155 -> 0 bytes wp-admin/images/ed-bg-vs.gif | Bin 291 -> 444 bytes wp-admin/images/fav-arrow-vs-rtl.gif | Bin 338 -> 0 bytes wp-admin/images/fav-arrow-vs.gif | Bin 338 -> 0 bytes wp-admin/images/fav-top-vs.gif | Bin 101 -> 0 bytes wp-admin/images/list-vs.png | Bin 1151 -> 0 bytes wp-admin/images/menu-bits-rtl-vs.gif | Bin 2102 -> 1555 bytes wp-admin/images/menu-bits-vs.gif | Bin 1984 -> 1448 bytes wp-admin/images/menu-dark-rtl-vs.gif | Bin 0 -> 245 bytes wp-admin/images/menu-dark-vs.gif | Bin 0 -> 245 bytes wp-admin/images/screen-options-right-up.gif | Bin 125 -> 0 bytes wp-admin/images/screen-options-right.gif | Bin 178 -> 0 bytes wp-admin/images/screen-options-toggle-vs.gif | Bin 0 -> 152 bytes wp-admin/images/screen-options-toggle.gif | Bin 0 -> 205 bytes wp-admin/images/sort.gif | Bin 0 -> 54 bytes wp-admin/images/upload-classic.png | Bin 0 -> 1631 bytes wp-admin/images/upload-fresh.png | Bin 0 -> 1051 bytes wp-admin/images/visit-site-button-grad-vs.gif | Bin 193 -> 0 bytes wp-admin/images/visit-site-button-grad.gif | Bin 136 -> 0 bytes wp-admin/images/widgets-arrow-vs.gif | Bin 0 -> 213 bytes wp-admin/images/wp-logo-vs.png | Bin 2367 -> 2324 bytes wp-admin/import.php | 34 +- wp-admin/includes/admin.php | 7 +- wp-admin/includes/bookmark.php | 87 +- .../includes/class-wp-comments-list-table.php | 557 +++ .../includes/class-wp-filesystem-direct.php | 36 +- .../includes/class-wp-links-list-table.php | 186 + wp-admin/includes/class-wp-list-table.php | 894 ++++ .../includes/class-wp-media-list-table.php | 374 ++ .../includes/class-wp-ms-sites-list-table.php | 340 ++ .../class-wp-ms-themes-list-table.php | 361 ++ .../includes/class-wp-ms-users-list-table.php | 276 ++ .../class-wp-plugin-install-list-table.php | 237 + .../includes/class-wp-plugins-list-table.php | 453 ++ .../includes/class-wp-posts-list-table.php | 1019 ++++ .../includes/class-wp-terms-list-table.php | 379 ++ .../class-wp-theme-install-list-table.php | 185 + .../includes/class-wp-themes-list-table.php | 241 + wp-admin/includes/class-wp-upgrader.php | 83 +- .../includes/class-wp-users-list-table.php | 319 ++ wp-admin/includes/comment.php | 34 +- wp-admin/includes/dashboard.php | 255 +- wp-admin/includes/deprecated.php | 508 +- wp-admin/includes/export.php | 449 +- wp-admin/includes/file.php | 108 +- wp-admin/includes/image-edit.php | 11 +- wp-admin/includes/import.php | 4 +- wp-admin/includes/internal-linking.php | 124 + wp-admin/includes/list-table.php | 104 + wp-admin/includes/manifest.php | 2 - wp-admin/includes/media.php | 243 +- wp-admin/includes/menu.php | 215 + wp-admin/includes/meta-boxes.php | 96 +- wp-admin/includes/misc.php | 109 +- wp-admin/includes/ms.php | 250 +- wp-admin/includes/nav-menu.php | 20 +- wp-admin/includes/plugin-install.php | 293 +- wp-admin/includes/plugin.php | 252 +- wp-admin/includes/post.php | 227 +- wp-admin/includes/schema.php | 14 +- wp-admin/includes/taxonomy.php | 81 +- wp-admin/includes/template.php | 2654 ++--------- wp-admin/includes/theme-install.php | 281 +- wp-admin/includes/theme.php | 180 +- wp-admin/includes/update-core.php | 24 +- wp-admin/includes/update.php | 77 +- wp-admin/includes/upgrade.php | 60 +- wp-admin/includes/user.php | 524 +- wp-admin/includes/widgets.php | 31 +- wp-admin/index-extra.php | 2 +- wp-admin/index.php | 37 +- wp-admin/install-helper.php | 20 +- wp-admin/install.php | 2 +- wp-admin/js/common.dev.js | 47 +- wp-admin/js/common.js | 2 +- wp-admin/js/custom-background.dev.js | 2 +- wp-admin/js/custom-background.js | 2 +- wp-admin/js/dashboard.dev.js | 11 +- wp-admin/js/dashboard.js | 2 +- wp-admin/js/edit-comments.dev.js | 86 +- wp-admin/js/edit-comments.js | 2 +- wp-admin/js/editor.dev.js | 47 +- wp-admin/js/editor.js | 2 +- wp-admin/js/farbtastic.js | 155 +- wp-admin/js/inline-edit-post.dev.js | 91 +- wp-admin/js/inline-edit-post.js | 2 +- wp-admin/js/list-table.dev.js | 337 ++ wp-admin/js/list-table.js | 1 + wp-admin/js/media-upload.dev.js | 13 +- wp-admin/js/media-upload.js | 2 +- wp-admin/js/media.dev.js | 8 + wp-admin/js/media.js | 2 +- wp-admin/js/nav-menu.dev.js | 24 +- wp-admin/js/nav-menu.js | 2 +- wp-admin/js/plugin-install.dev.js | 26 +- wp-admin/js/plugin-install.js | 2 +- wp-admin/js/post.dev.js | 19 +- wp-admin/js/post.js | 2 +- wp-admin/js/revisions-js.php | 3 + wp-admin/js/tags.dev.js | 8 +- wp-admin/js/tags.js | 2 +- wp-admin/js/theme.dev.js | 55 + wp-admin/js/theme.js | 1 + wp-admin/js/user-profile.dev.js | 1 + wp-admin/js/user-profile.js | 2 +- wp-admin/js/utils.dev.js | 22 - wp-admin/js/utils.js | 2 +- wp-admin/js/widgets.dev.js | 2 +- wp-admin/js/widgets.js | 2 +- wp-admin/link-category.php | 100 - wp-admin/link-manager.php | 247 +- wp-admin/link-parse-opml.php | 4 +- wp-admin/link.php | 2 +- wp-admin/maint/repair.php | 6 +- wp-admin/media-upload.php | 9 +- wp-admin/media.php | 23 +- wp-admin/menu-header.php | 5 +- wp-admin/menu.php | 369 +- wp-admin/moderation.php | 3 +- wp-admin/ms-admin.php | 66 +- wp-admin/ms-delete-site.php | 2 +- wp-admin/ms-edit.php | 627 +-- wp-admin/ms-options.php | 308 +- wp-admin/ms-sites.php | 738 +-- wp-admin/ms-themes.php | 89 +- wp-admin/ms-upgrade-network.php | 74 +- wp-admin/ms-users.php | 368 +- wp-admin/my-sites.php | 6 +- wp-admin/nav-menus.php | 27 +- wp-admin/network.php | 93 +- wp-admin/network/admin.php | 22 + wp-admin/network/edit.php | 482 ++ wp-admin/network/index-extra.php | 13 + wp-admin/network/index.php | 62 + wp-admin/network/menu.php | 73 + wp-admin/network/plugin-editor.php | 16 + wp-admin/network/plugin-install.php | 19 + wp-admin/network/plugins.php | 16 + wp-admin/network/profile.php | 16 + wp-admin/network/settings.php | 277 ++ wp-admin/network/setup.php | 16 + wp-admin/network/site-info.php | 166 + wp-admin/network/site-new.php | 145 + wp-admin/network/site-settings.php | 150 + wp-admin/network/site-themes.php | 179 + wp-admin/network/site-users.php | 308 ++ wp-admin/network/sites.php | 124 + wp-admin/network/theme-editor.php | 16 + wp-admin/network/theme-install.php | 19 + wp-admin/network/themes.php | 241 + wp-admin/network/update-core.php | 16 + wp-admin/network/update.php | 19 + wp-admin/network/upgrade.php | 86 + wp-admin/network/user-edit.php | 16 + wp-admin/network/user-new.php | 94 + wp-admin/network/users.php | 96 + wp-admin/options-discussion.php | 15 +- wp-admin/options-general.php | 33 +- wp-admin/options-head.php | 5 + wp-admin/options-media.php | 10 +- wp-admin/options-permalink.php | 67 +- wp-admin/options-privacy.php | 6 +- wp-admin/options-reading.php | 39 +- wp-admin/options-writing.php | 25 +- wp-admin/options.php | 12 +- wp-admin/plugin-editor.php | 35 +- wp-admin/plugin-install.php | 65 +- wp-admin/plugins.php | 554 +-- wp-admin/post-new.php | 25 +- wp-admin/post.php | 17 +- wp-admin/press-this.php | 64 +- wp-admin/profile.php | 2 +- wp-admin/revision.php | 2 +- wp-admin/setup-config.php | 8 +- wp-admin/sidebar.php | 128 - wp-admin/theme-editor.php | 67 +- wp-admin/theme-install.php | 79 +- wp-admin/themes.php | 270 +- wp-admin/tools.php | 5 +- wp-admin/update-core.php | 86 +- wp-admin/update.php | 39 +- wp-admin/upgrade.php | 26 +- wp-admin/upload.php | 501 +- wp-admin/user-edit.php | 86 +- wp-admin/user-new.php | 238 +- wp-admin/user/admin.php | 23 + wp-admin/user/index-extra.php | 12 + wp-admin/user/index.php | 12 + wp-admin/user/menu.php | 24 + wp-admin/user/profile.php | 12 + wp-admin/user/user-edit.php | 12 + wp-admin/users.php | 241 +- wp-admin/widgets.php | 20 +- wp-app.php | 10 +- wp-atom.php | 4 +- wp-comments-post.php | 2 +- wp-commentsrss2.php | 4 +- wp-config-sample.php | 6 +- wp-content/plugins/akismet/admin.php | 302 +- wp-content/plugins/akismet/akismet.css | 7 + wp-content/plugins/akismet/akismet.js | 10 + wp-content/plugins/akismet/akismet.php | 1031 ++-- wp-content/plugins/akismet/readme.txt | 67 +- wp-content/plugins/akismet/widget.php | 90 + wp-content/plugins/hello.php | 27 +- wp-content/themes/twentyten/archive.php | 6 +- wp-content/themes/twentyten/attachment.php | 106 +- wp-content/themes/twentyten/editor-style.css | 75 +- wp-content/themes/twentyten/footer.php | 7 +- wp-content/themes/twentyten/functions.php | 45 +- wp-content/themes/twentyten/header.php | 6 +- wp-content/themes/twentyten/index.php | 2 +- .../themes/twentyten/languages/twentyten.pot | 221 +- .../themes/twentyten/loop-attachment.php | 117 + wp-content/themes/twentyten/loop-page.php | 36 + wp-content/themes/twentyten/loop-single.php | 67 + wp-content/themes/twentyten/loop.php | 23 +- .../themes/twentyten/onecolumn-page.php | 21 +- wp-content/themes/twentyten/page.php | 26 +- wp-content/themes/twentyten/rtl.css | 5 +- wp-content/themes/twentyten/sidebar.php | 2 +- wp-content/themes/twentyten/single.php | 57 +- wp-content/themes/twentyten/style.css | 103 +- wp-feed.php | 4 +- wp-includes/admin-bar.php | 378 ++ wp-includes/author-template.php | 134 +- wp-includes/bookmark.php | 9 +- wp-includes/cache.php | 16 +- wp-includes/canonical.php | 91 +- wp-includes/capabilities.php | 229 +- wp-includes/category-template.php | 424 +- wp-includes/category.php | 16 - wp-includes/class-IXR.php | 433 +- wp-includes/class-http.php | 103 +- wp-includes/class-json.php | 76 +- wp-includes/class-oembed.php | 2 +- wp-includes/class-pop3.php | 5 +- wp-includes/class-simplepie.php | 2 +- wp-includes/class-snoopy.php | 14 +- wp-includes/class-wp-admin-bar.php | 236 + wp-includes/class-wp-ajax-response.php | 138 + wp-includes/class-wp-error.php | 212 + wp-includes/class-wp-http-ixr-client.php | 91 + wp-includes/class-wp-walker.php | 399 ++ wp-includes/class-wp-xmlrpc-server.php | 3527 ++++++++++++++ wp-includes/class-wp.php | 611 +++ wp-includes/class.wp-dependencies.php | 24 +- wp-includes/class.wp-scripts.php | 13 +- wp-includes/classes.php | 1700 ------- wp-includes/comment-template.php | 64 +- wp-includes/comment.php | 309 +- wp-includes/cron.php | 51 +- wp-includes/css/admin-bar-rtl.css | 1 + wp-includes/css/admin-bar-rtl.dev.css | 94 + wp-includes/css/admin-bar.css | 1 + wp-includes/css/admin-bar.dev.css | 298 ++ wp-includes/css/jquery-ui-dialog.css | 1 + wp-includes/css/jquery-ui-dialog.dev.css | 143 + wp-includes/default-embeds.php | 2 +- wp-includes/default-filters.php | 41 +- wp-includes/default-widgets.php | 49 +- wp-includes/deprecated.php | 86 +- wp-includes/feed-rss2.php | 2 +- wp-includes/feed.php | 6 +- wp-includes/formatting.php | 201 +- wp-includes/functions.php | 385 +- wp-includes/functions.wp-scripts.php | 16 +- wp-includes/functions.wp-styles.php | 14 + wp-includes/general-template.php | 284 +- wp-includes/images/admin-bar-sprite-rtl.png | Bin 0 -> 732 bytes wp-includes/images/admin-bar-sprite.png | Bin 0 -> 737 bytes wp-includes/images/wpmini-blue.png | Bin 0 -> 958 bytes wp-includes/js/admin-bar.dev.js | 140 + wp-includes/js/admin-bar.js | 1 + wp-includes/js/autosave.dev.js | 11 +- wp-includes/js/autosave.js | 2 +- .../js/imgareaselect/jquery.imgareaselect.js | 2 +- wp-includes/js/jcrop/jquery.Jcrop.js | 164 +- wp-includes/js/jquery/jquery.js | 291 +- wp-includes/js/jquery/jquery.query.js | 11 + .../js/jquery/jquery.serialize-object.js | 31 + wp-includes/js/jquery/suggest.js | 2 +- wp-includes/js/jquery/ui.button.js | 25 + wp-includes/js/jquery/ui.core.js | 19 +- wp-includes/js/jquery/ui.dialog.js | 41 +- wp-includes/js/jquery/ui.draggable.js | 49 +- wp-includes/js/jquery/ui.droppable.js | 26 +- wp-includes/js/jquery/ui.mouse.js | 17 + wp-includes/js/jquery/ui.position.js | 16 + wp-includes/js/jquery/ui.resizable.js | 46 +- wp-includes/js/jquery/ui.selectable.js | 21 +- wp-includes/js/jquery/ui.sortable.js | 59 +- wp-includes/js/jquery/ui.tabs.js | 34 +- wp-includes/js/jquery/ui.widget.js | 15 + wp-includes/js/json2.js | 12 +- wp-includes/js/l10n.dev.js | 23 + wp-includes/js/l10n.js | 1 + wp-includes/js/swfupload/handlers.js | 2 +- wp-includes/js/swfupload/license.txt | 32 + wp-includes/js/tinymce/blank.htm | 9 - wp-includes/js/tinymce/langs/wp-langs-en.js | 6 +- wp-includes/js/tinymce/langs/wp-langs.php | 6 +- .../plugins/fullscreen/editor_plugin.js | 2 +- .../tinymce/plugins/fullscreen/fullscreen.htm | 3 +- .../plugins/inlinepopups/editor_plugin.js | 2 +- .../inlinepopups/skins/clearlooks2/window.css | 15 +- .../tinymce/plugins/inlinepopups/template.htm | 2 +- .../js/tinymce/plugins/media/css/content.css | 6 - .../js/tinymce/plugins/media/css/media.css | 16 - .../js/tinymce/plugins/media/editor_plugin.js | 1 - .../js/tinymce/plugins/media/img/flash.gif | Bin 241 -> 0 bytes .../tinymce/plugins/media/img/flv_player.swf | Bin 11668 -> 0 bytes .../tinymce/plugins/media/img/quicktime.gif | Bin 303 -> 0 bytes .../tinymce/plugins/media/img/realmedia.gif | Bin 439 -> 0 bytes .../tinymce/plugins/media/img/shockwave.gif | Bin 387 -> 0 bytes .../js/tinymce/plugins/media/img/trans.gif | Bin 43 -> 0 bytes .../plugins/media/img/windowsmedia.gif | Bin 415 -> 0 bytes .../js/tinymce/plugins/media/js/embed.js | 73 - .../js/tinymce/plugins/media/js/media.js | 630 --- .../js/tinymce/plugins/media/media.htm | 822 ---- .../js/tinymce/plugins/paste/editor_plugin.js | 2 +- .../js/tinymce/plugins/paste/pastetext.htm | 5 +- .../js/tinymce/plugins/paste/pasteword.htm | 5 +- .../js/tinymce/plugins/safari/blank.htm | 1 - .../tinymce/plugins/safari/editor_plugin.js | 1 - .../spellchecker/classes/utils/JSON.php | 6 +- .../tinymce/plugins/spellchecker/config.php | 3 +- .../plugins/spellchecker/editor_plugin.js | 339 +- .../plugins/spellchecker/includes/general.php | 6 +- .../js/tinymce/plugins/spellchecker/rpc.php | 4 +- .../tinymce/plugins/tabfocus/editor_plugin.js | 2 +- .../plugins/wordpress/editor_plugin.dev.js | 141 +- .../plugins/wordpress/editor_plugin.js | 2 +- .../plugins/wpdialogs/editor_plugin.dev.js | 97 + .../plugins/wpdialogs/editor_plugin.js | 1 + .../tinymce/plugins/wpdialogs/js/popup.dev.js | 432 ++ .../js/tinymce/plugins/wpdialogs/js/popup.js | 1 + .../plugins/wpeditimage/editor_plugin.dev.js | 52 +- .../plugins/wpeditimage/editor_plugin.js | 2 +- .../tinymce/plugins/wplink/css/wplink-rtl.css | 1 + .../plugins/wplink/css/wplink-rtl.dev.css | 54 + .../js/tinymce/plugins/wplink/css/wplink.css | 1 + .../tinymce/plugins/wplink/css/wplink.dev.css | 163 + .../plugins/wplink/editor_plugin.dev.js | 60 + .../tinymce/plugins/wplink/editor_plugin.js | 1 + .../plugins/wplink/img/toggle-arrow.png | Bin 0 -> 3226 bytes .../tinymce/plugins/wplink/js/wplink.dev.js | 455 ++ .../js/tinymce/plugins/wplink/js/wplink.js | 1 + .../js/tinymce/themes/advanced/about.htm | 8 +- .../js/tinymce/themes/advanced/anchor.htm | 4 +- .../js/tinymce/themes/advanced/charmap.htm | 5 +- .../tinymce/themes/advanced/color_picker.htm | 6 +- .../themes/advanced/editor_template.js | 2 +- .../js/tinymce/themes/advanced/image.htm | 8 +- .../js/tinymce/themes/advanced/img/icons.gif | Bin 11505 -> 11794 bytes .../js/tinymce/themes/advanced/js/anchor.js | 14 +- .../js/tinymce/themes/advanced/js/charmap.js | 10 + .../js/tinymce/themes/advanced/js/image.js | 4 +- .../themes/advanced/js/source_editor.js | 18 +- .../js/tinymce/themes/advanced/link.htm | 10 +- .../themes/advanced/skins/default/content.css | 10 +- .../themes/advanced/skins/default/dialog.css | 7 +- .../themes/advanced/skins/default/ui.css | 11 +- .../themes/advanced/skins/o2k7/content.css | 10 +- .../themes/advanced/skins/o2k7/dialog.css | 5 +- .../tinymce/themes/advanced/skins/o2k7/ui.css | 8 +- .../themes/advanced/skins/wp_theme/ui.css | 6 +- .../tinymce/themes/advanced/source_editor.htm | 5 +- wp-includes/js/tinymce/tiny_mce.js | 2 +- wp-includes/js/tinymce/tiny_mce_popup.js | 2 +- .../js/tinymce/utils/editable_selects.js | 9 +- wp-includes/js/tinymce/utils/form_utils.js | 9 +- wp-includes/js/tinymce/utils/mctabs.js | 9 +- wp-includes/js/tinymce/utils/validate.js | 9 +- wp-includes/js/tinymce/wp-mce-help.php | 2 +- wp-includes/js/tinymce/wp-tinymce.js.gz | Bin 80093 -> 84515 bytes wp-includes/js/wp-lists.dev.js | 43 +- wp-includes/js/wp-lists.js | 2 +- wp-includes/kses.php | 17 +- wp-includes/l10n.php | 29 +- wp-includes/link-template.php | 356 +- wp-includes/load.php | 99 +- wp-includes/media.php | 51 +- wp-includes/meta.php | 175 +- wp-includes/ms-blogs.php | 197 +- wp-includes/ms-default-filters.php | 4 +- wp-includes/ms-deprecated.php | 10 +- wp-includes/ms-functions.php | 987 +++- wp-includes/ms-load.php | 63 +- wp-includes/ms-settings.php | 7 +- wp-includes/nav-menu-template.php | 76 +- wp-includes/nav-menu.php | 4 +- wp-includes/pluggable.php | 80 +- wp-includes/plugin.php | 10 +- wp-includes/pomo/streams.php | 2 +- wp-includes/post-template.php | 316 +- wp-includes/post-thumbnail-template.php | 23 +- wp-includes/post.php | 969 +++- wp-includes/query.php | 1867 +++++--- wp-includes/registration-functions.php | 7 +- wp-includes/registration.php | 331 +- wp-includes/rewrite.php | 141 +- wp-includes/rss.php | 16 +- wp-includes/script-loader.php | 181 +- wp-includes/taxonomy.php | 606 ++- wp-includes/theme-compat/comments-popup.php | 6 +- wp-includes/theme-compat/comments.php | 14 +- wp-includes/theme-compat/footer.php | 4 +- wp-includes/theme-compat/header.php | 4 +- wp-includes/theme-compat/sidebar.php | 4 +- wp-includes/theme.php | 445 +- wp-includes/update.php | 42 +- wp-includes/user.php | 880 +++- wp-includes/vars.php | 13 +- wp-includes/version.php | 8 +- wp-includes/widgets.php | 8 +- wp-includes/wp-db.php | 208 +- wp-includes/wp-diff.php | 2 +- wp-links-opml.php | 11 +- wp-load.php | 10 +- wp-login.php | 198 +- wp-pass.php | 3 +- wp-rdf.php | 4 +- wp-register.php | 6 +- wp-rss.php | 4 +- wp-rss2.php | 4 +- wp-settings.php | 23 +- wp-signup.php | 12 +- xmlrpc.php | 3278 +------------ 492 files changed, 35163 insertions(+), 25713 deletions(-) create mode 100644 wp-admin/css/theme-install-rtl.css create mode 100644 wp-admin/css/theme-install-rtl.dev.css delete mode 100644 wp-admin/edit-attachment-rows.php delete mode 100644 wp-admin/edit-link-categories.php delete mode 100644 wp-admin/edit-link-category-form.php delete mode 100644 wp-admin/edit-post-rows.php delete mode 100644 wp-admin/images/button-grad-active-vs.png delete mode 100644 wp-admin/images/button-grad-vs.png delete mode 100644 wp-admin/images/fav-arrow-vs-rtl.gif delete mode 100644 wp-admin/images/fav-arrow-vs.gif delete mode 100644 wp-admin/images/fav-top-vs.gif delete mode 100644 wp-admin/images/list-vs.png create mode 100644 wp-admin/images/menu-dark-rtl-vs.gif create mode 100644 wp-admin/images/menu-dark-vs.gif delete mode 100644 wp-admin/images/screen-options-right-up.gif delete mode 100644 wp-admin/images/screen-options-right.gif create mode 100644 wp-admin/images/screen-options-toggle-vs.gif create mode 100644 wp-admin/images/screen-options-toggle.gif create mode 100644 wp-admin/images/sort.gif create mode 100644 wp-admin/images/upload-classic.png create mode 100644 wp-admin/images/upload-fresh.png delete mode 100644 wp-admin/images/visit-site-button-grad-vs.gif delete mode 100644 wp-admin/images/visit-site-button-grad.gif create mode 100644 wp-admin/images/widgets-arrow-vs.gif create mode 100644 wp-admin/includes/class-wp-comments-list-table.php create mode 100644 wp-admin/includes/class-wp-links-list-table.php create mode 100644 wp-admin/includes/class-wp-list-table.php create mode 100644 wp-admin/includes/class-wp-media-list-table.php create mode 100644 wp-admin/includes/class-wp-ms-sites-list-table.php create mode 100644 wp-admin/includes/class-wp-ms-themes-list-table.php create mode 100644 wp-admin/includes/class-wp-ms-users-list-table.php create mode 100644 wp-admin/includes/class-wp-plugin-install-list-table.php create mode 100644 wp-admin/includes/class-wp-plugins-list-table.php create mode 100644 wp-admin/includes/class-wp-posts-list-table.php create mode 100644 wp-admin/includes/class-wp-terms-list-table.php create mode 100644 wp-admin/includes/class-wp-theme-install-list-table.php create mode 100644 wp-admin/includes/class-wp-themes-list-table.php create mode 100644 wp-admin/includes/class-wp-users-list-table.php create mode 100644 wp-admin/includes/internal-linking.php create mode 100644 wp-admin/includes/list-table.php create mode 100644 wp-admin/includes/menu.php create mode 100644 wp-admin/js/list-table.dev.js create mode 100644 wp-admin/js/list-table.js create mode 100644 wp-admin/js/theme.dev.js create mode 100644 wp-admin/js/theme.js delete mode 100644 wp-admin/link-category.php create mode 100644 wp-admin/network/admin.php create mode 100644 wp-admin/network/edit.php create mode 100644 wp-admin/network/index-extra.php create mode 100644 wp-admin/network/index.php create mode 100644 wp-admin/network/menu.php create mode 100644 wp-admin/network/plugin-editor.php create mode 100644 wp-admin/network/plugin-install.php create mode 100644 wp-admin/network/plugins.php create mode 100644 wp-admin/network/profile.php create mode 100644 wp-admin/network/settings.php create mode 100644 wp-admin/network/setup.php create mode 100644 wp-admin/network/site-info.php create mode 100644 wp-admin/network/site-new.php create mode 100644 wp-admin/network/site-settings.php create mode 100644 wp-admin/network/site-themes.php create mode 100644 wp-admin/network/site-users.php create mode 100644 wp-admin/network/sites.php create mode 100644 wp-admin/network/theme-editor.php create mode 100644 wp-admin/network/theme-install.php create mode 100644 wp-admin/network/themes.php create mode 100644 wp-admin/network/update-core.php create mode 100644 wp-admin/network/update.php create mode 100644 wp-admin/network/upgrade.php create mode 100644 wp-admin/network/user-edit.php create mode 100644 wp-admin/network/user-new.php create mode 100644 wp-admin/network/users.php delete mode 100644 wp-admin/sidebar.php create mode 100644 wp-admin/user/admin.php create mode 100644 wp-admin/user/index-extra.php create mode 100644 wp-admin/user/index.php create mode 100644 wp-admin/user/menu.php create mode 100644 wp-admin/user/profile.php create mode 100644 wp-admin/user/user-edit.php create mode 100644 wp-content/plugins/akismet/akismet.css create mode 100644 wp-content/plugins/akismet/akismet.js create mode 100644 wp-content/plugins/akismet/widget.php create mode 100644 wp-content/themes/twentyten/loop-attachment.php create mode 100644 wp-content/themes/twentyten/loop-page.php create mode 100644 wp-content/themes/twentyten/loop-single.php create mode 100644 wp-includes/admin-bar.php create mode 100644 wp-includes/class-wp-admin-bar.php create mode 100644 wp-includes/class-wp-ajax-response.php create mode 100644 wp-includes/class-wp-error.php create mode 100644 wp-includes/class-wp-http-ixr-client.php create mode 100644 wp-includes/class-wp-walker.php create mode 100644 wp-includes/class-wp-xmlrpc-server.php create mode 100644 wp-includes/class-wp.php delete mode 100644 wp-includes/classes.php create mode 100644 wp-includes/css/admin-bar-rtl.css create mode 100644 wp-includes/css/admin-bar-rtl.dev.css create mode 100644 wp-includes/css/admin-bar.css create mode 100644 wp-includes/css/admin-bar.dev.css create mode 100644 wp-includes/css/jquery-ui-dialog.css create mode 100644 wp-includes/css/jquery-ui-dialog.dev.css create mode 100644 wp-includes/images/admin-bar-sprite-rtl.png create mode 100644 wp-includes/images/admin-bar-sprite.png create mode 100644 wp-includes/images/wpmini-blue.png create mode 100644 wp-includes/js/admin-bar.dev.js create mode 100644 wp-includes/js/admin-bar.js create mode 100644 wp-includes/js/jquery/jquery.query.js create mode 100644 wp-includes/js/jquery/jquery.serialize-object.js create mode 100644 wp-includes/js/jquery/ui.button.js create mode 100644 wp-includes/js/jquery/ui.mouse.js create mode 100644 wp-includes/js/jquery/ui.position.js create mode 100644 wp-includes/js/jquery/ui.widget.js create mode 100644 wp-includes/js/l10n.dev.js create mode 100644 wp-includes/js/l10n.js create mode 100644 wp-includes/js/swfupload/license.txt delete mode 100644 wp-includes/js/tinymce/blank.htm delete mode 100644 wp-includes/js/tinymce/plugins/media/css/content.css delete mode 100644 wp-includes/js/tinymce/plugins/media/css/media.css delete mode 100644 wp-includes/js/tinymce/plugins/media/editor_plugin.js delete mode 100644 wp-includes/js/tinymce/plugins/media/img/flash.gif delete mode 100644 wp-includes/js/tinymce/plugins/media/img/flv_player.swf delete mode 100644 wp-includes/js/tinymce/plugins/media/img/quicktime.gif delete mode 100644 wp-includes/js/tinymce/plugins/media/img/realmedia.gif delete mode 100644 wp-includes/js/tinymce/plugins/media/img/shockwave.gif delete mode 100644 wp-includes/js/tinymce/plugins/media/img/trans.gif delete mode 100644 wp-includes/js/tinymce/plugins/media/img/windowsmedia.gif delete mode 100644 wp-includes/js/tinymce/plugins/media/js/embed.js delete mode 100644 wp-includes/js/tinymce/plugins/media/js/media.js delete mode 100644 wp-includes/js/tinymce/plugins/media/media.htm delete mode 100644 wp-includes/js/tinymce/plugins/safari/blank.htm delete mode 100644 wp-includes/js/tinymce/plugins/safari/editor_plugin.js create mode 100644 wp-includes/js/tinymce/plugins/wpdialogs/editor_plugin.dev.js create mode 100644 wp-includes/js/tinymce/plugins/wpdialogs/editor_plugin.js create mode 100644 wp-includes/js/tinymce/plugins/wpdialogs/js/popup.dev.js create mode 100644 wp-includes/js/tinymce/plugins/wpdialogs/js/popup.js create mode 100644 wp-includes/js/tinymce/plugins/wplink/css/wplink-rtl.css create mode 100644 wp-includes/js/tinymce/plugins/wplink/css/wplink-rtl.dev.css create mode 100644 wp-includes/js/tinymce/plugins/wplink/css/wplink.css create mode 100644 wp-includes/js/tinymce/plugins/wplink/css/wplink.dev.css create mode 100644 wp-includes/js/tinymce/plugins/wplink/editor_plugin.dev.js create mode 100644 wp-includes/js/tinymce/plugins/wplink/editor_plugin.js create mode 100644 wp-includes/js/tinymce/plugins/wplink/img/toggle-arrow.png create mode 100644 wp-includes/js/tinymce/plugins/wplink/js/wplink.dev.js create mode 100644 wp-includes/js/tinymce/plugins/wplink/js/wplink.js diff --git a/license.txt b/license.txt index d31195ab..eda6b00a 100644 --- a/license.txt +++ b/license.txt @@ -2,7 +2,7 @@ Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 51 Franklin St, Fifth Floor, Boston, MA 02110, USA + 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -279,3 +279,10 @@ POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS + +WRITTEN OFFER + +The source code for any program binaries or compressed scripts that are +included with WordPress can be freely obtained at the following URL: + + http://wordpress.org/download/source/ diff --git a/readme.html b/readme.html index 7dc2540c..bd56eb59 100644 --- a/readme.html +++ b/readme.html @@ -8,7 +8,7 @@

WordPress -
Version 3.0.6 +
Version 3.1

Semantic Personal Publishing Platform

@@ -31,17 +31,17 @@
  • The installer should then send you to the login page. Sign in with the username and password you chose during the installation. If a password was generated for you, you can then click on 'Profile' to change the password.
  • -

    Upgrading

    -

    Using the Automatic Upgrader

    -

    If you are upgrading from version 2.7 or higher, you can use the automatic upgrader:

    +

    Updating

    +

    Using the Automatic Updater

    +

    If you are updating from version 2.7 or higher, you can use the automatic updater:

    1. Open the wp-admin/update-core.php in your browser and follow the instructions.
    2. You wanted more, perhaps? That's it!
    -

    Upgrading Manually

    +

    Updating Manually

      -
    1. Before you upgrade anything, make sure you have backup copies of any files you may have modified such as index.php.
    2. +
    3. Before you update anything, make sure you have backup copies of any files you may have modified such as index.php.
    4. Delete your old WordPress files, saving ones you've modified.
    5. Upload the new files.
    6. Point your browser to /wp-admin/upgrade.php.
    7. @@ -101,7 +101,7 @@

      WordPress is the official continuation of b2/cafélog, which came from Michel V. The work has been continued by the WordPress developers. If you would like to support WordPress, please consider donating.

      -

      Copyright

      +

      License

      WordPress is free software, and is released under the terms of the GPL version 2 or (at your option) any later version. See license.txt.

      diff --git a/wp-activate.php b/wp-activate.php index b9e77070..6bc019c7 100644 --- a/wp-activate.php +++ b/wp-activate.php @@ -7,12 +7,10 @@ require( dirname(__FILE__) . '/wp-load.php' ); require( './wp-blog-header.php' ); if ( !is_multisite() ) { - wp_redirect( get_option( 'siteurl' ) . "/wp-login.php?action=register" ); + wp_redirect( site_url( '/wp-login.php?action=register' ) ); die(); } -require_once( ABSPATH . WPINC . '/registration.php'); - if ( is_object( $wp_object_cache ) ) $wp_object_cache->cache_enabled = false; @@ -30,7 +28,7 @@ function wpmu_activate_stylesheet() { #submit, #key { width: 90%; font-size: 24px; } #language { margin-top: .5em; } .error { background: #f66; } - span.h3 { padding:0 8px; font-size:1.3em; font-family:'Trebuchet MS','Lucida Grande',Verdana,Arial,Sans-Serif; font-weight:700; color:#333333; } + span.h3 { padding: 0 8px; font-size: 1.3em; font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif; font-weight: bold; color: #333; } '; if ( $signup->domain . $signup->path == '' ) { - printf( __('Your account has been activated. You may now login to the site using your chosen username of “%2$s”. Please check your email inbox at %3$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can reset your password.'), network_site_url( 'wp-login.php', 'login' ), $signup->user_login, $signup->user_email, network_site_url( 'wp-login.php?action=lostpassword', 'login' ) ); + printf( __('Your account has been activated. You may now log in to the site using your chosen username of “%2$s”. Please check your email inbox at %3$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can reset your password.'), network_site_url( 'wp-login.php', 'login' ), $signup->user_login, $signup->user_email, network_site_url( 'wp-login.php?action=lostpassword', 'login' ) ); } else { printf( __('Your site at %2$s is active. You may now log in to your site using your chosen username of “%3$s”. Please check your email inbox at %4$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can reset your password.'), 'http://' . $signup->domain, $signup->domain, $signup->user_login, $signup->user_email, network_site_url( 'wp-login.php?action=lostpassword' ) ); } diff --git a/wp-admin/admin-ajax.php b/wp-admin/admin-ajax.php index df64921b..d2a8d4d2 100644 --- a/wp-admin/admin-ajax.php +++ b/wp-admin/admin-ajax.php @@ -9,16 +9,16 @@ /** * Executing AJAX process. * - * @since unknown + * @since 2.1.0 */ define('DOING_AJAX', true); define('WP_ADMIN', true); -require_once('../wp-load.php'); - if ( ! isset( $_REQUEST['action'] ) ) die('-1'); +require_once('../wp-load.php'); + require_once('./includes/admin.php'); @header('Content-Type: text/html; charset=' . get_option('blog_charset')); send_nosniff_header(); @@ -50,16 +50,43 @@ if ( ! is_user_logged_in() ) { if ( isset( $_GET['action'] ) ) : switch ( $action = $_GET['action'] ) : -case 'ajax-tag-search' : - if ( !current_user_can( 'edit_posts' ) ) - die('-1'); +case 'fetch-list' : - $s = $_GET['q']; // is this slashed already? + $list_class = $_GET['list_args']['class']; + check_ajax_referer( "fetch-list-$list_class", '_ajax_fetch_list_nonce' ); - if ( isset($_GET['tax']) ) - $taxonomy = sanitize_title($_GET['tax']); - else + $current_screen = (object) $_GET['list_args']['screen']; + //TODO fix this in a better way see #15336 + $current_screen->is_network = 'false' === $current_screen->is_network ? false : true; + $current_screen->is_user = 'false' === $current_screen->is_user ? false : true; + + define( 'WP_NETWORK_ADMIN', $current_screen->is_network ); + define( 'WP_USER_ADMIN', $current_screen->is_user ); + + $wp_list_table = _get_list_table( $list_class ); + if ( ! $wp_list_table ) + die( '0' ); + + if ( ! $wp_list_table->ajax_user_can() ) + die( '-1' ); + + $wp_list_table->ajax_response(); + + die( '0' ); + break; +case 'ajax-tag-search' : + if ( isset( $_GET['tax'] ) ) { + $taxonomy = sanitize_key( $_GET['tax'] ); + $tax = get_taxonomy( $taxonomy ); + if ( ! $tax ) + die( '0' ); + if ( ! current_user_can( $tax->cap->assign_terms ) ) + die( '-1' ); + } else { die('0'); + } + + $s = stripslashes( $_GET['q'] ); if ( false !== strpos( $s, ',' ) ) { $s = explode( ',', $s ); @@ -69,7 +96,7 @@ case 'ajax-tag-search' : if ( strlen( $s ) < 2 ) die; // require 2 chars for matching - $results = $wpdb->get_col( "SELECT t.name FROM $wpdb->term_taxonomy AS tt INNER JOIN $wpdb->terms AS t ON tt.term_id = t.term_id WHERE tt.taxonomy = '$taxonomy' AND t.name LIKE ('%" . $s . "%')" ); + $results = $wpdb->get_col( $wpdb->prepare( "SELECT t.name FROM $wpdb->term_taxonomy AS tt INNER JOIN $wpdb->terms AS t ON tt.term_id = t.term_id WHERE tt.taxonomy = %s AND t.name LIKE (%s)", $taxonomy, '%' . like_escape( $s ) . '%' ) ); echo join( $results, "\n" ); die; @@ -162,7 +189,7 @@ endif; * @param int $comment_id * @return die */ -function _wp_ajax_delete_comment_response( $comment_id ) { +function _wp_ajax_delete_comment_response( $comment_id, $delta = -1 ) { $total = (int) @$_POST['_total']; $per_page = (int) @$_POST['_per_page']; $page = (int) @$_POST['_page']; @@ -171,43 +198,39 @@ function _wp_ajax_delete_comment_response( $comment_id ) { if ( !$total || !$per_page || !$page || !$url ) die( (string) time() ); - if ( --$total < 0 ) // Take the total from POST and decrement it (since we just deleted one) + $total += $delta; + if ( $total < 0 ) $total = 0; - if ( 0 != $total % $per_page && 1 != mt_rand( 1, $per_page ) ) // Only do the expensive stuff on a page-break, and about 1 other time per page - die( (string) time() ); + // Only do the expensive stuff on a page-break, and about 1 other time per page + if ( 0 == $total % $per_page || 1 == mt_rand( 1, $per_page ) ) { + $post_id = 0; + $status = 'total_comments'; // What type of comment count are we looking for? + $parsed = parse_url( $url ); + if ( isset( $parsed['query'] ) ) { + parse_str( $parsed['query'], $query_vars ); + if ( !empty( $query_vars['comment_status'] ) ) + $status = $query_vars['comment_status']; + if ( !empty( $query_vars['p'] ) ) + $post_id = (int) $query_vars['p']; + } + + $comment_count = wp_count_comments($post_id); - $post_id = 0; - $status = 'total_comments'; // What type of comment count are we looking for? - $parsed = parse_url( $url ); - if ( isset( $parsed['query'] ) ) { - parse_str( $parsed['query'], $query_vars ); - if ( !empty( $query_vars['comment_status'] ) ) - $status = $query_vars['comment_status']; - if ( !empty( $query_vars['p'] ) ) - $post_id = (int) $query_vars['p']; + if ( isset( $comment_count->$status ) ) // We're looking for a known type of comment count + $total = $comment_count->$status; + // else use the decremented value from above } - $comment_count = wp_count_comments($post_id); $time = time(); // The time since the last comment count - if ( isset( $comment_count->$status ) ) // We're looking for a known type of comment count - $total = $comment_count->$status; - // else use the decremented value from above - - $page_links = paginate_links( array( - 'base' => add_query_arg( 'apage', '%#%', $url ), - 'format' => '', - 'prev_text' => __('«'), - 'next_text' => __('»'), - 'total' => ceil($total / $per_page), - 'current' => $page - ) ); $x = new WP_Ajax_Response( array( 'what' => 'comment', 'id' => $comment_id, // here for completeness - not used 'supplemental' => array( - 'pageLinks' => $page_links, + 'total_items_i18n' => sprintf( _n( '1 item', '%s items', $total ), number_format_i18n( $total ) ), + 'total_pages' => ceil( $total / $per_page ), + 'total_pages_i18n' => number_format_i18n( ceil( $total / $per_page ) ), 'total' => $total, 'time' => $time ) @@ -304,6 +327,7 @@ case 'delete-comment' : // On success, die with time() instead of 1 check_ajax_referer( "delete-comment_$id" ); $status = wp_get_comment_status( $comment->comment_ID ); + $delta = -1; if ( isset($_POST['trash']) && 1 == $_POST['trash'] ) { if ( 'trash' == $status ) die( (string) time() ); @@ -312,6 +336,8 @@ case 'delete-comment' : // On success, die with time() instead of 1 if ( 'trash' != $status ) die( (string) time() ); $r = wp_untrash_comment( $comment->comment_ID ); + if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'trash' ) // undo trash, not in trash + $delta = 1; } elseif ( isset($_POST['spam']) && 1 == $_POST['spam'] ) { if ( 'spam' == $status ) die( (string) time() ); @@ -320,6 +346,8 @@ case 'delete-comment' : // On success, die with time() instead of 1 if ( 'spam' != $status ) die( (string) time() ); $r = wp_unspam_comment( $comment->comment_ID ); + if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'spam' ) // undo spam, not in spam + $delta = 1; } elseif ( isset($_POST['delete']) && 1 == $_POST['delete'] ) { $r = wp_delete_comment( $comment->comment_ID ); } else { @@ -327,7 +355,7 @@ case 'delete-comment' : // On success, die with time() instead of 1 } if ( $r ) // Decide if we need to send back '1' or a more complicated response including page links and comment counts - _wp_ajax_delete_comment_response( $comment->comment_ID ); + _wp_ajax_delete_comment_response( $comment->comment_ID, $delta ); die( '0' ); break; case 'delete-tag' : @@ -349,42 +377,6 @@ case 'delete-tag' : else die('0'); break; -case 'delete-link-cat' : - check_ajax_referer( "delete-link-category_$id" ); - if ( !current_user_can( 'manage_categories' ) ) - die('-1'); - - $cat = get_term( $id, 'link_category' ); - if ( !$cat || is_wp_error( $cat ) ) - die('1'); - - $cat_name = get_term_field('name', $id, 'link_category'); - - $default = get_option('default_link_category'); - - // Don't delete the default cats. - if ( $id == $default ) { - $x = new WP_AJAX_Response( array( - 'what' => 'link-cat', - 'id' => $id, - 'data' => new WP_Error( 'default-link-cat', sprintf(__("Can’t delete the %s category: this is the default one"), $cat_name) ) - ) ); - $x->send(); - } - - $r = wp_delete_term($id, 'link_category', array('default' => $default)); - if ( !$r ) - die('0'); - if ( is_wp_error($r) ) { - $x = new WP_AJAX_Response( array( - 'what' => 'link-cat', - 'id' => $id, - 'data' => $r - ) ); - $x->send(); - } - die('1'); - break; case 'delete-link' : check_ajax_referer( "delete-bookmark_$id" ); if ( !current_user_can( 'manage_links' ) ) @@ -515,56 +507,21 @@ case 'add-link-category' : // On the Fly } $x->send(); break; -case 'add-link-cat' : // From Blogroll -> Categories - check_ajax_referer( 'add-link-category' ); - if ( !current_user_can( 'manage_categories' ) ) - die('-1'); - - if ( '' === trim($_POST['name']) ) { - $x = new WP_Ajax_Response( array( - 'what' => 'link-cat', - 'id' => new WP_Error( 'name', __('You did not enter a category name.') ) - ) ); - $x->send(); - } - - $r = wp_insert_term($_POST['name'], 'link_category', $_POST ); - if ( is_wp_error( $r ) ) { - $x = new WP_AJAX_Response( array( - 'what' => 'link-cat', - 'id' => $r - ) ); - $x->send(); - } - - extract($r, EXTR_SKIP); - - if ( !$link_cat = link_cat_row( $term_id ) ) - die('0'); - - $x = new WP_Ajax_Response( array( - 'what' => 'link-cat', - 'id' => $term_id, - 'position' => -1, - 'data' => $link_cat - ) ); - $x->send(); - break; -case 'add-tag' : // From Manage->Tags +case 'add-tag' : check_ajax_referer( 'add-tag' ); $post_type = !empty($_POST['post_type']) ? $_POST['post_type'] : 'post'; $taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag'; $tax = get_taxonomy($taxonomy); - $x = new WP_Ajax_Response(); - if ( !current_user_can( $tax->cap->edit_terms ) ) die('-1'); + $x = new WP_Ajax_Response(); + $tag = wp_insert_term($_POST['tag-name'], $taxonomy, $_POST ); if ( !$tag || is_wp_error($tag) || (!$tag = get_term( $tag['term_id'], $taxonomy )) ) { - $message = __('An error has occured. Please reload the page and try again.'); + $message = __('An error has occurred. Please reload the page and try again.'); if ( is_wp_error($tag) && $tag->get_error_message() ) $message = $tag->get_error_message(); @@ -575,23 +532,21 @@ case 'add-tag' : // From Manage->Tags $x->send(); } - if ( isset($_POST['screen']) ) - set_current_screen($_POST['screen']); + set_current_screen( $_POST['screen'] ); + + $wp_list_table = _get_list_table('WP_Terms_List_Table'); $level = 0; - $tag_full_name = false; - $tag_full_name = $tag->name; if ( is_taxonomy_hierarchical($taxonomy) ) { - $_tag = $tag; - while ( $_tag->parent ) { - $_tag = get_term( $_tag->parent, $taxonomy ); - $tag_full_name = $_tag->name . ' — ' . $tag_full_name; - $level++; - } - $noparents = _tag_row( $tag, $level, $taxonomy ); + $level = count( get_ancestors( $tag->term_id, $taxonomy ) ); + ob_start(); + $wp_list_table->single_row( $tag, $level ); + $noparents = ob_get_clean(); } - $tag->name = $tag_full_name; - $parents = _tag_row( $tag, 0, $taxonomy); + + ob_start(); + $wp_list_table->single_row( $tag ); + $parents = ob_get_clean(); $x->add( array( 'what' => 'taxonomy', @@ -600,28 +555,29 @@ case 'add-tag' : // From Manage->Tags $x->add( array( 'what' => 'term', 'position' => $level, - 'supplemental' => get_term( $tag->term_id, $taxonomy, ARRAY_A ) //Refetch as $tag has been contaminated by the full name. + 'supplemental' => (array) $tag ) ); $x->send(); break; case 'get-tagcloud' : - if ( !current_user_can( 'edit_posts' ) ) - die('-1'); - - if ( isset($_POST['tax']) ) - $taxonomy = sanitize_title($_POST['tax']); - else + if ( isset( $_POST['tax'] ) ) { + $taxonomy = sanitize_key( $_POST['tax'] ); + $tax = get_taxonomy( $taxonomy ); + if ( ! $tax ) + die( '0' ); + if ( ! current_user_can( $tax->cap->assign_terms ) ) + die( '-1' ); + } else { die('0'); + } $tags = get_terms( $taxonomy, array( 'number' => 45, 'orderby' => 'count', 'order' => 'DESC' ) ); - if ( empty( $tags ) ) { - $tax = get_taxonomy( $taxonomy ); + if ( empty( $tags ) ) die( isset( $tax->no_tagcloud ) ? $tax->no_tagcloud : __('No tags found!') ); - } - if ( is_wp_error($tags) ) - die($tags->get_error_message()); + if ( is_wp_error( $tags ) ) + die( $tags->get_error_message() ); foreach ( $tags as $key => $tag ) { $tags[ $key ]->link = '#'; @@ -638,63 +594,27 @@ case 'get-tagcloud' : exit; break; -case 'add-comment' : - check_ajax_referer( $action ); - if ( !current_user_can( 'edit_posts' ) ) - die('-1'); - $search = isset($_POST['s']) ? $_POST['s'] : false; - $status = isset($_POST['comment_status']) ? $_POST['comment_status'] : 'all'; - $per_page = isset($_POST['per_page']) ? (int) $_POST['per_page'] + 8 : 28; - $start = isset($_POST['page']) ? ( intval($_POST['page']) * $per_page ) -1 : $per_page - 1; - if ( 1 > $start ) - $start = 27; - - $mode = isset($_POST['mode']) ? $_POST['mode'] : 'detail'; - $p = isset($_POST['p']) ? $_POST['p'] : 0; - $comment_type = isset($_POST['comment_type']) ? $_POST['comment_type'] : ''; - list($comments, $total) = _wp_get_comment_list( $status, $search, $start, 1, $p, $comment_type ); - - if ( get_option('show_avatars') ) - add_filter( 'comment_author', 'floated_admin_avatar' ); - - if ( !$comments ) - die('1'); - $x = new WP_Ajax_Response(); - foreach ( (array) $comments as $comment ) { - get_comment( $comment ); - ob_start(); - _wp_comment_row( $comment->comment_ID, $mode, $status, true, true ); - $comment_list_item = ob_get_contents(); - ob_end_clean(); - $x->add( array( - 'what' => 'comment', - 'id' => $comment->comment_ID, - 'data' => $comment_list_item - ) ); - } - $x->send(); - break; case 'get-comments' : check_ajax_referer( $action ); - $post_ID = (int) $_POST['post_ID']; - if ( !current_user_can( 'edit_post', $post_ID ) ) - die('-1'); + set_current_screen( 'edit-comments' ); - $start = isset($_POST['start']) ? intval($_POST['start']) : 0; - $num = isset($_POST['num']) ? intval($_POST['num']) : 10; + $wp_list_table = _get_list_table('WP_Post_Comments_List_Table'); - list($comments, $total) = _wp_get_comment_list( false, false, $start, $num, $post_ID ); + if ( !current_user_can( 'edit_post', $post_id ) ) + die('-1'); - if ( !$comments ) + $wp_list_table->prepare_items(); + + if ( !$wp_list_table->has_items() ) die('1'); $comment_list_item = ''; $x = new WP_Ajax_Response(); - foreach ( (array) $comments as $comment ) { + foreach ( $wp_list_table->items as $comment ) { get_comment( $comment ); ob_start(); - _wp_comment_row( $comment->comment_ID, 'single', false, false ); + $wp_list_table->single_row( $comment ); $comment_list_item .= ob_get_contents(); ob_end_clean(); } @@ -707,6 +627,8 @@ case 'get-comments' : case 'replyto-comment' : check_ajax_referer( $action, '_ajax_nonce-replyto-comment' ); + set_current_screen( 'edit-comments' ); + $comment_post_ID = (int) $_POST['comment_post_ID']; if ( !current_user_can( 'edit_post', $comment_post_ID ) ) die('-1'); @@ -744,22 +666,21 @@ case 'replyto-comment' : $comment = get_comment($comment_id); if ( ! $comment ) die('1'); - $modes = array( 'single', 'detail', 'dashboard' ); - $mode = isset($_POST['mode']) && in_array( $_POST['mode'], $modes ) ? $_POST['mode'] : 'detail'; $position = ( isset($_POST['position']) && (int) $_POST['position']) ? (int) $_POST['position'] : '-1'; - $checkbox = ( isset($_POST['checkbox']) && true == $_POST['checkbox'] ) ? 1 : 0; - - if ( get_option('show_avatars') && 'single' != $mode ) - add_filter( 'comment_author', 'floated_admin_avatar' ); $x = new WP_Ajax_Response(); ob_start(); - if ( 'dashboard' == $mode ) { + if ( 'dashboard' == $_REQUEST['mode'] ) { require_once( ABSPATH . 'wp-admin/includes/dashboard.php' ); - _wp_dashboard_recent_comments_row( $comment, false ); + _wp_dashboard_recent_comments_row( $comment ); } else { - _wp_comment_row( $comment->comment_ID, $mode, false, $checkbox ); + if ( 'single' == $_REQUEST['mode'] ) { + $wp_list_table = _get_list_table('WP_Post_Comments_List_Table'); + } else { + $wp_list_table = _get_list_table('WP_Comments_List_Table'); + } + $wp_list_table->single_row( $comment ); } $comment_list_item = ob_get_contents(); ob_end_clean(); @@ -776,6 +697,8 @@ case 'replyto-comment' : case 'edit-comment' : check_ajax_referer( 'replyto-comment', '_ajax_nonce-replyto-comment' ); + set_current_screen( 'edit-comments' ); + $comment_post_ID = (int) $_POST['comment_post_ID']; if ( ! current_user_can( 'edit_post', $comment_post_ID ) ) die('-1'); @@ -787,21 +710,19 @@ case 'edit-comment' : $_POST['comment_status'] = $_POST['status']; edit_comment(); - $mode = ( isset($_POST['mode']) && 'single' == $_POST['mode'] ) ? 'single' : 'detail'; $position = ( isset($_POST['position']) && (int) $_POST['position']) ? (int) $_POST['position'] : '-1'; - $checkbox = ( isset($_POST['checkbox']) && true == $_POST['checkbox'] ) ? 1 : 0; - $comments_listing = isset($_POST['comments_listing']) ? $_POST['comments_listing'] : ''; - - if ( get_option('show_avatars') && 'single' != $mode ) - add_filter( 'comment_author', 'floated_admin_avatar' ); + $comments_status = isset($_POST['comments_listing']) ? $_POST['comments_listing'] : ''; - $x = new WP_Ajax_Response(); + $checkbox = ( isset($_POST['checkbox']) && true == $_POST['checkbox'] ) ? 1 : 0; + $wp_list_table = _get_list_table( $checkbox ? 'WP_Comments_List_Table' : 'WP_Post_Comments_List_Table' ); ob_start(); - _wp_comment_row( $comment_id, $mode, $comments_listing, $checkbox ); + $wp_list_table->single_row( get_comment( $comment_id ) ); $comment_list_item = ob_get_contents(); ob_end_clean(); + $x = new WP_Ajax_Response(); + $x->add( array( 'what' => 'edit_comment', 'id' => $comment->comment_ID, @@ -819,7 +740,37 @@ case 'add-menu-item' : require_once ABSPATH . 'wp-admin/includes/nav-menu.php'; - $item_ids = wp_save_nav_menu_items( 0, $_POST['menu-item'] ); + // For performance reasons, we omit some object properties from the checklist. + // The following is a hacky way to restore them when adding non-custom items. + + $menu_items_data = array(); + foreach ( (array) $_POST['menu-item'] as $menu_item_data ) { + if ( + ! empty( $menu_item_data['menu-item-type'] ) && + 'custom' != $menu_item_data['menu-item-type'] && + ! empty( $menu_item_data['menu-item-object-id'] ) + ) { + switch( $menu_item_data['menu-item-type'] ) { + case 'post_type' : + $_object = get_post( $menu_item_data['menu-item-object-id'] ); + break; + + case 'taxonomy' : + $_object = get_term( $menu_item_data['menu-item-object-id'], $menu_item_data['menu-item-object'] ); + break; + } + + $_menu_items = array_map( 'wp_setup_nav_menu_item', array( $_object ) ); + $_menu_item = array_shift( $_menu_items ); + + // Restore the missing menu item properties + $menu_item_data['menu-item-description'] = $_menu_item->description; + } + + $menu_items_data[] = $menu_item_data; + } + + $item_ids = wp_save_nav_menu_items( 0, $menu_items_data ); if ( is_wp_error( $item_ids ) ) die('-1'); @@ -929,7 +880,6 @@ case 'add-user' : check_ajax_referer( $action ); if ( !current_user_can('create_users') ) die('-1'); - require_once(ABSPATH . WPINC . '/registration.php'); if ( !$user_id = add_user() ) die('0'); elseif ( is_wp_error( $user_id ) ) { @@ -941,10 +891,12 @@ case 'add-user' : } $user_object = new WP_User( $user_id ); + $wp_list_table = _get_list_table('WP_Users_List_Table'); + $x = new WP_Ajax_Response( array( 'what' => 'user', 'id' => $user_id, - 'data' => user_row( $user_object, '', $user_object->roles[0] ), + 'data' => $wp_list_table->single_row( $user_object, '', $user_object->roles[0] ), 'supplemental' => array( 'show-link' => sprintf(__( 'User %s added' ), "user-$user_id", $user_object->user_login), 'role' => $user_object->roles[0] @@ -1136,6 +1088,27 @@ case 'menu-quick-search': _wp_ajax_menu_quick_search( $_REQUEST ); + exit; + break; +case 'wp-link-ajax': + require_once ABSPATH . 'wp-admin/includes/internal-linking.php'; + + check_ajax_referer( 'internal-linking', '_ajax_linking_nonce' ); + + $args = array(); + + if ( isset( $_POST['search'] ) ) + $args['s'] = stripslashes( $_POST['search'] ); + $args['pagenum'] = ! empty( $_POST['page'] ) ? absint( $_POST['page'] ) : 1; + + $results = wp_link_query( $args ); + + if ( ! isset( $results ) ) + die( '0' ); + + echo json_encode( $results ); + echo "\n"; + exit; break; case 'menu-locations-save': @@ -1193,8 +1166,7 @@ case 'inline-save': die( __('You are not allowed to edit this post.') ); } - if ( isset($_POST['screen']) ) - set_current_screen($_POST['screen']); + set_current_screen( $_POST['screen'] ); if ( $last = wp_check_post_lock( $post_ID ) ) { $last_user = get_userdata( $last ); @@ -1231,68 +1203,48 @@ case 'inline-save': // update the post edit_post(); - if ( in_array( $_POST['post_type'], get_post_types( array( 'show_ui' => true ) ) ) ) { - $post = array(); - $post[] = get_post($_POST['post_ID']); - if ( is_post_type_hierarchical( $_POST['post_type'] ) ) { - page_rows( $post ); - } else { - $mode = $_POST['post_view']; - post_rows( $post ); - } - } + $wp_list_table = _get_list_table('WP_Posts_List_Table'); + + $mode = $_POST['post_view']; + $wp_list_table->display_rows( array( get_post( $_POST['post_ID'] ) ) ); exit; break; case 'inline-save-tax': check_ajax_referer( 'taxinlineeditnonce', '_inline_edit' ); - $taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : false; - if ( ! $taxonomy ) - die( __('Cheatin’ uh?') ); - $tax = get_taxonomy($taxonomy); + $taxonomy = sanitize_key( $_POST['taxonomy'] ); + $tax = get_taxonomy( $taxonomy ); + if ( ! $tax ) + die( '0' ); if ( ! current_user_can( $tax->cap->edit_terms ) ) - die( __('Cheatin’ uh?') ); - - if ( ! isset($_POST['tax_ID']) || ! ( $id = (int) $_POST['tax_ID'] ) ) - die(-1); + die( '-1' ); - switch ($_POST['tax_type']) { - case 'link-cat' : - $updated = wp_update_term($id, 'link_category', $_POST); + set_current_screen( 'edit-' . $taxonomy ); - if ( $updated && !is_wp_error($updated) ) - echo link_cat_row($updated['term_id']); - else - die( __('Category not updated.') ); + $wp_list_table = _get_list_table('WP_Terms_List_Table'); - break; - case 'tag' : - $taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag'; - - $tag = get_term( $id, $taxonomy ); - $_POST['description'] = $tag->description; - - $updated = wp_update_term($id, $taxonomy, $_POST); - if ( $updated && !is_wp_error($updated) ) { - $tag = get_term( $updated['term_id'], $taxonomy ); - if ( !$tag || is_wp_error( $tag ) ) { - if ( is_wp_error($tag) && $tag->get_error_message() ) - die( $tag->get_error_message() ); - die( __('Item not updated.') ); - } + if ( ! isset($_POST['tax_ID']) || ! ( $id = (int) $_POST['tax_ID'] ) ) + die(-1); - set_current_screen( 'edit-' . $taxonomy ); + $tag = get_term( $id, $taxonomy ); + $_POST['description'] = $tag->description; - echo _tag_row($tag, 0, $taxonomy); - } else { - if ( is_wp_error($updated) && $updated->get_error_message() ) - die( $updated->get_error_message() ); - die( __('Item not updated.') ); - } + $updated = wp_update_term($id, $taxonomy, $_POST); + if ( $updated && !is_wp_error($updated) ) { + $tag = get_term( $updated['term_id'], $taxonomy ); + if ( !$tag || is_wp_error( $tag ) ) { + if ( is_wp_error($tag) && $tag->get_error_message() ) + die( $tag->get_error_message() ); + die( __('Item not updated.') ); + } - break; + echo $wp_list_table->single_row( $tag ); + } else { + if ( is_wp_error($updated) && $updated->get_error_message() ) + die( $updated->get_error_message() ); + die( __('Item not updated.') ); } exit; @@ -1314,11 +1266,11 @@ case 'find_posts': $searchand = $search = ''; foreach ( (array) $search_terms as $term ) { - $term = addslashes_gpc($term); + $term = esc_sql( like_escape( $term ) ); $search .= "{$searchand}(($wpdb->posts.post_title LIKE '%{$term}%') OR ($wpdb->posts.post_content LIKE '%{$term}%'))"; $searchand = ' AND '; } - $term = $wpdb->escape($s); + $term = esc_sql( like_escape( $s ) ); if ( count($search_terms) > 1 && $search_terms[0] != $s ) $search .= " OR ($wpdb->posts.post_title LIKE '%{$term}%') OR ($wpdb->posts.post_content LIKE '%{$term}%')"; @@ -1367,19 +1319,6 @@ case 'find_posts': )); $x->send(); - break; -case 'lj-importer' : - check_ajax_referer( 'lj-api-import' ); - if ( !current_user_can( 'publish_posts' ) ) - die('-1'); - if ( empty( $_POST['step'] ) ) - die( '-1' ); - define('WP_IMPORTING', true); - include( ABSPATH . 'wp-admin/import/livejournal.php' ); - $result = $lj_api_import->{ 'step' . ( (int) $_POST['step'] ) }(); - if ( is_wp_error( $result ) ) - echo $result->get_error_message(); - die; break; case 'widgets-order' : check_ajax_referer( 'save-sidebar-widgets', 'savewidgets' ); @@ -1428,7 +1367,7 @@ case 'save-widget' : $sidebar_id = $_POST['sidebar']; $multi_number = !empty($_POST['multi_number']) ? (int) $_POST['multi_number'] : 0; $settings = isset($_POST['widget-' . $id_base]) && is_array($_POST['widget-' . $id_base]) ? $_POST['widget-' . $id_base] : false; - $error = '

      ' . __('An error has occured. Please reload the page and try again.') . '

      '; + $error = '

      ' . __('An error has occurred. Please reload the page and try again.') . '

      '; $sidebars = wp_get_sidebars_widgets(); $sidebar = isset($sidebars[$sidebar_id]) ? $sidebars[$sidebar_id] : array(); @@ -1518,15 +1457,16 @@ case 'set-post-thumbnail': die( _wp_post_thumbnail_html() ); } - if ( $thumbnail_id && get_post( $thumbnail_id ) ) { - $thumbnail_html = wp_get_attachment_image( $thumbnail_id, 'thumbnail' ); - if ( !empty( $thumbnail_html ) ) { - update_post_meta( $post_ID, '_thumbnail_id', $thumbnail_id ); - die( _wp_post_thumbnail_html( $thumbnail_id ) ); - } - } + if ( set_post_thumbnail( $post_ID, $thumbnail_id ) ) + die( _wp_post_thumbnail_html( $thumbnail_id ) ); die( '0' ); break; +case 'date_format' : + die( date_i18n( sanitize_option( 'date_format', $_POST['date'] ) ) ); + break; +case 'time_format' : + die( date_i18n( sanitize_option( 'time_format', $_POST['date'] ) ) ); + break; default : do_action( 'wp_ajax_' . $_POST['action'] ); die('0'); diff --git a/wp-admin/admin-header.php b/wp-admin/admin-header.php index 61ba38b2..ac793409 100644 --- a/wp-admin/admin-header.php +++ b/wp-admin/admin-header.php @@ -12,22 +12,38 @@ if ( ! defined( 'WP_ADMIN' ) ) get_admin_page_title(); $title = esc_html( strip_tags( $title ) ); + +if ( is_network_admin() ) + $admin_title = __( 'Network Admin' ); +elseif ( is_user_admin() ) + $admin_title = __( 'Global Dashboard' ); +else + $admin_title = get_bloginfo( 'name' ); + +if ( $admin_title == $title ) + $admin_title = sprintf( __( '%1$s — WordPress' ), $title ); +else + $admin_title = sprintf( __( '%1$s ‹ %2$s — WordPress' ), $title, $admin_title ); + +$admin_title = apply_filters( 'admin_title', $admin_title, $title ); + wp_user_settings(); wp_menu_unfold(); + ?> > -<?php echo $title; ?> ‹ <?php bloginfo('name') ?> — WordPress +<?php echo $admin_title; ?> @@ -86,9 +106,15 @@ document.body.className = c;
      -

      @@ -634,7 +644,8 @@ wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); ?> - + +

      @@ -648,6 +659,9 @@ wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); ?> */ function step_3() { check_admin_referer('custom-header-crop-image'); + if ( ! current_theme_supports( 'custom-header-uploads' ) ) + wp_die( 'Cheatin’ uh?' ); + if ( $_POST['oitar'] > 1 ) { $_POST['x1'] = $_POST['x1'] * $_POST['oitar']; $_POST['y1'] = $_POST['y1'] * $_POST['oitar']; diff --git a/wp-admin/edit-attachment-rows.php b/wp-admin/edit-attachment-rows.php deleted file mode 100644 index d88316be..00000000 --- a/wp-admin/edit-attachment-rows.php +++ /dev/null @@ -1,239 +0,0 @@ - - - - - - - - - - - - - - - -post_status != 'trash' ) - continue; -elseif ( !$is_trash && $post->post_status == 'trash' ) - continue; - -$alt = ( 'alternate' == $alt ) ? '' : 'alternate'; - -$post_owner = ( get_current_user_id() == $post->post_author ? 'self' : 'other' ); -$att_title = _draft_or_post_title(); -?> - post_status ); ?>' valign="top"> - - $column_display_name ) { - $class = "class=\"$column_name column-$column_name\""; - - $style = ''; - if ( in_array($column_name, $hidden) ) - $style = ' style="display:none;"'; - - $attributes = "$class$style"; - - switch($column_name) { - - case 'cb': - ?> - - - - - - - - - - - - post_date && 'date' == $column_name ) { - $t_time = $h_time = __('Unpublished'); - } else { - $t_time = get_the_time(__('Y/m/d g:i:s A')); - $m_time = $post->post_date; - $time = get_post_time( 'G', true, $post, false ); - if ( ( abs($t_diff = time() - $time) ) < 86400 ) { - if ( $t_diff < 0 ) - $h_time = sprintf( __('%s from now'), human_time_diff( $time ) ); - else - $h_time = sprintf( __('%s ago'), human_time_diff( $time ) ); - } else { - $h_time = mysql2date(__('Y/m/d'), $m_time); - } - } - ?> - - post_parent > 0 ) { - if ( get_post($post->post_parent) ) { - $title =_draft_or_post_title($post->post_parent); - } - ?> - - - - - - - - - - - - - -
      ID) ) { ?>>ID, array(80, 60), true ) ) { - if ( $is_trash ) echo $thumb; - else { -?> - - - - -> -

      - ID ), $matches ) ) - echo esc_html( strtoupper( $matches[1] ) ); - else - echo strtoupper( str_replace( 'image/', '', get_post_mime_type() ) ); - ?> -

      - ID) && !$is_trash ) - $actions['edit'] = '' . __('Edit') . ''; - if ( current_user_can('delete_post', $post->ID) ) { - if ( $is_trash ) - $actions['untrash'] = "ID) . "'>" . __('Restore') . ""; - elseif ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) - $actions['trash'] = "ID) . "'>" . __('Trash') . ""; - if ( $is_trash || !EMPTY_TRASH_DAYS || !MEDIA_TRASH ) { - $delete_ays = (!$is_trash && !MEDIA_TRASH) ? " onclick='return showNotice.warn();'" : ''; - $actions['delete'] = "ID) . "'>" . __('Delete Permanently') . ""; - } - } - if ( !$is_trash ) { - $title =_draft_or_post_title($post->post_parent); - $actions['view'] = '' . __('View') . ''; - } - $actions = apply_filters( 'media_row_actions', $actions, $post ); - $action_count = count($actions); - $i = 0; - echo '
      '; - foreach ( $actions as $action => $link ) { - ++$i; - ( $i == $action_count ) ? $sep = '' : $sep = ' | '; - echo "$link$sep"; - } - echo '
      '; - ?>
      >>slug'> " . esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'post_tag', 'display')) . ""; - echo join( ', ', $out ); - } else { - _e('No Tags'); - } - ?>>post_excerpt : ''; ?>>>, >
      -
      >
      - ID ); - $pending_phrase = sprintf( __('%s pending'), number_format( $left ) ); - if ( $left ) - echo ''; - comments_number("" . /* translators: comment count link */ _x('0', 'comment count') . '', "" . /* translators: comment count link */ _x('1', 'comment count') . '', "" . /* translators: comment count link: % will be substituted by comment count */ _x('%', 'comment count') . ''); - if ( $left ) - echo ''; - ?> -
      > - | - - >
      - - -

      - - - diff --git a/wp-admin/edit-comments.php b/wp-admin/edit-comments.php index fe4f3ead..40ef4a4d 100644 --- a/wp-admin/edit-comments.php +++ b/wp-admin/edit-comments.php @@ -8,69 +8,68 @@ /** WordPress Administration Bootstrap */ require_once('./admin.php'); - if ( !current_user_can('edit_posts') ) wp_die(__('Cheatin’ uh?')); -wp_enqueue_script('admin-comments'); -enqueue_comment_hotkeys_js(); +$wp_list_table = _get_list_table('WP_Comments_List_Table'); +$pagenum = $wp_list_table->get_pagenum(); -$post_id = isset($_REQUEST['p']) ? (int) $_REQUEST['p'] : 0; +$doaction = $wp_list_table->current_action(); -if ( isset($_REQUEST['doaction']) || isset($_REQUEST['doaction2']) || isset($_REQUEST['delete_all']) || isset($_REQUEST['delete_all2']) ) { - check_admin_referer('bulk-comments'); +if ( $doaction ) { + check_admin_referer( 'bulk-comments' ); - if ( (isset($_REQUEST['delete_all']) || isset($_REQUEST['delete_all2'])) && !empty($_REQUEST['pagegen_timestamp']) ) { - $comment_status = $wpdb->escape($_REQUEST['comment_status']); - $delete_time = $wpdb->escape($_REQUEST['pagegen_timestamp']); + if ( 'delete_all' == $doaction && !empty( $_REQUEST['pagegen_timestamp'] ) ) { + $comment_status = $wpdb->escape( $_REQUEST['comment_status'] ); + $delete_time = $wpdb->escape( $_REQUEST['pagegen_timestamp'] ); $comment_ids = $wpdb->get_col( "SELECT comment_ID FROM $wpdb->comments WHERE comment_approved = '$comment_status' AND '$delete_time' > comment_date_gmt" ); $doaction = 'delete'; - } elseif ( ($_REQUEST['action'] != -1 || $_REQUEST['action2'] != -1) && isset($_REQUEST['delete_comments']) ) { + } elseif ( isset( $_REQUEST['delete_comments'] ) ) { $comment_ids = $_REQUEST['delete_comments']; - $doaction = ($_REQUEST['action'] != -1) ? $_REQUEST['action'] : $_REQUEST['action2']; - } elseif ( $_REQUEST['doaction'] == 'undo' && isset($_REQUEST['ids']) ) { - $comment_ids = array_map( 'absint', explode(',', $_REQUEST['ids']) ); - $doaction = $_REQUEST['action']; - } else { + $doaction = ( $_REQUEST['action'] != -1 ) ? $_REQUEST['action'] : $_REQUEST['action2']; + } elseif ( isset( $_REQUEST['ids'] ) ) { + $comment_ids = array_map( 'absint', explode( ',', $_REQUEST['ids'] ) ); + } elseif ( wp_get_referer() ) { wp_redirect( wp_get_referer() ); + exit; } $approved = $unapproved = $spammed = $unspammed = $trashed = $untrashed = $deleted = 0; - $redirect_to = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'spammed', 'unspammed', 'approved', 'unapproved', 'ids'), wp_get_referer() ); - foreach ($comment_ids as $comment_id) { // Check the permissions on each - $_post_id = (int) $wpdb->get_var( $wpdb->prepare( "SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = %d", $comment_id) ); + $redirect_to = remove_query_arg( array( 'trashed', 'untrashed', 'deleted', 'spammed', 'unspammed', 'approved', 'unapproved', 'ids' ), wp_get_referer() ); + $redirect_to = add_query_arg( 'paged', $pagenum, $redirect_to ); - if ( !current_user_can('edit_post', $_post_id) ) + foreach ( $comment_ids as $comment_id ) { // Check the permissions on each + if ( !current_user_can( 'edit_comment', $comment_id ) ) continue; - switch( $doaction ) { + switch ( $doaction ) { case 'approve' : - wp_set_comment_status($comment_id, 'approve'); + wp_set_comment_status( $comment_id, 'approve' ); $approved++; break; case 'unapprove' : - wp_set_comment_status($comment_id, 'hold'); + wp_set_comment_status( $comment_id, 'hold' ); $unapproved++; break; case 'spam' : - wp_spam_comment($comment_id); + wp_spam_comment( $comment_id ); $spammed++; break; case 'unspam' : - wp_unspam_comment($comment_id); + wp_unspam_comment( $comment_id ); $unspammed++; break; case 'trash' : - wp_trash_comment($comment_id); + wp_trash_comment( $comment_id ); $trashed++; break; case 'untrash' : - wp_untrash_comment($comment_id); + wp_untrash_comment( $comment_id ); $untrashed++; break; case 'delete' : - wp_delete_comment($comment_id); + wp_delete_comment( $comment_id ); $deleted++; break; } @@ -91,55 +90,68 @@ if ( isset($_REQUEST['doaction']) || isset($_REQUEST['doaction2']) || isset($_R if ( $deleted ) $redirect_to = add_query_arg( 'deleted', $deleted, $redirect_to ); if ( $trashed || $spammed ) - $redirect_to = add_query_arg( 'ids', join(',', $comment_ids), $redirect_to ); + $redirect_to = add_query_arg( 'ids', join( ',', $comment_ids ), $redirect_to ); wp_redirect( $redirect_to ); exit; -} elseif ( ! empty($_GET['_wp_http_referer']) ) { - wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) ); +} elseif ( ! empty( $_GET['_wp_http_referer'] ) ) { + wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), stripslashes( $_SERVER['REQUEST_URI'] ) ) ); exit; } +$wp_list_table->prepare_items(); + +$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); +if ( $pagenum > $total_pages && $total_pages > 0 ) { + wp_redirect( add_query_arg( 'paged', $total_pages ) ); + exit; +} + +wp_enqueue_script('admin-comments'); +enqueue_comment_hotkeys_js(); + if ( $post_id ) $title = sprintf(__('Comments on “%s”'), wp_html_excerpt(_draft_or_post_title($post_id), 50)); else $title = __('Comments'); -add_contextual_help( $current_screen, '

      ' . __('You can manage comments made on your site similar to the way you manage Posts and other content. This screen is customizable in the same ways as other management screens, and you can act on comments using the on-hover action links or the Bulk Actions.') . '

      ' . - '

      ' . __('A yellow row means the comment is waiting for you to moderate it.') . '

      ' . - '

      ' . __('In the Author column, in addition to the author’s name, email address, and blog URL, the commenter’s IP address is shown. Clicking on this link will show you all the comments made from this IP address.') . '

      ' . - '

      ' . __('In the Comment column, above each comment it says “Submitted on,” followed by the date and time the comment was left on your site. Clicking on the date/time link will take you to that comment on your live site.') . '

      ' . - '

      ' . __('In the In Response To column, there are three elements. The text is the name of the post that inspired the comment, and links to the post editor for that entry. The “#” permalink symbol below leads to that post on your live site. The small bubble with the number in it shows how many comments that post has received. If the bubble is gray, you have moderated all comments for that post. If it is blue, there are pending comments. Clicking the bubble will filter the comments screen to show only comments on that post.') . '

      ' . - '

      ' . __('Many people take advantage of keyboard shortcuts to moderate their comments more quickly. Use the link below to learn more.') . '

      ' . +add_screen_option( 'per_page', array('label' => _x( 'Comments', 'comments per page (screen options)' )) ); + +add_contextual_help( $current_screen, '

      ' . __( 'You can manage comments made on your site similar to the way you manage Posts and other content. This screen is customizable in the same ways as other management screens, and you can act on comments using the on-hover action links or the Bulk Actions.' ) . '

      ' . + '

      ' . __( 'A yellow row means the comment is waiting for you to moderate it.' ) . '

      ' . + '

      ' . __( 'In the Author column, in addition to the author’s name, email address, and blog URL, the commenter’s IP address is shown. Clicking on this link will show you all the comments made from this IP address.' ) . '

      ' . + '

      ' . __( 'In the Comment column, above each comment it says “Submitted on,” followed by the date and time the comment was left on your site. Clicking on the date/time link will take you to that comment on your live site.' ) . '

      ' . + '

      ' . __( 'In the In Response To column, there are three elements. The text is the name of the post that inspired the comment, and links to the post editor for that entry. The “#” permalink symbol below leads to that post on your live site. The small bubble with the number in it shows how many comments that post has received. If the bubble is gray, you have moderated all comments for that post. If it is blue, there are pending comments. Clicking the bubble will filter the comments screen to show only comments on that post.' ) . '

      ' . + '

      ' . __( 'Many people take advantage of keyboard shortcuts to moderate their comments more quickly. Use the link below to learn more.' ) . '

      ' . '

      ' . __( 'For more information:' ) . '

      ' . - '

      ' . __( 'Comments Documentation' ) . '

      ' . - '

      ' . __( 'Comment Spam Documentation') . '

      ' . - '

      ' . __( 'Keyboard Shortcuts Documentation') . '

      ' . - '

      ' . __( 'Support Forums') . '

      ' + '

      ' . __( 'Documentation on Comments' ) . '

      ' . + '

      ' . __( 'Documentation on Comment Spam' ) . '

      ' . + '

      ' . __( 'Documentation on Keyboard Shortcuts' ) . '

      ' . + '

      ' . __( 'Support Forums' ) . '

      ' ); require_once('./admin-header.php'); - -$mode = ( empty($_GET['mode']) ) ? 'detail' : esc_attr($_GET['mode']); - -$comment_status = isset($_REQUEST['comment_status']) ? $_REQUEST['comment_status'] : 'all'; -if ( !in_array($comment_status, array('all', 'moderated', 'approved', 'spam', 'trash')) ) - $comment_status = 'all'; - -$comment_type = !empty($_GET['comment_type']) ? esc_attr($_GET['comment_type']) : ''; - -$search_dirty = ( isset($_GET['s']) ) ? $_GET['s'] : ''; -$search = esc_attr( $search_dirty ); ?> +?>
      -

      ' . sprintf( __( 'Search results for “%s”' ), wp_html_excerpt( esc_html( stripslashes( $_GET['s'] ) ), 50 ) ) . '' ); ?> +

      %s', + get_edit_post_link($post_id), + wp_html_excerpt(_draft_or_post_title($post_id), 50) + ) + ); +else + echo __('Comments'); + +if ( isset($_REQUEST['s']) && $_REQUEST['s'] ) + printf( '' . sprintf( __( 'Search results for “%s”' ), wp_html_excerpt( esc_html( stripslashes( $_REQUEST['s'] ) ), 50 ) ) . '' ); ?>

      ' . $error_msg . '

      '; } -if ( isset($_GET['approved']) || isset($_GET['deleted']) || isset($_GET['trashed']) || isset($_GET['untrashed']) || isset($_GET['spammed']) || isset($_GET['unspammed']) || isset($_GET['same']) ) { - $approved = isset( $_GET['approved'] ) ? (int) $_GET['approved'] : 0; - $deleted = isset( $_GET['deleted'] ) ? (int) $_GET['deleted'] : 0; - $trashed = isset( $_GET['trashed'] ) ? (int) $_GET['trashed'] : 0; - $untrashed = isset( $_GET['untrashed'] ) ? (int) $_GET['untrashed'] : 0; - $spammed = isset( $_GET['spammed'] ) ? (int) $_GET['spammed'] : 0; - $unspammed = isset( $_GET['unspammed'] ) ? (int) $_GET['unspammed'] : 0; - $same = isset( $_GET['same'] ) ? (int) $_GET['same'] : 0; +if ( isset($_REQUEST['approved']) || isset($_REQUEST['deleted']) || isset($_REQUEST['trashed']) || isset($_REQUEST['untrashed']) || isset($_REQUEST['spammed']) || isset($_REQUEST['unspammed']) || isset($_REQUEST['same']) ) { + $approved = isset( $_REQUEST['approved'] ) ? (int) $_REQUEST['approved'] : 0; + $deleted = isset( $_REQUEST['deleted'] ) ? (int) $_REQUEST['deleted'] : 0; + $trashed = isset( $_REQUEST['trashed'] ) ? (int) $_REQUEST['trashed'] : 0; + $untrashed = isset( $_REQUEST['untrashed'] ) ? (int) $_REQUEST['untrashed'] : 0; + $spammed = isset( $_REQUEST['spammed'] ) ? (int) $_REQUEST['spammed'] : 0; + $unspammed = isset( $_REQUEST['unspammed'] ) ? (int) $_REQUEST['unspammed'] : 0; + $same = isset( $_REQUEST['same'] ) ? (int) $_REQUEST['same'] : 0; if ( $approved > 0 || $deleted > 0 || $trashed > 0 || $untrashed > 0 || $spammed > 0 || $unspammed > 0 || $same > 0 ) { if ( $approved > 0 ) $messages[] = sprintf( _n( '%s comment approved', '%s comments approved', $approved ), $approved ); if ( $spammed > 0 ) { - $ids = isset($_GET['ids']) ? $_GET['ids'] : 0; + $ids = isset($_REQUEST['ids']) ? $_REQUEST['ids'] : 0; $messages[] = sprintf( _n( '%s comment marked as spam.', '%s comments marked as spam.', $spammed ), $spammed ) . ' ' . __('Undo') . '
      '; } @@ -175,7 +187,7 @@ if ( isset($_GET['approved']) || isset($_GET['deleted']) || isset($_GET['trashed $messages[] = sprintf( _n( '%s comment restored from the spam', '%s comments restored from the spam', $unspammed ), $unspammed ); if ( $trashed > 0 ) { - $ids = isset($_GET['ids']) ? $_GET['ids'] : 0; + $ids = isset($_REQUEST['ids']) ? $_REQUEST['ids'] : 0; $messages[] = sprintf( _n( '%s comment moved to the Trash.', '%s comments moved to the Trash.', $trashed ), $trashed ) . ' ' . __('Undo') . '
      '; } @@ -204,285 +216,31 @@ if ( isset($_GET['approved']) || isset($_GET['deleted']) || isset($_GET['trashed } ?> -
      -
        -moderated) ), "" . number_format_i18n($num_comments->moderated) . ""), -//, number_format_i18n($num_comments->spam) ), "" . number_format_i18n($num_comments->spam) . "") -$stati = array( - 'all' => _nx_noop('All', 'All', 'comments'), // singular not used - 'moderated' => _n_noop('Pending (%s)', 'Pending (%s)'), - 'approved' => _n_noop('Approved', 'Approved'), // singular not used - 'spam' => _n_noop('Spam (%s)', 'Spam (%s)'), - 'trash' => _n_noop('Trash (%s)', 'Trash (%s)') - ); +views(); ?> -if ( !EMPTY_TRASH_DAYS ) - unset($stati['trash']); - -$link = 'edit-comments.php'; -if ( !empty($comment_type) && 'all' != $comment_type ) - $link = add_query_arg( 'comment_type', $comment_type, $link ); - -foreach ( $stati as $status => $label ) { - $class = ( $status == $comment_status ) ? ' class="current"' : ''; - - if ( !isset( $num_comments->$status ) ) - $num_comments->$status = 10; - $link = add_query_arg( 'comment_status', $status, $link ); - if ( $post_id ) - $link = add_query_arg( 'p', absint( $post_id ), $link ); - /* - // I toyed with this, but decided against it. Leaving it in here in case anyone thinks it is a good idea. ~ Mark - if ( !empty( $_GET['s'] ) ) - $link = add_query_arg( 's', esc_attr( stripslashes( $_GET['s'] ) ), $link ); - */ - if ( isset( $label[2] ) ) - $translated_label = _nx( $label[0], $label[1], $num_comments->$status, $label[2] ); - else - $translated_label = _n( $label[0], $label[1], $num_comments->$status ); - $status_links[] = "
      • " . sprintf( - $translated_label, - number_format_i18n( $num_comments->$status ) - ) . ''; -} - -$status_links = apply_filters( 'comment_status_links', $status_links ); - -echo implode( " |
      • \n", $status_links) . ''; -unset($status_links); -?> -
      - - - -comment_post_ID; -} - -$_comment_pending_count = get_pending_comments_num($_comment_post_ids); - -$comments = array_slice($_comments, 0, $comments_per_page); -$extra_comments = array_slice($_comments, $comments_per_page); + -$page_links = paginate_links( array( - 'base' => add_query_arg( 'apage', '%#%' ), - 'format' => '', - 'prev_text' => __('«'), - 'next_text' => __('»'), - 'total' => ceil($total / $comments_per_page), - 'current' => $page -)); +search_box( __( 'Search Comments' ), 'comment' ); ?> -?> - - -
      - - -
      ' . __( 'Displaying %s–%s of %s' ) . '%s', - number_format_i18n( $start + 1 ), - number_format_i18n( min( $page * $comments_per_page, $total ) ), - '' . number_format_i18n( $total ) . '', - $page_links -); echo $page_links_text; ?>
      - - - - - - -
      - - - - - - - - - - - - - - - - - -
      - -
      + + + -
      - -
      - - - - - - - - - - - - - - - - -comment_ID, $mode, $comment_status ); -?> - - -comment_ID, $mode, $comment_status ); -?> - -
      - -
      -$page_links_text
      "; -?> - -
      - - - - - - - + + - -
      - -
      - - -
      - - -
      - - -

      - - -

      - - - - - +
      post_status && !current_user_can( $post_type_object- add_meta_box('slugdiv', __('Slug'), 'post_slug_meta_box', $post_type, 'normal', 'core'); if ( post_type_supports($post_type, 'author') ) { - $authors = get_editable_user_ids( $current_user->id ); // TODO: ROLE SYSTEM - if ( $post->post_author && !in_array($post->post_author, $authors) ) - $authors[] = $post->post_author; - if ( ( $authors && count( $authors ) > 1 ) || is_super_admin() ) + if ( is_super_admin() || current_user_can( $post_type_object->cap->edit_others_posts ) ) add_meta_box('authordiv', __('Author'), 'post_author_meta_box', $post_type, 'normal', 'core'); } @@ -166,18 +166,21 @@ do_action('do_meta_boxes', $post_type, 'normal', $post); do_action('do_meta_boxes', $post_type, 'advanced', $post); do_action('do_meta_boxes', $post_type, 'side', $post); +add_screen_option('layout_columns', array('max' => 2) ); + if ( 'post' == $post_type ) { add_contextual_help($current_screen, - '

      ' . __('The title field and the big Post Editing Area are fixed in place, but you can reposition all the other boxes that allow you to add metadata to your post using drag and drop, and can minimize or expand them by clicking the title bar of the box. You can also hide any of the boxes by using the Screen Options tab, where you can also choose a 1- or 2-column layout for this screen.') . '

      ' . + '

      ' . __('The title field and the big Post Editing Area are fixed in place, but you can reposition all the other boxes using drag and drop, and can minimize or expand them by clicking the title bar of the box. Use the Screen Options tab to unhide more boxes (Excerpt, Send Trackbacks, Custom Fields, Discussion, Slug, Author) or to choose a 1- or 2-column layout for this screen.') . '

      ' . '

      ' . __('Title - Enter a title for your post. After you enter a title, you’ll see the permalink below, which you can edit.') . '

      ' . - '

      ' . __('Post editor - Enter the text for your post. There are two modes of editing: Visual and HTML. Choose the mode by clicking on the appropriate tab. Visual mode gives you a WYSIWYG editor. Click the last icon in the row to get a second row of controls. The HTML mode allows you to enter raw HTML along with your post text. You can insert media files by clicking the icons above the post editor and following the directions.') . '

      ' . + '

      ' . __('Post editor - Enter the text for your post. There are two modes of editing: Visual and HTML. Choose the mode by clicking on the appropriate tab. Visual mode gives you a WYSIWYG editor. Click the last icon in the row to get a second row of controls. The screen icon just before that allows you to expand the edit box to full screen. The HTML mode allows you to enter raw HTML along with your post text. You can insert media files by clicking the icons above the post editor and following the directions.') . '

      ' . '

      ' . __('Publish - You can set the terms of publishing your post in the Publish box. For Status, Visibility, and Publish (immediately), click on the Edit link to reveal more options. Visibility includes options for password-protecting a post or making it stay at the top of your blog indefinitely (sticky). Publish (immediately) allows you to set a future or past date and time, so you can schedule a post to be published in the future or backdate a post.') . '

      ' . + ( ( current_theme_supports( 'post-formats' ) && post_type_supports( 'post', 'post-formats' ) ) ? '

      ' . __( 'Post Format - This designates how your theme will display a specific post. For example, you could have a standard blog post with a title and paragraphs, or a short aside that omits the title and contains a short text blurb. Please refer to the Codex for descriptions of each post format.' ) . '

      ' : '' ) . '

      ' . __('Featured Image - This allows you to associate an image with your post without inserting it. This is usually useful only if your theme makes use of the featured image as a post thumbnail on the home page, a custom header, etc.') . '

      ' . '

      ' . __('Send Trackbacks - Trackbacks are a way to notify legacy blog systems that you’ve linked to them. Enter the URL(s) you want to send trackbacks. If you link to other WordPress sites they’ll be notified automatically using pingbacks, and this field is unnecessary.') . '

      ' . '

      ' . __('Discussion - You can turn comments and pings on or off, and if there are comments on the post, you can see them here and moderate them.') . '

      ' . '

      ' . sprintf(__('You can also create posts with the Press This bookmarklet.'), 'options-writing.php') . '

      ' . '

      ' . __('For more information:') . '

      ' . - '

      ' . __('Documentation on Writing Posts') . '

      ' . + '

      ' . __('Documentation on Writing and Editing Posts') . '

      ' . '

      ' . __('Support Forums') . '

      ' ); } elseif ( 'page' == $post_type ) { @@ -187,7 +190,8 @@ if ( 'post' == $post_type ) { '

      ' . __('Template - Some themes have custom templates you can use for certain pages that might have additional features or custom layouts. If so, you’ll see them in this dropdown menu.') . '

      ' . '

      ' . __('Order - Pages are usually ordered alphabetically, but you can choose your own order by entering a number (1 for first, etc.) in this field.') . '

      ' . '

      ' . __('For more information:') . '

      ' . - '

      ' . __('Page Creation Documentation') . '

      ' . + '

      ' . __('Documentation on Adding New Pages') . '

      ' . + '

      ' . __('Documentation on Editing Pages') . '

      ' . '

      ' . __('Support Forums') . '

      ' ); } @@ -206,12 +210,13 @@ require_once('./admin-header.php');
      > + - - + + - - + + post_status ) @@ -238,17 +243,17 @@ $side_meta_boxes = do_meta_boxes($post_type, 'side', $post);
      - +
      ID); +$sample_permalink_html = ! empty( $post_type_object->publicly_queryable ) ? get_sample_permalink_html($post->ID) : ''; $shortlink = wp_get_shortlink($post->ID, 'post'); if ( !empty($shortlink) ) $sample_permalink_html .= '' . __('Get Shortlink') . ''; -if ( !( 'pending' == $post->post_status && !current_user_can( $post_type_object->cap->publish_posts ) ) ) { ?> +if ( ! empty( $post_type_object->publicly_queryable ) && ! ( 'pending' == $post->post_status && !current_user_can( $post_type_object->cap->publish_posts ) ) ) { ?>
      ID) && ! empty($sample_permalink_html) && 'auto-draft' != $post->post_status ) diff --git a/wp-admin/edit-form-comment.php b/wp-admin/edit-form-comment.php index 42f3e9d8..b3595366 100644 --- a/wp-admin/edit-form-comment.php +++ b/wp-admin/edit-form-comment.php @@ -71,7 +71,7 @@ $date = date_i18n( $datef, strtotime( $comment->comment_date ) ); comment_ID&_wp_original_http_referer=" . urlencode(wp_get_referer()), 'delete-comment_' . $comment->comment_ID) . "'>" . ( !EMPTY_TRASH_DAYS ? __('Delete Permanently') : __('Move to Trash') ) . "\n"; ?>
      - + '4' ) ); ?>
      diff --git a/wp-admin/edit-link-categories.php b/wp-admin/edit-link-categories.php deleted file mode 100644 index 711121be..00000000 --- a/wp-admin/edit-link-categories.php +++ /dev/null @@ -1,237 +0,0 @@ -%s category: this is the default one"), get_term_field('name', $cat_ID, 'link_category') ) ); - - wp_delete_term($cat_ID, 'link_category', array('default' => $default_cat_id)); - } - - $location = 'edit-link-categories.php'; - if ( $referer = wp_get_referer() ) { - if ( false !== strpos($referer, 'edit-link-categories.php') ) - $location = $referer; - } - - $location = add_query_arg('message', 6, $location); - wp_redirect($location); - exit(); - } -} elseif ( ! empty($_GET['_wp_http_referer']) ) { - wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) ); - exit; -} - -$title = __('Link Categories'); - -wp_enqueue_script('admin-categories'); -if ( current_user_can('manage_categories') ) - wp_enqueue_script('inline-edit-tax'); - -add_contextual_help($current_screen, '

      ' . __('You can create groups of links by using link categories. Link category names must be unique and link categories are separate from the categories you use for posts.') . '

      ' . - '

      ' . __('You can delete link categories, but that action does not delete the links within the category. Instead, it moves them to the default link category.') . '

      ' . - '

      ' . __('For more information:') . '

      ' . - '

      ' . __('Link Categories Documentation') . '

      ' . - '

      ' . __('Support Forums') . '

      ' -); - -require_once ('admin-header.php'); - -$messages[1] = __('Category added.'); -$messages[2] = __('Category deleted.'); -$messages[3] = __('Category updated.'); -$messages[4] = __('Category not added.'); -$messages[5] = __('Category not updated.'); -$messages[6] = __('Categories deleted.'); ?> - -
      - -

      ' . __('Search results for “%s”') . '', esc_html( stripslashes($_GET['s']) ) ); ?> -

      - - -

      - - - - - -
      - -
      - -
      -
      -
      -
      - - add_query_arg( 'pagenum', '%#%' ), - 'format' => '', - 'prev_text' => __('«'), - 'next_text' => __('»'), - 'total' => ceil(wp_count_terms('link_category') / $catsperpage), - 'current' => $pagenum -)); - -if ( $page_links ) - echo "
      $page_links
      "; -?> - -
      - - - -
      - -
      -
      - -
      - - - - - - - - - - - - - - - - $start, 'number' => $catsperpage, 'hide_empty' => 0); -if ( !empty( $_GET['s'] ) ) - $args['search'] = $_GET['s']; - -$categories = get_terms( 'link_category', $args ); -if ( $categories ) { - $output = ''; - foreach ( $categories as $category ) { - $output .= link_cat_row($category); - } - echo $output; - unset($category); -} - -?> - -
      - -
      -$page_links
      "; -?> - -
      - - -
      - -
      -
      -
      - - -
      -

      Note:
      Deleting a category does not delete the links in that category. Instead, links that were only assigned to the deleted category are set to the category %s.'), get_term_field('name', get_option('default_link_category'), 'link_category')) ?>

      -
      - - -
      -
      - -
      -
      - -parent = 0; do_action('add_link_category_form_pre', $category); ?> - -
      -

      -
      -
      - - - -
      - - -
      - -
      - - -

      -
      - -
      - - -

      -
      - -

      - -
      -
      - - - -
      -
      - -
      -
      - - - diff --git a/wp-admin/edit-link-category-form.php b/wp-admin/edit-link-category-form.php deleted file mode 100644 index 7e7c004c..00000000 --- a/wp-admin/edit-link-category-form.php +++ /dev/null @@ -1,92 +0,0 @@ -' . __('Edit Link Category') . ''; - $submit_text = __('Update Category'); - $form = '
      '; - $action = 'editedcat'; - $nonce_action = 'update-link-category_' . $cat_ID; - do_action('edit_link_category_form_pre', $category); -} else { - $heading = '

      ' . __('Add Link Category') . '

      '; - $submit_text = __('Add Category'); - $form = ''; - $action = 'addcat'; - $nonce_action = 'add-link-category'; - do_action('add_link_category_form_pre', $category); -} - -/** - * @ignore - * @since 2.7 - * @internal Used to prevent errors in page when no category is being edited. - * - * @param object $category - */ -function _fill_empty_link_category(&$category) { - if ( ! isset( $category->name ) ) - $category->name = ''; - - if ( ! isset( $category->slug ) ) - $category->slug = ''; - - if ( ! isset( $category->description ) ) - $category->description = ''; -} - -_fill_empty_link_category($category); -?> - -
      - - -
      - - - - - - - - - - - - - - - - - - - - -

      -

      -
      -

      - - -
      diff --git a/wp-admin/edit-link-form.php b/wp-admin/edit-link-form.php index 29e28623..f5bc0304 100644 --- a/wp-admin/edit-link-form.php +++ b/wp-admin/edit-link-form.php @@ -37,6 +37,8 @@ do_action('do_meta_boxes', 'link', 'normal', $link); do_action('do_meta_boxes', 'link', 'advanced', $link); do_action('do_meta_boxes', 'link', 'side', $link); +add_screen_option('layout_columns', array('max' => 2) ); + add_contextual_help($current_screen, '

      ' . __( 'You can add or edit links on this screen by entering information in each of the boxes. Only the link’s web address and name (the text you want to display on your site as the link) are required fields.' ) . '

      ' . '

      ' . __( 'The boxes for link name, web address, and description have fixed positions, while the others may be repositioned using drag and drop. You can also hide boxes you don’t use in the Screen Options tab, or minimize boxes by clicking on the title bar of the box.' ) . '

      ' . diff --git a/wp-admin/edit-post-rows.php b/wp-admin/edit-post-rows.php deleted file mode 100644 index 2bf88416..00000000 --- a/wp-admin/edit-post-rows.php +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - - -hierarchical ) - page_rows($posts, $pagenum, $per_page); -else - post_rows(); -?> - -
      \ No newline at end of file diff --git a/wp-admin/edit-tag-form.php b/wp-admin/edit-tag-form.php index 56674de0..daac9237 100644 --- a/wp-admin/edit-tag-form.php +++ b/wp-admin/edit-tag-form.php @@ -16,10 +16,14 @@ if ( empty($tag_ID) ) { ?> return; } +// Back compat hooks if ( 'category' == $taxonomy ) do_action('edit_category_form_pre', $tag ); +elseif ( 'link_category' == $taxonomy ) + do_action('edit_link_category_form_pre', $tag ); else do_action('edit_tag_form_pre', $tag); + do_action($taxonomy . '_pre_edit_form', $tag, $taxonomy); ?>
      @@ -48,7 +52,7 @@ do_action($taxonomy . '_pre_edit_form', $tag, $taxonomy); ?> - 0, 'hide_if_empty' => false, 'name' => 'parent', 'orderby' => 'name', 'taxonomy' => $taxonomy, 'selected' => $tag->parent, 'exclude' => $tag->term_id, 'hierarchical' => true, 'show_option_none' => __('None'))); ?>
      + 0, 'hide_if_empty' => false, 'name' => 'parent', 'orderby' => 'name', 'taxonomy' => $taxonomy, 'selected' => $tag->parent, 'exclude_tree' => $tag->term_id, 'hierarchical' => true, 'show_option_none' => __('None'))); ?>
      @@ -57,24 +61,33 @@ do_action($taxonomy . '_pre_edit_form', $tag, $taxonomy); ?> -
      +
      -

      diff --git a/wp-admin/edit-tags.php b/wp-admin/edit-tags.php index 057aa489..0a82e29f 100644 --- a/wp-admin/edit-tags.php +++ b/wp-admin/edit-tags.php @@ -8,60 +8,52 @@ /** WordPress Administration Bootstrap */ require_once('./admin.php'); +$tax = get_taxonomy( $taxnow ); +if ( !current_user_can( $tax->cap->manage_terms ) ) + wp_die( __( 'Cheatin’ uh?' ) ); -wp_reset_vars( array('action', 'tag', 'taxonomy', 'post_type') ); - -if ( empty($taxonomy) ) - $taxonomy = 'post_tag'; - -if ( !taxonomy_exists($taxonomy) ) - wp_die(__('Invalid taxonomy')); - -$tax = get_taxonomy($taxonomy); - -if ( ! current_user_can($tax->cap->manage_terms) ) - wp_die(__('Cheatin’ uh?')); +$wp_list_table = _get_list_table('WP_Terms_List_Table'); +$pagenum = $wp_list_table->get_pagenum(); $title = $tax->labels->name; -if ( empty($post_type) || !in_array( $post_type, get_post_types( array('public' => true) ) ) ) - $post_type = 'post'; - if ( 'post' != $post_type ) { $parent_file = "edit.php?post_type=$post_type"; $submenu_file = "edit-tags.php?taxonomy=$taxonomy&post_type=$post_type"; +} else if ( 'link_category' == $tax->name ) { + $parent_file = 'link-manager.php'; + $submenu_file = 'edit-tags.php?taxonomy=link_category'; } else { $parent_file = 'edit.php'; $submenu_file = "edit-tags.php?taxonomy=$taxonomy"; } -if ( isset( $_GET['action'] ) && isset($_GET['delete_tags']) && ( 'delete' == $_GET['action'] || 'delete' == $_GET['action2'] ) ) - $action = 'bulk-delete'; +add_screen_option( 'per_page', array('label' => $title, 'default' => 20, 'option' => 'edit_' . $tax->name . '_per_page') ); -switch($action) { +switch ( $wp_list_table->current_action() ) { case 'add-tag': - check_admin_referer('add-tag'); + check_admin_referer( 'add-tag' ); - if ( !current_user_can($tax->cap->edit_terms) ) - wp_die(__('Cheatin’ uh?')); + if ( !current_user_can( $tax->cap->edit_terms ) ) + wp_die( __( 'Cheatin’ uh?' ) ); - $ret = wp_insert_term($_POST['tag-name'], $taxonomy, $_POST); + $ret = wp_insert_term( $_POST['tag-name'], $taxonomy, $_POST ); $location = 'edit-tags.php?taxonomy=' . $taxonomy; if ( 'post' != $post_type ) $location .= '&post_type=' . $post_type; if ( $referer = wp_get_original_referer() ) { - if ( false !== strpos($referer, 'edit-tags.php') ) + if ( false !== strpos( $referer, 'edit-tags.php' ) ) $location = $referer; } if ( $ret && !is_wp_error( $ret ) ) - $location = add_query_arg('message', 1, $location); + $location = add_query_arg( 'message', 1, $location ); else - $location = add_query_arg('message', 4, $location); - wp_redirect($location); + $location = add_query_arg( 'message', 4, $location ); + wp_redirect( $location ); exit; break; @@ -70,50 +62,50 @@ case 'delete': if ( 'post' != $post_type ) $location .= '&post_type=' . $post_type; if ( $referer = wp_get_referer() ) { - if ( false !== strpos($referer, 'edit-tags.php') ) + if ( false !== strpos( $referer, 'edit-tags.php' ) ) $location = $referer; } - if ( !isset( $_GET['tag_ID'] ) ) { - wp_redirect($location); + if ( !isset( $_REQUEST['tag_ID'] ) ) { + wp_redirect( $location ); exit; } - $tag_ID = (int) $_GET['tag_ID']; - check_admin_referer('delete-tag_' . $tag_ID); + $tag_ID = (int) $_REQUEST['tag_ID']; + check_admin_referer( 'delete-tag_' . $tag_ID ); - if ( !current_user_can($tax->cap->delete_terms) ) - wp_die(__('Cheatin’ uh?')); + if ( !current_user_can( $tax->cap->delete_terms ) ) + wp_die( __( 'Cheatin’ uh?' ) ); - wp_delete_term( $tag_ID, $taxonomy); + wp_delete_term( $tag_ID, $taxonomy ); - $location = add_query_arg('message', 2, $location); - wp_redirect($location); + $location = add_query_arg( 'message', 2, $location ); + wp_redirect( $location ); exit; break; case 'bulk-delete': - check_admin_referer('bulk-tags'); + check_admin_referer( 'bulk-tags' ); - if ( !current_user_can($tax->cap->delete_terms) ) - wp_die(__('Cheatin’ uh?')); + if ( !current_user_can( $tax->cap->delete_terms ) ) + wp_die( __( 'Cheatin’ uh?' ) ); - $tags = (array) $_GET['delete_tags']; - foreach( $tags as $tag_ID ) { - wp_delete_term( $tag_ID, $taxonomy); + $tags = (array) $_REQUEST['delete_tags']; + foreach ( $tags as $tag_ID ) { + wp_delete_term( $tag_ID, $taxonomy ); } $location = 'edit-tags.php?taxonomy=' . $taxonomy; if ( 'post' != $post_type ) $location .= '&post_type=' . $post_type; if ( $referer = wp_get_referer() ) { - if ( false !== strpos($referer, 'edit-tags.php') ) + if ( false !== strpos( $referer, 'edit-tags.php' ) ) $location = $referer; } - $location = add_query_arg('message', 6, $location); - wp_redirect($location); + $location = add_query_arg( 'message', 6, $location ); + wp_redirect( $location ); exit; break; @@ -121,85 +113,107 @@ break; case 'edit': $title = $tax->labels->edit_item; - require_once ('admin-header.php'); - $tag_ID = (int) $_GET['tag_ID']; - - if ( !current_user_can($tax->cap->edit_terms) ) - wp_die( __('You are not allowed to edit this item.') ); + require_once ( 'admin-header.php' ); + $tag_ID = (int) $_REQUEST['tag_ID']; - $tag = get_term($tag_ID, $taxonomy, OBJECT, 'edit'); - include('./edit-tag-form.php'); + $tag = get_term( $tag_ID, $taxonomy, OBJECT, 'edit' ); + include( './edit-tag-form.php' ); break; case 'editedtag': $tag_ID = (int) $_POST['tag_ID']; - check_admin_referer('update-tag_' . $tag_ID); + check_admin_referer( 'update-tag_' . $tag_ID ); - if ( !current_user_can($tax->cap->edit_terms) ) - wp_die(__('Cheatin’ uh?')); + if ( !current_user_can( $tax->cap->edit_terms ) ) + wp_die( __( 'Cheatin’ uh?' ) ); - $ret = wp_update_term($tag_ID, $taxonomy, $_POST); + $ret = wp_update_term( $tag_ID, $taxonomy, $_POST ); $location = 'edit-tags.php?taxonomy=' . $taxonomy; if ( 'post' != $post_type ) $location .= '&post_type=' . $post_type; if ( $referer = wp_get_original_referer() ) { - if ( false !== strpos($referer, 'edit-tags.php') ) + if ( false !== strpos( $referer, 'edit-tags.php' ) ) $location = $referer; } if ( $ret && !is_wp_error( $ret ) ) - $location = add_query_arg('message', 3, $location); + $location = add_query_arg( 'message', 3, $location ); else - $location = add_query_arg('message', 5, $location); + $location = add_query_arg( 'message', 5, $location ); - wp_redirect($location); + wp_redirect( $location ); exit; break; default: +if ( ! empty($_REQUEST['_wp_http_referer']) ) { + $location = remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ); -if ( ! empty($_GET['_wp_http_referer']) ) { - wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) ); - exit; + if ( ! empty( $_REQUEST['paged'] ) ) + $location = add_query_arg( 'paged', (int) $_REQUEST['paged'] ); + + wp_redirect( $location ); + exit; +} + +$wp_list_table->prepare_items(); +$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); + +if ( $pagenum > $total_pages && $total_pages > 0 ) { + wp_redirect( add_query_arg( 'paged', $total_pages ) ); + exit; } wp_enqueue_script('admin-tags'); if ( current_user_can($tax->cap->edit_terms) ) wp_enqueue_script('inline-edit-tax'); -if ( 'category' == $taxonomy || 'post_tag' == $taxonomy ) { +if ( 'category' == $taxonomy || 'link_category' == $taxonomy || 'post_tag' == $taxonomy ) { + $help =''; if ( 'category' == $taxonomy ) - $help = '

      ' . sprintf(__('You can use categories to define sections of your site and group related posts. The default category is “Uncategorized” until you change it in your writing settings.'), 'options-writing.php') . '

      '; + $help = '

      ' . sprintf(__( 'You can use categories to define sections of your site and group related posts. The default category is “Uncategorized” until you change it in your writing settings.' ) , 'options-writing.php' ) . '

      '; + elseif ( 'link_category' == $taxonomy ) + $help = '

      ' . __( 'You can create groups of links by using link categories. Link category names must be unique and link categories are separate from the categories you use for posts.' ) . '

      '; else - $help = '

      ' . __('You can assign keywords to your posts using Post Tags. Unlike categories, tags have no hierarchy, meaning there’s no relationship from one tag to another.') . '

      '; + $help = '

      ' . __( 'You can assign keywords to your posts using Post Tags. Unlike categories, tags have no hierarchy, meaning there’s no relationship from one tag to another.' ) . '

      '; - $help .='

      ' . __('What’s the difference between categories and tags? Normally, tags are ad-hoc keywords that identify important information in your post (names, subjects, etc) that may or may not recur in other posts, while categories are pre-determined sections. If you think of your site like a book, the categories are like the Table of Contents and the tags are like the terms in the index.') . '

      '; + if ( 'link_category' == $taxonomy ) + $help .= '

      ' . __( 'You can delete link categories in the Bulk Action pulldown, but that action does not delete the links within the category. Instead, it moves them to the default link category.' ) . '

      '; + else + $help .='

      ' . __( 'What’s the difference between categories and tags? Normally, tags are ad-hoc keywords that identify important information in your post (names, subjects, etc) that may or may not recur in other posts, while categories are pre-determined sections. If you think of your site like a book, the categories are like the Table of Contents and the tags are like the terms in the index.' ) . '

      '; if ( 'category' == $taxonomy ) - $help .= '

      ' . __('When adding a new category on this screen, you’ll fill in the following fields:') . '

      '; - else - $help .= '

      ' . __('When adding a new tag on this screen, you’ll fill in the following fields:') . '

      '; + $help .= '

      ' . __( 'When adding a new category on this screen, you’ll fill in the following fields:' ) . '

      '; + elseif ( 'post_tag' == $taxonomy ) + $help .= '

      ' . __( 'When adding a new tag on this screen, you’ll fill in the following fields:' ) . '

      '; + + if ( 'category' == $taxonomy || 'post_tag' == $taxonomy ) - $help .= '
        ' . - '
      • ' . __('Name - The name is how it appears on your site.') . '
      • '; - if ( ! global_terms_enabled() ) - $help .= '
      • ' . __('Slug - The “slug” is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.') . '
      • '; + $help .= '
          ' . + '
        • ' . __( 'Name - The name is how it appears on your site.' ) . '
        • '; + + if ( ! global_terms_enabled() ) + if ( 'category' == $taxonomy || 'post_tag' == $taxonomy ) + $help .= '
        • ' . __( 'Slug - The “slug” is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.' ) . '
        • '; if ( 'category' == $taxonomy ) - $help .= '
        • ' . __('Parent - Categories, unlike tags, can have a hierarchy. You might have a Jazz category, and under that have children categories for Bebop and Big Band. Totally optional. To create a subcategory, just choose another category from the Parent dropdown.') . '
        • '; + $help .= '
        • ' . __( 'Parent - Categories, unlike tags, can have a hierarchy. You might have a Jazz category, and under that have children categories for Bebop and Big Band. Totally optional. To create a subcategory, just choose another category from the Parent dropdown.' ) . '
        • '; - $help .= '
        • ' . __('Description - The description is not prominent by default; however, some themes may display it.') . '
        • ' . + if ( 'category' == $taxonomy || 'post_tag' == $taxonomy ) + $help .= '
        • ' . __( 'Description - The description is not prominent by default; however, some themes may display it.' ) . '
        • ' . '
        ' . - '

        ' . __('You can change the display of this screen using the Screen Options tab to set how many items are displayed per screen and to display/hide columns in the table.') . '

        ' . - '

        ' . __('For more information:') . '

        '; + '

        ' . __( 'You can change the display of this screen using the Screen Options tab to set how many items are displayed per screen and to display/hide columns in the table.' ) . '

        ' . + '

        ' . __( 'For more information:' ) . '

        '; if ( 'category' == $taxonomy ) - $help .= '

        ' . __('Categories Documentation') . '

        '; + $help .= '

        ' . __( 'Documentation on Categories' ) . '

        '; + elseif ( 'link_category' == $taxonomy ) + $help .= '

        ' . __( 'Documentation on Link Categories' ) . '

        '; else - $help .= '

        ' . __('Tags Documentation') . '

        '; + $help .= '

        ' . __( 'Documentation on Post Tags' ) . '

        '; $help .= '

        ' . __('Support Forums') . '

        '; @@ -209,6 +223,9 @@ if ( 'category' == $taxonomy || 'post_tag' == $taxonomy ) { require_once ('admin-header.php'); +if ( !current_user_can($tax->cap->edit_terms) ) + wp_die( __('You are not allowed to edit this item.') ); + $messages[1] = __('Item added.'); $messages[2] = __('Item deleted.'); $messages[3] = __('Item updated.'); @@ -221,11 +238,11 @@ $messages[6] = __('Items deleted.');

        ' . __('Search results for “%s”') . '', esc_html( stripslashes($_GET['s']) ) ); ?> +if ( !empty($_REQUEST['s']) ) + printf( '' . __('Search results for “%s”') . '', esc_html( stripslashes($_REQUEST['s']) ) ); ?>

        - +

        @@ -234,11 +251,9 @@ endif; ?>
        - + +search_box( $tax->labels->search_items, 'tag' ); ?> +

        @@ -246,91 +261,11 @@ endif; ?>
        -
        + -
        - add_query_arg( 'pagenum', '%#%' ), - 'format' => '', - 'prev_text' => __('«'), - 'next_text' => __('»'), - 'total' => ceil(wp_count_terms($taxonomy, array('search' => $searchterms)) / $tags_per_page), - 'current' => $pagenum -)); - -if ( $page_links ) - echo "
        $page_links
        "; -?> - -
        - - - -
        - -
        -
        - -
        - - - - - - - - - - - - - - - - -
        - -
        -$page_links
        "; -?> - -
        - - -
        - -
        -
        +display(); ?>
        @@ -358,7 +293,7 @@ do_action('after-' . $taxonomy . '-table', $taxonomy); labels->popular_items ) ) { if ( current_user_can( $tax->cap->edit_terms ) ) $tag_cloud = wp_tag_cloud( array( 'taxonomy' => $taxonomy, 'echo' => false, 'link' => 'edit' ) ); else @@ -375,10 +310,14 @@ endif; } if ( current_user_can($tax->cap->edit_terms) ) { + // Back compat hooks. Deprecated in preference to {$taxonomy}_pre_add_form if ( 'category' == $taxonomy ) - do_action('add_category_form_pre', (object)array('parent' => 0) ); // Back compat hook. Deprecated in preference to $taxonomy_pre_add_form + do_action('add_category_form_pre', (object)array('parent' => 0) ); + elseif ( 'link_category' == $taxonomy ) + do_action('add_link_category_form_pre', (object)array('parent' => 0) ); else - do_action('add_tag_form_pre', $taxonomy); // Back compat hook. Applies to all Taxonomies -not- categories + do_action('add_tag_form_pre', $taxonomy); + do_action($taxonomy . '_pre_add_form', $taxonomy); ?> @@ -402,7 +341,7 @@ if ( current_user_can($tax->cap->edit_terms) ) {

        - +
        @@ -422,13 +361,17 @@ if ( current_user_can($tax->cap->edit_terms) ) { if ( ! is_taxonomy_hierarchical($taxonomy) ) do_action('add_tag_form_fields', $taxonomy); do_action($taxonomy . '_add_form_fields', $taxonomy); -?> -

        -labels->add_new_item, 'button' ); + +// Back compat hooks. Deprecated in preference to {$taxonomy}_add_form if ( 'category' == $taxonomy ) - do_action('edit_category_form', (object)array('parent' => 0) ); // Back compat hook. Deprecated in preference to $taxonomy_add_form + do_action('edit_category_form', (object)array('parent' => 0) ); +elseif ( 'link_category' == $taxonomy ) + do_action('edit_link_category_form', (object)array('parent' => 0) ); else - do_action('add_tag_form', $taxonomy); // Back compat hook. Applies to all Taxonomies -not- categories + do_action('add_tag_form', $taxonomy); + do_action($taxonomy . '_add_form', $taxonomy); ?>
        @@ -440,7 +383,7 @@ do_action($taxonomy . '_add_form', $taxonomy);
        - +inline_edit(); ?> true ) $post_type = $_GET['post_type']; else wp_die( __('Invalid post type') ); + $_GET['post_type'] = $post_type; -$post_type_object = get_post_type_object($post_type); +$post_type_object = get_post_type_object( $post_type ); if ( !current_user_can($post_type_object->cap->edit_posts) ) wp_die(__('Cheatin’ uh?')); +$wp_list_table = _get_list_table('WP_Posts_List_Table'); +$pagenum = $wp_list_table->get_pagenum(); + // Back-compat for viewing comments of an entry -if ( $_redirect = intval( max( @$_GET['p'], @$_GET['attachment_id'], @$_GET['page_id'] ) ) ) { - wp_redirect( admin_url('edit-comments.php?p=' . $_redirect ) ); - exit; -} else { - unset( $_redirect ); +foreach ( array( 'p', 'attachment_id', 'page_id' ) as $_redirect ) { + if ( ! empty( $_REQUEST[ $_redirect ] ) ) { + wp_redirect( admin_url( 'edit-comments.php?p=' . absint( $_REQUEST[ $_redirect ] ) ) ); + exit; + } } +unset( $_redirect ); if ( 'post' != $post_type ) { $parent_file = "edit.php?post_type=$post_type"; @@ -40,34 +45,32 @@ if ( 'post' != $post_type ) { $post_new_file = 'post-new.php'; } -$pagenum = isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 0; -if ( empty($pagenum) ) - $pagenum = 1; -$edit_per_page = 'edit_' . $post_type . '_per_page'; -$per_page = (int) get_user_option( $edit_per_page ); -if ( empty( $per_page ) || $per_page < 1 ) - $per_page = 20; - -$per_page = apply_filters( $edit_per_page, $per_page ); -$per_page = apply_filters( 'edit_posts_per_page', $per_page, $post_type ); +$doaction = $wp_list_table->current_action(); -// Handle bulk actions -if ( isset($_GET['doaction']) || isset($_GET['doaction2']) || isset($_GET['delete_all']) || isset($_GET['delete_all2']) || isset($_GET['bulk_edit']) ) { +if ( $doaction ) { check_admin_referer('bulk-posts'); - $sendback = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'ids'), wp_get_referer() ); + $sendback = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'ids'), wp_get_referer() ); + $sendback = add_query_arg( 'paged', $pagenum, $sendback ); if ( strpos($sendback, 'post.php') !== false ) $sendback = admin_url($post_new_file); - if ( isset($_GET['delete_all']) || isset($_GET['delete_all2']) ) { - $post_status = preg_replace('/[^a-z0-9_-]+/i', '', $_GET['post_status']); - $post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type=%s AND post_status = %s", $post_type, $post_status ) ); + if ( 'delete_all' == $doaction ) { + $post_status = preg_replace('/[^a-z0-9_-]+/i', '', $_REQUEST['post_status']); + if ( get_post_status_object($post_status) ) // Check the post status exists first + $post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type=%s AND post_status = %s", $post_type, $post_status ) ); $doaction = 'delete'; - } elseif ( ( $_GET['action'] != -1 || $_GET['action2'] != -1 ) && ( isset($_GET['post']) || isset($_GET['ids']) ) ) { - $post_ids = isset($_GET['post']) ? array_map( 'intval', (array) $_GET['post'] ) : explode(',', $_GET['ids']); - $doaction = ($_GET['action'] != -1) ? $_GET['action'] : $_GET['action2']; - } else { - wp_redirect( admin_url("edit.php?post_type=$post_type") ); + } elseif ( isset( $_REQUEST['media'] ) ) { + $post_ids = $_REQUEST['media']; + } elseif ( isset( $_REQUEST['ids'] ) ) { + $post_ids = explode( ',', $_REQUEST['ids'] ); + } elseif ( !empty( $_REQUEST['post'] ) ) { + $post_ids = array_map('intval', $_REQUEST['post']); + } + + if ( !isset( $post_ids ) ) { + wp_redirect( $sendback ); + exit; } switch ( $doaction ) { @@ -82,7 +85,7 @@ if ( isset($_GET['doaction']) || isset($_GET['doaction2']) || isset($_GET['delet $trashed++; } - $sendback = add_query_arg( array('trashed' => $trashed, 'ids' => join(',', $post_ids)), $sendback ); + $sendback = add_query_arg( array('trashed' => $trashed, 'ids' => join(',', $post_ids) ), $sendback ); break; case 'untrash': $untrashed = 0; @@ -117,7 +120,7 @@ if ( isset($_GET['doaction']) || isset($_GET['doaction2']) || isset($_GET['delet $sendback = add_query_arg('deleted', $deleted, $sendback); break; case 'edit': - $done = bulk_edit_posts($_GET); + $done = bulk_edit_posts($_REQUEST); if ( is_array($done) ) { $done['updated'] = count( $done['updated'] ); @@ -128,32 +131,24 @@ if ( isset($_GET['doaction']) || isset($_GET['doaction2']) || isset($_GET['delet break; } - if ( isset($_GET['action']) ) - $sendback = remove_query_arg( array('action', 'action2', 'tags_input', 'post_author', 'comment_status', 'ping_status', '_status', 'post', 'bulk_edit', 'post_view'), $sendback ); + $sendback = remove_query_arg( array('action', 'action2', 'tags_input', 'post_author', 'comment_status', 'ping_status', '_status', 'post', 'bulk_edit', 'post_view'), $sendback ); wp_redirect($sendback); exit(); -} elseif ( ! empty($_GET['_wp_http_referer']) ) { +} elseif ( ! empty($_REQUEST['_wp_http_referer']) ) { wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) ); exit; } -wp_enqueue_script('inline-edit-post'); +$wp_list_table->prepare_items(); -$user_posts = false; -if ( !current_user_can($post_type_object->cap->edit_others_posts) ) { - $user_posts_count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(1) FROM $wpdb->posts WHERE post_type = '%s' AND post_status NOT IN ('trash', 'auto-draft') AND post_author = %d", $post_type, $current_user->ID) ); - $user_posts = true; - if ( $user_posts_count && empty($_GET['post_status']) && empty($_GET['all_posts']) && empty($_GET['author']) ) - $_GET['author'] = $current_user->ID; +$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); +if ( $pagenum > $total_pages && $total_pages > 0 ) { + wp_redirect( add_query_arg( 'paged', $total_pages ) ); + exit; } -$avail_post_stati = wp_edit_posts_query(); - -if ( $post_type_object->hierarchical ) - $num_pages = ceil($wp_query->post_count / $per_page); -else - $num_pages = $wp_query->max_num_pages; +wp_enqueue_script('inline-edit-post'); $title = $post_type_object->labels->name; @@ -175,70 +170,67 @@ if ( 'post' == $post_type ) { '
      ' . '

      ' . __('You can also edit multiple posts at once. Select the posts you want to edit using the checkboxes, select Edit from the Bulk Actions menu and click Apply. You will be able to change the metadata (categories, author, etc.) for all selected posts at once. To remove a post from the grouping, just click the x next to its name in the Bulk Edit area that appears.') . '

      ' . '

      ' . __('For more information:') . '

      ' . - '

      ' . __('Edit Posts Documentation') . '

      ' . + '

      ' . __('Documentation on Managing Posts') . '

      ' . '

      ' . __('Support Forums') . '

      ' ); } elseif ( 'page' == $post_type ) { add_contextual_help($current_screen, - '

      ' . __('Pages are similar to to Posts in that they have a title, body text, and associated metadata, but they are different in that they are not part of the chronological blog stream, kind of like permanent posts. Pages are not categorized or tagged, but can have a hierarchy. You can nest Pages under other Pages by making one the “Parent” of the other, creating a group of Pages.') . '

      ' . + '

      ' . __('Pages are similar to Posts in that they have a title, body text, and associated metadata, but they are different in that they are not part of the chronological blog stream, kind of like permanent posts. Pages are not categorized or tagged, but can have a hierarchy. You can nest Pages under other Pages by making one the “Parent” of the other, creating a group of Pages.') . '

      ' . '

      ' . __('Managing Pages is very similar to managing Posts, and the screens can be customized in the same way.') . '

      ' . '

      ' . __('You can also perform the same types of actions, including narrowing the list by using the filters, acting on a Page using the action links that appear when you hover over a row, or using the Bulk Actions menu to edit the metadata for multiple Pages at once.') . '

      ' . '

      ' . __('For more information:') . '

      ' . - '

      ' . __('Page Management Documentation') . '

      ' . + '

      ' . __('Documentation on Managing Pages') . '

      ' . '

      ' . __('Support Forums') . '

      ' ); } -require_once('./admin-header.php'); - -if ( empty($_GET['mode']) ) - $mode = 'list'; -else - $mode = esc_attr($_GET['mode']); ?> +add_screen_option( 'per_page', array('label' => $title, 'default' => 20) ); +require_once('./admin-header.php'); +?>

      labels->name ); ?> labels->add_new); ?> ' . __('Search results for “%s”') . '', get_search_query() ); ?>

      -

      |

      +if ( isset($_REQUEST['posted']) && $_REQUEST['posted'] ) : $_REQUEST['posted'] = (int) $_REQUEST['posted']; ?> +

      |

      - +

      -' . __('Undo') . '
      '; - unset($_GET['trashed']); + unset($_REQUEST['trashed']); } -if ( isset($_GET['untrashed']) && (int) $_GET['untrashed'] ) { - printf( _n( 'Item restored from the Trash.', '%s items restored from the Trash.', $_GET['untrashed'] ), number_format_i18n( $_GET['untrashed'] ) ); - unset($_GET['undeleted']); +if ( isset($_REQUEST['untrashed']) && (int) $_REQUEST['untrashed'] ) { + printf( _n( 'Item restored from the Trash.', '%s items restored from the Trash.', $_REQUEST['untrashed'] ), number_format_i18n( $_REQUEST['untrashed'] ) ); + unset($_REQUEST['undeleted']); } $_SERVER['REQUEST_URI'] = remove_query_arg( array('locked', 'skipped', 'updated', 'deleted', 'trashed', 'untrashed'), $_SERVER['REQUEST_URI'] ); @@ -246,218 +238,27 @@ $_SERVER['REQUEST_URI'] = remove_query_arg( array('locked', 'skipped', 'updated'

      -
      +views(); ?> - + - +search_box( $post_type_object->labels->search_items, 'post' ); ?> - + - - - - -
      - add_query_arg( 'paged', '%#%' ), - 'format' => '', - 'prev_text' => __('«'), - 'next_text' => __('»'), - 'total' => $num_pages, - 'current' => $pagenum -)); - -$is_trash = isset($_GET['post_status']) && $_GET['post_status'] == 'trash'; - -?> - -
      - - - - - -prepare("SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts WHERE post_type = %s ORDER BY post_date DESC", $post_type); -$arc_result = $wpdb->get_results( $arc_query ); +display(); ?> -$month_count = count($arc_result); - -if ( $month_count && !( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) { -$m = isset($_GET['m']) ? (int)$_GET['m'] : 0; -?> - - - - __('View all categories'), 'hide_empty' => 0, 'hierarchical' => 1, - 'show_count' => 0, 'orderby' => 'name', 'selected' => $cat); - wp_dropdown_categories($dropdown_options); -} -do_action('restrict_manage_posts'); -?> - -cap->edit_others_posts) ) { ?> - - -
      - - -
      hierarchical ? $wp_query->post_count : $wp_query->found_posts; - $page_links_text = sprintf( '' . __( 'Displaying %s–%s of %s' ) . '%s', - number_format_i18n( ( $pagenum - 1 ) * $per_page + 1 ), - number_format_i18n( min( $pagenum * $per_page, $count_posts ) ), - number_format_i18n( $count_posts ), - $page_links - ); - echo $page_links_text; - ?>
      -hierarchical ) { -?> - - - - -
      -
      - -
      - - - -
      + $page_links_text
      "; +if ( $wp_list_table->has_items() ) + $wp_list_table->inline_edit(); ?> -
      - - -cap->edit_others_posts) ) { ?> - - -
      -
      -
      -
      - - -
      -

      labels->not_found_in_trash; -else - echo $post_type_object->labels->not_found; -?>

      - - - - - -

      diff --git a/wp-admin/export.php b/wp-admin/export.php index 01f3bf98..b765fa02 100644 --- a/wp-admin/export.php +++ b/wp-admin/export.php @@ -16,52 +16,102 @@ if ( !current_user_can('export') ) require_once('./includes/export.php'); $title = __('Export'); -add_contextual_help($current_screen, - '

      ' . __('You can export a file of your site’s content in order to import it into another installation or platform. The export file will be an XML file format called WXR. Posts, pages, comments, custom fields, categories, and tags can be included. You can set filters to have the WXR file only include a certain date, author, category, tag, all posts or all pages, certain publishing statuses.') . '

      ' . +function add_js() { +?> + +' . __('You can export a file of your site’s content in order to import it into another installation or platform. The export file will be an XML file format called WXR. Posts, pages, comments, custom fields, categories, and tags can be included. You can choose for the WXR file to include only certain posts or pages by setting the dropdown filters to limit the export by category, author, date range by month, or publishing status.') . '

      ' . '

      ' . __('Once generated, your WXR file can be imported by another WordPress site or by another blogging platform able to access this format.') . '

      ' . '

      ' . __('For more information:') . '

      ' . - '

      ' . __('Export Documentation') . '

      ' . + '

      ' . __('Documentation on Export') . '

      ' . '

      ' . __('Support Forums') . '

      ' ); if ( isset( $_GET['download'] ) ) { - $author = isset($_GET['author']) ? $_GET['author'] : 'all'; - $taxonomy = array(); - foreach ( get_taxonomies( array( 'show_ui' => true ) ) as $tax ) - $taxonomy[ $tax ] = ! empty( $_GET['export_taxonomy'][ $tax ] ) ? $_GET['export_taxonomy'][ $tax ] : 'all'; - $post_type = isset($_GET['export_post_type']) ? stripslashes_deep($_GET['export_post_type']) : 'all'; - $status = isset($_GET['export_post_status']) ? stripslashes_deep($_GET['export_post_status']) : 'all'; - $mm_start = isset($_GET['mm_start']) ? $_GET['mm_start'] : 'all'; - $mm_end = isset($_GET['mm_end']) ? $_GET['mm_end'] : 'all'; - if( $mm_start != 'all' ) { - $start_date = sprintf( "%04d-%02d-%02d", substr( $mm_start, 0, 4 ), substr( $mm_start, 5, 2 ), 1 ); - } else { - $start_date = 'all'; + $args = array(); + + if ( ! isset( $_GET['content'] ) || 'all' == $_GET['content'] ) { + $args['content'] = 'all'; + } else if ( 'posts' == $_GET['content'] ) { + $args['content'] = 'post'; + + if ( $_GET['cat'] ) + $args['category'] = (int) $_GET['cat']; + + if ( $_GET['post_author'] ) + $args['author'] = (int) $_GET['post_author']; + + if ( $_GET['post_start_date'] || $_GET['post_end_date'] ) { + $args['start_date'] = $_GET['post_start_date']; + $args['end_date'] = $_GET['post_end_date']; } - if( $mm_end != 'all' ) { - $end_date = sprintf( "%04d-%02d-%02d", substr( $mm_end, 0, 4 ), substr( $mm_end, 5, 2 ), 1 ); - } else { - $end_date = 'all'; + + if ( $_GET['post_status'] ) + $args['status'] = $_GET['post_status']; + } else if ( 'pages' == $_GET['content'] ) { + $args['content'] = 'page'; + + if ( $_GET['page_author'] ) + $args['author'] = (int) $_GET['page_author']; + + if ( $_GET['page_start_date'] || $_GET['page_end_date'] ) { + $args['start_date'] = $_GET['page_start_date']; + $args['end_date'] = $_GET['page_end_date']; } - export_wp( array( 'author' => $author, 'taxonomy' => $taxonomy, 'post_type' => $post_type, 'post_status' => $status, 'start_date' => $start_date, 'end_date' => $end_date ) ); + if ( $_GET['page_status'] ) + $args['status'] = $_GET['page_status']; + } else { + $args['content'] = $_GET['content']; + } + + export_wp( $args ); die(); } require_once ('admin-header.php'); -$dateoptions = $edateoptions = ''; -$types = "'" . implode("', '", get_post_types( array( 'public' => true, 'can_export' => true ), 'names' )) . "'"; -$stati = "'" . implode("', '", get_post_stati( array( 'internal' => false ), 'names' )) . "'"; -if ( $monthyears = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, YEAR(DATE_ADD(post_date, INTERVAL 1 MONTH)) AS `eyear`, MONTH(DATE_ADD(post_date, INTERVAL 1 MONTH)) AS `emonth` FROM $wpdb->posts WHERE post_type IN ($types) AND post_status IN ($stati) ORDER BY post_date ASC ") ) { - foreach ( $monthyears as $k => $monthyear ) - $monthyears[$k]->lmonth = $wp_locale->get_month( $monthyear->month, 2 ); - for( $s = 0, $e = count( $monthyears ) - 1; $e >= 0; $s++, $e-- ) { - $dateoptions .= "\t\n"; - $edateoptions .= "\t\n"; +function export_date_options() { + global $wpdb, $wp_locale; + + $months = $wpdb->get_results( " + SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month + FROM $wpdb->posts + WHERE post_type = 'post' AND post_status != 'auto-draft' + ORDER BY post_date DESC + " ); + + $month_count = count( $months ); + if ( !$month_count || ( 1 == $month_count && 0 == $months[0]->month ) ) + return; + + foreach ( $months as $date ) { + if ( 0 == $date->year ) + continue; + + $month = zeroise( $date->month, 2 ); + echo ''; } } - ?>
      @@ -70,80 +120,87 @@ if ( $monthyears = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`

      -

      -
      -

      - - - - - - - - - - - - - - - true ), 'objects' ) as $tax_obj ) { - $term_dropdown = wp_dropdown_categories( array( 'taxonomy' => $tax_obj->name, 'hide_if_empty' => true, 'show_option_all' => __( 'All Terms' ), 'name' => 'export_taxonomy[' . $tax_obj->name . ']', 'id' => 'taxonomy-' . $tax_obj->name, 'class' => '', 'echo' => false ) ); - if ( $term_dropdown ) - echo ''; -} + $authors = $wpdb->get_col( "SELECT DISTINCT post_author FROM {$wpdb->posts} WHERE post_type = 'post'" ); + wp_dropdown_users( array( 'include' => $authors, 'name' => 'post_author', 'multi' => true, 'show_option_all' => __('All') ) ); ?> - - - - - - - - -
      - -
      - -
      - +

      +

      + +

      +
        +
      • + + __('All') ) ); ?> +
      • +
      • + get_results( "SELECT DISTINCT u.id, u.display_name FROM $wpdb->users u INNER JOIN $wpdb->posts p WHERE u.id = p.post_author ORDER BY u.display_name" ); -foreach ( (array) $authors as $author ) { - echo "\n"; -} -?> - -
      ' . $term_dropdown . '
      - -
      - -
      -

      - -

      -
      -
      + +
    8. + + + +
    9. +
    10. + + +
    11. + +

      +
        +
      • + get_col( "SELECT DISTINCT post_author FROM {$wpdb->posts} WHERE post_type = 'page'" ); + wp_dropdown_users( array( 'include' => $authors, 'name' => 'page_author', 'multi' => true, 'show_option_all' => __('All') ) ); +?> +
      • +
      • + + + +
      • +
      • + + +
      • +
      + false, 'can_export' => true ), 'objects' ) as $post_type ) : ?> +

      + -include ('admin-footer.php'); -?> + + + + + diff --git a/wp-admin/images/blue-grad.png b/wp-admin/images/blue-grad.png index 36e0f6bc25b10ca27ca968108563518fe5dc49db..868a657cca2e16c23e59c0b5050d49c817c9cff3 100644 GIT binary patch delta 321 zcmZ3$c#&y>WIZzj1B1k$?^-~Lx!B1wgoA_Q_Cx;%KyGY+Pl)ULAOGJ0(f5CEzx{jj z?eFWae_nq1{p!n~7oUGU|MctG$DdC>{CNES`=fW?9=`qh;LVqNufN=V_4&@rPq$xu zy!rgYjc4z#KYe%Y$-AqM-(GqA=JKOAmma>p`0&+*2d^&Ne`)V_t-cFr6K8=(WHAE+ zw-5+3UbC#5R5WfrBD=NDxcD>w(6ux+}$0I1H%)5S4_W2WrER^A2%h65WOzFYTyzNZ`a zeuow%A*+oZE^0v&yPc*i655*KqHT4t+p#A}Xmi97Ewhc?&T}3KZLc`8nqTWXr&xZ< Rx-_7144$rjF6*2UngFk#p|}75 delta 143 zcmV;A0C4}&0-ynq8Gix*005vskWT;r02y>eSaefwW^{L9a%BKPWN%_+AW3auXJt}l zVPtu6$z?nM002TsL_t(|+G2e5=@$bMU}8W8EdSB?4FA#P|Kr#HpOAU~@ycWH38*LF xK7#J~Pe4Dzf6ClPvj0&9u*45Z?gI!g0Px-{A!CZtp8x;=00>D%PDHLkV1kuRJBI)O diff --git a/wp-admin/images/button-grad-active-vs.png b/wp-admin/images/button-grad-active-vs.png deleted file mode 100644 index dc641725f90ae1c2600aa73f61fd71852de7b2ca..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 152 zcmeAS@N?(olHy`uVBq!ia0vp^tUxTs!2~3;Wt?9DDajJoh?3y^w370~qErUQl>DSr z1<%~X^wgl##FWaylc_d9MOL0Jjv*Ddl1k3aJ<`B3Ln45YTUl8-&W@Q`+4B|WrDSr z1<%~X^wgl##FWaylc_d9MYf(Ujv*Ddl6qdpoNr)>`1k*R|C#h82i6y#Bx=~&{;RB1 zKk>gk{-1o?zxohU`MZ1SMP`4WKkZ?sTs#9K8^fQ=ep~#F0-b>dF?hQAxvX>d`0MX&=;Oz9)^7`xb{O0lb*X8f(^!wQ6@6_Y%(ctRd>-5>@@Xz1r;qCR(;p^1n?BwtF+UW7> z^!)7h{oU&G(BSIg?)KB-?A7G$w6@c8fe{{R300001yR~C_A4Uu3CkzfsxU=5LA z1d(kLe+JpWk#I;X8jna~VaaSdorkD&N~IdE*sNB&>3Y9l@M26Zo6VZEdd+4#-tf3w zPN>`Oc)ViI@B94&fr5jCgbas>iHeFMjgF6ykQkGcm6nzvnVOrNoF1Q`p`xM{rKYE- zr~#|2t*)*Tv9hzYv>dm%xw^Uty}rM|zzM^|Ud6`78Oh4a%*+$d(9zP;57pM!*w_u* z+}+;Z0^#E0GiuZr1OPjhe(V$g delta 256 zcmV+b0ssEI1ET^@M@dFFIbjq4B>=<#0ORiW;qCU@>h#;`^x5e2*5~rr=kwO*^WW?C z;qCX{>-E;=^4RF}-|Y6?>-FO8_u1(4)#mcx?DpL1_1fw5*XQ$*fgX{~5`P7tARvxp zSw3j0u59b7Ni5Ga9o%@X>r(Ikz@TvWYZ#Bnq;knbBA(EwRH~?2uh^`1dv$of;IMd1 z22alDw0g~MyWeVod`_>|2l%{xzo+>BfPsR8goTEI1c{1^jEoSEkdcy;l$DVTn3Xb%goKm GApkpugP+9! diff --git a/wp-admin/images/fav-arrow-vs-rtl.gif b/wp-admin/images/fav-arrow-vs-rtl.gif deleted file mode 100644 index a9c0721c0928d89cbbb314fd7af5b1f3d1553484..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 338 zcmZ?wbhEHb6l73fSZd0!c;{K)(&^sCQ|*(R{mN!IrFS@{v^ZyUIHtDxluXO4?sm=Y zcFE{;NNI6QYxOOj+%R#We|}GS=M1-;UeEkVUitmL<#QKqJuz{~*6ACM_buG$p4;!9 z)8|z%$s>PabZ%XCO;ips0^DxB<*KOro+z^iD=g6(H~ za@qsaYyHY*dY4RhOlw=d=e$?`q!oKF{3iqyf3h$#FxWHbFaQC_PYi7N2j&-e==_U2 z_GH3>5Tn`07)-2m)mFJMmaVw^FYKPY)*a6Cho;DLA4p4|GH-s1+j8wGE8|awTz8ow zZLg?MVx;aX?9^Ht{0%PabZ%XCO;ips0^DxB<*KOro+z^iD=g6(H~ za@qsaYyHY*dY4RhOlw=d=e$?`q!oKF{Qv)-0WVPe$->CMV9KBaQU&r816%%q@LUfa zsqB`;lV-$dF`rBSGGm4m>op}a>zKm!75QtG=XGi(oi}36*dDp{N|58~>#AGN8ZFv5 z+sjnOPu-|gLD5v$k6*wO5?>NW5?c~) L67%LHM+R#ELJfGj diff --git a/wp-admin/images/fav-top-vs.gif b/wp-admin/images/fav-top-vs.gif deleted file mode 100644 index b9aa3d3905c00a5e903c05c1d02cc97472b9310e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 101 zcmZ?wbhEHbWM<%D*v!BX+ORC9eQjLly2zGQVU5dUJJvw(EZ*psMAT%y8>Lw?3 z000BhNklQkd_Kd1S=-`Q1Bsw)f(FL zr6AbigHWhT1Lm>*0gY521gk~#rA6#RDX39v2oy9`!5<-E3DTv+WPi-e^ zJMKh+U%1TdojIR-&e?nJ-o0q8`M)*b9pDmh+B_?bnX(h*I1brtmRv4}ZQIzk zjiprTJei`;+akZjlFD^mwAKhAykIR0ODUZ;uW1I}`13CShWFgZd)IFo!AA>Ew0&-3 znCzng|Gu~Yz=Mwt@!`31E$u#=o#pP{UI5DFGTCf4SkuC4#{hWwoq61 zHwD*;x@ANIu2t59`?%l$4xc*3p<~DB>+9qA>C;py6*8GjYyw*`+9}LyN?_sP`x67( z>B^7GiQXT3e0RfVDH~UrfuRFN#>~tN{r&v_6pO`xQ2){5j26&qzUt!)_wQgjDeKCPznc9EVq5Im}%>3MF+AbeLD&_}l2y#G&VS{$PPhwZ`Dc(+xZ?fm>C}TGifk z0%nhn8R3rWT|+sG<#nnkPY8ii^U798MRnZ^*r{*u?&qJxGF;cCR;y8~d0$?SrBK)? zrCRdZ$<>-30a%jUJ-rP)3&3`_qMyinQ?>5sSXd{D<8`X&xKc{&>Q<0X9w>P4ZQN4c5R=pNSDSc9_@nBXVTl0MWjr3fq40?azs9{qcP%rGiBtAU`tf zjS=eWR6>X*-u!nr5;6SoeO}Wx#t-<&z5({1ecuS2JM&s12a+nf?eGK6j|?-u*Sw{< z{L9x3tSGNr-`f5c-tOddqILm?lhY|{+Y=Zqp>EYJFB)*Tgp$fXqDqzbudV+hsV+`X zqVm_kGz5R(jlM@dFFIbl2id;#V~0RR90Rf($6)q<} z)8g#W;p*n``R@1r-0AY@^7`TJ_0{C<-s|-4`2W!0>g)CV(BJ9W=<(L&?%?e7)Z^^f z=I`nA`|9-kFMd%;O5%n=clKq;_L5?jg8;v z?Vg^V`uh6V;pE-s?3uO4Lo_tEL97uduPQ zv$VCgu?4xhyS%-=zrew~6vV~G$H>Xb%go0d&(P7*)6~`0*U}r>+uYsW-{9fm-45mE z=jiF`f9ve+=nL@i^7Hid_V@VnAp89N{{H|23LNOKgTaFc6DnNDu%W|*1R_eDNU@^D zix@Lfe891z$B!UGiX2JuBZiYGQ>t9avZc$HDkI38NwcQSn>cgotcjqf&!0ep3LQ$c zD9{E-lPX=xw5ijlP?uVmO0}xht5~yY-D=f?f7h>I!-^eCwyfE(8q%s=%eJlCw{ZXC zvb{jJuHCzM^XlEp_b!CLfCCF2Ot`S&!-6v?Ud*_$({Vj%bx9eg6-S5bL-yCySMM$6@m*NPQ1ABh~mj0#s?Gl`J?n<$5JtY2^yfZMohIUJ5`$m{GFlgO@cxC+2!9SUE&=Z>mRv zl{CUpP{muh*dlGo~ZuZkCIc(a06>vy+$muq*sa@Xs2ziJn3cEe&<>~+VU z*lB&qR@W?b&rTODqAXSmqqQ_*i=(zYatox1;D#&ixa5{=?z!v*004pNvb*kp?ZW%6 zfbr5hZ-DjUdoO_b^1JVU{Q~^2e}4fJJaB&nBYZG_2{XL#ehowXuznF!JaPYi6=Qs{ zdOL*R@y8*gP=a$At0%+>AbX6$b0w?SL&_?c!1BiG5s?DOEkM_@dMJGSLUcQ)XMzeL zoL~dcG_Th}2sua>w0bU#jI^QCJw2b*@?jmH*6?xtp4aYy-JaO#CS4!df9s*Gp4#cL zjh@@*!EK)0<0zTjw(4cO>pHyX#x6U*1qM+2?d;+Xd+xmN?mNA@ z1K+#w0s>)sfH4H1Jif}0e=q{T%F8f<2qO3wL;yETPkr?SE5AMW{_&tZa17Ja>pi>2 z|Bi3)>kr?)`n0x=Lv4~>h_3hd_eXJ-T7|1nd!Si?rAc#` zMsSr^f~Z7plUs(YNOG54hpkL^oKbwCR)MEWb(>6krCy1zRe+^fgQ-Ptl>h(#RDPsV zeWOo#pH6t4N_3f7gsRTY&iD55+uGGqdYx2!pip?5jH$$b(9qGUztV`Mz^J~^q`J>X zZjnxQnT)E%ew(#SbeD>!!hf8$hNQlOp}SRmpo^))NN|%&a+OJOlTUYg(3rhA;Y+TGw(e4gOo;NRcgN^+Bb zow%X6&C$`)owds0=j`X~@#X67)7979;pOb??BU{S5{C&f}gqS>gwU+FuJq&ehh~pSH^X|NoKUtda0~e0PICJW(S)ixSpFo2O9ZIw)P!C9xDqYI7sne%Wms*%g zwW`&tShH%~YE^;Pf3IM}iXBU~tl6*;(yCp{wyoQ@aO1MAK)0^lyLj{J-OKlGhQELV z3m#0ku;IgkH7H)pxUu8MkRwZO456~+%a}83-psi(W&@x@iylq7wCU5RM{iioy0z=q zuw%=f?V5w_+qiS<-p#wW@7xc93m;Crxbfr2lM|P~yt(t|f6${#pHBUGhwIq0Yv0bj zyZ7(f5s3dEPrkhQ^XSv7FW;cO`}gqU%b!obK70cB^XuQwzrX+g0PdH-fCLt3;DHDx zsNjMIUf|$^5Jo8BgcMe2VT220sNsejcIe@UAcn|c03?=Z;)y7xsN#w&w&>!EFvd8+ zj5OA0+*pMVA`=%9oa zYUrVeCaUP7j5g}%qmV`_>7~rJ{POoT;+9 zYMiaY|N1JNvC=y0o3-M4tDCvgm>{jRUkLeZ zmv|_fEFIPk`=uDl{xRgWT@sS46J(6*?U$Q;um+Ljb~#8TT)?|-n(>~QubKOn*)N&@ zjv26+e*=eEFqj8_nXs1&ciAwP4{sTz)UDsK{2zHKLHrZmMe@&;^X`gN97;4X1!w+`OT{qozn!$#h zN)-RWx8HU4Z6^#O3|@Ghgd1)r5r@;sIGUPZa>C@3N5V&tkE0of3Y>F(hLDytZl)S3 zlwNulLK*>tnsfBvdKE*et|lW*G;xU}v9GS?A&yKzBnl*~nFc3*{2u(8WfTd#oy*tR ze>|N?91p$pb0X1)oibd3eGc1qU#AW%*a^P);nx{R`E*Vqgq={VUuXMv&hSF~^Vcaq z{dW4mL;m~MslT0zc!Zs%KnXiV;RXgoV4V=5KsssR2zFWm1nVTh2)@BiNx%UHHCU$% z+6fLeu+t7gSf>$+5E6EZK_OBY1Qxome@-q~ft_MFLm9%*hFHs?4tF@D5ZuX!b^>CZ z|Aa^Y#^2cp;5yeA5uD&&NN4NSP>oU)(@L&T9zVQ|Bpe{zN< zMxM!$W`bmyBuOSpj>(c@!ep2<2_{Z{$&+3JWtT+BB~ot5lv+Y%mQ;x)R$j@KR)S@f zWJx7jPRW*1!ex|n2_;@W$(K$7W|M@;Bw{Yfm`Xxsl9Y)gW**6zMuKLMq)8-d4#}EA z!e)@P2_$a*$eTU_XD7r-&PAHjGfw41=Q-2TIU_8uXw74F~``bb;4y diff --git a/wp-admin/images/menu-bits-vs.gif b/wp-admin/images/menu-bits-vs.gif index c6ad9310d287813dc63fced04de236c65964b604..30f0bc8342daaedfbbdf6ccd644b24359bfffbc3 100644 GIT binary patch delta 1281 zcmV+c1^)WL52y=&M@dFFIbl2id;#V`0RR90(dF*T$GKIBs`vNz>GS*9=kUeAus z=<@pI@c7#3@$dNm-0AY-?)KK@?(6mZ(c$XY=I`$K|L*tx-Rkq|^!()S_u%aG-s|+$ zFJi1mhkZK*x}{cCdu>+9s?Lo_tEL^UuduPQv$VCgu_3v-yS%-= zzrew~5X8mC$H>Xb%go0X&(P7*)6~`0*U|;r+uYsW-{9fm-3jI9=jiF`f9ve+=pgX% z^7Hid_V@Vn3j6&1{{H|23LNO~g296b6DnNDu%W|*4kAjNNU@^Dix@Lft9avZc$HDl^EONwcQSn>cgotXZL_&!0ep3LQ$cD9{E-lPX=xw5ijl zP?s*4O0}xht5~yY-D=fI!-^eCwyfE(64I(&%eJlCw{ZXCvVB0euHCzM^XlEp z_pXM&fCCF2Ot`S&!-793Ud*_$({Vj%bxA}fbHA3bL-yCySMM$9)b%WPQ1ABP7XSeSo|qzv1FF~} zivqeBBa8vcSR;)9f7+NMj{oV{Bai<17$lJW30WkO{27@f|C0MD*(8(tITsi~Br zYN@K2vZ`sPuzp(NthCl@>#exvs_T3M06<``zxp~Lu)_)~AhE|98z8dFDhnX9&pP`b zw9`uKAGOz7+aI>uYRezD-+H?rxZ{eeAGzn6n;*LCs*4}AJcuCgydtuxJNUc zwA07#D)rO?3Q(Zc1Y$j))>U8ab=F^R9d_4Xmo2v0e^rx^wEzMT93TlKu+4RUBaA>o z33C5ecikkwAixj)?L9)?fs?=j+kFO3IDl-U9pK!IkNvphkvm@b*_e}^`Q(=W2f62z zgWkD+pOYTC>7(~oy6UI1o;rW4!``~=ukRPT?X%-vyMDLxp1be6=hwUNzY`xke#0YQ ryzx=Lv4~>h_3hd_eXJ-T7|1nd!Si?rAc#` zMsSr^f~Z7plUs(YNOG54hpkL^oKbwCR)MEWb(>6krCy1zRe+^fgQ-Ptl>h(#RDPsV zeWOo#pH6t4N_3f7gsRTY&iD55+uGGqdYx2!pip?5jH$$b(9qGUztV`Mz^J~^q`J>X zZjnxQnT)E%ew(#SbeD>!!hf8$hNQlOp}SRmpo^))NN|%&a+OJOlTUYg(3rhA;Y+TGw(e4gOo;NRcgN^+Bb zow%X6&C$`)owds0=j`X~@#X67)7979;pOb??BU{P5{C&f}gqS>gwU+FuJq&ehh~pSH@8(7loHY=0s71OWg5od7HV0000y z0DJ)e2>$>N2pmYTpuvL(6Dll7p`pWv5F<*QNUt9avZc$HDjCR}NwcQSn>cgotXZI^&!0ep3LQ$cC{PbblPX=xw5ijlP?uVmO0}xh zt5~yY-D*{V*MF~I!-^eCwyfE(5z?w%%eJlCw{YXKtw6V~-Me`6>fOutZic^r0}CEZ zxUk{Ff;A{!%($`R$B-jSZVaKa<;$2eYu?PcGiC#zLyI0wy0q!js7G&D&APSg*RW&D zp6!~0?c2C>>)y?~x9{8!f(su`ytwh>$deP7z`VKh=YPl6XyAbeCaBNG7S|l1w(~0+o_zM{=bwNED(Iku7Ha6B zh$gD&qKr1`=%bKED(R$@R%&UQ01RMfrkiS7Cx54(dP*m#ql!8wsi&GMC#tKe8Yio- zy8j9%th37cCat&H>L#wc>e?o+zxv81u*0f)hZ7$pt1J~yoC)g}CPW*p9L+lGDjmuu ziwCB%{-LZGYSKyuvL6rjgDns2N7#@cVK|K=KS zuYUsvTX3-l&uj0(_%f`o!~8<*ufzaTEU?7{V{EX-2y?7(!yrE#a>SRGZ1Tw{r>yeI zESE_`3wFL7Gt70$T;~WS*om{wIp5qfojd!?v(97K`9lpxBVFgwcCulHokb`CwbXS+ zZKnt@T%C2DSZjSX5nqQ5Bp;ESV7A$qXn%sH2$l$Wh6-@Q9Y>l#7$IaADde5E8g$$L zEo2ov1U`qFbq^`YB~3KJh?*pzK;#sT9I|HPMEb!=8k0LtWEpHyUZ>}Dl7NJrqTAWW z=yhHpgPl37UT5p9yG|zyI@n3O?X}m*LLhbuF-h-G0B`3DGYnsRox~e&Cl5X>-+z3a z%-i|MB6d)iL=zacU?(Q*VF*&769_<%hc?(@PCEpF7o8HJ zhdRV5h&ybA6@~z(AOZplg2==XLBIqw;80E=FoYtqKqohZVN-VkKp4je#xj12jAu0C zsL;4ZHJ*x%Z*=3T;5bJ)zKV`_wBxMsxJNzSijRNvCMAjqHt(gCuQfwd?>rBBeY?^)!k z)wAZkKXGKDgT!Jd5pEGvb|)q$78VW;rNA#YzSbzuPAo{W$WY4RK6a^UcS86KZN16o zm#nw6Op#`T6a6TVnE`KmK0X*w9?t)Y?+t-qqQYRoBFxY53B=i5(T51hI3{`0q!*Y2IU@nF~S^X*G_ z>^yev#oG_3uHWlewrl&5)1jTK{{R2aKr~SN$->CMAjqHt(gCuQfwf3Mq&G!n+T+eu zs@}Ua8{L>g7BmPruyg+5>}V4F`BzM!{o(Rv6St0AZ@*61nx>|sV|}}7>w~-s(|uj% zQ?^*1joTfcx+Ch|vi-q@e`4aF-``o=P#<62RMuYC(bn11-Ph7Mp}Deu%A~I8y)&n_ M&Ym}IiXwwG0FC8n_y7O^ literal 0 HcmV?d00001 diff --git a/wp-admin/images/screen-options-right-up.gif b/wp-admin/images/screen-options-right-up.gif deleted file mode 100644 index 6556aeeda3d51f89d3bf3026e8220863babf69bd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 125 zcmV-@0D}KVNk%w1VG{rs0J9GOy}iB7&CS8V!PC>z;^N}m+}y^-#^B)K%F4>)M)WlW8UsF* diff --git a/wp-admin/images/screen-options-right.gif b/wp-admin/images/screen-options-right.gif deleted file mode 100644 index 8fcf25489905d9855e8e8402e3017b8541a4642a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 178 zcmZ?wbhEHb6lM@-I3mcfckkY7*RJi~zyJRI`;Q+#e)#a=qeqVp9z3{j-@c0%FP=Yt z{@%TNr%s(ZapJ_STeprJIdb~+X`nI&qJiR17DfgJK?WU=4v?J;tojKmeJPpqGFGk2 tdA+Yd=X@ITo$t!rZF8a5anYy_&}6FB}sre*K2Lm`egzP)&MiIL>&MC diff --git a/wp-admin/images/screen-options-toggle-vs.gif b/wp-admin/images/screen-options-toggle-vs.gif new file mode 100644 index 0000000000000000000000000000000000000000..3b9b8af34ff9141d9498c77e879a1ca3a10b26b2 GIT binary patch literal 152 zcmV;J0B8S4Nk%w1VG{r@0J8u9|NsBO!ot43zPh@)uCA`Cs;Zuzo|>APl9G~+j*g0o zih_cId3kwtb#-xZaR2}SA^8LW2LJ#7EC2ui022T%000C<5XecZy*TU5yZ>M)j+Ww_ z=Mro~gE~Zapou3iPBVOkV}ytmX-F&@kI1BQ$!t0SK~V2!!|6P;Q;pMl#Wtpw>Paq} GBLF)FctMQ- literal 0 HcmV?d00001 diff --git a/wp-admin/images/screen-options-toggle.gif b/wp-admin/images/screen-options-toggle.gif new file mode 100644 index 0000000000000000000000000000000000000000..ed0a5fd373f283a2bdfe038db842375ef2ce9780 GIT binary patch literal 205 zcmZ?wbhEHb6lTz4IKsg2=+UD+d-gnh`0)Dm>lZFuICt*c!Gj0y-Me?-z=7k(k3V?u zVDH|&ckkZaw{PFIYu8SnK7IA-)srVro;`c^#EBCOL;%H~EQ}y!Iv@gMCj+aOfvCT2E6_QgCUj@J;+iu}?9E|}=7pL9jmI9catb8%%jSBmjaq+WP1)(URg6L_ cPd}`Yo$Rfscj?vNChgn)-`C!LugG8x0KEZN(EtDd literal 0 HcmV?d00001 diff --git a/wp-admin/images/sort.gif b/wp-admin/images/sort.gif new file mode 100644 index 0000000000000000000000000000000000000000..2a5a6e8ceb3bbeef9993896ee8ed3b787823a1a7 GIT binary patch literal 54 zcmZ?wbhEHb zW-&11@8|vfe4cY&p3X280~HVm1aoz9 z@&?XSV3D9;V6Q>KKY&2sO|DLReCTf{3tjOf5AAe$P2L8V1e3ViIoazs1fEqvMW<+{ zyyKnI0%x4o?>60AfNh_&J?hE0b+f&nx#}u6!0fDvDvzQE@ozJ zcX&MVdIwg0ZLO7bafRE8l*6v1v^@FBKURqADfA5*dszx%g4t`1rU~-X>9VZ8hr?>h)M!M4r8V-SO0d zA~xY7_+)4D?dzTg#9{#40@uf65ky{fiNdG-bDE@;+>)yI`t7)5XCEZ9Lfw(g`I4H%n z-g_Safk3ulFk#9#6-AkW_R!8Zr!E zBJw53-ZHcTy~)fBYvYNFOs(+}8slmJ}d$ipZ-&16mdl`OnvfFL2_BXw0nl)GZeXW9nyp9=`R zv$L}bNejdf4);B|<3ozkmXNQ-BAQ4njx!IpPx?M^&7K*331N3TH&+vxmI4Qg34P*z z^}C!05Bd=fteEQRYQ=aL=N+ol@9T}(mAmwWn&rH-#1b>yHK6s_Qwmvr1E1gD({nZV z84mS}TXnTZWmQ#ud%Gv>FRf++pdD+ajrf7r-Q8u{x2>DkDd-y_pre=B7Qv{P2_IhD z%4T&4WWg^e2+{s6DuJP*po1(-0g3(m{WXU zS1>y0x$3z&T4hBAFV%R}7#d^Vh>N~eUoX;h``ZnUhgzhXrF!>j);R?R1|Ea$DJ1S8 z3@syj{5$s4AmC5e>A9h*$Z!PnOp`KW->tbWy!={0fC ziqSf?q~8)B8Oh7Z$w`o9u^@ACNahbxU68h^z=VVosiWdy?U<3$nRdPJmHsuDNKYjx zF?1f~{$-21&Up#peh=u2wk-bf6wkjQub3HRJz5tB|Uq&ckvAm-Seom z^03_3o0rEhO?-KJzaxoMkg=WnN^@vnK(+cn^x)SU3tB_s)r93yqB=05(lA z3P`;Dl-yb3&E5YaO;YWUHB((pA9a*tT(uPC1>ysSef%jttpjO>B*ZZ^pxYrmN{Hw&&oMu*~?@_G1-} zQ@Alh=203AOUyW%=cXvxxoQ%i<%h($ literal 0 HcmV?d00001 diff --git a/wp-admin/images/upload-fresh.png b/wp-admin/images/upload-fresh.png new file mode 100644 index 0000000000000000000000000000000000000000..92fd355c82ed81690fdc75dec27e0ddeeaa1a361 GIT binary patch literal 1051 zcmV+$1mydPP)`DxA|} z$Q@~Z-7%!cITdOI^F@p?sN!=cC_YsT#>pZ^>{Az2LYzALjN&3f3@(@o%>@RbE~3VF zu{BJY@|_wHYC;8%UxMRNVS@U>3I7VuKQvJ$ZSh64F;NE$xD}o;`>4v?3QJ-_%BYg~ z8X_V}s0tpT@J#rEI>03m9+v}@$xnRY`H6|LITl~UDNVhybeRZ_t5=p0HBRva=SYf1onrYX}L+pt38)X24_AI+l36wOB{x zITB5`6DAyyNBzZ1(RAzKvB@54Ko(o1SH`i)GSIU|L39z@de(^W*z?yph^}GGSdZa(j>LP!k>>oSc%iz|obQS^%dzJCU=_{z zs|}u^=6qXx5w_<1uj2PUziQ5ZEq*t=5OaQ4^y!H1jPqq59r`oL`9-lc6z4hrv&b`b zpBHid4z8#(mM%NXIsYvuT&BK)OHO#Z;{5-?`2h|sZ0aeGO$#USUya|22O@pLvSECOS!%y&O0Q93msRFu^Rx+OseQ&t-3IX; z)>%_5(kGfE_t<1l{r~?z11Ui9CkrD3g8N{R)e(aBX(!`QWrgYPG|w0--4qivu|rtN|kg BHa7qO diff --git a/wp-admin/images/visit-site-button-grad.gif b/wp-admin/images/visit-site-button-grad.gif deleted file mode 100644 index a7b703e5592564ab5ee0ca8694e4320897dea0e8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 136 zcmZ?wbhEHbWM46!ic9e+C8y#h)yU3=Dig%|HM$gMr0#!bwT3U8?KPPBvelp!Fn?Ph){uj`tov lo%1ER$Mr96(`w*b#_Xvm)W9>3rG2tyjKI_bDME}4)&Tv~Dv1C9 diff --git a/wp-admin/images/widgets-arrow-vs.gif b/wp-admin/images/widgets-arrow-vs.gif new file mode 100644 index 0000000000000000000000000000000000000000..c6398e6775b2e9cfd8a9561f77a7d5f9316ed131 GIT binary patch literal 213 zcmZ?wbhEHb6l73fIKsfNblqm>*esX0Y_q^v%a8=~z*wu$M9biKr`SyAxU7p$->urb zecAfW8+PtJeCEQQqbC=y-MD%0!GovI|NsA=fe4`ZlZBCiL6|`Yq!wf+18dL%qu!KE zzeg+kURG_(<2KGIVfk=u`DLBrRx{FZ}qZ)x34Qvi0sneNu#y_3jZEUrsapG7r9TVF|k`_~qB#Inzi9rxpu7%}VSYS`~ zKKlLs_9zc%bo!fl^VrAteLvsh^F3Z%C=`OHJ&pa7wYq6j&40MjyeAk831*jU&(QPS zw4~2DE-p}%ozhaO%(z{n*>v+sx@Ig+P%7df?r9A8{l7ZiemFY!T7G8A^sX|cX=hP( zl3XgvPm+m~=>ImC*S6yJO+6Sl+V1OSGNu>Ic@-r&@BR2I)yJNs`wI=Yc>Cd*wxQ|c zFK7w}Ufo@uAAc_vs_41P>xX&k3i$j1CMOdMAuTbU-RU^Je#76}hNkZH={N5#&%1E6 zrsDK!z0>G@9(wN|&xE*q1~GqI33biS5>Mb zj13L=^X;B9X^I5lL9KcpdH&mLjo`AG!MkDyzt78Ld~O#wt!DPzWw(OIVPhBjjhEYI zp*X}0dG*H0C5<#Yo`vaOOwOx8$WUJ-)UEV zbU+b{z}be*b1!Zy>O;a5Q0R!kQYj9(1vCe=5si=ss&fe%e7c-!1c;UN0;= z+#nVS!GyJ6e}53(ZR%fFg5&dMXnLdvkx0a31!4)jd$)g`0W0X#*Pr{6s(X0$2s5C* zYvh~iyo_OLGT3x@!dd90TrLLz0tf{hDt{I*k74_yR$mXL~p2huMmMiz14JSP^YH zzOforW~>YaTpW|5>&o3eo*bo+un1F+*xcN*L$h^LMi!C-+}Ly;>gRbcJXf9v0e^gf z(jka?hmp89FvXKgl!*Z&$&40o|BZrv-U8G`!_6uLGmADNB5YMbs8(JjL3QT=1h}rj$aASEfP^%G5-j9F=BHNrgSgPQeYF3z|hPRPqw;L8A}7JB!2|QX^QNh z1CKAj48n?|NLdM+OHGO&U9!83WIaT3yo96~!+fnyLzyxSLJ@EZD*=tnEyK0e!8Os! z0hh29!pYY1O%m zI7G&N!y?Oj^z1^9Nf9Z?PfKLse>7oYUajT~ab!D^k&I1}Nzfn#v_^UcMGiM47KPTq z=`_OT4r@!Vj?S1$T)u$eK$SW|Mvkppo!GUaht@4sW_Yw#At`bHLw^G)r^0o;V^4WL zZ9|Zgn!vp6L0Lg$MAz*s0m358!_}o%86_)3bw!sO?jXF0aTxO`a6N$6>P!!@N zVisoBQgLF&YV#DavfnCQx?H%7v zqw>h}+rWv|Q@u_uSbtg9it(UK358k7Y|YZoTUk_yV8m?VL-f$^!?+6+VWoVAwNJdE zXpwHhxYIkXd84lShrERZ*X{Fv__)hLAv;-D6)U;boiRNr9=^3t6H5&NMU5CUT6mnP zeWnP~aZ`SbgNwW;our#Ev}MW*>o%g}FYi1(w`i5tcaGen_J4awt7gwXUz1i$8Dx4S&BfGhanU8St0f7Cs4moNxx!=3Q_(fwOKx<9a`V|2E0?`9Po zuiXK&%XaML_LvN{+Ig!p7J3>?Qsj#a(?Y~teOh%haAN-sAYG)hzI8xD82@uArSq4Q zUroPwt7q%=4u4%US$+09HL+pBlnzZXesGZuIeMs#lVP;RN6$-|0_OP#sEc%x?zMOu z?$?)ab#5M*l>Gd9TQ`PQPi&4JS}=&&bkR^DlA5p)E#qLaI9$95=?{kVzxuGfvjufs z+TfeuiJxZYZ+8Epb9naqFK7z-zOiSEN`{+EbgeR)9e>!A!tYWVGLWFuhcfA)WU8%ED>KD_^Suip4tUPk!iw5m7Q4nDi#$LT1RcS)qF#S9q1hj0G!jKb&fq`2K~h0o_x_`IHE ztltD`>Rg;yDwP&)d&MhBt_*OJ%n(gnF?J=|bi5ufG9n}hdKSbUYqwk9`*G0canpN3 xq0k``i>s$Z;002ovPDHLkV1myfVoCr2 delta 2319 zcmV+q3Gnum62B6VNq^xV#C2D+x>qb703QF@BG*Mzt8iY-}fsLUU?5sa&#Qur=nB7SAW)$@O_r|^(~TVlCMd= zWJ&z#`_oTiSHT3n`Q83`6&^fz5J{(BlI$cg-0rlXytxbgb|-Ak5up=i&?Cxdz>3B3 z$TThBM^2LSB(EzJih=oTGq(CMz&bj;Mp9_8-`AfkD#hiRCJZ`5LjEJ}%rLTUB*F_`l@tog$`Y)UDwPUkP<*pCJqa^2Gk=(xnu23w6sNwd#Ai3|;B-kj zimMxO>hP|d?8N9Qvb~kQxixPMcs;Kwz0(%GkHFm%Q^MO{?=C=mLMA@w2nV6qSDXYSnoE@Gj)0C-sr)GAR;_t(;{*%bvIP+oBKr@w@=v zyM8H7AAj0`q?kzf`T4=e$47WB5tuFfjL9)c)(Z;?z~TI5h%p8VTWphUGlmyS9LiZv z9CeJka$bDvEXKyCus?4pe!OX=Fertay<`t3Cntq)$fau*e#bg26|Ftk|G`D{4pFBl zl)~l9gs=AAbL!8P)d)|owe=zI zw;#))i3|!v$uIW8>KMV^cRpt?9@&B~JZ;9&o%x>XrgVI}PWWJqgIm_+36`aHF9eKm1b>*_x5{k|To9YIWdyYqIdxp6A$$a8ALtiK%H_aZR%*q=K|K z3YS8b>unbCoJFJ22!Pco@dydX_fWZ`z)Fl`A;Rxv6Y_|4-LI5rh&$o zjLihrRkrnD*gc7i*l_GxwL}=6oD0i=HJTY@Dlnb#jcX!&27NB|PVYi-?N7~Nii_!d}JMqV+^&O{c;o}y||D-aUEw2KxD81i4jI|&zOwO1PmjtaltBB z?*vvnZN^Yfq$wf5<0DVP83QTyF{dOH9JW>ljKTcx10t(|MPacsE6cmgMX~kX1kBB zLAxNz;N7+%blOLd5^1E+hY08Fqi&%a;8{tXOrXsa9wgYbQ;#wLD?UxF7VPgMhqBD; zoiuj&ei0Sb?&ZmI22DwQr+Cl0R~ov-v%EBuC|pio$DmU@^J2C!fjV=7C){`X?h57{ z1s%1~y2Y__c&)=O)X_-hm4B|b+lm3_81k3IA$N%h0lr#UudKx)beKR{Yac~Pg)Ny2 zg;VTY9bvGZz$9!Y@b9GwQP9zvUrxm~JmwNiIbYk%NppJra$P4}E*CD=c6bbDB_V(& z=&CX@51YOdnd z(S-5o2VgA5WNanvUU_HvVd3VLqV@iIqZ#)5!{P%maMEJsUhkn^zeG_Or0UO4jT6Pn zl1<*k2J2U`mi7b362gK;cCJbjEqDB4 zwa6nMTPc4^Z=15bd%YD}GE$IX5^0h)A)ClkNvFo*M6+!eSu}Qo{Cq?`yjfh0A=d;L zgR#i;8}fdDSo2&w`SP=?5KH;GP~U|!*XqTG;er0hiZ(tR&3}{AFvo@veR%2b)kMHE zLUZD1cdSy%!$#_PzRyjL5(HVV);fa9UWc%8=HPa)O@FrS#hCxUfE239t7Yc+h@wlc z?96%dLODLIY{sN_QMpS+dbXkknY3i9HJ;Di6O*X7*m1MlMrom1nNd&&D6wPtV!XU% z1&6)D>-oSF{TZ<$k;tVFj~?5xu5kY|S-N*hYQz9)wvCW9&HHPn*J-gMI}r!-%rJ!- zIMn=W_J6DSe$D=`pHqs0p^`Qpop-6t2JG~^=2><%Y9$uaf2*y_P1jDGI8ko3 pS|`0`d7!vv3t_q?%>N270Ekx(1`};=0{{R300>D%PDHLkV1n>`o6rCN diff --git a/wp-admin/import.php b/wp-admin/import.php index 08c5daf0..f94f7047 100644 --- a/wp-admin/import.php +++ b/wp-admin/import.php @@ -20,7 +20,7 @@ add_contextual_help($current_screen, '

      ' . __('This screen lists links to plugins to import data from blogging/content management platforms. Choose the platform you want to import from, and click Install Now when you are prompted in the popup window. If your platform is not listed, click the link to search the plugin directory for other importer plugins to see if there is one for your platform.') . '

      ' . '

      ' . __('In previous versions of WordPress, all the importers were built-in, but they have been turned into plugins as of version 3.0 since most people only use them once or infrequently.') . '

      ' . '

      ' . __('For more information:') . '

      ' . - '

      ' . __('Import Documentation') . '

      ' . + '

      ' . __('Documentation on Import') . '

      ' . '

      ' . __('Support Forums') . '

      ' ); @@ -37,11 +37,14 @@ if ( current_user_can('install_plugins') ) ); if ( ! empty( $_GET['invalid'] ) && !empty($popular_importers[$_GET['invalid']][3]) ) { - wp_redirect("import.php?import=" . $popular_importers[$_GET['invalid']][3]); + wp_redirect( admin_url('import.php?import=' . $popular_importers[$_GET['invalid']][3]) ); exit; } add_thickbox(); +wp_enqueue_script( 'plugin-install' ); +wp_admin_css( 'plugin-install' ); + require_once ('admin-header.php'); $parent_file = 'tools.php'; ?> @@ -58,18 +61,21 @@ $parent_file = 'tools.php'; // Load all importers so that they can register. $import_loc = 'wp-admin/import'; -$import_root = ABSPATH.$import_loc; -$imports_dir = @ opendir($import_root); -if ($imports_dir) { - while (($file = readdir($imports_dir)) !== false) { - if ($file{0} == '.') { - continue; - } elseif (substr($file, -4) == '.php') { - require_once($import_root . '/' . $file); +$import_root = ABSPATH . $import_loc; + +if ( file_exists( $import_root ) ) { + $imports_dir = opendir($import_root); + if ($imports_dir) { + while (($file = readdir($imports_dir)) !== false) { + if ($file[0] == '.') { + continue; + } elseif (substr($file, -4) == '.php') { + require_once($import_root . '/' . $file); + } } } + closedir( $imports_dir ); } -@closedir($imports_dir); $importers = get_importers(); @@ -108,8 +114,8 @@ if (empty ($importers)) { } } if ( empty($action) ) - $action = '' . $data[0] . ''; } else { $action = "{$data[0]}"; @@ -130,7 +136,7 @@ if (empty ($importers)) { } if ( current_user_can('install_plugins') ) - echo '

      ' . sprintf( __('If the importer you need is not listed, search the plugins directory to see if an importer is available.'), esc_url(admin_url('plugin-install.php?tab=search&type=tag&s=importer')) ) . '

      '; + echo '

      ' . sprintf( __('If the importer you need is not listed, search the plugins directory to see if an importer is available.'), esc_url( network_admin_url( 'plugin-install.php?tab=search&type=tag&s=importer' ) ) ) . '

      '; ?> diff --git a/wp-admin/includes/admin.php b/wp-admin/includes/admin.php index 23c9ee2b..37f5c8ec 100644 --- a/wp-admin/includes/admin.php +++ b/wp-admin/includes/admin.php @@ -39,6 +39,10 @@ require_once(ABSPATH . 'wp-admin/includes/taxonomy.php'); /** WordPress Template Administration API */ require_once(ABSPATH . 'wp-admin/includes/template.php'); +/** WordPress List Table Administration API and base class */ +require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php'); +require_once(ABSPATH . 'wp-admin/includes/list-table.php'); + /** WordPress Theme Administration API */ require_once(ABSPATH . 'wp-admin/includes/theme.php'); @@ -48,9 +52,6 @@ require_once(ABSPATH . 'wp-admin/includes/user.php'); /** WordPress Update Administration API */ require_once(ABSPATH . 'wp-admin/includes/update.php'); -/** WordPress Registration API */ -require_once(ABSPATH . WPINC . '/registration.php'); - /** WordPress Deprecated Administration API */ require_once(ABSPATH . 'wp-admin/includes/deprecated.php'); diff --git a/wp-admin/includes/bookmark.php b/wp-admin/includes/bookmark.php index 09e5411e..0ed560c1 100644 --- a/wp-admin/includes/bookmark.php +++ b/wp-admin/includes/bookmark.php @@ -7,27 +7,27 @@ */ /** - * {@internal Missing Short Description}} + * Add a link to using values provided in $_POST. * - * @since unknown + * @since 2.0.0 * - * @return unknown + * @return int|WP_Error Value 0 or WP_Error on failure. The link ID on success. */ function add_link() { return edit_link(); } /** - * {@internal Missing Short Description}} + * Update or insert a link using values provided in $_POST. * - * @since unknown + * @since 2.0.0 * - * @param unknown_type $link_id - * @return unknown + * @param int $link_id Optional. ID of the link to edit. + * @return int|WP_Error Value 0 or WP_Error on failure. The link ID on success. */ -function edit_link( $link_id = '' ) { - if (!current_user_can( 'manage_links' )) - wp_die( __( 'Cheatin’ uh?' )); +function edit_link( $link_id = 0 ) { + if ( !current_user_can( 'manage_links' ) ) + wp_die( __( 'Cheatin’ uh?' ) ); $_POST['link_url'] = esc_html( $_POST['link_url'] ); $_POST['link_url'] = esc_url($_POST['link_url']); @@ -39,27 +39,27 @@ function edit_link( $link_id = '' ) { if ( !empty( $link_id ) ) { $_POST['link_id'] = $link_id; - return wp_update_link( $_POST); + return wp_update_link( $_POST ); } else { - return wp_insert_link( $_POST); + return wp_insert_link( $_POST ); } } /** - * {@internal Missing Short Description}} + * Retrieve the default link for editing. * - * @since unknown + * @since 2.0.0 * - * @return unknown + * @return object Default link */ function get_default_link_to_edit() { if ( isset( $_GET['linkurl'] ) ) - $link->link_url = esc_url( $_GET['linkurl']); + $link->link_url = esc_url( $_GET['linkurl'] ); else $link->link_url = ''; if ( isset( $_GET['name'] ) ) - $link->link_name = esc_attr( $_GET['name']); + $link->link_name = esc_attr( $_GET['name'] ); else $link->link_name = ''; @@ -69,12 +69,12 @@ function get_default_link_to_edit() { } /** - * {@internal Missing Short Description}} + * Delete link specified from database * - * @since unknown + * @since 2.0.0 * - * @param unknown_type $link_id - * @return unknown + * @param int $link_id ID of the link to delete + * @return bool True */ function wp_delete_link( $link_id ) { global $wpdb; @@ -93,12 +93,12 @@ function wp_delete_link( $link_id ) { } /** - * {@internal Missing Short Description}} + * Retrieves the link categories associated with the link specified. * - * @since unknown + * @since 2.1.0 * - * @param unknown_type $link_id - * @return unknown + * @param int $link_id Link ID to look up + * @return array The requested link's categories */ function wp_get_link_cats( $link_id = 0 ) { @@ -108,24 +108,25 @@ function wp_get_link_cats( $link_id = 0 ) { } /** - * {@internal Missing Short Description}} + * Retrieve link data based on ID. * - * @since unknown + * @since 2.0.0 * - * @param unknown_type $link_id - * @return unknown + * @param int $link_id ID of link to retrieve + * @return object Link for editing */ function get_link_to_edit( $link_id ) { return get_bookmark( $link_id, OBJECT, 'edit' ); } /** - * {@internal Missing Short Description}} + * This function inserts/updates links into/in the database. * - * @since unknown + * @since 2.0.0 * - * @param unknown_type $linkdata - * @return unknown + * @param array $linkdata Elements that make up the link to insert. + * @param bool $wp_error Optional. If true return WP_Error object on failure. + * @return int|WP_Error Value 0 or WP_Error on failure. The link ID on success. */ function wp_insert_link( $linkdata, $wp_error = false ) { global $wpdb; @@ -181,7 +182,7 @@ function wp_insert_link( $linkdata, $wp_error = false ) { $link_rel = ''; // Make sure we set a valid category - if ( ! isset( $link_category ) ||0 == count( $link_category ) || !is_array( $link_category ) ) { + if ( ! isset( $link_category ) || 0 == count( $link_category ) || !is_array( $link_category ) ) { $link_category = array( get_option( 'default_link_category' ) ); } @@ -215,12 +216,12 @@ function wp_insert_link( $linkdata, $wp_error = false ) { } /** - * {@internal Missing Short Description}} + * Update link with the specified link categories. * - * @since unknown + * @since 2.1.0 * - * @param unknown_type $link_id - * @param unknown_type $link_categories + * @param int $link_id ID of link to update + * @param array $link_categories Array of categories to */ function wp_set_link_cats( $link_id = 0, $link_categories = array() ) { // If $link_categories isn't already an array, make it one: @@ -233,15 +234,15 @@ function wp_set_link_cats( $link_id = 0, $link_categories = array() ) { wp_set_object_terms( $link_id, $link_categories, 'link_category' ); clean_bookmark_cache( $link_id ); -} // wp_set_link_cats() +} /** - * {@internal Missing Short Description}} + * Update a link in the database. * - * @since unknown + * @since 2.0.0 * - * @param unknown_type $linkdata - * @return unknown + * @param array $linkdata Link data to update. + * @return int|WP_Error Value 0 or WP_Error on failure. The updated link ID on success. */ function wp_update_link( $linkdata ) { $link_id = (int) $linkdata['link_id']; diff --git a/wp-admin/includes/class-wp-comments-list-table.php b/wp-admin/includes/class-wp-comments-list-table.php new file mode 100644 index 00000000..90c158fe --- /dev/null +++ b/wp-admin/includes/class-wp-comments-list-table.php @@ -0,0 +1,557 @@ + 'comments', + 'singular' => 'comment', + 'ajax' => true, + ) ); + } + + function ajax_user_can() { + return current_user_can('edit_posts'); + } + + function prepare_items() { + global $post_id, $comment_status, $search, $comment_type; + + $comment_status = isset( $_REQUEST['comment_status'] ) ? $_REQUEST['comment_status'] : 'all'; + if ( !in_array( $comment_status, array( 'all', 'moderated', 'approved', 'spam', 'trash' ) ) ) + $comment_status = 'all'; + + $comment_type = !empty( $_REQUEST['comment_type'] ) ? $_REQUEST['comment_type'] : ''; + + $search = ( isset( $_REQUEST['s'] ) ) ? $_REQUEST['s'] : ''; + + $user_id = ( isset( $_REQUEST['user_id'] ) ) ? $_REQUEST['user_id'] : ''; + + $orderby = ( isset( $_REQUEST['orderby'] ) ) ? $_REQUEST['orderby'] : ''; + $order = ( isset( $_REQUEST['order'] ) ) ? $_REQUEST['order'] : ''; + + $comments_per_page = $this->get_per_page( $comment_status ); + + $doing_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX; + + if ( isset( $_REQUEST['number'] ) ) { + $number = (int) $_REQUEST['number']; + } + else { + $number = $comments_per_page + min( 8, $comments_per_page ); // Grab a few extra + } + + $page = $this->get_pagenum(); + + if ( isset( $_REQUEST['start'] ) ) { + $start = $_REQUEST['start']; + } else { + $start = ( $page - 1 ) * $comments_per_page; + } + + if ( $doing_ajax && isset( $_REQUEST['offset'] ) ) { + $start += $_REQUEST['offset']; + } + + $status_map = array( + 'moderated' => 'hold', + 'approved' => 'approve' + ); + + $args = array( + 'status' => isset( $status_map[$comment_status] ) ? $status_map[$comment_status] : $comment_status, + 'search' => $search, + 'user_id' => $user_id, + 'offset' => $start, + 'number' => $number, + 'post_id' => $post_id, + 'type' => $comment_type, + 'orderby' => $orderby, + 'order' => $order, + ); + + $_comments = get_comments( $args ); + + update_comment_cache( $_comments ); + + $this->items = array_slice( $_comments, 0, $comments_per_page ); + $this->extra_items = array_slice( $_comments, $comments_per_page ); + + $total_comments = get_comments( array_merge( $args, array('count' => true, 'offset' => 0, 'number' => 0) ) ); + + $_comment_post_ids = array(); + foreach ( $_comments as $_c ) { + $_comment_post_ids[] = $_c->comment_post_ID; + } + + $this->pending_count = get_pending_comments_num( $_comment_post_ids ); + + $this->set_pagination_args( array( + 'total_items' => $total_comments, + 'per_page' => $comments_per_page, + ) ); + } + + function get_per_page( $comment_status = 'all' ) { + $comments_per_page = $this->get_items_per_page( 'edit_comments_per_page' ); + $comments_per_page = apply_filters( 'comments_per_page', $comments_per_page, $comment_status ); + return $comments_per_page; + } + + function no_items() { + global $comment_status; + + if ( 'moderated' == $comment_status ) + _e( 'No comments awaiting moderation… yet.' ); + else + _e( 'No comments found.' ); + } + + function get_views() { + global $post_id, $comment_status; + + $status_links = array(); + $num_comments = ( $post_id ) ? wp_count_comments( $post_id ) : wp_count_comments(); + //, number_format_i18n($num_comments->moderated) ), "" . number_format_i18n($num_comments->moderated) . ""), + //, number_format_i18n($num_comments->spam) ), "" . number_format_i18n($num_comments->spam) . "") + $stati = array( + 'all' => _nx_noop('All', 'All', 'comments'), // singular not used + 'moderated' => _n_noop('Pending (%s)', 'Pending (%s)'), + 'approved' => _n_noop('Approved', 'Approved'), // singular not used + 'spam' => _n_noop('Spam (%s)', 'Spam (%s)'), + 'trash' => _n_noop('Trash (%s)', 'Trash (%s)') + ); + + if ( !EMPTY_TRASH_DAYS ) + unset($stati['trash']); + + $link = 'edit-comments.php'; + if ( !empty($comment_type) && 'all' != $comment_type ) + $link = add_query_arg( 'comment_type', $comment_type, $link ); + + foreach ( $stati as $status => $label ) { + $class = ( $status == $comment_status ) ? ' class="current"' : ''; + + if ( !isset( $num_comments->$status ) ) + $num_comments->$status = 10; + $link = add_query_arg( 'comment_status', $status, $link ); + if ( $post_id ) + $link = add_query_arg( 'p', absint( $post_id ), $link ); + /* + // I toyed with this, but decided against it. Leaving it in here in case anyone thinks it is a good idea. ~ Mark + if ( !empty( $_REQUEST['s'] ) ) + $link = add_query_arg( 's', esc_attr( stripslashes( $_REQUEST['s'] ) ), $link ); + */ + $status_links[$status] = "" . sprintf( + translate_nooped_plural( $label, $num_comments->$status ), + number_format_i18n( $num_comments->$status ) + ) . ''; + } + + $status_links = apply_filters( 'comment_status_links', $status_links ); + return $status_links; + } + + function get_bulk_actions() { + global $comment_status; + + $actions = array(); + if ( in_array( $comment_status, array( 'all', 'approved' ) ) ) + $actions['unapprove'] = __( 'Unapprove' ); + if ( in_array( $comment_status, array( 'all', 'moderated', 'spam' ) ) ) + $actions['approve'] = __( 'Approve' ); + if ( in_array( $comment_status, array( 'all', 'moderated', 'approved' ) ) ) + $actions['spam'] = _x( 'Mark as Spam', 'comment' ); + + if ( 'trash' == $comment_status ) + $actions['untrash'] = __( 'Restore' ); + elseif ( 'spam' == $comment_status ) + $actions['unspam'] = _x( 'Not Spam', 'comment' ); + + if ( in_array( $comment_status, array( 'trash', 'spam' ) ) || !EMPTY_TRASH_DAYS ) + $actions['delete'] = __( 'Delete Permanently' ); + else + $actions['trash'] = __( 'Move to Trash' ); + + return $actions; + } + + function extra_tablenav( $which ) { + global $comment_status, $comment_type; +?> +
      + + + 'post-query-submit' ) ); + } + + if ( ( 'spam' == $comment_status || 'trash' == $comment_status ) && current_user_can( 'moderate_comments' ) ) { + wp_nonce_field( 'bulk-destroy', '_destroy_nonce' ); + $title = ( 'spam' == $comment_status ) ? esc_attr__( 'Empty Spam' ) : esc_attr__( 'Empty Trash' ); + submit_button( $title, 'button-secondary apply', 'delete_all', false ); + } + do_action( 'manage_comments_nav', $comment_status ); + echo '
      '; + } + + function current_action() { + if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) ) + return 'delete_all'; + + return parent::current_action(); + } + + function get_columns() { + global $post_id; + + $columns = array(); + + if ( $this->checkbox ) + $columns['cb'] = ''; + + $columns['author'] = __( 'Author' ); + $columns['comment'] = _x( 'Comment', 'column name' ); + + if ( !$post_id ) + $columns['response'] = _x( 'In Response To', 'column name' ); + + return $columns; + } + + function get_sortable_columns() { + return array( + 'author' => 'comment_author', + 'response' => 'comment_post_ID' + ); + } + + function display() { + extract( $this->_args ); + + wp_nonce_field( "fetch-list-" . get_class( $this ), '_ajax_fetch_list_nonce' ); + + $this->display_tablenav( 'top' ); + +?> + + + + print_column_headers(); ?> + + + + + + print_column_headers( false ); ?> + + + + + display_rows_or_placeholder(); ?> + + + + items = $this->extra_items; $this->display_rows(); ?> + +
      +display_tablenav( 'bottom' ); + } + + function single_row( $a_comment ) { + global $post, $comment, $the_comment_status; + + $comment = $a_comment; + $the_comment_status = wp_get_comment_status( $comment->comment_ID ); + + $post = get_post( $comment->comment_post_ID ); + + $this->user_can = current_user_can( 'edit_comment', $comment->comment_ID ); + + echo ""; + echo $this->single_row_columns( $comment ); + echo ""; + } + + function column_cb( $comment ) { + if ( $this->user_can ) + echo ""; + } + + function column_comment( $comment ) { + global $post, $comment_status, $the_comment_status; + + $user_can = $this->user_can; + + $comment_url = esc_url( get_comment_link( $comment->comment_ID ) ); + + $ptime = date( 'G', strtotime( $comment->comment_date ) ); + if ( ( abs( time() - $ptime ) ) < 86400 ) + $ptime = sprintf( __( '%s ago' ), human_time_diff( $ptime ) ); + else + $ptime = mysql2date( __( 'Y/m/d \a\t g:i A' ), $comment->comment_date ); + + if ( $user_can ) { + $del_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "delete-comment_$comment->comment_ID" ) ); + $approve_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "approve-comment_$comment->comment_ID" ) ); + + $url = "comment.php?c=$comment->comment_ID"; + + $approve_url = esc_url( $url . "&action=approvecomment&$approve_nonce" ); + $unapprove_url = esc_url( $url . "&action=unapprovecomment&$approve_nonce" ); + $spam_url = esc_url( $url . "&action=spamcomment&$del_nonce" ); + $unspam_url = esc_url( $url . "&action=unspamcomment&$del_nonce" ); + $trash_url = esc_url( $url . "&action=trashcomment&$del_nonce" ); + $untrash_url = esc_url( $url . "&action=untrashcomment&$del_nonce" ); + $delete_url = esc_url( $url . "&action=deletecomment&$del_nonce" ); + } + + echo ''; + comment_text(); + if ( $user_can ) { ?> + + '', 'unapprove' => '', + 'reply' => '', + 'quickedit' => '', + 'edit' => '', + 'spam' => '', 'unspam' => '', + 'trash' => '', 'untrash' => '', 'delete' => '' + ); + + if ( $comment_status && 'all' != $comment_status ) { // not looking at all comments + if ( 'approved' == $the_comment_status ) + $actions['unapprove'] = "" . __( 'Unapprove' ) . ''; + else if ( 'unapproved' == $the_comment_status ) + $actions['approve'] = "" . __( 'Approve' ) . ''; + } else { + $actions['approve'] = "" . __( 'Approve' ) . ''; + $actions['unapprove'] = "" . __( 'Unapprove' ) . ''; + } + + if ( 'spam' != $the_comment_status && 'trash' != $the_comment_status ) { + $actions['spam'] = "" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . ''; + } elseif ( 'spam' == $the_comment_status ) { + $actions['unspam'] = "" . _x( 'Not Spam', 'comment' ) . ''; + } elseif ( 'trash' == $the_comment_status ) { + $actions['untrash'] = "" . __( 'Restore' ) . ''; + } + + if ( 'spam' == $the_comment_status || 'trash' == $the_comment_status || !EMPTY_TRASH_DAYS ) { + $actions['delete'] = "" . __( 'Delete Permanently' ) . ''; + } else { + $actions['trash'] = "" . _x( 'Trash', 'verb' ) . ''; + } + + if ( 'trash' != $the_comment_status ) { + $actions['edit'] = "". __( 'Edit' ) . ''; + $actions['quickedit'] = '' . __( 'Quick Edit' ) . ''; + if ( 'spam' != $the_comment_status ) + $actions['reply'] = '' . __( 'Reply' ) . ''; + } + + $actions = apply_filters( 'comment_row_actions', array_filter( $actions ), $comment ); + + $i = 0; + echo '
      '; + foreach ( $actions as $action => $link ) { + ++$i; + ( ( ( 'approve' == $action || 'unapprove' == $action ) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | '; + + // Reply and quickedit need a hide-if-no-js span when not added with ajax + if ( ( 'reply' == $action || 'quickedit' == $action ) && ! defined('DOING_AJAX') ) + $action .= ' hide-if-no-js'; + elseif ( ( $action == 'untrash' && $the_comment_status == 'trash' ) || ( $action == 'unspam' && $the_comment_status == 'spam' ) ) { + if ( '1' == get_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', true ) ) + $action .= ' approve'; + else + $action .= ' unapprove'; + } + + echo "$sep$link"; + } + echo '
      '; + } + } + + function column_author( $comment ) { + global $comment_status; + + $author_url = get_comment_author_url(); + if ( 'http://' == $author_url ) + $author_url = ''; + $author_url_display = preg_replace( '|http://(www\.)?|i', '', $author_url ); + if ( strlen( $author_url_display ) > 50 ) + $author_url_display = substr( $author_url_display, 0, 49 ) . '...'; + + echo ""; comment_author(); echo '
      '; + if ( !empty( $author_url ) ) + echo "$author_url_display
      "; + + if ( $this->user_can ) { + if ( !empty( $comment->comment_author_email ) ) { + comment_author_email_link(); + echo '
      '; + } + echo ''; + comment_author_IP(); + echo ''; + } + } + + function column_date( $comment ) { + return get_comment_date( __( 'Y/m/d \a\t g:ia' ) ); + } + + function column_response( $comment ) { + global $post; + + if ( isset( $this->pending_count[$post->ID] ) ) { + $pending_comments = $this->pending_count[$post->ID]; + } else { + $_pending_count_temp = get_pending_comments_num( array( $post->ID ) ); + $pending_comments = $this->pending_count[$post->ID] = $_pending_count_temp[$post->ID]; + } + + if ( current_user_can( 'edit_post', $post->ID ) ) { + $post_link = ""; + $post_link .= get_the_title( $post->ID ) . ''; + } else { + $post_link = get_the_title( $post->ID ); + } + + echo ''; + if ( 'attachment' == $post->post_type && ( $thumb = wp_get_attachment_image( $post->ID, array( 80, 60 ), true ) ) ) + echo $thumb; + } + + function column_default( $comment, $column_name ) { + do_action( 'manage_comments_custom_column', $column_name, $comment->comment_ID ); + } +} + +/** + * Post Comments List Table class. + * + * @package WordPress + * @subpackage List_Table + * @since 3.1.0 + * @access private + * + * @see WP_Comments_Table + */ +class WP_Post_Comments_List_Table extends WP_Comments_List_Table { + + function get_column_info() { + $this->_column_headers = array( + array( + 'author' => __( 'Author' ), + 'comment' => _x( 'Comment', 'column name' ), + ), + array(), + array(), + ); + + return $this->_column_headers; + } + + function get_table_classes() { + $classes = parent::get_table_classes(); + $classes[] = 'comments-box'; + return $classes; + } + + function display( $output_empty = false ) { + extract( $this->_args ); + + wp_nonce_field( "fetch-list-" . get_class( $this ), '_ajax_fetch_list_nonce' ); +?> + + > + display_rows_or_placeholder(); ?> + + + diff --git a/wp-admin/includes/class-wp-filesystem-direct.php b/wp-admin/includes/class-wp-filesystem-direct.php index 538a683e..94319bce 100644 --- a/wp-admin/includes/class-wp-filesystem-direct.php +++ b/wp-admin/includes/class-wp-filesystem-direct.php @@ -19,7 +19,7 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base { /** * constructor * - * @param $arg mixed ingored argument + * @param mixed $arg ingored argument */ function WP_Filesystem_Direct($arg) { $this->method = 'direct'; @@ -36,7 +36,7 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base { /** * Reads entire file into a string * - * @param $file string Name of the file to read. + * @param string $file Name of the file to read. * @return string|bool The function returns the read data or false on failure. */ function get_contents($file) { @@ -45,7 +45,7 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base { /** * Reads entire file into an array * - * @param $file string Path to the file. + * @param string $file Path to the file. * @return array|bool the file contents in an array or false on failure. */ function get_contents_array($file) { @@ -54,9 +54,9 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base { /** * Write a string to a file * - * @param $file string Remote path to the file where to write the data. - * @param $contents string The data to write. - * @param $mode int (optional) The file permissions as octal number, usually 0644. + * @param string $file Remote path to the file where to write the data. + * @param string $contents The data to write. + * @param int $mode (optional) The file permissions as octal number, usually 0644. * @return bool False upon failure. */ function put_contents($file, $contents, $mode = false ) { @@ -78,7 +78,7 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base { /** * Change directory * - * @param $dir string The new current directory. + * @param string $dir The new current directory. * @return bool Returns true on success or false on failure. */ function chdir($dir) { @@ -87,9 +87,9 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base { /** * Changes file group * - * @param $file string Path to the file. - * @param $group mixed A group name or number. - * @param $recursive bool (optional) If set True changes file group recursivly. Defaults to False. + * @param string $file Path to the file. + * @param mixed $group A group name or number. + * @param bool $recursive (optional) If set True changes file group recursivly. Defaults to False. * @return bool Returns true on success or false on failure. */ function chgrp($file, $group, $recursive = false) { @@ -110,9 +110,9 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base { /** * Changes filesystem permissions * - * @param $file string Path to the file. - * @param $mode int (optional) The permissions as octal number, usually 0644 for files, 0755 for dirs. - * @param $recursive bool (optional) If set True changes file group recursivly. Defaults to False. + * @param string $file Path to the file. + * @param int $mode (optional) The permissions as octal number, usually 0644 for files, 0755 for dirs. + * @param bool $recursive (optional) If set True changes file group recursivly. Defaults to False. * @return bool Returns true on success or false on failure. */ function chmod($file, $mode = false, $recursive = false) { @@ -138,9 +138,9 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base { /** * Changes file owner * - * @param $file string Path to the file. - * @param $owner mixed A user name or number. - * @param $recursive bool (optional) If set True changes file owner recursivly. Defaults to False. + * @param string $file Path to the file. + * @param mixed $owner A user name or number. + * @param bool $recursive (optional) If set True changes file owner recursivly. Defaults to False. * @return bool Returns true on success or false on failure. */ function chown($file, $owner, $recursive = false) { @@ -160,7 +160,7 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base { /** * Gets file owner * - * @param $file string Path to the file. + * @param string $file Path to the file. * @return string Username of the user. */ function owner($file) { @@ -177,7 +177,7 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base { * * FIXME does not handle errors in fileperms() * - * @param $file string Path to the file. + * @param string $file Path to the file. * @return string Mode of the file (last 4 digits). */ function getchmod($file) { diff --git a/wp-admin/includes/class-wp-links-list-table.php b/wp-admin/includes/class-wp-links-list-table.php new file mode 100644 index 00000000..bf1c0bc6 --- /dev/null +++ b/wp-admin/includes/class-wp-links-list-table.php @@ -0,0 +1,186 @@ + 'bookmarks', + ) ); + } + + function ajax_user_can() { + return current_user_can( 'manage_links' ); + } + + function prepare_items() { + global $cat_id, $s, $orderby, $order; + + wp_reset_vars( array( 'action', 'cat_id', 'linkurl', 'name', 'image', 'description', 'visible', 'target', 'category', 'link_id', 'submit', 'orderby', 'order', 'links_show_cat_id', 'rating', 'rel', 'notes', 'linkcheck[]', 's' ) ); + + $args = array( 'hide_invisible' => 0, 'hide_empty' => 0 ); + + if ( 'all' != $cat_id ) + $args['category'] = $cat_id; + if ( !empty( $s ) ) + $args['search'] = $s; + if ( !empty( $orderby ) ) + $args['orderby'] = $orderby; + if ( !empty( $order ) ) + $args['order'] = $order; + + $this->items = get_bookmarks( $args ); + } + + function no_items() { + _e( 'No links found.' ); + } + + function get_bulk_actions() { + $actions = array(); + $actions['delete'] = __( 'Delete' ); + + return $actions; + } + + function extra_tablenav( $which ) { + global $cat_id; + + if ( 'top' != $which ) + return; +?> +
      + $cat_id, + 'name' => 'cat_id', + 'taxonomy' => 'link_category', + 'show_option_all' => __( 'View all categories' ), + 'hide_empty' => true, + 'hierarchical' => 1, + 'show_count' => 0, + 'orderby' => 'name', + ); + wp_dropdown_categories( $dropdown_options ); + submit_button( __( 'Filter' ), 'secondary', false, false, array( 'id' => 'post-query-submit' ) ); +?> +
      + '', + 'name' => __( 'Name' ), + 'url' => __( 'URL' ), + 'categories' => __( 'Categories' ), + 'rel' => __( 'Relationship' ), + 'visible' => __( 'Visible' ), + 'rating' => __( 'Rating' ) + ); + } + + function get_sortable_columns() { + return array( + 'name' => 'name', + 'url' => 'url', + 'visible' => 'visible', + 'rating' => 'rating' + ); + } + + function display_rows() { + global $cat_id; + + $alt = 0; + + foreach ( $this->items as $link ) { + $link = sanitize_bookmark( $link ); + $link->link_name = esc_attr( $link->link_name ); + $link->link_category = wp_get_link_cats( $link->link_id ); + + $short_url = url_shorten( $link->link_url ); + + $visible = ( $link->link_visible == 'Y' ) ? __( 'Yes' ) : __( 'No' ); + $rating = $link->link_rating; + $style = ( $alt++ % 2 ) ? '' : ' class="alternate"'; + + $edit_link = get_edit_bookmark_link( $link ); +?> + > +get_column_info(); + + foreach ( $columns as $column_name => $column_display_name ) { + $class = "class='column-$column_name'"; + + $style = ''; + if ( in_array( $column_name, $hidden ) ) + $style = ' style="display:none;"'; + + $attributes = $class . $style; + + switch ( $column_name ) { + case 'cb': + echo ''; + break; + + case 'name': + echo "link_name ) ) . "'>$link->link_name
      "; + + $actions = array(); + $actions['edit'] = '' . __( 'Edit' ) . ''; + $actions['delete'] = "link_id ) . "' onclick=\"if ( confirm( '" . esc_js( sprintf( __( "You are about to delete this link '%s'\n 'Cancel' to stop, 'OK' to delete." ), $link->link_name ) ) . "' ) ) { return true;}return false;\">" . __( 'Delete' ) . ""; + echo $this->row_actions( $actions ); + + echo ''; + break; + case 'url': + echo "link_name ) )."'>$short_url"; + break; + case 'categories': + ?>>link_category as $category ) { + $cat = get_term( $category, 'link_category', OBJECT, 'display' ); + if ( is_wp_error( $cat ) ) + echo $cat->get_error_message(); + $cat_name = $cat->name; + if ( $cat_id != $category ) + $cat_name = "$cat_name"; + $cat_names[] = $cat_name; + } + echo implode( ', ', $cat_names ); + ?>>link_rel ) ? '
      ' : $link->link_rel; ?>>> + >link_id ); ?> + + + diff --git a/wp-admin/includes/class-wp-list-table.php b/wp-admin/includes/class-wp-list-table.php new file mode 100644 index 00000000..1d80a7ba --- /dev/null +++ b/wp-admin/includes/class-wp-list-table.php @@ -0,0 +1,894 @@ + '', + 'singular' => '', + 'ajax' => false + ) ); + + $screen = get_current_screen(); + + add_filter( "manage_{$screen->id}_columns", array( &$this, 'get_columns' ), 0 ); + + if ( !$args['plural'] ) + $args['plural'] = $screen->base; + + $this->_args = $args; + + if ( $args['ajax'] ) { + // wp_enqueue_script( 'list-table' ); + add_action( 'admin_footer', array( &$this, '_js_vars' ) ); + } + } + + /** + * Checks the current user's permissions + * @uses wp_die() + * + * @since 3.1.0 + * @access public + * @abstract + */ + function ajax_user_can() { + die( 'function WP_List_Table::ajax_user_can() must be over-ridden in a sub-class.' ); + } + + /** + * Prepares the list of items for displaying. + * @uses WP_List_Table::set_pagination_args() + * + * @since 3.1.0 + * @access public + * @abstract + */ + function prepare_items() { + die( 'function WP_List_Table::prepare_items() must be over-ridden in a sub-class.' ); + } + + /** + * An internal method that sets all the necessary pagination arguments + * + * @param array $args An associative array with information about the pagination + * @access protected + */ + function set_pagination_args( $args ) { + $args = wp_parse_args( $args, array( + 'total_items' => 0, + 'total_pages' => 0, + 'per_page' => 0, + ) ); + + if ( !$args['total_pages'] && $args['per_page'] > 0 ) + $args['total_pages'] = ceil( $args['total_items'] / $args['per_page'] ); + + $this->_pagination_args = $args; + } + + /** + * Access the pagination args + * + * @since 3.1.0 + * @access public + * + * @param string $key + * @return array + */ + function get_pagination_arg( $key ) { + if ( 'page' == $key ) + return $this->get_pagenum(); + + if ( isset( $this->_pagination_args[$key] ) ) + return $this->_pagination_args[$key]; + } + + /** + * Whether the table has items to display or not + * + * @since 3.1.0 + * @access public + * + * @return bool + */ + function has_items() { + return !empty( $this->items ); + } + + /** + * Message to be displayed when there are no items + * + * @since 3.1.0 + * @access public + */ + function no_items() { + _e( 'No items found.' ); + } + + /** + * Display the search box. + * + * @since 3.1.0 + * @access public + * + * @param string $text The search button text + * @param string $input_id The search input id + */ + function search_box( $text, $input_id ) { + if ( empty( $_REQUEST['s'] ) && !$this->has_items() ) + return; + + $input_id = $input_id . '-search-input'; + + if ( ! empty( $_REQUEST['orderby'] ) ) + echo ''; + if ( ! empty( $_REQUEST['order'] ) ) + echo ''; +?> + + link ) with the list + * of views available on this table. + * + * @since 3.1.0 + * @access protected + * + * @return array + */ + function get_views() { + return array(); + } + + /** + * Display the bulk actions dropdown. + * + * @since 3.1.0 + * @access public + */ + function views() { + $screen = get_current_screen(); + + $views = $this->get_views(); + $views = apply_filters( 'views_' . $screen->id, $views ); + + if ( empty( $views ) ) + return; + + echo "
        \n"; + foreach ( $views as $class => $view ) { + $views[ $class ] = "\t
      • $view"; + } + echo implode( " |
      • \n", $views ) . "\n"; + echo "
      "; + } + + /** + * Get an associative array ( option_name => option_title ) with the list + * of bulk actions available on this table. + * + * @since 3.1.0 + * @access protected + * + * @return array + */ + function get_bulk_actions() { + return array(); + } + + /** + * Display the bulk actions dropdown. + * + * @since 3.1.0 + * @access public + */ + function bulk_actions() { + $screen = get_current_screen(); + + if ( is_null( $this->_actions ) ) { + $no_new_actions = $this->_actions = $this->get_bulk_actions(); + // This filter can currently only be used to remove actions. + $this->_actions = apply_filters( 'bulk_actions-' . $screen->id, $this->_actions ); + $this->_actions = array_intersect_assoc( $this->_actions, $no_new_actions ); + $two = ''; + } else { + $two = '2'; + } + + if ( empty( $this->_actions ) ) + return; + + echo "\n"; + + submit_button( __( 'Apply' ), 'button-secondary action', false, false, array( 'id' => "doaction$two" ) ); + echo "\n"; + } + + /** + * Get the current action selected from the bulk actions dropdown. + * + * @since 3.1.0 + * @access public + * + * @return string|bool The action name or False if no action was selected + */ + function current_action() { + if ( isset( $_REQUEST['action'] ) && -1 != $_REQUEST['action'] ) + return $_REQUEST['action']; + + if ( isset( $_REQUEST['action2'] ) && -1 != $_REQUEST['action2'] ) + return $_REQUEST['action2']; + + return false; + } + + /** + * Generate row actions div + * + * @since 3.1.0 + * @access protected + * + * @param array $actions The list of actions + * @param bool $always_visible Wether the actions should be always visible + * @return string + */ + function row_actions( $actions, $always_visible = false ) { + $action_count = count( $actions ); + $i = 0; + + if ( !$action_count ) + return ''; + + $out = '
      '; + foreach ( $actions as $action => $link ) { + ++$i; + ( $i == $action_count ) ? $sep = '' : $sep = ' | '; + $out .= "$link$sep"; + } + $out .= '
      '; + + return $out; + } + + /** + * Display a monthly dropdown for filtering items + * + * @since 3.1.0 + * @access protected + */ + function months_dropdown( $post_type ) { + global $wpdb, $wp_locale; + + $months = $wpdb->get_results( $wpdb->prepare( " + SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month + FROM $wpdb->posts + WHERE post_type = %s + ORDER BY post_date DESC + ", $post_type ) ); + + $month_count = count( $months ); + + if ( !$month_count || ( 1 == $month_count && 0 == $months[0]->month ) ) + return; + + $m = isset( $_GET['m'] ) ? (int) $_GET['m'] : 0; +?> + + __( 'List View' ), + 'excerpt' => __( 'Excerpt View' ) + ); + +?> + +
      + $title ) { + $class = ( $current_mode == $mode ) ? 'class="current"' : ''; + echo "$title\n"; + } + ?> +
      +'; + + echo "" . number_format_i18n( get_comments_number() ) . ""; + + if ( $pending_comments ) + echo ''; + } + + /** + * Get the current page number + * + * @since 3.1.0 + * @access protected + * + * @return int + */ + function get_pagenum() { + $pagenum = isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 0; + + if( isset( $this->_pagination_args['total_pages'] ) && $pagenum > $this->_pagination_args['total_pages'] ) + $pagenum = $this->_pagination_args['total_pages']; + + return max( 1, $pagenum ); + } + + /** + * Get number of items to display on a single page + * + * @since 3.1.0 + * @access protected + * + * @return int + */ + function get_items_per_page( $option, $default = 20 ) { + $per_page = (int) get_user_option( $option ); + if ( empty( $per_page ) || $per_page < 1 ) + $per_page = $default; + + return (int) apply_filters( $option, $per_page ); + } + + /** + * Display the pagination. + * + * @since 3.1.0 + * @access protected + */ + function pagination( $which ) { + if ( empty( $this->_pagination_args ) ) + return; + + extract( $this->_pagination_args ); + + $output = '' . sprintf( _n( '1 item', '%s items', $total_items ), number_format_i18n( $total_items ) ) . ''; + + $current = $this->get_pagenum(); + + $current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; + + $current_url = remove_query_arg( array( 'hotkeys_highlight_last', 'hotkeys_highlight_first' ), $current_url ); + + $page_links = array(); + + $disable_first = $disable_last = ''; + if ( $current == 1 ) + $disable_first = ' disabled'; + if ( $current == $total_pages ) + $disable_last = ' disabled'; + + $page_links[] = sprintf( "%s", + 'first-page' . $disable_first, + esc_attr__( 'Go to the first page' ), + esc_url( remove_query_arg( 'paged', $current_url ) ), + '«' + ); + + $page_links[] = sprintf( "%s", + 'prev-page' . $disable_first, + esc_attr__( 'Go to the previous page' ), + esc_url( add_query_arg( 'paged', max( 1, $current-1 ), $current_url ) ), + '‹' + ); + + if ( 'bottom' == $which ) + $html_current_page = $current; + else + $html_current_page = sprintf( "", + esc_attr__( 'Current page' ), + esc_attr( 'paged' ), + $current, + strlen( $total_pages ) + ); + + $html_total_pages = sprintf( "%s", number_format_i18n( $total_pages ) ); + $page_links[] = '' . sprintf( _x( '%1$s of %2$s', 'paging' ), $html_current_page, $html_total_pages ) . ''; + + $page_links[] = sprintf( "%s", + 'next-page' . $disable_last, + esc_attr__( 'Go to the next page' ), + esc_url( add_query_arg( 'paged', min( $total_pages, $current+1 ), $current_url ) ), + '›' + ); + + $page_links[] = sprintf( "%s", + 'last-page' . $disable_last, + esc_attr__( 'Go to the last page' ), + esc_url( add_query_arg( 'paged', $total_pages, $current_url ) ), + '»' + ); + + $output .= "\n" . join( "\n", $page_links ); + + $page_class = $total_pages < 2 ? ' one-page' : ''; + + $this->_pagination = "
      $output
      "; + + echo $this->_pagination; + } + + /** + * Get a list of columns. The format is: + * 'internal-name' => 'Title' + * + * @since 3.1.0 + * @access protected + * @abstract + * + * @return array + */ + function get_columns() { + die( 'function WP_List_Table::get_columns() must be over-ridden in a sub-class.' ); + } + + /** + * Get a list of sortable columns. The format is: + * 'internal-name' => 'orderby' + * or + * 'internal-name' => array( 'orderby', true ) + * + * The second format will make the initial sorting order be descending + * + * @since 3.1.0 + * @access protected + * + * @return array + */ + function get_sortable_columns() { + return array(); + } + + /** + * Get a list of all, hidden and sortable columns, with filter applied + * + * @since 3.1.0 + * @access protected + * + * @return array + */ + function get_column_info() { + if ( isset( $this->_column_headers ) ) + return $this->_column_headers; + + $screen = get_current_screen(); + + $columns = get_column_headers( $screen ); + $hidden = get_hidden_columns( $screen ); + + $_sortable = apply_filters( "manage_{$screen->id}_sortable_columns", $this->get_sortable_columns() ); + + $sortable = array(); + foreach ( $_sortable as $id => $data ) { + if ( empty( $data ) ) + continue; + + $data = (array) $data; + if ( !isset( $data[1] ) ) + $data[1] = false; + + $sortable[$id] = $data; + } + + $this->_column_headers = array( $columns, $hidden, $sortable ); + + return $this->_column_headers; + } + + /** + * Return number of visible columns + * + * @since 3.1.0 + * @access public + * + * @return int + */ + function get_column_count() { + list ( $columns, $hidden ) = $this->get_column_info(); + $hidden = array_intersect( array_keys( $columns ), array_filter( $hidden ) ); + return count( $columns ) - count( $hidden ); + } + + /** + * Print column headers, accounting for hidden and sortable columns. + * + * @since 3.1.0 + * @access protected + * + * @param bool $with_id Whether to set the id attribute or not + */ + function print_column_headers( $with_id = true ) { + $screen = get_current_screen(); + + list( $columns, $hidden, $sortable ) = $this->get_column_info(); + + $current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; + $current_url = remove_query_arg( 'paged', $current_url ); + + if ( isset( $_GET['orderby'] ) ) + $current_orderby = $_GET['orderby']; + else + $current_orderby = ''; + + if ( isset( $_GET['order'] ) && 'desc' == $_GET['order'] ) + $current_order = 'desc'; + else + $current_order = 'asc'; + + foreach ( $columns as $column_key => $column_display_name ) { + $class = array( 'manage-column', "column-$column_key" ); + + $style = ''; + if ( in_array( $column_key, $hidden ) ) + $style = 'display:none;'; + + $style = ' style="' . $style . '"'; + + if ( 'cb' == $column_key ) + $class[] = 'check-column'; + elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ) ) ) + $class[] = 'num'; + + if ( isset( $sortable[$column_key] ) ) { + list( $orderby, $desc_first ) = $sortable[$column_key]; + + if ( $current_orderby == $orderby ) { + $order = 'asc' == $current_order ? 'desc' : 'asc'; + $class[] = 'sorted'; + $class[] = $current_order; + } else { + $order = $desc_first ? 'desc' : 'asc'; + $class[] = 'sortable'; + $class[] = $desc_first ? 'asc' : 'desc'; + } + + $column_display_name = '' . $column_display_name . ''; + } + + $id = $with_id ? "id='$column_key'" : ''; + + if ( !empty( $class ) ) + $class = "class='" . join( ' ', $class ) . "'"; + + echo "$column_display_name"; + } + } + + /** + * Display the table + * + * @since 3.1.0 + * @access public + */ + function display() { + extract( $this->_args ); + + $this->display_tablenav( 'top' ); + +?> + + + + print_column_headers(); ?> + + + + + + print_column_headers( false ); ?> + + + + > + display_rows_or_placeholder(); ?> + +
      +display_tablenav( 'bottom' ); + } + + /** + * Get a list of CSS classes for the tag + * + * @since 3.1.0 + * @access protected + * + * @return array + */ + function get_table_classes() { + return array( 'widefat', 'fixed', $this->_args['plural'] ); + } + + /** + * Generate the table navigation above or below the table + * + * @since 3.1.0 + * @access protected + */ + function display_tablenav( $which ) { + if ( 'top' == $which ) + wp_nonce_field( 'bulk-' . $this->_args['plural'] ); +?> +
      + +
      + bulk_actions( $which ); ?> +
      +extra_tablenav( $which ); + $this->pagination( $which ); +?> + +
      +
      + part of the table + * + * @since 3.1.0 + * @access protected + */ + function display_rows_or_placeholder() { + if ( $this->has_items() ) { + $this->display_rows(); + } else { + list( $columns, $hidden ) = $this->get_column_info(); + echo ''; + } + } + + /** + * Generate the table rows + * + * @since 3.1.0 + * @access protected + */ + function display_rows() { + foreach ( $this->items as $item ) + $this->single_row( $item ); + } + + /** + * Generates content for a single row of the table + * + * @since 3.1.0 + * @access protected + * + * @param object $item The current item + */ + function single_row( $item ) { + static $row_class = ''; + $row_class = ( $row_class == '' ? ' class="alternate"' : '' ); + + echo ''; + echo $this->single_row_columns( $item ); + echo ''; + } + + /** + * Generates the columns for a single row of the table + * + * @since 3.1.0 + * @access protected + * + * @param object $item The current item + */ + function single_row_columns( $item ) { + list( $columns, $hidden ) = $this->get_column_info(); + + foreach ( $columns as $column_name => $column_display_name ) { + $class = "class='$column_name column-$column_name'"; + + $style = ''; + if ( in_array( $column_name, $hidden ) ) + $style = ' style="display:none;"'; + + $attributes = "$class$style"; + + if ( 'cb' == $column_name ) { + echo ''; + } + elseif ( method_exists( $this, 'column_' . $column_name ) ) { + echo ""; + } + else { + echo ""; + } + } + } + + /** + * Handle an incoming ajax request (called from admin-ajax.php) + * + * @since 3.1.0 + * @access public + */ + function ajax_response() { + $this->prepare_items(); + + extract( $this->_args ); + extract( $this->_pagination_args ); + + ob_start(); + if ( ! empty( $_REQUEST['no_placeholder'] ) ) + $this->display_rows(); + else + $this->display_rows_or_placeholder(); + + $rows = ob_get_clean(); + + $response = array( 'rows' => $rows ); + + if ( isset( $total_items ) ) + $response['total_items_i18n'] = sprintf( _n( '1 item', '%s items', $total_items ), number_format_i18n( $total_items ) ); + + if ( isset( $total_pages ) ) { + $response['total_pages'] = $total_pages; + $response['total_pages_i18n'] = number_format_i18n( $total_pages ); + } + + die( json_encode( $response ) ); + } + + /** + * Send required variables to JavaScript land + * + * @access private + */ + function _js_vars() { + $args = array( + 'class' => get_class( $this ), + 'screen' => get_current_screen() + ); + + printf( "\n", json_encode( $args ) ); + } +} +?> diff --git a/wp-admin/includes/class-wp-media-list-table.php b/wp-admin/includes/class-wp-media-list-table.php new file mode 100644 index 00000000..5e05f01e --- /dev/null +++ b/wp-admin/includes/class-wp-media-list-table.php @@ -0,0 +1,374 @@ +detached = isset( $_REQUEST['detached'] ) || isset( $_REQUEST['find_detached'] ); + + parent::WP_List_Table( array( + 'plural' => 'media' + ) ); + } + + function ajax_user_can() { + return current_user_can('upload_files'); + } + + function prepare_items() { + global $lost, $wpdb, $wp_query, $post_mime_types, $avail_post_mime_types; + + $q = $_REQUEST; + + if ( !empty( $lost ) ) + $q['post__in'] = implode( ',', $lost ); + + list( $post_mime_types, $avail_post_mime_types ) = wp_edit_attachments_query( $q ); + + $this->is_trash = isset( $_REQUEST['status'] ) && 'trash' == $_REQUEST['status']; + + $this->set_pagination_args( array( + 'total_items' => $wp_query->found_posts, + 'total_pages' => $wp_query->max_num_pages, + 'per_page' => $wp_query->query_vars['posts_per_page'], + ) ); + } + + function get_views() { + global $wpdb, $post_mime_types, $avail_post_mime_types; + + $type_links = array(); + $_num_posts = (array) wp_count_attachments(); + $_total_posts = array_sum($_num_posts) - $_num_posts['trash']; + if ( !isset( $total_orphans ) ) + $total_orphans = $wpdb->get_var( "SELECT COUNT( * ) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status != 'trash' AND post_parent < 1" ); + $matches = wp_match_mime_types(array_keys($post_mime_types), array_keys($_num_posts)); + foreach ( $matches as $type => $reals ) + foreach ( $reals as $real ) + $num_posts[$type] = ( isset( $num_posts[$type] ) ) ? $num_posts[$type] + $_num_posts[$real] : $_num_posts[$real]; + + $class = ( empty($_GET['post_mime_type']) && !$this->detached && !isset($_GET['status']) ) ? ' class="current"' : ''; + $type_links['all'] = "" . sprintf( _nx( 'All (%s)', 'All (%s)', $_total_posts, 'uploaded files' ), number_format_i18n( $_total_posts ) ) . ''; + foreach ( $post_mime_types as $mime_type => $label ) { + $class = ''; + + if ( !wp_match_mime_types($mime_type, $avail_post_mime_types) ) + continue; + + if ( !empty($_GET['post_mime_type']) && wp_match_mime_types($mime_type, $_GET['post_mime_type']) ) + $class = ' class="current"'; + if ( !empty( $num_posts[$mime_type] ) ) + $type_links[$mime_type] = "" . sprintf( translate_nooped_plural( $label[2], $num_posts[$mime_type] ), number_format_i18n( $num_posts[$mime_type] )) . ''; + } + $type_links['detached'] = 'detached ? ' class="current"' : '' ) . '>' . sprintf( _nx( 'Unattached (%s)', 'Unattached (%s)', $total_orphans, 'detached files' ), number_format_i18n( $total_orphans ) ) . ''; + + if ( !empty($_num_posts['trash']) ) + $type_links['trash'] = '' . sprintf( _nx( 'Trash (%s)', 'Trash (%s)', $_num_posts['trash'], 'uploaded files' ), number_format_i18n( $_num_posts['trash'] ) ) . ''; + + return $type_links; + } + + function get_bulk_actions() { + $actions = array(); + $actions['delete'] = __( 'Delete Permanently' ); + if ( $this->detached ) + $actions['attach'] = __( 'Attach to a post' ); + + return $actions; + } + + function extra_tablenav( $which ) { + global $post_type; + $post_type_obj = get_post_type_object( $post_type ); +?> +
      +detached && !$this->is_trash ) { + $this->months_dropdown( $post_type ); + + do_action( 'restrict_manage_posts' ); + submit_button( __( 'Filter' ), 'secondary', false, false, array( 'id' => 'post-query-submit' ) ); + } + + if ( $this->detached ) { + submit_button( __( 'Scan for lost attachments' ), 'secondary', 'find_detached', false ); + } elseif ( $this->is_trash && current_user_can( 'edit_others_posts' ) ) { + submit_button( __( 'Empty Trash' ), 'button-secondary apply', 'delete_all', false ); + } ?> +
      +'; + $posts_columns['icon'] = ''; + /* translators: column name */ + $posts_columns['title'] = _x( 'File', 'column name' ); + $posts_columns['author'] = __( 'Author' ); + //$posts_columns['tags'] = _x( 'Tags', 'column name' ); + /* translators: column name */ + if ( !$this->detached ) { + $posts_columns['parent'] = _x( 'Attached to', 'column name' ); + $posts_columns['comments'] = '
      Comments
      '; + } + /* translators: column name */ + $posts_columns['date'] = _x( 'Date', 'column name' ); + $posts_columns = apply_filters( 'manage_media_columns', $posts_columns, $this->detached ); + + return $posts_columns; + } + + function get_sortable_columns() { + return array( + 'title' => 'title', + 'author' => 'author', + 'parent' => 'parent', + 'comments' => 'comment_count', + 'date' => array( 'date', true ), + ); + } + + function display_rows() { + global $post, $id; + + add_filter( 'the_title','esc_html' ); + $alt = ''; + + while ( have_posts() ) : the_post(); + + if ( $this->is_trash && $post->post_status != 'trash' + || !$this->is_trash && $post->post_status == 'trash' ) + continue; + + $alt = ( 'alternate' == $alt ) ? '' : 'alternate'; + $post_owner = ( get_current_user_id() == $post->post_author ) ? 'self' : 'other'; + $att_title = _draft_or_post_title(); +?> + post_status ); ?>' valign="top"> +get_column_info(); +foreach ( $columns as $column_name => $column_display_name ) { + $class = "class='$column_name column-$column_name'"; + + $style = ''; + if ( in_array( $column_name, $hidden ) ) + $style = ' style="display:none;"'; + + $attributes = $class . $style; + + switch ( $column_name ) { + + case 'cb': +?> + + + + + + + + + + + +post_date && 'date' == $column_name ) { + $t_time = $h_time = __( 'Unpublished' ); + } else { + $t_time = get_the_time( __( 'Y/m/d g:i:s A' ) ); + $m_time = $post->post_date; + $time = get_post_time( 'G', true, $post, false ); + if ( ( abs( $t_diff = time() - $time ) ) < 86400 ) { + if ( $t_diff < 0 ) + $h_time = sprintf( __( '%s from now' ), human_time_diff( $time ) ); + else + $h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) ); + } else { + $h_time = mysql2date( __( 'Y/m/d' ), $m_time ); + } + } +?> + +post_parent > 0 ) { + if ( get_post( $post->post_parent ) ) { + $title =_draft_or_post_title( $post->post_parent ); + } +?> + + + + + + + + + +detached ) { + if ( current_user_can( 'edit_post', $post->ID ) ) + $actions['edit'] = '' . __( 'Edit' ) . ''; + if ( current_user_can( 'delete_post', $post->ID ) ) + if ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) { + $actions['trash'] = "ID ) . "'>" . __( 'Trash' ) . ""; + } else { + $delete_ays = !MEDIA_TRASH ? " onclick='return showNotice.warn();'" : ''; + $actions['delete'] = "ID ) . "'>" . __( 'Delete Permanently' ) . ""; + } + $actions['view'] = '' . __( 'View' ) . ''; + if ( current_user_can( 'edit_post', $post->ID ) ) + $actions['attach'] = ''.__( 'Attach' ).''; + } + else { + if ( current_user_can( 'edit_post', $post->ID ) && !$this->is_trash ) + $actions['edit'] = '' . __( 'Edit' ) . ''; + if ( current_user_can( 'delete_post', $post->ID ) ) { + if ( $this->is_trash ) + $actions['untrash'] = "ID ) . "'>" . __( 'Restore' ) . ""; + elseif ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) + $actions['trash'] = "ID ) . "'>" . __( 'Trash' ) . ""; + if ( $this->is_trash || !EMPTY_TRASH_DAYS || !MEDIA_TRASH ) { + $delete_ays = ( !$this->is_trash && !MEDIA_TRASH ) ? " onclick='return showNotice.warn();'" : ''; + $actions['delete'] = "ID ) . "'>" . __( 'Delete Permanently' ) . ""; + } + } + if ( !$this->is_trash ) { + $title =_draft_or_post_title( $post->post_parent ); + $actions['view'] = '' . __( 'View' ) . ''; + } + } + + $actions = apply_filters( 'media_row_actions', $actions, $post, $this->detached ); + + return $actions; + } +} + +?> diff --git a/wp-admin/includes/class-wp-ms-sites-list-table.php b/wp-admin/includes/class-wp-ms-sites-list-table.php new file mode 100644 index 00000000..c1bf68b6 --- /dev/null +++ b/wp-admin/includes/class-wp-ms-sites-list-table.php @@ -0,0 +1,340 @@ + 'sites', + ) ); + } + + function ajax_user_can() { + return current_user_can( 'manage_sites' ); + } + + function prepare_items() { + global $s, $mode, $wpdb, $current_site; + + $mode = ( empty( $_REQUEST['mode'] ) ) ? 'list' : $_REQUEST['mode']; + + $per_page = $this->get_items_per_page( 'sites_network_per_page' ); + + $pagenum = $this->get_pagenum(); + + $s = isset( $_REQUEST['s'] ) ? stripslashes( trim( $_REQUEST[ 's' ] ) ) : ''; + $wild = ''; + if ( false !== strpos($s, '*') ) { + $wild = '%'; + $s = trim($s, '*'); + } + + $like_s = esc_sql( like_escape( $s ) ); + + $large_network = false; + // If the network is large and a search is not being performed, show only the latest blogs with no paging in order + // to avoid expensive count queries. + if ( !$s && ( get_blog_count() >= 10000 ) ) { + if ( !isset($_REQUEST['orderby']) ) + $_GET['orderby'] = $_REQUEST['orderby'] = ''; + if ( !isset($_REQUEST['order']) ) + $_GET['order'] = $_REQUEST['order'] = 'DESC'; + $large_network = true; + } + + $query = "SELECT * FROM {$wpdb->blogs} WHERE site_id = '{$wpdb->siteid}' "; + + if ( empty($s) ) { + // Nothing to do. + } elseif ( preg_match('/^[0-9]+\./', $s) ) { + // IP address + $reg_blog_ids = $wpdb->get_col( "SELECT blog_id FROM {$wpdb->registration_log} WHERE {$wpdb->registration_log}.IP LIKE ( '{$like_s}$wild' )" ); + + if ( !$reg_blog_ids ) + $reg_blog_ids = array( 0 ); + + $query = "SELECT * + FROM {$wpdb->blogs} + WHERE site_id = '{$wpdb->siteid}' + AND {$wpdb->blogs}.blog_id IN (" . implode( ', ', $reg_blog_ids ) . ")"; + } else { + if ( is_numeric($s) ) { + $query .= " AND ( {$wpdb->blogs}.blog_id = '{$like_s}' )"; + } elseif ( is_subdomain_install() ) { + $blog_s = str_replace( '.' . $current_site->domain, '', $like_s ); + $blog_s .= $wild . '.' . $current_site->domain; + $query .= " AND ( {$wpdb->blogs}.domain LIKE '$blog_s' ) "; + } else { + if ( $like_s != trim('/', $current_site->path) ) + $blog_s = $current_site->path .= $like_s . $wild . '/'; + else + $blog_s = $like_s; + $query .= " AND ( {$wpdb->blogs}.path LIKE '$blog_s' )"; + } + } + + $order_by = isset( $_REQUEST['orderby'] ) ? $_REQUEST['orderby'] : ''; + if ( $order_by == 'registered' ) { + $query .= ' ORDER BY registered '; + } elseif ( $order_by == 'lastupdated' ) { + $query .= ' ORDER BY last_updated '; + } elseif ( $order_by == 'blogname' ) { + if ( is_subdomain_install() ) + $query .= ' ORDER BY domain '; + else + $query .= ' ORDER BY path '; + } elseif ( $order_by == 'blog_id' ) { + $query .= ' ORDER BY blog_id '; + } else { + $order_by = null; + } + + if ( isset( $order_by ) ) { + $order = ( isset( $_REQUEST['order'] ) && 'DESC' == strtoupper( $_REQUEST['order'] ) ) ? "DESC" : "ASC"; + $query .= $order; + } + + // Don't do an unbounded count on large networks + if ( ! $large_network ) + $total = $wpdb->get_var( str_replace( 'SELECT *', 'SELECT COUNT( blog_id )', $query ) ); + + $query .= " LIMIT " . intval( ( $pagenum - 1 ) * $per_page ) . ", " . intval( $per_page ); + $this->items = $wpdb->get_results( $query, ARRAY_A ); + + if ( $large_network ) + $total = count($this->items); + + $this->set_pagination_args( array( + 'total_items' => $total, + 'per_page' => $per_page, + ) ); + } + + function no_items() { + _e( 'No sites found.' ); + } + + function get_bulk_actions() { + $actions = array(); + if ( current_user_can( 'delete_sites' ) ) + $actions['delete'] = __( 'Delete' ); + $actions['spam'] = _x( 'Mark as Spam', 'site' ); + $actions['notspam'] = _x( 'Not Spam', 'site' ); + + return $actions; + } + + function pagination( $which ) { + global $mode; + + parent::pagination( $which ); + + if ( 'top' == $which ) + $this->view_switcher( $mode ); + } + + function get_columns() { + $blogname_columns = ( is_subdomain_install() ) ? __( 'Domain' ) : __( 'Path' ); + $sites_columns = array( + 'cb' => '', + 'blogname' => $blogname_columns, + 'lastupdated' => __( 'Last Updated' ), + 'registered' => _x( 'Registered', 'site' ), + 'users' => __( 'Users' ) + ); + + if ( has_filter( 'wpmublogsaction' ) ) + $sites_columns['plugins'] = __( 'Actions' ); + + $sites_columns = apply_filters( 'wpmu_blogs_columns', $sites_columns ); + + return $sites_columns; + } + + function get_sortable_columns() { + return array( + 'blogname' => 'blogname', + 'lastupdated' => 'lastupdated', + 'registered' => 'blog_id', + ); + } + + function display_rows() { + global $current_site, $mode; + + $status_list = array( + 'archived' => array( 'site-archived', __( 'Archived' ) ), + 'spam' => array( 'site-spammed', _x( 'Spam', 'site' ) ), + 'deleted' => array( 'site-deleted', __( 'Deleted' ) ), + 'mature' => array( 'site-mature', __( 'Mature' ) ) + ); + + $class = ''; + foreach ( $this->items as $blog ) { + $class = ( 'alternate' == $class ) ? '' : 'alternate'; + reset( $status_list ); + + $blog_states = array(); + foreach ( $status_list as $status => $col ) { + if ( get_blog_status( $blog['blog_id'], $status ) == 1 ) { + $class = $col[0]; + $blog_states[] = $col[1]; + } + } + $blog_state = ''; + if ( ! empty( $blog_states ) ) { + $state_count = count( $blog_states ); + $i = 0; + $blog_state .= ' - '; + foreach ( $blog_states as $state ) { + ++$i; + ( $i == $state_count ) ? $sep = '' : $sep = ', '; + $blog_state .= "$state$sep"; + } + } + echo ""; + + $blogname = ( is_subdomain_install() ) ? str_replace( '.'.$current_site->domain, '', $blog['domain'] ) : $blog['path']; + + list( $columns, $hidden ) = $this->get_column_info(); + + foreach ( $columns as $column_name => $column_display_name ) { + $style = ''; + if ( in_array( $column_name, $hidden ) ) + $style = ' style="display:none;"'; + + switch ( $column_name ) { + case 'cb': ?> + + + + "; ?> + + ' . sprintf( _x( '%1$s – %2$s', '%1$s: site name. %2$s: site tagline.' ), get_blog_option( $blog['blog_id'], 'blogname' ), get_blog_option( $blog['blog_id'], 'blogdescription ' ) ) . '

      '; + + // Preordered. + $actions = array( + 'edit' => '', 'backend' => '', + 'activate' => '', 'deactivate' => '', + 'archive' => '', 'unarchive' => '', + 'spam' => '', 'unspam' => '', + 'delete' => '', + 'visit' => '', + ); + + $actions['edit'] = '' . __( 'Edit' ) . ''; + $actions['backend'] = "" . __( 'Dashboard' ) . ''; + if ( $current_site->blog_id != $blog['blog_id'] ) { + if ( get_blog_status( $blog['blog_id'], 'deleted' ) == '1' ) + $actions['activate'] = '' . __( 'Activate' ) . ''; + else + $actions['deactivate'] = '' . __( 'Deactivate' ) . ''; + + if ( get_blog_status( $blog['blog_id'], 'archived' ) == '1' ) + $actions['unarchive'] = '' . __( 'Unarchive' ) . ''; + else + $actions['archive'] = '' . _x( 'Archive', 'verb; site' ) . ''; + + if ( get_blog_status( $blog['blog_id'], 'spam' ) == '1' ) + $actions['unspam'] = '' . _x( 'Not Spam', 'site' ) . ''; + else + $actions['spam'] = '' . _x( 'Spam', 'site' ) . ''; + + if ( current_user_can( 'delete_site', $blog['blog_id'] ) ) + $actions['delete'] = '' . __( 'Delete' ) . ''; + } + + $actions['visit'] = "" . __( 'Visit' ) . ''; + + $actions = apply_filters( 'manage_sites_action_links', array_filter( $actions ), $blog['blog_id'], $blogname ); + echo $this->row_actions( $actions ); + ?> + + "; + if ( 'list' == $mode ) + $date = 'Y/m/d'; + else + $date = 'Y/m/d \<\b\r \/\> g:i:s a'; + echo ( $blog['last_updated'] == '0000-00-00 00:00:00' ) ? __( 'Never' ) : mysql2date( $date, $blog['last_updated'] ); ?> + + "; + if ( $blog['registered'] == '0000-00-00 00:00:00' ) + echo '—'; + else + echo mysql2date( $date, $blog['registered'] ); + ?> + + "; + $blogusers = get_users( array( 'blog_id' => $blog['blog_id'], 'number' => 6) ); + if ( is_array( $blogusers ) ) { + $blogusers_warning = ''; + if ( count( $blogusers ) > 5 ) { + $blogusers = array_slice( $blogusers, 0, 5 ); + $blogusers_warning = __( 'Only showing first 5 users.' ) . ' ' . __( 'More' ) . ''; + } + foreach ( $blogusers as $user_object ) { + echo '' . esc_html( $user_object->user_login ) . ' '; + if ( 'list' != $mode ) + echo '( ' . $user_object->user_email . ' )'; + echo '
      '; + } + if ( $blogusers_warning != '' ) + echo '' . $blogusers_warning . '
      '; + } + ?> + + + "; + do_action( 'wpmublogsaction', $blog['blog_id'] ); ?> + + "; + do_action( 'manage_sites_custom_column', $column_name, $blog['blog_id'] ); + echo ""; + break; + } + } + ?> + + diff --git a/wp-admin/includes/class-wp-ms-themes-list-table.php b/wp-admin/includes/class-wp-ms-themes-list-table.php new file mode 100644 index 00000000..6e34a163 --- /dev/null +++ b/wp-admin/includes/class-wp-ms-themes-list-table.php @@ -0,0 +1,361 @@ +get_pagenum(); + + $screen = get_current_screen(); + $this->is_site_themes = ( 'site-themes-network' == $screen->id ) ? true : false; + + if ( $this->is_site_themes ) + $this->site_id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0; + + parent::WP_List_Table( array( + 'plural' => 'themes' + ) ); + } + + function get_table_classes() { + return array( 'widefat', 'plugins' ); // todo: remove and add CSS for .themes + } + + function ajax_user_can() { + $menu_perms = get_site_option( 'menu_items', array() ); + + if ( empty( $menu_perms['themes'] ) && ! is_super_admin() ) + return false; + + if ( $this->is_site_themes && !current_user_can('manage_sites') ) + return false; + elseif ( !$this->is_site_themes && !current_user_can('manage_network_themes') ) + return false; + return true; + } + + function prepare_items() { + global $status, $themes, $totals, $page, $orderby, $order, $s; + + wp_reset_vars( array( 'orderby', 'order', 's' ) ); + + $themes = array( + 'all' => apply_filters( 'all_themes', get_themes() ), + 'search' => array(), + 'enabled' => array(), + 'disabled' => array(), + 'upgrade' => array() + ); + + $site_allowed_themes = get_site_allowed_themes(); + if ( !$this->is_site_themes ) { + $allowed_themes = $site_allowed_themes; + $themes_per_page = $this->get_items_per_page( 'themes_network_per_page' ); + } else { + $allowed_themes = wpmu_get_blog_allowedthemes( $this->site_id ); + $themes_per_page = $this->get_items_per_page( 'site_themes_network_per_page' ); + } + + $current = get_site_transient( 'update_themes' ); + + foreach ( (array) $themes['all'] as $key => $theme ) { + $theme_key = $theme['Stylesheet']; + + if ( isset( $allowed_themes [ $theme_key ] ) ) { + $themes['all'][$key]['enabled'] = true; + $themes['enabled'][$key] = $themes['all'][$key]; + } + else { + $themes['all'][$key]['enabled'] = false; + $themes['disabled'][$key] = $themes['all'][$key]; + } + if ( isset( $current->response[ $theme['Template'] ] ) ) + $themes['upgrade'][$key] = $themes['all'][$key]; + + if ( $this->is_site_themes && isset( $site_allowed_themes[$theme_key] ) ) { + unset( $themes['all'][$key] ); + unset( $themes['enabled'][$key] ); + unset( $themes['disabled'][$key] ); + } + } + + if ( !current_user_can( 'update_themes' ) || $this->is_site_themes ) + $themes['upgrade'] = array(); + + if ( $s ) { + $status = 'search'; + $themes['search'] = array_filter( $themes['all'], array( &$this, '_search_callback' ) ); + } + + $totals = array(); + foreach ( $themes as $type => $list ) + $totals[ $type ] = count( $list ); + + if ( empty( $themes[ $status ] ) && !in_array( $status, array( 'all', 'search' ) ) ) + $status = 'all'; + + $this->items = $themes[ $status ]; + $total_this_page = $totals[ $status ]; + + if ( $orderby ) { + $orderby = ucfirst( $orderby ); + $order = strtoupper( $order ); + + uasort( $this->items, array( &$this, '_order_callback' ) ); + } + + $start = ( $page - 1 ) * $themes_per_page; + + if ( $total_this_page > $themes_per_page ) + $this->items = array_slice( $this->items, $start, $themes_per_page ); + + $this->set_pagination_args( array( + 'total_items' => $total_this_page, + 'per_page' => $themes_per_page, + ) ); + } + + function _search_callback( $theme ) { + static $term; + if ( is_null( $term ) ) + $term = stripslashes( $_REQUEST['s'] ); + + $search_fields = array( 'Name', 'Title', 'Description', 'Author', 'Author Name', 'Author URI', 'Template', 'Stylesheet' ); + foreach ( $search_fields as $field ) + if ( stripos( $theme[ $field ], $term ) !== false ) + return true; + + return false; + } + + function _order_callback( $theme_a, $theme_b ) { + global $orderby, $order; + + $a = $theme_a[$orderby]; + $b = $theme_b[$orderby]; + + if ( $a == $b ) + return 0; + + if ( 'DESC' == $order ) + return ( $a < $b ) ? 1 : -1; + else + return ( $a < $b ) ? -1 : 1; + } + + function no_items() { + global $themes; + + if ( !empty( $themes['all'] ) ) + _e( 'No themes found.' ); + else + _e( 'You do not appear to have any themes available at this time.' ); + } + + function get_columns() { + global $status; + + return array( + 'cb' => '', + 'name' => __( 'Theme' ), + 'description' => __( 'Description' ), + ); + } + + function get_sortable_columns() { + return array( + 'name' => 'name', + ); + } + + function get_views() { + global $totals, $status; + + $status_links = array(); + foreach ( $totals as $type => $count ) { + if ( !$count ) + continue; + + switch ( $type ) { + case 'all': + $text = _nx( 'All (%s)', 'All (%s)', $count, 'themes' ); + break; + case 'enabled': + $text = _n( 'Enabled (%s)', 'Enabled (%s)', $count ); + break; + case 'disabled': + $text = _n( 'Disabled (%s)', 'Disabled (%s)', $count ); + break; + case 'upgrade': + $text = _n( 'Update Available (%s)', 'Update Available (%s)', $count ); + break; + } + + if ( $this->is_site_themes ) + $url = 'site-themes.php?id=' . $this->site_id; + else + $url = 'themes.php'; + + if ( 'search' != $type ) { + $status_links[$type] = sprintf( "%s", + esc_url( add_query_arg('theme_status', $type, $url) ), + ( $type == $status ) ? ' class="current"' : '', + sprintf( $text, number_format_i18n( $count ) ) + ); + } + } + + return $status_links; + } + + function get_bulk_actions() { + global $status; + + $actions = array(); + if ( 'enabled' != $status ) + $actions['enable-selected'] = $this->is_site_themes ? __( 'Enable' ) : __( 'Network Enable' ); + if ( 'disabled' != $status ) + $actions['disable-selected'] = $this->is_site_themes ? __( 'Disable' ) : __( 'Network Disable' ); + if ( ! $this->is_site_themes ) { + if ( current_user_can( 'delete_themes' ) ) + $actions['delete-selected'] = __( 'Delete' ); + if ( current_user_can( 'update_themes' ) ) + $actions['update-selected'] = __( 'Update' ); + } + return $actions; + } + + function bulk_actions( $which ) { + global $status; + parent::bulk_actions( $which ); + } + + function current_action() { + return parent::current_action(); + } + + function display_rows() { + foreach ( $this->items as $key => $theme ) + $this->single_row( $key, $theme ); + } + + function single_row( $key, $theme ) { + global $status, $page, $s; + + $context = $status; + + if ( $this->is_site_themes ) + $url = "site-themes.php?id={$this->site_id}&"; + else + $url = 'themes.php?'; + + // preorder + $actions = array( + 'enable' => '', + 'disable' => '', + 'edit' => '', + 'delete' => '' + ); + + $theme_key = $theme['Stylesheet']; + + if ( empty( $theme['enabled'] ) ) + $actions['enable'] = '' . ( $this->is_site_themes ? __( 'Enable' ) : __( 'Network Enable' ) ) . ''; + else + $actions['disable'] = '' . ( $this->is_site_themes ? __( 'Disable' ) : __( 'Network Disable' ) ) . ''; + + if ( current_user_can('edit_themes') ) + $actions['edit'] = '' . __('Edit') . ''; + + if ( empty( $theme['enabled'] ) && current_user_can( 'delete_themes' ) && ! $this->is_site_themes && $theme_key != get_option( 'stylesheet' ) && $theme_key != get_option( 'template' ) ) + $actions['delete'] = '' . __( 'Delete' ) . ''; + + $actions = apply_filters( 'theme_action_links', array_filter( $actions ), $theme_key, $theme, $context ); + $actions = apply_filters( "theme_action_links_$theme_key", $actions, $theme_key, $theme, $context ); + + $class = empty( $theme['enabled'] ) ? 'inactive' : 'active'; + $checkbox_id = "checkbox_" . md5($theme['Name']); + $checkbox = ""; + + $description = '

      ' . $theme['Description'] . '

      '; + $theme_name = $theme['Name']; + + $id = sanitize_title( $theme_name ); + + echo ""; + + list( $columns, $hidden ) = $this->get_column_info(); + + foreach ( $columns as $column_name => $column_display_name ) { + $style = ''; + if ( in_array( $column_name, $hidden ) ) + $style = ' style="display:none;"'; + + switch ( $column_name ) { + case 'cb': + echo ""; + break; + case 'name': + echo ""; + break; + case 'description': + echo ""; + break; + + default: + echo ""; + } + } + + echo ""; + + if ( $this->is_site_themes ) + remove_action( "after_theme_row_$theme_key", 'wp_theme_update_row' ); + do_action( 'after_theme_row', $theme_key, $theme, $status ); + do_action( "after_theme_row_$theme_key", $theme_key, $theme, $status ); + } +} + +?> diff --git a/wp-admin/includes/class-wp-ms-users-list-table.php b/wp-admin/includes/class-wp-ms-users-list-table.php new file mode 100644 index 00000000..36d55e1c --- /dev/null +++ b/wp-admin/includes/class-wp-ms-users-list-table.php @@ -0,0 +1,276 @@ +get_items_per_page( 'users_network_per_page' ); + + $role = isset( $_REQUEST['role'] ) ? $_REQUEST['role'] : ''; + + $paged = $this->get_pagenum(); + + $args = array( + 'number' => $users_per_page, + 'offset' => ( $paged-1 ) * $users_per_page, + 'search' => $usersearch, + 'blog_id' => 0, + 'fields' => 'all_with_meta' + ); + + $args['search'] = ltrim($args['search'], '*'); + + if ( $role == 'super' ) { + $logins = implode( "', '", get_super_admins() ); + $args['include'] = $wpdb->get_col( "SELECT ID FROM $wpdb->users WHERE user_login IN ('$logins')" ); + } + + // If the network is large and a search is not being performed, show only the latest users with no paging in order + // to avoid expensive count queries. + if ( !$usersearch && ( get_blog_count() >= 10000 ) ) { + if ( !isset($_REQUEST['orderby']) ) + $_GET['orderby'] = $_REQUEST['orderby'] = 'id'; + if ( !isset($_REQUEST['order']) ) + $_GET['order'] = $_REQUEST['order'] = 'DESC'; + $args['count_total'] = false; + } + + if ( isset( $_REQUEST['orderby'] ) ) + $args['orderby'] = $_REQUEST['orderby']; + + if ( isset( $_REQUEST['order'] ) ) + $args['order'] = $_REQUEST['order']; + + $mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode']; + + // Query the user IDs for this page + $wp_user_search = new WP_User_Query( $args ); + + $this->items = $wp_user_search->get_results(); + + $this->set_pagination_args( array( + 'total_items' => $wp_user_search->get_total(), + 'per_page' => $users_per_page, + ) ); + } + + function get_bulk_actions() { + $actions = array(); + if ( current_user_can( 'delete_users' ) ) + $actions['delete'] = __( 'Delete' ); + $actions['spam'] = _x( 'Mark as Spam', 'user' ); + $actions['notspam'] = _x( 'Not Spam', 'user' ); + + return $actions; + } + + function no_items() { + _e( 'No users found.' ); + } + + function get_views() { + global $wp_roles, $role; + + $total_users = get_user_count(); + $super_admins = get_super_admins(); + $total_admins = count( $super_admins ); + + $current_role = false; + $class = $role != 'super' ? ' class="current"' : ''; + $role_links = array(); + $role_links['all'] = "" . sprintf( _nx( 'All (%s)', 'All (%s)', $total_users, 'users' ), number_format_i18n( $total_users ) ) . ''; + $class = $role == 'super' ? ' class="current"' : ''; + $role_links['super'] = "" . sprintf( _n( 'Super Admin (%s)', 'Super Admins (%s)', $total_admins ), number_format_i18n( $total_admins ) ) . ''; + + return $role_links; + } + + function pagination( $which ) { + global $mode; + + parent::pagination ( $which ); + + if ( 'top' == $which ) + $this->view_switcher( $mode ); + } + + function get_columns() { + $users_columns = array( + 'cb' => '', + 'username' => __( 'Username' ), + 'name' => __( 'Name' ), + 'email' => __( 'E-mail' ), + 'registered' => _x( 'Registered', 'user' ), + 'blogs' => __( 'Sites' ) + ); + $users_columns = apply_filters( 'wpmu_users_columns', $users_columns ); + + return $users_columns; + } + + function get_sortable_columns() { + return array( + 'username' => 'login', + 'name' => 'name', + 'email' => 'email', + 'registered' => 'id', + ); + } + + function display_rows() { + global $current_site, $mode; + + $alt = ''; + $super_admins = get_super_admins(); + foreach ( $this->items as $user ) { + $alt = ( 'alternate' == $alt ) ? '' : 'alternate'; + + $status_list = array( 'spam' => 'site-spammed', 'deleted' => 'site-deleted' ); + + foreach ( $status_list as $status => $col ) { + if ( $user->$status ) + $alt .= " $col"; + } + + ?> + + get_column_info(); + + foreach ( $columns as $column_name => $column_display_name ) : + $class = "class='$column_name column-$column_name'"; + + $style = ''; + if ( in_array( $column_name, $hidden ) ) + $style = ' style="display:none;"'; + + $attributes = "$class$style"; + + + switch ( $column_name ) { + case 'cb': ?> + + user_email, 32 ); + if ( get_current_user_id() == $user->ID ) { + $edit_link = esc_url( network_admin_url( 'profile.php' ) ); + } else { + $edit_link = esc_url( network_admin_url( add_query_arg( 'wp_http_referer', urlencode( stripslashes( $_SERVER['REQUEST_URI'] ) ), 'user-edit.php?user_id=' . $user->ID ) ) ); + } + + echo " + $user->first_name $user->last_name"; + break; + + case 'email': + echo ""; + break; + + case 'registered': + if ( 'list' == $mode ) + $date = 'Y/m/d'; + else + $date = 'Y/m/d \<\b\r \/\> g:i:s a'; + + echo ""; + break; + + case 'blogs': + $blogs = get_blogs_of_user( $user->ID, true ); + echo " + "; + echo apply_filters( 'manage_users_custom_column', '', $column_name, $user->ID ); + echo ""; + break; + } + endforeach + ?> + + diff --git a/wp-admin/includes/class-wp-plugin-install-list-table.php b/wp-admin/includes/class-wp-plugin-install-list-table.php new file mode 100644 index 00000000..4893ae66 --- /dev/null +++ b/wp-admin/includes/class-wp-plugin-install-list-table.php @@ -0,0 +1,237 @@ +get_pagenum(); + + $per_page = 30; + + // These are the tabs which are shown on the page + $tabs = array(); + $tabs['dashboard'] = __( 'Search' ); + if ( 'search' == $tab ) + $tabs['search'] = __( 'Search Results' ); + $tabs['upload'] = __( 'Upload' ); + $tabs['featured'] = _x( 'Featured','Plugin Installer' ); + $tabs['popular'] = _x( 'Popular','Plugin Installer' ); + $tabs['new'] = _x( 'Newest','Plugin Installer' ); + $tabs['updated'] = _x( 'Recently Updated','Plugin Installer' ); + + $nonmenu_tabs = array( 'plugin-information' ); //Valid actions to perform which do not have a Menu item. + + $tabs = apply_filters( 'install_plugins_tabs', $tabs ); + $nonmenu_tabs = apply_filters( 'install_plugins_nonmenu_tabs', $nonmenu_tabs ); + + // If a non-valid menu tab has been selected, And its not a non-menu action. + if ( empty( $tab ) || ( !isset( $tabs[ $tab ] ) && !in_array( $tab, (array) $nonmenu_tabs ) ) ) + $tab = key( $tabs ); + + $args = array( 'page' => $paged, 'per_page' => $per_page ); + + switch ( $tab ) { + case 'search': + $type = isset( $_REQUEST['type'] ) ? stripslashes( $_REQUEST['type'] ) : ''; + $term = isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : ''; + + switch ( $type ) { + case 'tag': + $args['tag'] = sanitize_title_with_dashes( $term ); + break; + case 'term': + $args['search'] = $term; + break; + case 'author': + $args['author'] = $term; + break; + } + + add_action( 'install_plugins_table_header', 'install_search_form' ); + break; + + case 'featured': + case 'popular': + case 'new': + case 'updated': + $args['browse'] = $tab; + break; + + default: + $args = false; + } + + if ( !$args ) + return; + + $api = plugins_api( 'query_plugins', $args ); + + if ( is_wp_error( $api ) ) + wp_die( $api->get_error_message() . '

      ' . __( 'Try again' ) . '' ); + + $this->items = $api->plugins; + + $this->set_pagination_args( array( + 'total_items' => $api->info['results'], + 'per_page' => $per_page, + ) ); + } + + function no_items() { + _e( 'No plugins match your request.' ); + } + + function get_views() { + global $tabs, $tab; + + $display_tabs = array(); + foreach ( (array) $tabs as $action => $text ) { + $class = ( $action == $tab ) ? ' class="current"' : ''; + $href = self_admin_url('plugin-install.php?tab=' . $action); + $display_tabs['plugin-install-'.$action] = "$text"; + } + + return $display_tabs; + } + + function display_tablenav( $which ) { + if ( 'top' == $which ) { ?> +

      +
      + +
      + pagination( $which ); ?> + +
      +
      + +
      + pagination( $which ); ?> + +
      +
      + _args ); + + return array( 'widefat', $plural ); + } + + function get_columns() { + return array( + 'name' => __( 'Name' ), + 'version' => __( 'Version' ), + 'rating' => __( 'Rating' ), + 'description' => __( 'Description' ), + ); + } + + function display_rows() { + $plugins_allowedtags = array( + 'a' => array( 'href' => array(),'title' => array(), 'target' => array() ), + 'abbr' => array( 'title' => array() ),'acronym' => array( 'title' => array() ), + 'code' => array(), 'pre' => array(), 'em' => array(),'strong' => array(), + 'ul' => array(), 'ol' => array(), 'li' => array(), 'p' => array(), 'br' => array() + ); + + list( $columns, $hidden ) = $this->get_column_info(); + + $style = array(); + foreach ( $columns as $column_name => $column_display_name ) { + $style[ $column_name ] = in_array( $column_name, $hidden ) ? 'style="display:none;"' : ''; + } + + foreach ( (array) $this->items as $plugin ) { + if ( is_object( $plugin ) ) + $plugin = (array) $plugin; + + $title = wp_kses( $plugin['name'], $plugins_allowedtags ); + //Limit description to 400char, and remove any HTML. + $description = strip_tags( $plugin['description'] ); + if ( strlen( $description ) > 400 ) + $description = mb_substr( $description, 0, 400 ) . '…'; + //remove any trailing entities + $description = preg_replace( '/&[^;\s]{0,6}$/', '', $description ); + //strip leading/trailing & multiple consecutive lines + $description = trim( $description ); + $description = preg_replace( "|(\r?\n)+|", "\n", $description ); + //\n =>
      + $description = nl2br( $description ); + $version = wp_kses( $plugin['version'], $plugins_allowedtags ); + + $name = strip_tags( $title . ' ' . $version ); + + $author = $plugin['author']; + if ( ! empty( $plugin['author'] ) ) + $author = ' ' . sprintf( __( 'By %s' ), $author ) . '.'; + + $author = wp_kses( $author, $plugins_allowedtags ); + + $action_links = array(); + $action_links[] = '' . __( 'Details' ) . ''; + + if ( current_user_can( 'install_plugins' ) || current_user_can( 'update_plugins' ) ) { + $status = install_plugin_install_status( $plugin ); + + switch ( $status['status'] ) { + case 'install': + if ( $status['url'] ) + $action_links[] = '' . __( 'Install Now' ) . ''; + break; + case 'update_available': + if ( $status['url'] ) + $action_links[] = '' . sprintf( __( 'Update Now' ), $status['version'] ) . ''; + break; + case 'latest_installed': + case 'newer_installed': + $action_links[] = '' . __( 'Installed' ) . ''; + break; + } + } + + $action_links = apply_filters( 'plugin_install_action_links', $action_links, $plugin ); + ?> + + + + + + + diff --git a/wp-admin/includes/class-wp-plugins-list-table.php b/wp-admin/includes/class-wp-plugins-list-table.php new file mode 100644 index 00000000..eefffb10 --- /dev/null +++ b/wp-admin/includes/class-wp-plugins-list-table.php @@ -0,0 +1,453 @@ +get_pagenum(); + + parent::WP_List_Table( array( + 'plural' => 'plugins', + ) ); + } + + function get_table_classes() { + return array( 'widefat', $this->_args['plural'] ); + } + + function ajax_user_can() { + if ( is_multisite() ) { + $menu_perms = get_site_option( 'menu_items', array() ); + + if ( empty( $menu_perms['plugins'] ) && ! is_super_admin() ) + return false; + } + + return current_user_can('activate_plugins'); + } + + function prepare_items() { + global $status, $plugins, $totals, $page, $orderby, $order, $s; + + wp_reset_vars( array( 'orderby', 'order', 's' ) ); + + $plugins = array( + 'all' => apply_filters( 'all_plugins', get_plugins() ), + 'search' => array(), + 'active' => array(), + 'inactive' => array(), + 'recently_activated' => array(), + 'upgrade' => array(), + 'mustuse' => array(), + 'dropins' => array() + ); + + $screen = get_current_screen(); + + if ( ! is_multisite() || ( $screen->is_network && current_user_can('manage_network_plugins') ) ) { + if ( apply_filters( 'show_advanced_plugins', true, 'mustuse' ) ) + $plugins['mustuse'] = get_mu_plugins(); + if ( apply_filters( 'show_advanced_plugins', true, 'dropins' ) ) + $plugins['dropins'] = get_dropins(); + + $current = get_site_transient( 'update_plugins' ); + foreach ( (array) $plugins['all'] as $plugin_file => $plugin_data ) { + if ( isset( $current->response[ $plugin_file ] ) ) + $plugins['upgrade'][ $plugin_file ] = $plugin_data; + } + } + + set_transient( 'plugin_slugs', array_keys( $plugins['all'] ), 86400 ); + + $recently_activated = get_option( 'recently_activated', array() ); + + $one_week = 7*24*60*60; + foreach ( $recently_activated as $key => $time ) + if ( $time + $one_week < time() ) + unset( $recently_activated[$key] ); + update_option( 'recently_activated', $recently_activated ); + + foreach ( (array) $plugins['all'] as $plugin_file => $plugin_data ) { + // Filter into individual sections + if ( is_multisite() && is_network_only_plugin( $plugin_file ) && !$screen->is_network ) { + unset( $plugins['all'][ $plugin_file] ); + } elseif ( is_plugin_active_for_network($plugin_file) && !$screen->is_network ) { + unset( $plugins['all'][ $plugin_file ] ); + } elseif ( is_multisite() && is_network_only_plugin( $plugin_file ) && !current_user_can( 'manage_network_plugins' ) ) { + $plugins['network'][ $plugin_file ] = $plugin_data; + } elseif ( ( !$screen->is_network && is_plugin_active( $plugin_file ) ) + || ( $screen->is_network && is_plugin_active_for_network( $plugin_file ) ) ) { + $plugins['active'][ $plugin_file ] = $plugin_data; + } else { + if ( !$screen->is_network && isset( $recently_activated[ $plugin_file ] ) ) // Was the plugin recently activated? + $plugins['recently_activated'][ $plugin_file ] = $plugin_data; + $plugins['inactive'][ $plugin_file ] = $plugin_data; + } + } + + if ( !current_user_can( 'update_plugins' ) ) + $plugins['upgrade'] = array(); + + if ( $s ) { + $status = 'search'; + $plugins['search'] = array_filter( $plugins['all'], array( &$this, '_search_callback' ) ); + } + + $totals = array(); + foreach ( $plugins as $type => $list ) + $totals[ $type ] = count( $list ); + + if ( empty( $plugins[ $status ] ) && !in_array( $status, array( 'all', 'search' ) ) ) + $status = 'all'; + + $this->items = array(); + foreach ( $plugins[ $status ] as $plugin_file => $plugin_data ) { + // Translate, Don't Apply Markup, Sanitize HTML + $this->items[$plugin_file] = _get_plugin_data_markup_translate( $plugin_file, $plugin_data, false, true ); + } + + $total_this_page = $totals[ $status ]; + + if ( $orderby ) { + $orderby = ucfirst( $orderby ); + $order = strtoupper( $order ); + + uasort( $this->items, array( &$this, '_order_callback' ) ); + } + + $plugins_per_page = $this->get_items_per_page( str_replace( '-', '_', $screen->id . '_per_page' ) ); + + $start = ( $page - 1 ) * $plugins_per_page; + + if ( $total_this_page > $plugins_per_page ) + $this->items = array_slice( $this->items, $start, $plugins_per_page ); + + $this->set_pagination_args( array( + 'total_items' => $total_this_page, + 'per_page' => $plugins_per_page, + ) ); + } + + function _search_callback( $plugin ) { + static $term; + if ( is_null( $term ) ) + $term = stripslashes( $_REQUEST['s'] ); + + foreach ( $plugin as $value ) + if ( stripos( $value, $term ) !== false ) + return true; + + return false; + } + + function _order_callback( $plugin_a, $plugin_b ) { + global $orderby, $order; + + $a = $plugin_a[$orderby]; + $b = $plugin_b[$orderby]; + + if ( $a == $b ) + return 0; + + if ( 'DESC' == $order ) + return ( $a < $b ) ? 1 : -1; + else + return ( $a < $b ) ? -1 : 1; + } + + function no_items() { + global $plugins; + + if ( !empty( $plugins['all'] ) ) + _e( 'No plugins found.' ); + else + _e( 'You do not appear to have any plugins available at this time.' ); + } + + function get_columns() { + global $status; + + return array( + 'cb' => !in_array( $status, array( 'mustuse', 'dropins' ) ) ? '' : '', + 'name' => __( 'Plugin' ), + 'description' => __( 'Description' ), + ); + } + + function get_sortable_columns() { + return array(); + } + + function display_tablenav( $which ) { + global $status; + + if ( !in_array( $status, array( 'mustuse', 'dropins' ) ) ) + parent::display_tablenav( $which ); + } + + function get_views() { + global $totals, $status; + + $status_links = array(); + foreach ( $totals as $type => $count ) { + if ( !$count ) + continue; + + switch ( $type ) { + case 'all': + $text = _nx( 'All (%s)', 'All (%s)', $count, 'plugins' ); + break; + case 'active': + $text = _n( 'Active (%s)', 'Active (%s)', $count ); + break; + case 'recently_activated': + $text = _n( 'Recently Active (%s)', 'Recently Active (%s)', $count ); + break; + case 'inactive': + $text = _n( 'Inactive (%s)', 'Inactive (%s)', $count ); + break; + case 'network': + $text = _n( 'Network (%s)', 'Network (%s)', $count ); + break; + case 'mustuse': + $text = _n( 'Must-Use (%s)', 'Must-Use (%s)', $count ); + break; + case 'dropins': + $text = _n( 'Drop-ins (%s)', 'Drop-ins (%s)', $count ); + break; + case 'upgrade': + $text = _n( 'Update Available (%s)', 'Update Available (%s)', $count ); + break; + } + + if ( 'search' != $type ) { + $status_links[$type] = sprintf( "%s", + add_query_arg('plugin_status', $type, 'plugins.php'), + ( $type == $status ) ? ' class="current"' : '', + sprintf( $text, number_format_i18n( $count ) ) + ); + } + } + + return $status_links; + } + + function get_bulk_actions() { + global $status; + + $actions = array(); + + $screen = get_current_screen(); + + if ( 'active' != $status ) { + $action = $screen->is_network ? 'network-activate-selected' : 'activate-selected'; + $actions[ $action ] = __( 'Activate' ); + } + + if ( 'inactive' != $status && 'recent' != $status ) + $actions['deactivate-selected'] = __( 'Deactivate' ); + + if ( !is_multisite() || $screen->is_network ) { + if ( current_user_can( 'update_plugins' ) ) + $actions['update-selected'] = __( 'Update' ); + if ( current_user_can( 'delete_plugins' ) && ( 'active' != $status ) ) + $actions['delete-selected'] = __( 'Delete' ); + } + + return $actions; + } + + function bulk_actions( $which ) { + global $status; + + if ( in_array( $status, array( 'mustuse', 'dropins' ) ) ) + return; + + parent::bulk_actions( $which ); + } + + function extra_tablenav( $which ) { + global $status; + + if ( 'recently_activated' == $status ) { ?> +
      + +
      + is_network && in_array( $status, array( 'mustuse', 'dropins' ) ) ) + return; + + foreach ( $this->items as $plugin_file => $plugin_data ) + $this->single_row( $plugin_file, $plugin_data ); + } + + function single_row( $plugin_file, $plugin_data ) { + global $status, $page, $s; + + $context = $status; + + $screen = get_current_screen(); + + // preorder + $actions = array( + 'network_deactivate' => '', 'deactivate' => '', + 'network_only' => '', 'activate' => '', + 'network_activate' => '', + 'edit' => '', + 'delete' => '', + ); + + if ( 'mustuse' == $context ) { + $is_active = true; + } elseif ( 'dropins' == $context ) { + $dropins = _get_dropins(); + $plugin_name = $plugin_file; + if ( $plugin_file != $plugin_data['Name'] ) + $plugin_name .= '
      ' . $plugin_data['Name']; + if ( true === ( $dropins[ $plugin_file ][1] ) ) { // Doesn't require a constant + $is_active = true; + $description = '

      ' . $dropins[ $plugin_file ][0] . '

      '; + } elseif ( constant( $dropins[ $plugin_file ][1] ) ) { // Constant is true + $is_active = true; + $description = '

      ' . $dropins[ $plugin_file ][0] . '

      '; + } else { + $is_active = false; + $description = '

      ' . $dropins[ $plugin_file ][0] . ' ' . __('Inactive:') . ' ' . sprintf( __( 'Requires %s in wp-config.php.' ), "define('" . $dropins[ $plugin_file ][1] . "', true);" ) . '

      '; + } + if ( $plugin_data['Description'] ) + $description .= '

      ' . $plugin_data['Description'] . '

      '; + } else { + $is_active_for_network = is_plugin_active_for_network($plugin_file); + if ( $screen->is_network ) + $is_active = $is_active_for_network; + else + $is_active = is_plugin_active( $plugin_file ); + + if ( $is_active_for_network && !is_super_admin() && !$screen->is_network ) + return; + + if ( $screen->is_network ) { + if ( $is_active_for_network ) { + if ( current_user_can( 'manage_network_plugins' ) ) + $actions['network_deactivate'] = '' . __('Network Deactivate') . ''; + } else { + if ( current_user_can( 'manage_network_plugins' ) ) + $actions['network_activate'] = '' . __('Network Activate') . ''; + if ( current_user_can( 'delete_plugins' ) && ! is_plugin_active( $plugin_file ) ) + $actions['delete'] = '' . __('Delete') . ''; + } + } else { + if ( $is_active ) { + $actions['deactivate'] = '' . __('Deactivate') . ''; + } else { + $actions['activate'] = '' . __('Activate') . ''; + + if ( ! is_multisite() && current_user_can('delete_plugins') ) + $actions['delete'] = '' . __('Delete') . ''; + } // end if $is_active + } // end if $screen->is_network + + if ( ( ! is_multisite() || $screen->is_network ) && current_user_can('edit_plugins') && is_writable(WP_PLUGIN_DIR . '/' . $plugin_file) ) + $actions['edit'] = '' . __('Edit') . ''; + } // end if $context + + $prefix = $screen->is_network ? 'network_admin_' : ''; + $actions = apply_filters( $prefix . 'plugin_action_links', array_filter( $actions ), $plugin_file, $plugin_data, $context ); + $actions = apply_filters( $prefix . "plugin_action_links_$plugin_file", $actions, $plugin_file, $plugin_data, $context ); + + $class = $is_active ? 'active' : 'inactive'; + $checkbox_id = "checkbox_" . md5($plugin_data['Name']); + $checkbox = in_array( $status, array( 'mustuse', 'dropins' ) ) ? '' : ""; + if ( 'dropins' != $context ) { + $description = '

      ' . ( $plugin_data['Description'] ? $plugin_data['Description'] : ' ' ) . '

      '; + $plugin_name = $plugin_data['Name']; + } + + $id = sanitize_title( $plugin_name ); + + echo ""; + + list( $columns, $hidden ) = $this->get_column_info(); + + foreach ( $columns as $column_name => $column_display_name ) { + $style = ''; + if ( in_array( $column_name, $hidden ) ) + $style = ' style="display:none;"'; + + switch ( $column_name ) { + case 'cb': + echo ""; + break; + case 'name': + echo ""; + break; + case 'description': + echo ""; + break; + default: + echo ""; + } + } + + echo ""; + + do_action( 'after_plugin_row', $plugin_file, $plugin_data, $status ); + do_action( "after_plugin_row_$plugin_file", $plugin_file, $plugin_data, $status ); + } +} + +?> diff --git a/wp-admin/includes/class-wp-posts-list-table.php b/wp-admin/includes/class-wp-posts-list-table.php new file mode 100644 index 00000000..e623ab59 --- /dev/null +++ b/wp-admin/includes/class-wp-posts-list-table.php @@ -0,0 +1,1019 @@ + true ) ) ) ) + $post_type = $_REQUEST['post_type']; + else + wp_die( __( 'Invalid post type' ) ); + $_REQUEST['post_type'] = $post_type; + + $post_type_object = get_post_type_object( $post_type ); + + if ( !current_user_can( $post_type_object->cap->edit_others_posts ) ) { + $this->user_posts_count = $wpdb->get_var( $wpdb->prepare( " + SELECT COUNT( 1 ) FROM $wpdb->posts + WHERE post_type = %s AND post_status NOT IN ( 'trash', 'auto-draft' ) + AND post_author = %d + ", $post_type, get_current_user_id() ) ); + + if ( $this->user_posts_count && empty( $_REQUEST['post_status'] ) && empty( $_REQUEST['all_posts'] ) && empty( $_REQUEST['author'] ) && empty( $_REQUEST['show_sticky'] ) ) + $_GET['author'] = get_current_user_id(); + } + + if ( 'post' == $post_type && $sticky_posts = get_option( 'sticky_posts' ) ) { + $sticky_posts = implode( ', ', array_map( 'absint', (array) $sticky_posts ) ); + $this->sticky_posts_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT( 1 ) FROM $wpdb->posts WHERE post_type = %s AND post_status != 'trash' AND ID IN ($sticky_posts)", $post_type ) ); + } + + parent::WP_List_Table( array( + 'plural' => 'posts', + ) ); + } + + function ajax_user_can() { + global $post_type_object; + + return current_user_can( $post_type_object->cap->edit_posts ); + } + + function prepare_items() { + global $post_type_object, $post_type, $avail_post_stati, $wp_query, $per_page, $mode; + + $avail_post_stati = wp_edit_posts_query(); + + $this->hierarchical_display = ( $post_type_object->hierarchical && 'menu_order title' == $wp_query->query['orderby'] ); + + $total_items = $this->hierarchical_display ? $wp_query->post_count : $wp_query->found_posts; + + $per_page = $this->get_items_per_page( 'edit_' . $post_type . '_per_page' ); + $per_page = apply_filters( 'edit_posts_per_page', $per_page, $post_type ); + + if ( $this->hierarchical_display ) + $total_pages = ceil( $total_items / $per_page ); + else + $total_pages = $wp_query->max_num_pages; + + $mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode']; + + $this->is_trash = isset( $_REQUEST['post_status'] ) && $_REQUEST['post_status'] == 'trash'; + + $this->set_pagination_args( array( + 'total_items' => $total_items, + 'total_pages' => $total_pages, + 'per_page' => $per_page + ) ); + } + + function has_items() { + return have_posts(); + } + + function no_items() { + global $post_type_object; + + if ( isset( $_REQUEST['post_status'] ) && 'trash' == $_REQUEST['post_status'] ) + echo $post_type_object->labels->not_found_in_trash; + else + echo $post_type_object->labels->not_found; + } + + function get_views() { + global $post_type, $post_type_object, $locked_post_status, $avail_post_stati; + + if ( !empty($locked_post_status) ) + return array(); + + $status_links = array(); + $num_posts = wp_count_posts( $post_type, 'readable' ); + $class = ''; + $allposts = ''; + + $current_user_id = get_current_user_id(); + + if ( $this->user_posts_count ) { + if ( isset( $_GET['author'] ) && ( $_GET['author'] == $current_user_id ) ) + $class = ' class="current"'; + $status_links['mine'] = "" . sprintf( _nx( 'Mine (%s)', 'Mine (%s)', $this->user_posts_count, 'posts' ), number_format_i18n( $this->user_posts_count ) ) . ''; + $allposts = '&all_posts=1'; + } + + $total_posts = array_sum( (array) $num_posts ); + + // Subtract post types that are not included in the admin all list. + foreach ( get_post_stati( array('show_in_admin_all_list' => false) ) as $state ) + $total_posts -= $num_posts->$state; + + $class = empty( $class ) && empty( $_REQUEST['post_status'] ) && empty( $_REQUEST['show_sticky'] ) ? ' class="current"' : ''; + $status_links['all'] = "" . sprintf( _nx( 'All (%s)', 'All (%s)', $total_posts, 'posts' ), number_format_i18n( $total_posts ) ) . ''; + + foreach ( get_post_stati(array('show_in_admin_status_list' => true), 'objects') as $status ) { + $class = ''; + + $status_name = $status->name; + + if ( !in_array( $status_name, $avail_post_stati ) ) + continue; + + if ( empty( $num_posts->$status_name ) ) + continue; + + if ( isset($_REQUEST['post_status']) && $status_name == $_REQUEST['post_status'] ) + $class = ' class="current"'; + + $status_links[$status_name] = "" . sprintf( translate_nooped_plural( $status->label_count, $num_posts->$status_name ), number_format_i18n( $num_posts->$status_name ) ) . ''; + } + + if ( ! empty( $this->sticky_posts_count ) ) { + $class = ! empty( $_REQUEST['show_sticky'] ) ? ' class="current"' : ''; + + $sticky_link = array( 'sticky' => "" . sprintf( _nx( 'Sticky (%s)', 'Sticky (%s)', $this->sticky_posts_count, 'posts' ), number_format_i18n( $this->sticky_posts_count ) ) . '' ); + + // Sticky comes after Publish, or if not listed, after All. + $split = 1 + array_search( ( isset( $status_links['publish'] ) ? 'publish' : 'all' ), array_keys( $status_links ) ); + $status_links = array_merge( array_slice( $status_links, 0, $split ), $sticky_link, array_slice( $status_links, $split ) ); + } + + return $status_links; + } + + function get_bulk_actions() { + $actions = array(); + + if ( $this->is_trash ) + $actions['untrash'] = __( 'Restore' ); + else + $actions['edit'] = __( 'Edit' ); + + if ( $this->is_trash || !EMPTY_TRASH_DAYS ) + $actions['delete'] = __( 'Delete Permanently' ); + else + $actions['trash'] = __( 'Move to Trash' ); + + return $actions; + } + + function extra_tablenav( $which ) { + global $post_type, $post_type_object, $cat; +?> +
      +months_dropdown( $post_type ); + + if ( is_object_in_taxonomy( $post_type, 'category' ) ) { + $dropdown_options = array( + 'show_option_all' => __( 'View all categories' ), + 'hide_empty' => 0, + 'hierarchical' => 1, + 'show_count' => 0, + 'orderby' => 'name', + 'selected' => $cat + ); + wp_dropdown_categories( $dropdown_options ); + } + do_action( 'restrict_manage_posts' ); + submit_button( __( 'Filter' ), 'secondary', false, false, array( 'id' => 'post-query-submit' ) ); + } + + if ( $this->is_trash && current_user_can( $post_type_object->cap->edit_others_posts ) ) { + submit_button( __( 'Empty Trash' ), 'button-secondary apply', 'delete_all', false ); + } +?> +
      +hierarchical ) + $this->view_switcher( $mode ); + } + + function get_table_classes() { + global $post_type_object; + + return array( 'widefat', 'fixed', $post_type_object->hierarchical ? 'pages' : 'posts' ); + } + + function get_columns() { + $screen = get_current_screen(); + + if ( empty( $screen ) ) + $post_type = 'post'; + else + $post_type = $screen->post_type; + + $posts_columns = array(); + + $posts_columns['cb'] = ''; + + /* translators: manage posts column name */ + $posts_columns['title'] = _x( 'Title', 'column name' ); + + if ( post_type_supports( $post_type, 'author' ) ) + $posts_columns['author'] = __( 'Author' ); + + if ( empty( $post_type ) || is_object_in_taxonomy( $post_type, 'category' ) ) + $posts_columns['categories'] = __( 'Categories' ); + + if ( empty( $post_type ) || is_object_in_taxonomy( $post_type, 'post_tag' ) ) + $posts_columns['tags'] = __( 'Tags' ); + + $post_status = !empty( $_REQUEST['post_status'] ) ? $_REQUEST['post_status'] : 'all'; + if ( post_type_supports( $post_type, 'comments' ) && !in_array( $post_status, array( 'pending', 'draft', 'future' ) ) ) + $posts_columns['comments'] = '
      ' . esc_attr__( 'Comments' ) . '
      '; + + $posts_columns['date'] = __( 'Date' ); + + if ( 'page' == $post_type ) + $posts_columns = apply_filters( 'manage_pages_columns', $posts_columns ); + else + $posts_columns = apply_filters( 'manage_posts_columns', $posts_columns, $post_type ); + $posts_columns = apply_filters( "manage_{$post_type}_posts_columns", $posts_columns ); + + return $posts_columns; + } + + function get_sortable_columns() { + return array( + 'title' => 'title', + 'author' => 'author', + 'parent' => 'parent', + 'comments' => 'comment_count', + 'date' => array( 'date', true ) + ); + } + + function display_rows( $posts = array() ) { + global $wp_query, $post_type_object, $per_page; + + if ( empty( $posts ) ) + $posts = $wp_query->posts; + + if ( $this->hierarchical_display ) { + $this->_display_rows_hierarchical( $posts, $this->get_pagenum(), $per_page ); + } else { + $this->_display_rows( $posts ); + } + } + + function _display_rows( $posts ) { + global $post, $mode; + + add_filter( 'the_title', 'esc_html' ); + + // Create array of post IDs. + $post_ids = array(); + + foreach ( $posts as $a_post ) + $post_ids[] = $a_post->ID; + + $this->comment_pending_count = get_pending_comments_num( $post_ids ); + + foreach ( $posts as $post ) + $this->single_row( $post ); + } + + function _display_rows_hierarchical( $pages, $pagenum = 1, $per_page = 20 ) { + global $wpdb; + + $level = 0; + + if ( ! $pages ) { + $pages = get_pages( array( 'sort_column' => 'menu_order' ) ); + + if ( ! $pages ) + return false; + } + + /* + * arrange pages into two parts: top level pages and children_pages + * children_pages is two dimensional array, eg. + * children_pages[10][] contains all sub-pages whose parent is 10. + * It only takes O( N ) to arrange this and it takes O( 1 ) for subsequent lookup operations + * If searching, ignore hierarchy and treat everything as top level + */ + if ( empty( $_REQUEST['s'] ) ) { + + $top_level_pages = array(); + $children_pages = array(); + + foreach ( $pages as $page ) { + + // catch and repair bad pages + if ( $page->post_parent == $page->ID ) { + $page->post_parent = 0; + $wpdb->update( $wpdb->posts, array( 'post_parent' => 0 ), array( 'ID' => $page->ID ) ); + clean_page_cache( $page->ID ); + } + + if ( 0 == $page->post_parent ) + $top_level_pages[] = $page; + else + $children_pages[ $page->post_parent ][] = $page; + } + + $pages = &$top_level_pages; + } + + $count = 0; + $start = ( $pagenum - 1 ) * $per_page; + $end = $start + $per_page; + + foreach ( $pages as $page ) { + if ( $count >= $end ) + break; + + if ( $count >= $start ) + echo "\t" . $this->single_row( $page, $level ); + + $count++; + + if ( isset( $children_pages ) ) + $this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page ); + } + + // if it is the last pagenum and there are orphaned pages, display them with paging as well + if ( isset( $children_pages ) && $count < $end ){ + foreach ( $children_pages as $orphans ){ + foreach ( $orphans as $op ) { + if ( $count >= $end ) + break; + if ( $count >= $start ) + echo "\t" . $this->single_row( $op, 0 ); + $count++; + } + } + } + } + + /** + * Given a top level page ID, display the nested hierarchy of sub-pages + * together with paging support + * + * @since 3.1.0 (Standalone function exists since 2.6.0) + * + * @param unknown_type $children_pages + * @param unknown_type $count + * @param unknown_type $parent + * @param unknown_type $level + * @param unknown_type $pagenum + * @param unknown_type $per_page + */ + function _page_rows( &$children_pages, &$count, $parent, $level, $pagenum, $per_page ) { + + if ( ! isset( $children_pages[$parent] ) ) + return; + + $start = ( $pagenum - 1 ) * $per_page; + $end = $start + $per_page; + + foreach ( $children_pages[$parent] as $page ) { + + if ( $count >= $end ) + break; + + // If the page starts in a subtree, print the parents. + if ( $count == $start && $page->post_parent > 0 ) { + $my_parents = array(); + $my_parent = $page->post_parent; + while ( $my_parent ) { + $my_parent = get_post( $my_parent ); + $my_parents[] = $my_parent; + if ( !$my_parent->post_parent ) + break; + $my_parent = $my_parent->post_parent; + } + $num_parents = count( $my_parents ); + while ( $my_parent = array_pop( $my_parents ) ) { + echo "\t" . $this->single_row( $my_parent, $level - $num_parents ); + $num_parents--; + } + } + + if ( $count >= $start ) + echo "\t" . $this->single_row( $page, $level ); + + $count++; + + $this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page ); + } + + unset( $children_pages[$parent] ); //required in order to keep track of orphans + } + + function single_row( $a_post, $level = 0 ) { + global $post, $current_screen, $mode; + static $rowclass; + + $global_post = $post; + $post = $a_post; + setup_postdata( $post ); + + $rowclass = 'alternate' == $rowclass ? '' : 'alternate'; + $post_owner = ( get_current_user_id() == $post->post_author ? 'self' : 'other' ); + $edit_link = get_edit_post_link( $post->ID ); + $title = _draft_or_post_title(); + $post_type_object = get_post_type_object( $post->post_type ); + $can_edit_post = current_user_can( $post_type_object->cap->edit_post, $post->ID ); + $post_format = get_post_format( $post->ID ); + $post_format_class = ( $post_format && !is_wp_error($post_format) ) ? 'format-' . sanitize_html_class( $post_format ) : 'format-default'; + ?> + post_status . ' ' . $post_format_class); ?> iedit' valign="top"> + get_column_info(); + + foreach ( $columns as $column_name => $column_display_name ) { + $class = "class=\"$column_name column-$column_name\""; + + $style = ''; + if ( in_array( $column_name, $hidden ) ) + $style = ' style="display:none;"'; + + $attributes = "$class$style"; + + switch ( $column_name ) { + + case 'cb': + ?> + + hierarchical_display ) { + $attributes = 'class="post-title page-title column-title"' . $style; + + if ( 0 == $level && (int) $post->post_parent > 0 ) { + //sent level 0 by accident, by default, or because we don't know the actual level + $find_main_page = (int) $post->post_parent; + while ( $find_main_page > 0 ) { + $parent = get_page( $find_main_page ); + + if ( is_null( $parent ) ) + break; + + $level++; + $find_main_page = (int) $parent->post_parent; + + if ( !isset( $parent_name ) ) + $parent_name = apply_filters( 'the_title', $parent->post_title, $parent->ID ); + } + } + + $post->post_title = esc_html( $post->post_title ); + $pad = str_repeat( '— ', $level ); +?> + '; + break; + + case 'date': + if ( '0000-00-00 00:00:00' == $post->post_date && 'date' == $column_name ) { + $t_time = $h_time = __( 'Unpublished' ); + $time_diff = 0; + } else { + $t_time = get_the_time( __( 'Y/m/d g:i:s A' ) ); + $m_time = $post->post_date; + $time = get_post_time( 'G', true, $post ); + + $time_diff = time() - $time; + + if ( $time_diff > 0 && $time_diff < 24*60*60 ) + $h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) ); + else + $h_time = mysql2date( __( 'Y/m/d' ), $m_time ); + } + + echo ''; + break; + + case 'categories': + ?> + + + + + + + + + + + + post_type ); + $post_type_object = get_post_type_object( $screen->post_type ); + + $taxonomy_names = get_object_taxonomies( $screen->post_type ); + $hierarchical_taxonomies = array(); + $flat_taxonomies = array(); + foreach ( $taxonomy_names as $taxonomy_name ) { + $taxonomy = get_taxonomy( $taxonomy_name ); + + if ( !$taxonomy->show_ui ) + continue; + + if ( $taxonomy->hierarchical ) + $hierarchical_taxonomies[] = $taxonomy; + else + $flat_taxonomies[] = $taxonomy; + } + + $m = ( isset( $mode ) && 'excerpt' == $mode ) ? 'excerpt' : 'list'; + $can_publish = current_user_can( $post_type_object->cap->publish_posts ); + $core_columns = array( 'cb' => true, 'date' => true, 'title' => true, 'categories' => true, 'tags' => true, 'comments' => true, 'author' => true ); + + ?> + +
      '; + $this->no_items(); + echo '
      '; + echo $this->column_cb( $item ); + echo '"; + echo call_user_func( array( &$this, 'column_' . $column_name ), $item ); + echo ""; + echo $this->column_default( $item, $column_name ); + echo "
      ID ) ) { ?>>ID, array( 80, 60 ), true ) ) { + if ( $this->is_trash ) { + echo $thumb; + } else { +?> + + + + + + >is_trash ) echo $att_title; else { ?> +

      +ID ), $matches ) ) + echo esc_html( strtoupper( $matches[1] ) ); + else + echo strtoupper( str_replace( 'image/', '', get_post_mime_type() ) ); +?> +

      +row_actions( $this->_get_row_actions( $post, $att_title ) ); +?> +
      >>slug'> " . esc_html( sanitize_term_field( 'name', $c->name, $c->term_id, 'post_tag', 'display' ) ) . ""; + echo join( ', ', $out ); + } else { + _e( 'No Tags' ); + } +?> + >post_excerpt : ''; ?>>> + , + + >
      +
      > +
      +ID ); + + $this->comments_bubble( $post->ID, $pending_comments ); +?> +
      +
      > + +
      + + + +
      $checkbox$theme_name"; + echo $this->row_actions( $actions, true ); + echo " +
      $description
      +
      "; + + $theme_meta = array(); + + if ( !empty( $theme['Version'] ) ) + $theme_meta[] = sprintf( __( 'Version %s' ), $theme['Version'] ); + + if ( !empty( $theme['Author'] ) ) + $theme_meta[] = sprintf( __( 'By %s' ), $theme['Author'] ); + + if ( !empty( $theme['Theme URI'] ) ) + $theme_meta[] = '' . __( 'Visit Theme Site' ) . ''; + + $theme_meta = apply_filters( 'theme_row_meta', $theme_meta, $theme_key, $theme, $status ); + echo implode( ' | ', $theme_meta ); + + echo "
      "; + do_action( 'manage_themes_custom_column', $column_name, $theme_key, $theme ); + echo "
      + + "; ?> + user_login ); ?>user_login, $super_admins ) ) + echo ' - ' . __( 'Super Admin' ); + ?> +
      + ' . __( 'Edit' ) . ''; + + if ( current_user_can( 'delete_user', $user->ID) && ! in_array( $user->user_login, $super_admins ) ) { + $actions['delete'] = '' . __( 'Delete' ) . ''; + } + + echo $this->row_actions( $actions ); + ?> +
      $user->user_email" . mysql2date( $date, $user->user_registered ) . ""; + if ( is_array( $blogs ) ) { + foreach ( (array) $blogs as $key => $val ) { + if ( !can_edit_network( $val->site_id ) ) + continue; + + $path = ( $val->path == '/' ) ? '' : $val->path; + echo ''; + echo '' . str_replace( '.' . $current_site->domain, '', $val->domain . $path ) . ''; + echo ' '; + $actions = array(); + $actions['edit'] = '' . __( 'Edit' ) . ''; + + $class = ''; + if ( get_blog_status( $val->userblog_id, 'spam' ) == 1 ) + $class .= 'site-spammed '; + if ( get_blog_status( $val->userblog_id, 'mature' ) == 1 ) + $class .= 'site-mature '; + if ( get_blog_status( $val->userblog_id, 'deleted' ) == 1 ) + $class .= 'site-deleted '; + if ( get_blog_status( $val->userblog_id, 'archived' ) == 1 ) + $class .= 'site-archived '; + + $actions['view'] = '' . __( 'View' ) . ''; + + $actions = apply_filters('ms_user_list_site_actions', $actions, $val->userblog_id); + + $i=0; + $action_count = count( $actions ); + foreach ( $actions as $action => $link ) { + ++$i; + ( $i == $action_count ) ? $sep = '' : $sep = ' | '; + echo "$link$sep"; + } + echo '
      '; + } + } + ?> +
      > + + >> +
      +
      +
      <?php _e( '5 stars' ) ?>
      +
      <?php _e( '4 stars' ) ?>
      +
      <?php _e( '3 stars' ) ?>
      +
      <?php _e( '2 stars' ) ?>
      +
      <?php _e( '1 star' ) ?>
      +
      +
      >
      $checkbox$plugin_name"; + echo $this->row_actions( $actions, true ); + echo " +
      $description
      +
      "; + + $plugin_meta = array(); + if ( !empty( $plugin_data['Version'] ) ) + $plugin_meta[] = sprintf( __( 'Version %s' ), $plugin_data['Version'] ); + if ( !empty( $plugin_data['Author'] ) ) { + $author = $plugin_data['Author']; + if ( !empty( $plugin_data['AuthorURI'] ) ) + $author = '' . $plugin_data['Author'] . ''; + $plugin_meta[] = sprintf( __( 'By %s' ), $author ); + } + if ( ! empty( $plugin_data['PluginURI'] ) ) + $plugin_meta[] = '' . __( 'Visit plugin site' ) . ''; + + $plugin_meta = apply_filters( 'plugin_row_meta', $plugin_meta, $plugin_file, $plugin_data, $status ); + echo implode( ' | ', $plugin_meta ); + + echo "
      "; + do_action( 'manage_plugins_custom_column', $column_name, $plugin_file, $plugin_data ); + echo "
      >post_status != 'trash' ) { ?>labels->parent_item_colon . ' ' . esc_html( $parent_name ) : ''; ?> + + >post_status != 'trash' ) { ?> +post_status ) { + $actions['edit'] = '' . __( 'Edit' ) . ''; + $actions['inline hide-if-no-js'] = '' . __( 'Quick Edit' ) . ''; + } + if ( current_user_can( $post_type_object->cap->delete_post, $post->ID ) ) { + if ( 'trash' == $post->post_status ) + $actions['untrash'] = "ID ) ), 'untrash-' . $post->post_type . '_' . $post->ID ) . "'>" . __( 'Restore' ) . ""; + elseif ( EMPTY_TRASH_DAYS ) + $actions['trash'] = "" . __( 'Trash' ) . ""; + if ( 'trash' == $post->post_status || !EMPTY_TRASH_DAYS ) + $actions['delete'] = "" . __( 'Delete Permanently' ) . ""; + } + if ( in_array( $post->post_status, array( 'pending', 'draft' ) ) ) { + if ( $can_edit_post ) + $actions['view'] = '' . __( 'Preview' ) . ''; + } elseif ( 'trash' != $post->post_status ) { + $actions['view'] = '' . __( 'View' ) . ''; + } + + $actions = apply_filters( is_post_type_hierarchical( $post->post_type ) ? 'page_row_actions' : 'post_row_actions', $actions, $post ); + echo $this->row_actions( $actions ); + + get_inline_data( $post ); + echo ''; + if ( 'excerpt' == $mode ) + echo apply_filters( 'post_date_column_time', $t_time, $post, $column_name, $mode ); + else + echo '' . apply_filters( 'post_date_column_time', $h_time, $post, $column_name, $mode ) . ''; + echo '
      '; + if ( 'publish' == $post->post_status ) { + _e( 'Published' ); + } elseif ( 'future' == $post->post_status ) { + if ( $time_diff > 0 ) + echo '' . __( 'Missed schedule' ) . ''; + else + _e( 'Scheduled' ); + } else { + _e( 'Last Modified' ); + } + echo '
      >%s', + esc_url( add_query_arg( array( 'post_type' => $post->post_type, 'category_name' => $c->slug ), 'edit.php' ) ), + esc_html( sanitize_term_field( 'name', $c->name, $c->term_id, 'category', 'display' ) ) + ); + } + echo join( ', ', $out ); + } else { + _e( 'Uncategorized' ); + } + ?>>ID ); + if ( !empty( $tags ) ) { + $out = array(); + foreach ( $tags as $c ) { + $out[] = sprintf( '%s', + esc_url( add_query_arg( array( 'post_type' => $post->post_type, 'tag' => $c->slug ), 'edit.php' ) ), + esc_html( sanitize_term_field( 'name', $c->name, $c->term_id, 'tag', 'display' ) ) + ); + } + echo join( ', ', $out ); + } else { + _e( 'No Tags' ); + } + ?>>
      + comment_pending_count[$post->ID] ) ? $this->comment_pending_count[$post->ID] : 0; + + $this->comments_bubble( $post->ID, $pending_comments ); + ?> +
      >%s', + esc_url( add_query_arg( array( 'post_type' => $post->post_type, 'author' => get_the_author_meta( 'ID' ) ), 'edit.php' )), + get_the_author() + ); + ?>>post_type ) ) + do_action( 'manage_pages_custom_column', $column_name, $post->ID ); + else + do_action( 'manage_posts_custom_column', $column_name, $post->ID ); + do_action( "manage_{$post->post_type}_posts_custom_column", $column_name, $post->ID ); + ?>
      + + + post_type "; + echo $bulk ? "bulk-edit-row bulk-edit-row-$hclass bulk-edit-$screen->post_type" : "quick-edit-row quick-edit-row-$hclass inline-edit-$screen->post_type"; + ?>" style="display: none"> + +
      + +
      +

      + post_type, 'title' ) ) : + if ( $bulk ) : ?> +
      +
      +
      + + + + + + + + + + + +
      + +
      +
      + post_type, 'author' ) ) : + $authors_dropdown = ''; + + if ( is_super_admin() || current_user_can( $post_type_object->cap->edit_others_posts ) ) : + $users_opt = array( + 'hide_if_only_one_author' => false, + 'who' => 'authors', + 'name' => 'post_author', + 'class'=> 'authors', + 'multi' => 1, + 'echo' => 0 + ); + if ( $bulk ) + $users_opt['show_option_none'] = __( '— No Change —' ); + + if ( $authors = wp_dropdown_users( $users_opt ) ) : + $authors_dropdown = ''; + endif; + endif; // authors + ?> + + + +
      + + + + + + +
      + + + +
      + + + +
      + + + + labels->name ) ?> + + + + +
        + $taxonomy->name ) ) ?> +
      + + + +
      + + + +
      + + post_type, 'author' ) && $bulk ) + echo $authors_dropdown; + ?> + + hierarchical ) : ?> + + + + post_type, 'page-attributes' ) ) : + if ( !$bulk ) : ?> + + + + + + + + hierarchical ?> + + + + + + + + + + + + post_type, 'comments' ) || post_type_supports( $screen->post_type, 'trackbacks' ) ) : + if ( $bulk ) : ?> + +
      + post_type, 'comments' ) ) : ?> + + post_type, 'trackbacks' ) ) : ?> + + +
      + + + +
      + post_type, 'comments' ) ) : ?> + + post_type, 'trackbacks' ) ) : ?> + + +
      + + + +
      + + + post_type && $can_publish && current_user_can( $post_type_object->cap->edit_others_posts ) ) : ?> + + + + + + + + + + + + + +
      + +
      + + get_column_info(); + + foreach ( $columns as $column_name => $column_display_name ) { + if ( isset( $core_columns[$column_name] ) ) + continue; + do_action( $bulk ? 'bulk_edit_custom_box' : 'quick_edit_custom_box', $column_name, $screen->post_type ); + } + ?> +

      + + + + + 's' ) ); + } ?> + + +
      +

      +
      + diff --git a/wp-admin/includes/class-wp-terms-list-table.php b/wp-admin/includes/class-wp-terms-list-table.php new file mode 100644 index 00000000..ac4d963c --- /dev/null +++ b/wp-admin/includes/class-wp-terms-list-table.php @@ -0,0 +1,379 @@ + true ) ) ) ) + $post_type = 'post'; + + parent::WP_List_Table( array( + 'plural' => 'tags', + 'singular' => 'tag', + ) ); + } + + function ajax_user_can() { + global $tax; + + return current_user_can( $tax->cap->manage_terms ); + } + + function prepare_items() { + global $taxonomy; + + $tags_per_page = $this->get_items_per_page( 'edit_' . $taxonomy . '_per_page' ); + + if ( 'post_tag' == $taxonomy ) { + $tags_per_page = apply_filters( 'edit_tags_per_page', $tags_per_page ); + $tags_per_page = apply_filters( 'tagsperpage', $tags_per_page ); // Old filter + } elseif ( 'category' == $taxonomy ) { + $tags_per_page = apply_filters( 'edit_categories_per_page', $tags_per_page ); // Old filter + } + + $search = !empty( $_REQUEST['s'] ) ? trim( stripslashes( $_REQUEST['s'] ) ) : ''; + + $args = array( + 'search' => $search, + 'page' => $this->get_pagenum(), + 'number' => $tags_per_page, + ); + + if ( !empty( $_REQUEST['orderby'] ) ) + $args['orderby'] = trim( stripslashes( $_REQUEST['orderby'] ) ); + + if ( !empty( $_REQUEST['order'] ) ) + $args['order'] = trim( stripslashes( $_REQUEST['order'] ) ); + + $this->callback_args = $args; + + $this->set_pagination_args( array( + 'total_items' => wp_count_terms( $taxonomy, compact( 'search' ) ), + 'per_page' => $tags_per_page, + ) ); + } + + function has_items() { + // todo: populate $this->items in prepare_items() + return true; + } + + function get_bulk_actions() { + $actions = array(); + $actions['delete'] = __( 'Delete' ); + + return $actions; + } + + function current_action() { + if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['delete_tags'] ) && ( 'delete' == $_REQUEST['action'] || 'delete' == $_REQUEST['action2'] ) ) + return 'bulk-delete'; + + return parent::current_action(); + } + + function get_columns() { + global $taxonomy, $typenow; + + $columns = array( + 'cb' => '', + 'name' => __( 'Name' ), + 'description' => __( 'Description' ), + 'slug' => __( 'Slug' ), + ); + + if ( 'link_category' == $taxonomy ) { + $columns['links'] = __( 'Links' ); + } else { + $post_type = empty( $typenow ) ? 'post' : $typenow; + $post_type_object = get_post_type_object( $post_type ); + $columns['posts'] = $post_type_object ? $post_type_object->labels->name : __( 'Posts' ); + } + + return $columns; + } + + function get_sortable_columns() { + return array( + 'name' => 'name', + 'description' => 'description', + 'slug' => 'slug', + 'posts' => 'count', + 'links' => 'count' + ); + } + + function display_rows_or_placeholder() { + global $taxonomy; + + $args = wp_parse_args( $this->callback_args, array( + 'page' => 1, + 'number' => 20, + 'search' => '', + 'hide_empty' => 0 + ) ); + + extract( $args, EXTR_SKIP ); + + $args['offset'] = $offset = ( $page - 1 ) * $number; + + // convert it to table rows + $out = ''; + $count = 0; + + $terms = array(); + + if ( is_taxonomy_hierarchical( $taxonomy ) && !isset( $orderby ) ) { + // We'll need the full set of terms then. + $args['number'] = $args['offset'] = 0; + + $terms = get_terms( $taxonomy, $args ); + if ( !empty( $search ) ) // Ignore children on searches. + $children = array(); + else + $children = _get_term_hierarchy( $taxonomy ); + + // Some funky recursion to get the job done( Paging & parents mainly ) is contained within, Skip it for non-hierarchical taxonomies for performance sake + $out .= $this->_rows( $taxonomy, $terms, $children, $offset, $number, $count ); + } else { + $terms = get_terms( $taxonomy, $args ); + foreach ( $terms as $term ) + $out .= $this->single_row( $term, 0, $taxonomy ); + $count = $number; // Only displaying a single page. + } + + if ( empty( $terms ) ) { + list( $columns, $hidden ) = $this->get_column_info(); + echo ''; + $this->no_items(); + echo ''; + } else { + echo $out; + } + } + + function _rows( $taxonomy, $terms, &$children, $start = 0, $per_page = 20, &$count, $parent = 0, $level = 0 ) { + + $end = $start + $per_page; + + $output = ''; + foreach ( $terms as $key => $term ) { + + if ( $count >= $end ) + break; + + if ( $term->parent != $parent && empty( $_REQUEST['s'] ) ) + continue; + + // If the page starts in a subtree, print the parents. + if ( $count == $start && $term->parent > 0 && empty( $_REQUEST['s'] ) ) { + $my_parents = $parent_ids = array(); + $p = $term->parent; + while ( $p ) { + $my_parent = get_term( $p, $taxonomy ); + $my_parents[] = $my_parent; + $p = $my_parent->parent; + if ( in_array( $p, $parent_ids ) ) // Prevent parent loops. + break; + $parent_ids[] = $p; + } + unset( $parent_ids ); + + $num_parents = count( $my_parents ); + while ( $my_parent = array_pop( $my_parents ) ) { + $output .= "\t" . $this->single_row( $my_parent, $level - $num_parents, $taxonomy ); + $num_parents--; + } + } + + if ( $count >= $start ) + $output .= "\t" . $this->single_row( $term, $level, $taxonomy ); + + ++$count; + + unset( $terms[$key] ); + + if ( isset( $children[$term->term_id] ) && empty( $_REQUEST['s'] ) ) + $output .= $this->_rows( $taxonomy, $terms, $children, $start, $per_page, $count, $term->term_id, $level + 1 ); + } + + return $output; + } + + function single_row( $tag, $level = 0 ) { + static $row_class = ''; + $row_class = ( $row_class == '' ? ' class="alternate"' : '' ); + + $this->level = $level; + + echo ''; + echo $this->single_row_columns( $tag ); + echo ''; + } + + function column_cb( $tag ) { + global $taxonomy, $tax; + + $default_term = get_option( 'default_' . $taxonomy ); + + if ( current_user_can( $tax->cap->delete_terms ) && $tag->term_id != $default_term ) + return ''; + else + return ' '; + } + + function column_name( $tag ) { + global $taxonomy, $tax, $post_type; + + $default_term = get_option( 'default_' . $taxonomy ); + + $pad = str_repeat( '— ', max( 0, $this->level ) ); + $name = apply_filters( 'term_name', $pad . ' ' . $tag->name, $tag ); + $qe_data = get_term( $tag->term_id, $taxonomy, OBJECT, 'edit' ); + $edit_link = get_edit_term_link( $tag->term_id, $taxonomy, $post_type ); + + $out = '' . $name . '
      '; + + $actions = array(); + if ( current_user_can( $tax->cap->edit_terms ) ) { + $actions['edit'] = '' . __( 'Edit' ) . ''; + $actions['inline hide-if-no-js'] = '' . __( 'Quick Edit' ) . ''; + } + if ( current_user_can( $tax->cap->delete_terms ) && $tag->term_id != $default_term ) + $actions['delete'] = "term_id ) . "'>" . __( 'Delete' ) . ""; + + $actions = apply_filters( 'tag_row_actions', $actions, $tag ); + $actions = apply_filters( "{$taxonomy}_row_actions", $actions, $tag ); + + $out .= $this->row_actions( $actions ); + $out .= ''; + + return $out; + } + + function column_description( $tag ) { + return $tag->description; + } + + function column_slug( $tag ) { + return apply_filters( 'editable_slug', $tag->slug ); + } + + function column_posts( $tag ) { + global $taxonomy, $post_type; + + $count = number_format_i18n( $tag->count ); + + $tax = get_taxonomy( $taxonomy ); + + if ( ! $tax->public ) + return $count; + + if ( $tax->query_var ) { + $args = array( $tax->query_var => $tag->slug ); + } else { + $args = array( 'taxonomy' => $tax->name, 'term' => $tag->slug ); + } + + $args['post_type'] = $post_type; + + return "$count"; + } + + function column_links( $tag ) { + $count = number_format_i18n( $tag->count ); + if ( $count ) + $count = "$count"; + return $count; + } + + function column_default( $tag, $column_name ) { + $screen = get_current_screen(); + + return apply_filters( "manage_{$screen->taxonomy}_custom_column", '', $column_name, $tag->term_id ); + } + + /** + * Outputs the hidden row displayed when inline editing + * + * @since 3.1.0 + */ + function inline_edit() { + global $tax; + + if ( ! current_user_can( $tax->cap->edit_terms ) ) + return; +?> + +
      + +
      + diff --git a/wp-admin/includes/class-wp-theme-install-list-table.php b/wp-admin/includes/class-wp-theme-install-list-table.php new file mode 100644 index 00000000..7e44267c --- /dev/null +++ b/wp-admin/includes/class-wp-theme-install-list-table.php @@ -0,0 +1,185 @@ +get_pagenum(); + + $per_page = 30; + + // These are the tabs which are shown on the page, + $tabs = array(); + $tabs['dashboard'] = __( 'Search' ); + if ( 'search' == $tab ) + $tabs['search'] = __( 'Search Results' ); + $tabs['upload'] = __( 'Upload' ); + $tabs['featured'] = _x( 'Featured','Theme Installer' ); + //$tabs['popular'] = _x( 'Popular','Theme Installer' ); + $tabs['new'] = _x( 'Newest','Theme Installer' ); + $tabs['updated'] = _x( 'Recently Updated','Theme Installer' ); + + $nonmenu_tabs = array( 'theme-information' ); // Valid actions to perform which do not have a Menu item. + + $tabs = apply_filters( 'install_themes_tabs', $tabs ); + $nonmenu_tabs = apply_filters( 'install_themes_nonmenu_tabs', $nonmenu_tabs ); + + // If a non-valid menu tab has been selected, And its not a non-menu action. + if ( empty( $tab ) || ( ! isset( $tabs[ $tab ] ) && ! in_array( $tab, (array) $nonmenu_tabs ) ) ) + $tab = key( $tabs ); + + $args = array( 'page' => $paged, 'per_page' => $per_page, 'fields' => $theme_field_defaults ); + + switch ( $tab ) { + case 'search': + $type = isset( $_REQUEST['type'] ) ? stripslashes( $_REQUEST['type'] ) : ''; + $term = isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : ''; + + switch ( $type ) { + case 'tag': + $terms = explode( ',', $term ); + $terms = array_map( 'trim', $terms ); + $terms = array_map( 'sanitize_title_with_dashes', $terms ); + $args['tag'] = $terms; + break; + case 'term': + $args['search'] = $term; + break; + case 'author': + $args['author'] = $term; + break; + } + + if ( !empty( $_POST['features'] ) ) { + $terms = $_POST['features']; + $terms = array_map( 'trim', $terms ); + $terms = array_map( 'sanitize_title_with_dashes', $terms ); + $args['tag'] = $terms; + $_REQUEST['s'] = implode( ',', $terms ); + $_REQUEST['type'] = 'tag'; + } + + add_action( 'install_themes_table_header', 'install_theme_search_form' ); + break; + + case 'featured': + //case 'popular': + case 'new': + case 'updated': + $args['browse'] = $tab; + break; + + default: + $args = false; + } + + if ( !$args ) + return; + + $api = themes_api( 'query_themes', $args ); + + if ( is_wp_error( $api ) ) + wp_die( $api->get_error_message() . '

      ' . __( 'Try again' ) . '' ); + + $this->items = $api->themes; + + $this->set_pagination_args( array( + 'total_items' => $api->info['results'], + 'per_page' => $per_page, + ) ); + } + + function no_items() { + _e( 'No themes match your request.' ); + } + + function get_views() { + global $tabs, $tab; + + $display_tabs = array(); + foreach ( (array) $tabs as $action => $text ) { + $class = ( $action == $tab ) ? ' class="current"' : ''; + $href = self_admin_url('theme-install.php?tab=' . $action); + $display_tabs['theme-install-'.$action] = "$text"; + } + + return $display_tabs; + } + + function get_columns() { + return array(); + } + + function display() { + + // wp_nonce_field( "fetch-list-" . get_class( $this ), '_ajax_fetch_list_nonce' ); +?> +

      +
      + +
      + pagination( 'top' ); ?> + +
      +
      + + + + display_rows_or_placeholder(); ?> + +
      + +
      + pagination( 'bottom' ); ?> + +
      +
      +items; + + $rows = ceil( count( $themes ) / 3 ); + $table = array(); + $theme_keys = array_keys( $themes ); + for ( $row = 1; $row <= $rows; $row++ ) + for ( $col = 1; $col <= 3; $col++ ) + $table[$row][$col] = array_shift( $theme_keys ); + + foreach ( $table as $row => $cols ) { + echo "\t\n"; + foreach ( $cols as $col => $theme_index ) { + $class = array( 'available-theme' ); + if ( $row == 1 ) $class[] = 'top'; + if ( $col == 1 ) $class[] = 'left'; + if ( $row == $rows ) $class[] = 'bottom'; + if ( $col == 3 ) $class[] = 'right'; + ?> + + \n"; + } // end foreach $table + } +} + +?> diff --git a/wp-admin/includes/class-wp-themes-list-table.php b/wp-admin/includes/class-wp-themes-list-table.php new file mode 100644 index 00000000..91e1d254 --- /dev/null +++ b/wp-admin/includes/class-wp-themes-list-table.php @@ -0,0 +1,241 @@ +search = array_merge( $this->search, array_filter( array_map( 'trim', explode( ',', $search ) ) ) ); + $this->search = array_unique( $this->search ); + } + + if ( !empty( $_REQUEST['features'] ) ) { + $this->features = $_REQUEST['features']; + $this->features = array_map( 'trim', $this->features ); + $this->features = array_map( 'sanitize_title_with_dashes', $this->features ); + $this->features = array_unique( $this->features ); + } + + if ( $this->search || $this->features ) { + foreach ( $themes as $key => $theme ) { + if ( !$this->search_theme( $theme ) ) + unset( $themes[ $key ] ); + } + } + + unset( $themes[$ct->name] ); + uksort( $themes, "strnatcasecmp" ); + + $per_page = 15; + $page = $this->get_pagenum(); + + $start = ( $page - 1 ) * $per_page; + + $this->items = array_slice( $themes, $start, $per_page ); + + $this->set_pagination_args( array( + 'total_items' => count( $themes ), + 'per_page' => $per_page, + ) ); + } + + function no_items() { + if ( $this->search || $this->features ) { + _e( 'No items found.' ); + return; + } + + if ( is_multisite() ) { + if ( current_user_can( 'install_themes' ) && current_user_can( 'manage_network_themes' ) ) { + printf( __( 'You only have one theme enabled for this site right now. Visit the Network Admin to enable or install more themes.' ), network_admin_url( 'site-themes.php?id=' . $GLOBALS['blog_id'] ), network_admin_url( 'theme-install.php' ) ); + + return; + } elseif ( current_user_can( 'manage_network_themes' ) ) { + printf( __( 'You only have one theme enabled for this site right now. Visit the Network Admin to enable more themes.' ), network_admin_url( 'site-themes.php?id=' . $GLOBALS['blog_id'] ) ); + + return; + } + // else, fallthrough. install_themes doesn't help if you can't enable it. + } else { + if ( current_user_can( 'install_themes' ) ) { + printf( __( 'You only have one theme installed right now. Live a little! You can choose from over 1,000 free themes in the WordPress.org Theme Directory at any time: just click on the Install Themes tab above.' ), admin_url( 'theme-install.php' ) ); + + return; + } + } + // Fallthrough. + printf( __( 'Only the current theme is available to you. Contact the %s administrator for information about accessing additional themes.' ), get_site_option( 'site_name' ) ); + } + + function tablenav( $which = 'top' ) { + if ( $this->get_pagination_arg( 'total_pages' ) <= 1 ) + return; + ?> +
      + pagination( $which ); ?> + +
      +
      + + tablenav( 'top' ); ?> + + + + display_rows_or_placeholder(); ?> + +
      + + tablenav( 'bottom' ); ?> +items; + $theme_names = array_keys( $themes ); + natcasesort( $theme_names ); + + $table = array(); + $rows = ceil( count( $theme_names ) / 3 ); + for ( $row = 1; $row <= $rows; $row++ ) + for ( $col = 1; $col <= 3; $col++ ) + $table[$row][$col] = array_shift( $theme_names ); + + foreach ( $table as $row => $cols ) { +?> + + $theme_name ) { + $class = array( 'available-theme' ); + if ( $row == 1 ) $class[] = 'top'; + if ( $col == 1 ) $class[] = 'left'; + if ( $row == $rows ) $class[] = 'bottom'; + if ( $col == 3 ) $class[] = 'right'; +?> + + 1, 'template' => $template, 'stylesheet' => $stylesheet, 'preview_iframe' => true, 'TB_iframe' => 'true' ), $preview_link ) ); + $preview_text = esc_attr( sprintf( __( 'Preview of “%s”' ), $title ) ); + $tags = $themes[$theme_name]['Tags']; + $thickbox_class = 'thickbox thickbox-preview'; + $activate_link = wp_nonce_url( "themes.php?action=activate&template=".urlencode( $template )."&stylesheet=".urlencode( $stylesheet ), 'switch-theme_' . $template ); + $activate_text = esc_attr( sprintf( __( 'Activate “%s”' ), $title ) ); + $actions = array(); + $actions[] = '' . __( 'Activate' ) . ''; + $actions[] = '' . __( 'Preview' ) . ''; + if ( ! is_multisite() && current_user_can( 'delete_themes' ) ) + $actions[] = '' . __( 'Delete' ) . ''; + $actions = apply_filters( 'theme_action_links', $actions, $themes[$theme_name] ); + + $actions = implode ( ' | ', $actions ); +?> + + + + + +

      +

      + + +

      %2$s. The stylesheet files are located in %3$s. %4$s uses templates from %5$s. Changes made to the templates will affect both themes.' ), $title, str_replace( WP_CONTENT_DIR, '', $template_dir ), str_replace( WP_CONTENT_DIR, '', $stylesheet_dir ), $title, $parent_theme ); ?>

      + +

      %2$s.' ), $title, str_replace( WP_CONTENT_DIR, '', $template_dir ), str_replace( WP_CONTENT_DIR, '', $stylesheet_dir ) ); ?>

      + + +

      + + + + + + +search ) > 0 ) { + foreach ( $this->search as $word ) { + $matched = 0; + + // In a tag? + if ( in_array( $word, array_map( 'sanitize_title_with_dashes', $theme['Tags'] ) ) ) + $matched = 1; + + // In one of the fields? + foreach ( array( 'Name', 'Title', 'Description', 'Author', 'Template', 'Stylesheet' ) AS $field ) { + if ( stripos( $theme[$field], $word ) !== false ) + $matched++; + } + + if ( $matched == 0 ) + return false; + } + } + + // Now search the features + if ( count( $this->features ) > 0 ) { + foreach ( $this->features as $word ) { + // In a tag? + if ( !in_array( $word, array_map( 'sanitize_title_with_dashes', $theme['Tags'] ) ) ) + return false; + } + } + + // Only get here if each word exists in the tags or one of the fields + return true; + } +} + +?> diff --git a/wp-admin/includes/class-wp-upgrader.php b/wp-admin/includes/class-wp-upgrader.php index 28185fce..3b5ab902 100644 --- a/wp-admin/includes/class-wp-upgrader.php +++ b/wp-admin/includes/class-wp-upgrader.php @@ -368,14 +368,14 @@ class Plugin_Upgrader extends WP_Upgrader { function upgrade_strings() { $this->strings['up_to_date'] = __('The plugin is at the latest version.'); - $this->strings['no_package'] = __('Upgrade package not available.'); + $this->strings['no_package'] = __('Update package not available.'); $this->strings['downloading_package'] = __('Downloading update from %s…'); $this->strings['unpack_package'] = __('Unpacking the update…'); $this->strings['deactivate_plugin'] = __('Deactivating the plugin…'); $this->strings['remove_old'] = __('Removing the old version of the plugin…'); $this->strings['remove_old_failed'] = __('Could not remove the old plugin.'); - $this->strings['process_failed'] = __('Plugin upgrade failed.'); - $this->strings['process_success'] = __('Plugin upgraded successfully.'); + $this->strings['process_failed'] = __('Plugin update failed.'); + $this->strings['process_success'] = __('Plugin updated successfully.'); } function install_strings() { @@ -468,7 +468,12 @@ class Plugin_Upgrader extends WP_Upgrader { $this->skin->bulk_header(); - $this->maintenance_mode(true); + // Only start maintenance mode if running in Multisite OR the plugin is in use + $maintenance = is_multisite(); // @TODO: This should only kick in for individual sites if at all possible. + foreach ( $plugins as $plugin ) + $maintenance = $maintenance || (is_plugin_active($plugin) && isset($current->response[ $plugin ]) ); // Only activate Maintenance mode if a plugin is active AND has an update available + if ( $maintenance ) + $this->maintenance_mode(true); $results = array(); @@ -603,13 +608,13 @@ class Theme_Upgrader extends WP_Upgrader { function upgrade_strings() { $this->strings['up_to_date'] = __('The theme is at the latest version.'); - $this->strings['no_package'] = __('Upgrade package not available.'); + $this->strings['no_package'] = __('Update package not available.'); $this->strings['downloading_package'] = __('Downloading update from %s…'); $this->strings['unpack_package'] = __('Unpacking the update…'); $this->strings['remove_old'] = __('Removing the old version of the theme…'); $this->strings['remove_old_failed'] = __('Could not remove the old theme.'); - $this->strings['process_failed'] = __('Theme upgrade failed.'); - $this->strings['process_success'] = __('Theme upgraded successfully.'); + $this->strings['process_failed'] = __('Theme update failed.'); + $this->strings['process_success'] = __('Theme updated successfully.'); } function install_strings() { @@ -712,7 +717,12 @@ class Theme_Upgrader extends WP_Upgrader { $this->skin->bulk_header(); - $this->maintenance_mode(true); + // Only start maintenance mode if running in Multisite OR the theme is in use + $maintenance = is_multisite(); // @TODO: This should only kick in for individual sites if at all possible. + foreach ( $themes as $theme ) + $maintenance = $maintenance || $theme == get_stylesheet() || $theme == get_template(); + if ( $maintenance ) + $this->maintenance_mode(true); $results = array(); @@ -780,7 +790,7 @@ class Theme_Upgrader extends WP_Upgrader { if ( $theme != get_stylesheet() ) //If not current return $return; - //Change to maintainence mode now. + //Change to maintenance mode now. if ( ! $this->bulk ) $this->maintenance_mode(true); @@ -796,6 +806,7 @@ class Theme_Upgrader extends WP_Upgrader { return $return; //Ensure stylesheet name hasnt changed after the upgrade: + // @TODO: Note, This doesnt handle the Template changing, or the Template name changing. if ( $theme == get_stylesheet() && $theme != $this->result['destination_name'] ) { $theme_info = $this->theme_info(); $stylesheet = $this->result['destination_name']; @@ -803,7 +814,7 @@ class Theme_Upgrader extends WP_Upgrader { switch_theme($template, $stylesheet, true); } - //Time to remove maintainence mode + //Time to remove maintenance mode if ( ! $this->bulk ) $this->maintenance_mode(false); return $return; @@ -850,7 +861,7 @@ class Core_Upgrader extends WP_Upgrader { function upgrade_strings() { $this->strings['up_to_date'] = __('WordPress is at the latest version.'); - $this->strings['no_package'] = __('Upgrade package not available.'); + $this->strings['no_package'] = __('Update package not available.'); $this->strings['downloading_package'] = __('Downloading update from %s…'); $this->strings['unpack_package'] = __('Unpacking the update…'); $this->strings['copy_failed'] = __('Could not copy files.'); @@ -1006,7 +1017,7 @@ class Plugin_Upgrader_Skin extends WP_Upgrader_Skin { } function __construct($args = array()) { - $defaults = array( 'url' => '', 'plugin' => '', 'nonce' => '', 'title' => __('Upgrade Plugin') ); + $defaults = array( 'url' => '', 'plugin' => '', 'nonce' => '', 'title' => __('Update Plugin') ); $args = wp_parse_args($args, $defaults); $this->plugin = $args['plugin']; @@ -1026,7 +1037,7 @@ class Plugin_Upgrader_Skin extends WP_Upgrader_Skin { $update_actions = array( 'activate_plugin' => '' . __('Activate Plugin') . '', - 'plugins_page' => '' . __('Return to Plugins page') . '' + 'plugins_page' => '' . __('Return to Plugins page') . '' ); if ( $this->plugin_active ) unset( $update_actions['activate_plugin'] ); @@ -1035,7 +1046,7 @@ class Plugin_Upgrader_Skin extends WP_Upgrader_Skin { $update_actions = apply_filters('update_plugin_complete_actions', $update_actions, $this->plugin); if ( ! empty($update_actions) ) - $this->feedback('' . __('Actions:') . ' ' . implode(' | ', (array)$update_actions)); + $this->feedback(implode(' | ', (array)$update_actions)); } function before() { @@ -1069,8 +1080,8 @@ class Bulk_Upgrader_Skin extends WP_Upgrader_Skin { } function add_strings() { - $this->upgrader->strings['skin_upgrade_start'] = __('The update process is starting. This process may take awhile on some hosts, so please be patient.'); - $this->upgrader->strings['skin_update_failed_error'] = __('An error occured while updating %1$s: %2$s.'); + $this->upgrader->strings['skin_upgrade_start'] = __('The update process is starting. This process may take a while on some hosts, so please be patient.'); + $this->upgrader->strings['skin_update_failed_error'] = __('An error occurred while updating %1$s: %2$s.'); $this->upgrader->strings['skin_update_failed'] = __('The update of %1$s failed.'); $this->upgrader->strings['skin_update_successful'] = __('%1$s updated successfully.').' '.__('Show Details').'.'; $this->upgrader->strings['skin_upgrade_end'] = __('All updates have been completed.'); @@ -1184,13 +1195,13 @@ class Bulk_Plugin_Upgrader_Skin extends Bulk_Upgrader_Skin { function bulk_footer() { parent::bulk_footer(); $update_actions = array( - 'plugins_page' => '' . __('Return to Plugins page') . '', - 'updates_page' => '' . __('Return to WordPress Updates') . '' + 'plugins_page' => '' . __('Return to Plugins page') . '', + 'updates_page' => '' . __('Return to WordPress Updates') . '' ); $update_actions = apply_filters('update_bulk_plugins_complete_actions', $update_actions, $this->plugin_info); if ( ! empty($update_actions) ) - $this->feedback('' . __('Actions:') . ' ' . implode(' | ', (array)$update_actions)); + $this->feedback(implode(' | ', (array)$update_actions)); } } @@ -1215,13 +1226,13 @@ class Bulk_Theme_Upgrader_Skin extends Bulk_Upgrader_Skin { function bulk_footer() { parent::bulk_footer(); $update_actions = array( - 'themes_page' => '' . __('Return to Themes page') . '', - 'updates_page' => '' . __('Return to WordPress Updates') . '' + 'themes_page' => '' . __('Return to Themes page') . '', + 'updates_page' => '' . __('Return to WordPress Updates') . '' ); $update_actions = apply_filters('update_bulk_theme_complete_actions', $update_actions, $this->theme_info); if ( ! empty($update_actions) ) - $this->feedback('' . __('Actions:') . ' ' . implode(' | ', (array)$update_actions)); + $this->feedback(implode(' | ', (array)$update_actions)); } } @@ -1270,15 +1281,17 @@ class Plugin_Installer_Skin extends WP_Upgrader_Skin { else $install_actions['activate_plugin'] = '' . __('Activate Plugin') . ''; - if ( is_multisite() && current_user_can( 'manage_network_plugins' ) ) - $install_actions['network_activate'] = '' . __('Network Activate') . ''; + if ( is_multisite() && current_user_can( 'manage_network_plugins' ) ) { + $install_actions['network_activate'] = '' . __('Network Activate') . ''; + unset( $install_actions['activate_plugin'] ); + } if ( 'import' == $from ) $install_actions['importers_page'] = '' . __('Return to Importers') . ''; else if ( $this->type == 'web' ) - $install_actions['plugins_page'] = '' . __('Return to Plugin Installer') . ''; + $install_actions['plugins_page'] = '' . __('Return to Plugin Installer') . ''; else - $install_actions['plugins_page'] = '' . __('Return to Plugins page') . ''; + $install_actions['plugins_page'] = '' . __('Return to Plugins page') . ''; if ( ! $this->result || is_wp_error($this->result) ) { @@ -1287,7 +1300,7 @@ class Plugin_Installer_Skin extends WP_Upgrader_Skin { } $install_actions = apply_filters('install_plugin_complete_actions', $install_actions, $this->api, $plugin_file); if ( ! empty($install_actions) ) - $this->feedback('' . __('Actions:') . ' ' . implode(' | ', (array)$install_actions)); + $this->feedback(implode(' | ', (array)$install_actions)); } } @@ -1345,16 +1358,16 @@ class Theme_Installer_Skin extends WP_Upgrader_Skin { ); if ( $this->type == 'web' ) - $install_actions['themes_page'] = '' . __('Return to Theme Installer') . ''; + $install_actions['themes_page'] = '' . __('Return to Theme Installer') . ''; else - $install_actions['themes_page'] = '' . __('Return to Themes page') . ''; + $install_actions['themes_page'] = '' . __('Return to Themes page') . ''; - if ( ! $this->result || is_wp_error($this->result) ) + if ( ! $this->result || is_wp_error($this->result) || is_network_admin() ) unset( $install_actions['activate'], $install_actions['preview'] ); $install_actions = apply_filters('install_theme_complete_actions', $install_actions, $this->api, $stylesheet, $theme_info); if ( ! empty($install_actions) ) - $this->feedback('' . __('Actions:') . ' ' . implode(' | ', (array)$install_actions)); + $this->feedback(implode(' | ', (array)$install_actions)); } } @@ -1375,7 +1388,7 @@ class Theme_Upgrader_Skin extends WP_Upgrader_Skin { } function __construct($args = array()) { - $defaults = array( 'url' => '', 'theme' => '', 'nonce' => '', 'title' => __('Upgrade Theme') ); + $defaults = array( 'url' => '', 'theme' => '', 'nonce' => '', 'title' => __('Update Theme') ); $args = wp_parse_args($args, $defaults); $this->theme = $args['theme']; @@ -1404,11 +1417,11 @@ class Theme_Upgrader_Skin extends WP_Upgrader_Skin { unset($update_actions['preview'], $update_actions['activate']); } - $update_actions['themes_page'] = '' . __('Return to Themes page') . ''; + $update_actions['themes_page'] = '' . __('Return to Themes page') . ''; $update_actions = apply_filters('update_theme_complete_actions', $update_actions, $this->theme); if ( ! empty($update_actions) ) - $this->feedback('' . __('Actions:') . ' ' . implode(' | ', (array)$update_actions)); + $this->feedback(implode(' | ', (array)$update_actions)); } } @@ -1452,4 +1465,4 @@ class File_Upload_Upgrader { $this->package = $uploads['basedir'] . '/' . $this->filename; } } -} +} \ No newline at end of file diff --git a/wp-admin/includes/class-wp-users-list-table.php b/wp-admin/includes/class-wp-users-list-table.php new file mode 100644 index 00000000..d52d75f0 --- /dev/null +++ b/wp-admin/includes/class-wp-users-list-table.php @@ -0,0 +1,319 @@ +is_site_users = 'site-users-network' == $screen->id; + + if ( $this->is_site_users ) + $this->site_id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0; + + parent::WP_List_Table( array( + 'singular' => 'user', + 'plural' => 'users' + ) ); + } + + function ajax_user_can() { + if ( $this->is_site_users ) + return current_user_can( 'manage_sites' ); + else + return current_user_can( 'list_users' ); + } + + function prepare_items() { + global $role, $usersearch; + + $usersearch = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : ''; + + $role = isset( $_REQUEST['role'] ) ? $_REQUEST['role'] : ''; + + $per_page = ( $this->is_site_users ) ? 'site_users_network_per_page' : 'users_per_page'; + $users_per_page = $this->get_items_per_page( $per_page ); + + $paged = $this->get_pagenum(); + + $args = array( + 'number' => $users_per_page, + 'offset' => ( $paged-1 ) * $users_per_page, + 'role' => $role, + 'search' => $usersearch, + 'fields' => 'all_with_meta' + ); + + $args['search'] = '*' . $args['search'] . '*'; + + if ( $this->is_site_users ) + $args['blog_id'] = $this->site_id; + + if ( isset( $_REQUEST['orderby'] ) ) + $args['orderby'] = $_REQUEST['orderby']; + + if ( isset( $_REQUEST['order'] ) ) + $args['order'] = $_REQUEST['order']; + + // Query the user IDs for this page + $wp_user_search = new WP_User_Query( $args ); + + $this->items = $wp_user_search->get_results(); + + $this->set_pagination_args( array( + 'total_items' => $wp_user_search->get_total(), + 'per_page' => $users_per_page, + ) ); + } + + function no_items() { + _e( 'No matching users were found.' ); + } + + function get_views() { + global $wp_roles, $role; + + if ( $this->is_site_users ) { + $url = 'site-users.php?id=' . $this->site_id; + switch_to_blog( $this->site_id ); + $users_of_blog = count_users(); + restore_current_blog(); + } else { + $url = 'users.php'; + $users_of_blog = count_users(); + } + $total_users = $users_of_blog['total_users']; + $avail_roles =& $users_of_blog['avail_roles']; + unset($users_of_blog); + + $current_role = false; + $class = empty($role) ? ' class="current"' : ''; + $role_links = array(); + $role_links['all'] = "" . sprintf( _nx( 'All (%s)', 'All (%s)', $total_users, 'users' ), number_format_i18n( $total_users ) ) . ''; + foreach ( $wp_roles->get_names() as $this_role => $name ) { + if ( !isset($avail_roles[$this_role]) ) + continue; + + $class = ''; + + if ( $this_role == $role ) { + $current_role = $role; + $class = ' class="current"'; + } + + $name = translate_user_role( $name ); + /* translators: User role name with count */ + $name = sprintf( __('%1$s (%2$s)'), $name, $avail_roles[$this_role] ); + $role_links[$this_role] = "$name"; + } + + return $role_links; + } + + function get_bulk_actions() { + $actions = array(); + + if ( is_multisite() ) { + if ( current_user_can( 'remove_users' ) ) + $actions['remove'] = __( 'Remove' ); + } else { + if ( current_user_can( 'delete_users' ) ) + $actions['delete'] = __( 'Delete' ); + } + + return $actions; + } + + function extra_tablenav( $which ) { + if ( 'top' != $which ) + return; + if ( ! current_user_can( 'promote_users' ) ) + return; +?> +
      + + + +
      + '', + 'username' => __( 'Username' ), + 'name' => __( 'Name' ), + 'email' => __( 'E-mail' ), + 'role' => __( 'Role' ), + 'posts' => __( 'Posts' ) + ); + + if ( $this->is_site_users ) + unset( $c['posts'] ); + + return $c; + } + + function get_sortable_columns() { + $c = array( + 'username' => 'login', + 'name' => 'name', + 'email' => 'email', + ); + + if ( $this->is_site_users ) + unset( $c['posts'] ); + + return $c; + } + + function display_rows() { + // Query the post counts for this page + if ( ! $this->is_site_users ) + $post_counts = count_many_users_posts( array_keys( $this->items ) ); + + $style = ''; + foreach ( $this->items as $userid => $user_object ) { + $role = reset( $user_object->roles ); + + if ( is_multisite() && empty( $role ) ) + continue; + + $style = ( ' class="alternate"' == $style ) ? '' : ' class="alternate"'; + echo "\n\t", $this->single_row( $user_object, $style, $role, isset( $post_counts ) ? $post_counts[ $userid ] : 0 ); + } + } + + /** + * Generate HTML for a single row on the users.php admin panel. + * + * @since 2.1.0 + * + * @param object $user_object + * @param string $style Optional. Attributes added to the TR element. Must be sanitized. + * @param string $role Key for the $wp_roles array. + * @param int $numposts Optional. Post count to display for this user. Defaults to zero, as in, a new user has made zero posts. + * @return string + */ + function single_row( $user_object, $style = '', $role = '', $numposts = 0 ) { + global $wp_roles; + + if ( !( is_object( $user_object ) && is_a( $user_object, 'WP_User' ) ) ) + $user_object = new WP_User( (int) $user_object ); + $user_object = sanitize_user_object( $user_object, 'display' ); + $email = $user_object->user_email; + + if ( $this->is_site_users ) + $url = "site-users.php?id={$this->site_id}&"; + else + $url = 'users.php?'; + + $checkbox = ''; + // Check if the user for this row is editable + if ( current_user_can( 'list_users' ) ) { + // Set up the user editing link + // TODO: make profile/user-edit determination a separate function + if ( get_current_user_id() == $user_object->ID ) { + $edit_link = 'profile.php'; + } else { + $edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( stripslashes( $_SERVER['REQUEST_URI'] ) ), "user-edit.php?user_id=$user_object->ID" ) ); + } + + // Set up the hover actions for this user + $actions = array(); + + if ( current_user_can( 'edit_user', $user_object->ID ) ) { + $edit = "$user_object->user_login
      "; + $actions['edit'] = '' . __( 'Edit' ) . ''; + } else { + $edit = "$user_object->user_login
      "; + } + + if ( !is_multisite() && get_current_user_id() != $user_object->ID && current_user_can( 'delete_user', $user_object->ID ) ) + $actions['delete'] = "" . __( 'Delete' ) . ""; + if ( is_multisite() && get_current_user_id() != $user_object->ID && current_user_can( 'remove_user', $user_object->ID ) ) + $actions['remove'] = "" . __( 'Remove' ) . ""; + $actions = apply_filters( 'user_row_actions', $actions, $user_object ); + $edit .= $this->row_actions( $actions ); + + // Set up the checkbox ( because the user is editable, otherwise its empty ) + $checkbox = ""; + + } else { + $edit = '' . $user_object->user_login . ''; + } + $role_name = isset( $wp_roles->role_names[$role] ) ? translate_user_role( $wp_roles->role_names[$role] ) : __( 'None' ); + $avatar = get_avatar( $user_object->ID, 32 ); + + $r = ""; + + list( $columns, $hidden ) = $this->get_column_info(); + + foreach ( $columns as $column_name => $column_display_name ) { + $class = "class=\"$column_name column-$column_name\""; + + $style = ''; + if ( in_array( $column_name, $hidden ) ) + $style = ' style="display:none;"'; + + $attributes = "$class$style"; + + switch ( $column_name ) { + case 'cb': + $r .= "$checkbox"; + break; + case 'username': + $r .= "$avatar $edit"; + break; + case 'name': + $r .= "$user_object->first_name $user_object->last_name"; + break; + case 'email': + $r .= "$email"; + break; + case 'role': + $r .= "$role_name"; + break; + case 'posts': + $attributes = 'class="posts column-posts num"' . $style; + $r .= ""; + if ( $numposts > 0 ) { + $r .= ""; + $r .= $numposts; + $r .= ''; + } else { + $r .= 0; + } + $r .= ""; + break; + default: + $r .= ""; + $r .= apply_filters( 'manage_users_custom_column', '', $column_name, $user_object->ID ); + $r .= ""; + } + } + $r .= ''; + + return $r; + } +} + +?> diff --git a/wp-admin/includes/comment.php b/wp-admin/includes/comment.php index 185251a0..d731130a 100644 --- a/wp-admin/includes/comment.php +++ b/wp-admin/includes/comment.php @@ -9,11 +9,11 @@ /** * {@internal Missing Short Description}} * - * @since unknown + * @since 2.0.0 * @uses $wpdb * - * @param string $comment_author - * @param string $comment_date + * @param string $comment_author Author of the comment + * @param string $comment_date Date of the comment * @return mixed Comment ID on success. */ function comment_exists($comment_author, $comment_date) { @@ -27,16 +27,14 @@ function comment_exists($comment_author, $comment_date) { } /** - * {@internal Missing Short Description}} + * Update a comment with values provided in $_POST. * - * @since unknown + * @since 2.0.0 */ function edit_comment() { - $comment_post_ID = (int) $_POST['comment_post_ID']; - - if (!current_user_can( 'edit_post', $comment_post_ID )) - wp_die( __('You are not allowed to edit comments on this post, so you cannot edit this comment.' )); + if ( ! current_user_can( 'edit_comment', (int) $_POST['comment_ID'] ) ) + wp_die ( __( 'You are not allowed to edit comments on this post.' ) ); $_POST['comment_author'] = $_POST['newcomment_author']; $_POST['comment_author_email'] = $_POST['newcomment_author_email']; @@ -52,7 +50,7 @@ function edit_comment() { } } - if (!empty ( $_POST['edit_date'] ) ) { + if ( !empty ( $_POST['edit_date'] ) ) { $aa = $_POST['aa']; $mm = $_POST['mm']; $jj = $_POST['jj']; @@ -66,16 +64,16 @@ function edit_comment() { $_POST['comment_date'] = "$aa-$mm-$jj $hh:$mn:$ss"; } - wp_update_comment( $_POST); + wp_update_comment( $_POST ); } /** * {@internal Missing Short Description}} * - * @since unknown + * @since 2.0.0 * - * @param unknown_type $id - * @return unknown + * @param int $id ID of comment to retrieve + * @return bool|object Comment if found. False on failure. */ function get_comment_to_edit( $id ) { if ( !$comment = get_comment($id) ) @@ -98,7 +96,7 @@ function get_comment_to_edit( $id ) { /** * Get the number of pending comments on a post or posts * - * @since unknown + * @since 2.3.0 * @uses $wpdb * * @param int|array $post_id Either a single Post ID or an array of Post IDs @@ -158,10 +156,4 @@ function enqueue_comment_hotkeys_js() { if ( 'true' == get_user_option( 'comment_shortcuts' ) ) wp_enqueue_script( 'jquery-table-hotkeys' ); } - -if ( is_admin() && isset($pagenow) && ('edit-comments.php' == $pagenow || 'edit.php' == $pagenow) ) { - if ( get_option('show_avatars') ) - add_filter( 'comment_author', 'floated_admin_avatar' ); -} - ?> diff --git a/wp-admin/includes/dashboard.php b/wp-admin/includes/dashboard.php index 8486581b..8f937f36 100644 --- a/wp-admin/includes/dashboard.php +++ b/wp-admin/includes/dashboard.php @@ -9,13 +9,14 @@ /** * Registers dashboard widgets. * - * handles POST data, sets up filters. + * Handles POST data, sets up filters. * - * @since unknown + * @since 2.5.0 */ function wp_dashboard_setup() { global $wp_registered_widgets, $wp_registered_widget_controls, $wp_dashboard_control_callbacks; $wp_dashboard_control_callbacks = array(); + $screen = get_current_screen(); $update = false; $widget_options = get_option( 'dashboard_widget_options' ); @@ -25,42 +26,50 @@ function wp_dashboard_setup() { /* Register Widgets and Controls */ // Right Now - wp_add_dashboard_widget( 'dashboard_right_now', __( 'Right Now' ), 'wp_dashboard_right_now' ); + if ( is_blog_admin() && current_user_can('edit_posts') ) + wp_add_dashboard_widget( 'dashboard_right_now', __( 'Right Now' ), 'wp_dashboard_right_now' ); + + if ( is_network_admin() ) + wp_add_dashboard_widget( 'network_dashboard_right_now', __( 'Right Now' ), 'wp_network_dashboard_right_now' ); // Recent Comments Widget - if ( !isset( $widget_options['dashboard_recent_comments'] ) || !isset( $widget_options['dashboard_recent_comments']['items'] ) ) { - $update = true; - $widget_options['dashboard_recent_comments'] = array( - 'items' => 5, - ); + if ( is_blog_admin() && current_user_can('moderate_comments') ) { + if ( !isset( $widget_options['dashboard_recent_comments'] ) || !isset( $widget_options['dashboard_recent_comments']['items'] ) ) { + $update = true; + $widget_options['dashboard_recent_comments'] = array( + 'items' => 5, + ); + } + $recent_comments_title = __( 'Recent Comments' ); + wp_add_dashboard_widget( 'dashboard_recent_comments', $recent_comments_title, 'wp_dashboard_recent_comments', 'wp_dashboard_recent_comments_control' ); } - $recent_comments_title = __( 'Recent Comments' ); - wp_add_dashboard_widget( 'dashboard_recent_comments', $recent_comments_title, 'wp_dashboard_recent_comments', 'wp_dashboard_recent_comments_control' ); // Incoming Links Widget - if ( !isset( $widget_options['dashboard_incoming_links'] ) || !isset( $widget_options['dashboard_incoming_links']['home'] ) || $widget_options['dashboard_incoming_links']['home'] != get_option('home') ) { - $update = true; - $num_items = isset($widget_options['dashboard_incoming_links']['items']) ? $widget_options['dashboard_incoming_links']['items'] : 10; - $widget_options['dashboard_incoming_links'] = array( - 'home' => get_option('home'), - 'link' => apply_filters( 'dashboard_incoming_links_link', 'http://blogsearch.google.com/blogsearch?scoring=d&partner=wordpress&q=link:' . trailingslashit( get_option('home') ) ), - 'url' => isset($widget_options['dashboard_incoming_links']['url']) ? apply_filters( 'dashboard_incoming_links_feed', $widget_options['dashboard_incoming_links']['url'] ) : apply_filters( 'dashboard_incoming_links_feed', 'http://blogsearch.google.com/blogsearch_feeds?scoring=d&ie=utf-8&num=' . $num_items . '&output=rss&partner=wordpress&q=link:' . trailingslashit( get_option('home') ) ), - 'items' => $num_items, - 'show_date' => isset($widget_options['dashboard_incoming_links']['show_date']) ? $widget_options['dashboard_incoming_links']['show_date'] : false - ); + if ( is_blog_admin() && current_user_can('publish_posts') ) { + if ( !isset( $widget_options['dashboard_incoming_links'] ) || !isset( $widget_options['dashboard_incoming_links']['home'] ) || $widget_options['dashboard_incoming_links']['home'] != get_option('home') ) { + $update = true; + $num_items = isset($widget_options['dashboard_incoming_links']['items']) ? $widget_options['dashboard_incoming_links']['items'] : 10; + $widget_options['dashboard_incoming_links'] = array( + 'home' => get_option('home'), + 'link' => apply_filters( 'dashboard_incoming_links_link', 'http://blogsearch.google.com/blogsearch?scoring=d&partner=wordpress&q=link:' . trailingslashit( get_option('home') ) ), + 'url' => isset($widget_options['dashboard_incoming_links']['url']) ? apply_filters( 'dashboard_incoming_links_feed', $widget_options['dashboard_incoming_links']['url'] ) : apply_filters( 'dashboard_incoming_links_feed', 'http://blogsearch.google.com/blogsearch_feeds?scoring=d&ie=utf-8&num=' . $num_items . '&output=rss&partner=wordpress&q=link:' . trailingslashit( get_option('home') ) ), + 'items' => $num_items, + 'show_date' => isset($widget_options['dashboard_incoming_links']['show_date']) ? $widget_options['dashboard_incoming_links']['show_date'] : false + ); + } + wp_add_dashboard_widget( 'dashboard_incoming_links', __( 'Incoming Links' ), 'wp_dashboard_incoming_links', 'wp_dashboard_incoming_links_control' ); } - wp_add_dashboard_widget( 'dashboard_incoming_links', __( 'Incoming Links' ), 'wp_dashboard_incoming_links', 'wp_dashboard_incoming_links_control' ); // WP Plugins Widget - if ( current_user_can( 'install_plugins' ) ) + if ( ( ! is_multisite() && is_blog_admin() && current_user_can( 'install_plugins' ) ) || ( is_network_admin() && current_user_can( 'manage_network_plugins' ) && current_user_can( 'install_plugins' ) ) ) wp_add_dashboard_widget( 'dashboard_plugins', __( 'Plugins' ), 'wp_dashboard_plugins' ); // QuickPress Widget - if ( current_user_can('edit_posts') ) + if ( is_blog_admin() && current_user_can('edit_posts') ) wp_add_dashboard_widget( 'dashboard_quick_press', __( 'QuickPress' ), 'wp_dashboard_quick_press' ); // Recent Drafts - if ( current_user_can('edit_posts') ) + if ( is_blog_admin() && current_user_can('edit_posts') ) wp_add_dashboard_widget( 'dashboard_recent_drafts', __('Recent Drafts'), 'wp_dashboard_recent_drafts' ); // Primary feed (Dev Blog) Widget @@ -94,10 +103,17 @@ function wp_dashboard_setup() { wp_add_dashboard_widget( 'dashboard_secondary', $widget_options['dashboard_secondary']['title'], 'wp_dashboard_secondary', 'wp_dashboard_secondary_control' ); // Hook to register new widgets - do_action( 'wp_dashboard_setup' ); - // Filter widget order - $dashboard_widgets = apply_filters( 'wp_dashboard_widgets', array() ); + if ( is_network_admin() ) { + do_action( 'wp_network_dashboard_setup' ); + $dashboard_widgets = apply_filters( 'wp_network_dashboard_widgets', array() ); + } elseif ( is_user_admin() ) { + do_action( 'wp_user_dashboard_setup' ); + $dashboard_widgets = apply_filters( 'wp_user_dashboard_widgets', array() ); + } else { + do_action( 'wp_dashboard_setup' ); + $dashboard_widgets = apply_filters( 'wp_dashboard_widgets', array() ); + } foreach ( $dashboard_widgets as $widget_id ) { $name = empty( $wp_registered_widgets[$widget_id]['all_link'] ) ? $wp_registered_widgets[$widget_id]['name'] : $wp_registered_widgets[$widget_id]['name'] . " " . __('View all') . ''; @@ -115,46 +131,57 @@ function wp_dashboard_setup() { if ( $update ) update_option( 'dashboard_widget_options', $widget_options ); - do_action('do_meta_boxes', 'dashboard', 'normal', ''); - do_action('do_meta_boxes', 'dashboard', 'side', ''); + do_action('do_meta_boxes', $screen->id, 'normal', ''); + do_action('do_meta_boxes', $screen->id, 'side', ''); } function wp_add_dashboard_widget( $widget_id, $widget_name, $callback, $control_callback = null ) { + $screen = get_current_screen(); global $wp_dashboard_control_callbacks; + if ( $control_callback && current_user_can( 'edit_dashboard' ) && is_callable( $control_callback ) ) { $wp_dashboard_control_callbacks[$widget_id] = $control_callback; if ( isset( $_GET['edit'] ) && $widget_id == $_GET['edit'] ) { list($url) = explode( '#', add_query_arg( 'edit', false ), 2 ); $widget_name .= ' ' . __( 'Cancel' ) . ''; - add_meta_box( $widget_id, $widget_name, '_wp_dashboard_control_callback', 'dashboard', 'normal', 'core' ); - return; + $callback = '_wp_dashboard_control_callback'; + } else { + list($url) = explode( '#', add_query_arg( 'edit', $widget_id ), 2 ); + $widget_name .= ' ' . __( 'Configure' ) . ''; } - list($url) = explode( '#', add_query_arg( 'edit', $widget_id ), 2 ); - $widget_name .= ' ' . __( 'Configure' ) . ''; } - $side_widgets = array('dashboard_quick_press', 'dashboard_recent_drafts', 'dashboard_primary', 'dashboard_secondary'); + + if ( is_blog_admin () ) + $side_widgets = array('dashboard_quick_press', 'dashboard_recent_drafts', 'dashboard_primary', 'dashboard_secondary'); + else if (is_network_admin() ) + $side_widgets = array('dashboard_primary', 'dashboard_secondary'); + else + $side_widgets = array(); + $location = 'normal'; if ( in_array($widget_id, $side_widgets) ) $location = 'side'; - add_meta_box( $widget_id, $widget_name , $callback, 'dashboard', $location, 'core' ); + add_meta_box( $widget_id, $widget_name , $callback, $screen->id, $location, 'core' ); } function _wp_dashboard_control_callback( $dashboard, $meta_box ) { echo '
      '; wp_dashboard_trigger_widget_control( $meta_box['id'] ); - echo '

      '; - + echo ''; + submit_button( __('Submit') ); echo '
      '; } /** * Displays the dashboard. * - * @since unknown + * @since 2.5.0 */ function wp_dashboard() { global $screen_layout_columns; + $screen = get_current_screen(); + $hide2 = $hide3 = $hide4 = ''; switch ( $screen_layout_columns ) { case 4: @@ -176,16 +203,16 @@ function wp_dashboard() {
      \n"; - do_meta_boxes( 'dashboard', 'normal', '' ); + do_meta_boxes( $screen->id, 'normal', '' ); echo "\t
      \n"; - do_meta_boxes( 'dashboard', 'side', '' ); + do_meta_boxes( $screen->id, 'side', '' ); echo "\t
      \n"; - do_meta_boxes( 'dashboard', 'column3', '' ); + do_meta_boxes( $screen->id, 'column3', '' ); echo "\t
      \n"; - do_meta_boxes( 'dashboard', 'column4', '' ); + do_meta_boxes( $screen->id, 'column4', '' ); ?>
      @@ -383,6 +410,53 @@ function wp_dashboard_right_now() { do_action( 'activity_box_end' ); } +function wp_network_dashboard_right_now() { + $actions = array(); + if ( current_user_can('create_sites') ) + $actions['create-site'] = '' . __( 'Create a New Site' ) . ''; + if ( current_user_can('create_users') ) + $actions['create-user'] = '' . __( 'Create a New User' ) . ''; + + $c_users = get_user_count(); + $c_blogs = get_blog_count(); + + $user_text = sprintf( _n( '%s user', '%s users', $c_users ), number_format_i18n( $c_users ) ); + $blog_text = sprintf( _n( '%s site', '%s sites', $c_blogs ), number_format_i18n( $c_blogs ) ); + + $sentence = sprintf( __( 'You have %1$s and %2$s.' ), $blog_text, $user_text ); + + if ( $actions ) { + echo '
        '; + foreach ( $actions as $class => $action ) { + $actions[ $class ] = "\t
      • $action"; + } + echo implode( " |
      • \n", $actions ) . "\n"; + echo '
      '; + } +?> +
      + +

      + + +
      +

      + + 'submit_users' ) ); ?> +

      +
      + +
      +

      + + 'submit_sites' ) ); ?> +

      +
      +
      - +
      @@ -460,7 +534,7 @@ function wp_dashboard_quick_press_output() { - + 'save-post', 'tabindex'=> 4 ) ); ?> @@ -517,7 +591,7 @@ function wp_dashboard_recent_drafts( $drafts = false ) { /** * Display recent comments dashboard widget content. * - * @since unknown + * @since 2.5.0 */ function wp_dashboard_recent_comments() { global $wpdb; @@ -532,10 +606,8 @@ function wp_dashboard_recent_comments() { $start = 0; $widgets = get_option( 'dashboard_widget_options' ); - if ( isset( $widgets['dashboard_recent_comments'] ) && isset( $widgets['dashboard_recent_comments']['items'] ) ) - $total_items = (int) $widgets['dashboard_recent_comments']['items']; - else - $total_items = 5; + $total_items = isset( $widgets['dashboard_recent_comments'] ) && isset( $widgets['dashboard_recent_comments']['items'] ) + ? absint( $widgets['dashboard_recent_comments']['items'] ) : 5; while ( count( $comments ) < 5 && $possible = $wpdb->get_results( "SELECT * FROM $wpdb->comments c LEFT JOIN $wpdb->posts p ON c.comment_post_ID = p.ID WHERE p.post_status != 'trash' ORDER BY c.comment_date_gmt DESC LIMIT $start, 50" ) ) { @@ -586,7 +658,7 @@ function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) { $comment_link = '#'; $actions_string = ''; - if ( current_user_can('edit_post', $comment->comment_post_ID) ) { + if ( current_user_can( 'edit_comment', $comment->comment_ID ) ) { // preorder it: Approve | Reply | Edit | Spam | Trash $actions = array( 'approve' => '', 'unapprove' => '', @@ -605,15 +677,15 @@ function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) { $trash_url = esc_url( "comment.php?action=trashcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" ); $delete_url = esc_url( "comment.php?action=deletecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" ); - $actions['approve'] = "" . __( 'Approve' ) . ''; - $actions['unapprove'] = "" . __( 'Unapprove' ) . ''; - $actions['edit'] = "". __('Edit') . ''; - $actions['reply'] = '' . __('Reply') . ''; - $actions['spam'] = "" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . ''; + $actions['approve'] = "" . __( 'Approve' ) . ''; + $actions['unapprove'] = "" . __( 'Unapprove' ) . ''; + $actions['edit'] = "". __('Edit') . ''; + $actions['reply'] = '' . __('Reply') . ''; + $actions['spam'] = "" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . ''; if ( !EMPTY_TRASH_DAYS ) $actions['delete'] = "" . __('Delete Permanently') . ''; else - $actions['trash'] = "" . _x('Trash', 'verb') . ''; + $actions['trash'] = "" . _x('Trash', 'verb') . ''; $actions = apply_filters( 'comment_row_actions', array_filter($actions), $comment ); @@ -683,9 +755,7 @@ function wp_dashboard_recent_comments_control() { $widget_options['dashboard_recent_comments'] = array(); if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget-recent-comments']) ) { - $number = (int) stripslashes($_POST['widget-recent-comments']['items']); - if ( $number < 1 || $number > 30 ) - $number = 5; + $number = absint( $_POST['widget-recent-comments']['items'] ); $widget_options['dashboard_recent_comments']['items'] = $number; update_option( 'dashboard_widget_options', $widget_options ); } @@ -693,7 +763,7 @@ function wp_dashboard_recent_comments_control() { $number = isset( $widget_options['dashboard_recent_comments']['items'] ) ? (int) $widget_options['dashboard_recent_comments']['items'] : ''; echo '

      '; - echo ' ' . __( '(at most 30)' ) . '

      '; + echo '

      '; } function wp_dashboard_incoming_links() { @@ -703,7 +773,7 @@ function wp_dashboard_incoming_links() { /** * Display incoming links dashboard widget content. * - * @since unknown + * @since 2.5.0 */ function wp_dashboard_incoming_links_output() { $widgets = get_option( 'dashboard_widget_options' ); @@ -763,8 +833,8 @@ function wp_dashboard_incoming_links_output() { /* translators: incoming links feed, %1$s is other person, %3$s is content */ $text = __( '%1$s linked here saying, "%3$s"' ); - if ( $show_date ) { - if ( $show_author || $show_summary ) + if ( !empty($show_date) ) { + if ( !empty($show_author) || !empty($show_summary) ) /* translators: incoming links feed, %4$s is the date */ $text .= ' ' . __( 'on %4$s' ); $date = esc_html( strip_tags( $item->get_date() ) ); @@ -795,9 +865,9 @@ function wp_dashboard_primary_control() { /** * {@internal Missing Short Description}} * - * @since unknown + * @since 2.5.0 * - * @param int $widget_id + * @param string $widget_id */ function wp_dashboard_rss_output( $widget_id ) { $widgets = get_option( 'dashboard_widget_options' ); @@ -817,7 +887,7 @@ function wp_dashboard_secondary_control() { /** * Display secondary dashboard RSS widget feed. * - * @since unknown + * @since 2.5.0 * * @return unknown */ @@ -852,7 +922,7 @@ function wp_dashboard_plugins() { /** * Display plugins most popular, newest plugins, and recently updated widget text. * - * @since unknown + * @since 2.5.0 */ function wp_dashboard_plugins_output() { $popular = fetch_feed( 'http://wordpress.org/extend/plugins/rss/browse/popular/' ); @@ -938,9 +1008,9 @@ function wp_dashboard_plugins_output() { * echoes out output for this widget. If not cache, echo a "Loading..." stub * which is later replaced by AJAX call (see top of /wp-admin/index.php) * - * @since unknown + * @since 2.5.0 * - * @param int $widget_id + * @param string $widget_id * @param callback $callback * @param array $check_urls RSS feeds * @return bool False on failure. True on success. @@ -981,7 +1051,7 @@ function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = ar /** * Calls widget control callback. * - * @since unknown + * @since 2.5.0 * * @param int $widget_control_id Registered Widget ID. */ @@ -999,10 +1069,10 @@ function wp_dashboard_trigger_widget_control( $widget_control_id = false ) { * Sets up $args to be used as input to wp_widget_rss_form(). Handles POST data * from RSS-type widgets. * - * @since unknown + * @since 2.5.0 * - * @param string widget_id - * @param array form_inputs + * @param string $widget_id + * @param array $form_inputs */ function wp_dashboard_rss_control( $widget_id, $form_inputs = array() ) { if ( !$widget_options = get_option( 'dashboard_widget_options' ) ) @@ -1034,6 +1104,45 @@ function wp_dashboard_rss_control( $widget_id, $form_inputs = array() ) { wp_widget_rss_form( $widget_options[$widget_id], $form_inputs ); } +// Display File upload quota on dashboard +function wp_dashboard_quota() { + if ( !is_multisite() || !current_user_can('edit_posts') || get_site_option( 'upload_space_check_disabled' ) ) + return true; + + $quota = get_space_allowed(); + $used = get_dirsize( BLOGUPLOADDIR ) / 1024 / 1024; + + if ( $used > $quota ) + $percentused = '100'; + else + $percentused = ( $used / $quota ) * 100; + $used_color = ( $percentused < 70 ) ? ( ( $percentused >= 40 ) ? 'waiting' : 'approved' ) : 'spam'; + $used = round( $used, 2 ); + $percentused = number_format( $percentused ); + + ?> +

      +
      + + + + + +
      %2$sMB' ), esc_url( admin_url( 'upload.php' ) ), $quota ); ?>
      +
      +
      + + + + + +
      %2$sMB (%3$s%%)' ), esc_url( admin_url( 'upload.php' ) ), $used, $percentused ); ?>
      +
      +
      + \ No newline at end of file + +/** + * @deprecated 3.1.0 + * + * @return array List of user IDs. + */ +function get_author_user_ids() { + _deprecated_function( __FUNCTION__, '3.1', 'get_users()' ); + + global $wpdb; + if ( !is_multisite() ) + $level_key = $wpdb->get_blog_prefix() . 'user_level'; + else + $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels + + return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value != '0'", $level_key) ); +} + +/** + * @deprecated 3.1.0 + * + * @param int $user_id User ID. + * @return array|bool List of editable authors. False if no editable users. + */ +function get_editable_authors( $user_id ) { + _deprecated_function( __FUNCTION__, '3.1', 'get_users()' ); + + global $wpdb; + + $editable = get_editable_user_ids( $user_id ); + + if ( !$editable ) { + return false; + } else { + $editable = join(',', $editable); + $authors = $wpdb->get_results( "SELECT * FROM $wpdb->users WHERE ID IN ($editable) ORDER BY display_name" ); + } + + return apply_filters('get_editable_authors', $authors); +} + +/** + * @deprecated 3.1.0 + * + * @param int $user_id User ID. + * @param bool $exclude_zeros Optional, default is true. Whether to exclude zeros. + * @return unknown + */ +function get_editable_user_ids( $user_id, $exclude_zeros = true, $post_type = 'post' ) { + _deprecated_function( __FUNCTION__, '3.1', 'get_users()' ); + + global $wpdb; + + $user = new WP_User( $user_id ); + $post_type_obj = get_post_type_object($post_type); + + if ( ! $user->has_cap($post_type_obj->cap->edit_others_posts) ) { + if ( $user->has_cap($post_type_obj->cap->edit_posts) || ! $exclude_zeros ) + return array($user->id); + else + return array(); + } + + if ( !is_multisite() ) + $level_key = $wpdb->get_blog_prefix() . 'user_level'; + else + $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels + + $query = $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s", $level_key); + if ( $exclude_zeros ) + $query .= " AND meta_value != '0'"; + + return $wpdb->get_col( $query ); +} + +/** + * @deprecated 3.1.0 + */ +function get_nonauthor_user_ids() { + _deprecated_function( __FUNCTION__, '3.1', 'get_users()' ); + + global $wpdb; + + if ( !is_multisite() ) + $level_key = $wpdb->get_blog_prefix() . 'user_level'; + else + $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels + + return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value = '0'", $level_key) ); +} + +if ( !class_exists('WP_User_Search') ) : +/** + * WordPress User Search class. + * + * @since 2.1.0 + * @deprecated 3.1.0 + */ +class WP_User_Search { + + /** + * {@internal Missing Description}} + * + * @since 2.1.0 + * @access private + * @var unknown_type + */ + var $results; + + /** + * {@internal Missing Description}} + * + * @since 2.1.0 + * @access private + * @var unknown_type + */ + var $search_term; + + /** + * Page number. + * + * @since 2.1.0 + * @access private + * @var int + */ + var $page; + + /** + * Role name that users have. + * + * @since 2.5.0 + * @access private + * @var string + */ + var $role; + + /** + * Raw page number. + * + * @since 2.1.0 + * @access private + * @var int|bool + */ + var $raw_page; + + /** + * Amount of users to display per page. + * + * @since 2.1.0 + * @access public + * @var int + */ + var $users_per_page = 50; + + /** + * {@internal Missing Description}} + * + * @since 2.1.0 + * @access private + * @var unknown_type + */ + var $first_user; + + /** + * {@internal Missing Description}} + * + * @since 2.1.0 + * @access private + * @var int + */ + var $last_user; + + /** + * {@internal Missing Description}} + * + * @since 2.1.0 + * @access private + * @var string + */ + var $query_limit; + + /** + * {@internal Missing Description}} + * + * @since 3.0.0 + * @access private + * @var string + */ + var $query_orderby; + + /** + * {@internal Missing Description}} + * + * @since 3.0.0 + * @access private + * @var string + */ + var $query_from; + + /** + * {@internal Missing Description}} + * + * @since 3.0.0 + * @access private + * @var string + */ + var $query_where; + + /** + * {@internal Missing Description}} + * + * @since 2.1.0 + * @access private + * @var int + */ + var $total_users_for_query = 0; + + /** + * {@internal Missing Description}} + * + * @since 2.1.0 + * @access private + * @var bool + */ + var $too_many_total_users = false; + + /** + * {@internal Missing Description}} + * + * @since 2.1.0 + * @access private + * @var unknown_type + */ + var $search_errors; + + /** + * {@internal Missing Description}} + * + * @since 2.7.0 + * @access private + * @var unknown_type + */ + var $paging_text; + + /** + * PHP4 Constructor - Sets up the object properties. + * + * @since 2.1.0 + * + * @param string $search_term Search terms string. + * @param int $page Optional. Page ID. + * @param string $role Role name. + * @return WP_User_Search + */ + function WP_User_Search ($search_term = '', $page = '', $role = '') { + _deprecated_function( __FUNCTION__, '3.1', 'WP_User_Query' ); + + $this->search_term = $search_term; + $this->raw_page = ( '' == $page ) ? false : (int) $page; + $this->page = (int) ( '' == $page ) ? 1 : $page; + $this->role = $role; + + $this->prepare_query(); + $this->query(); + $this->prepare_vars_for_template_usage(); + $this->do_paging(); + } + + /** + * {@internal Missing Short Description}} + * + * {@internal Missing Long Description}} + * + * @since 2.1.0 + * @access public + */ + function prepare_query() { + global $wpdb; + $this->first_user = ($this->page - 1) * $this->users_per_page; + + $this->query_limit = $wpdb->prepare(" LIMIT %d, %d", $this->first_user, $this->users_per_page); + $this->query_orderby = ' ORDER BY user_login'; + + $search_sql = ''; + if ( $this->search_term ) { + $searches = array(); + $search_sql = 'AND ('; + foreach ( array('user_login', 'user_nicename', 'user_email', 'user_url', 'display_name') as $col ) + $searches[] = $col . " LIKE '%$this->search_term%'"; + $search_sql .= implode(' OR ', $searches); + $search_sql .= ')'; + } + + $this->query_from = " FROM $wpdb->users"; + $this->query_where = " WHERE 1=1 $search_sql"; + + if ( $this->role ) { + $this->query_from .= " INNER JOIN $wpdb->usermeta ON $wpdb->users.ID = $wpdb->usermeta.user_id"; + $this->query_where .= $wpdb->prepare(" AND $wpdb->usermeta.meta_key = '{$wpdb->prefix}capabilities' AND $wpdb->usermeta.meta_value LIKE %s", '%' . $this->role . '%'); + } elseif ( is_multisite() ) { + $level_key = $wpdb->prefix . 'capabilities'; // wpmu site admins don't have user_levels + $this->query_from .= ", $wpdb->usermeta"; + $this->query_where .= " AND $wpdb->users.ID = $wpdb->usermeta.user_id AND meta_key = '{$level_key}'"; + } + + do_action_ref_array( 'pre_user_search', array( &$this ) ); + } + + /** + * {@internal Missing Short Description}} + * + * {@internal Missing Long Description}} + * + * @since 2.1.0 + * @access public + */ + function query() { + global $wpdb; + + $this->results = $wpdb->get_col("SELECT DISTINCT($wpdb->users.ID)" . $this->query_from . $this->query_where . $this->query_orderby . $this->query_limit); + + if ( $this->results ) + $this->total_users_for_query = $wpdb->get_var("SELECT COUNT(DISTINCT($wpdb->users.ID))" . $this->query_from . $this->query_where); // no limit + else + $this->search_errors = new WP_Error('no_matching_users_found', __('No matching users were found!')); + } + + /** + * {@internal Missing Short Description}} + * + * {@internal Missing Long Description}} + * + * @since 2.1.0 + * @access public + */ + function prepare_vars_for_template_usage() { + $this->search_term = stripslashes($this->search_term); // done with DB, from now on we want slashes gone + } + + /** + * {@internal Missing Short Description}} + * + * {@internal Missing Long Description}} + * + * @since 2.1.0 + * @access public + */ + function do_paging() { + if ( $this->total_users_for_query > $this->users_per_page ) { // have to page the results + $args = array(); + if( ! empty($this->search_term) ) + $args['usersearch'] = urlencode($this->search_term); + if( ! empty($this->role) ) + $args['role'] = urlencode($this->role); + + $this->paging_text = paginate_links( array( + 'total' => ceil($this->total_users_for_query / $this->users_per_page), + 'current' => $this->page, + 'base' => 'users.php?%_%', + 'format' => 'userspage=%#%', + 'add_args' => $args + ) ); + if ( $this->paging_text ) { + $this->paging_text = sprintf( '' . __( 'Displaying %s–%s of %s' ) . '%s', + number_format_i18n( ( $this->page - 1 ) * $this->users_per_page + 1 ), + number_format_i18n( min( $this->page * $this->users_per_page, $this->total_users_for_query ) ), + number_format_i18n( $this->total_users_for_query ), + $this->paging_text + ); + } + } + } + + /** + * {@internal Missing Short Description}} + * + * {@internal Missing Long Description}} + * + * @since 2.1.0 + * @access public + * + * @return unknown + */ + function get_results() { + return (array) $this->results; + } + + /** + * Displaying paging text. + * + * @see do_paging() Builds paging text. + * + * @since 2.1.0 + * @access public + */ + function page_links() { + echo $this->paging_text; + } + + /** + * Whether paging is enabled. + * + * @see do_paging() Builds paging text. + * + * @since 2.1.0 + * @access public + * + * @return bool + */ + function results_are_paged() { + if ( $this->paging_text ) + return true; + return false; + } + + /** + * Whether there are search terms. + * + * @since 2.1.0 + * @access public + * + * @return bool + */ + function is_search() { + if ( $this->search_term ) + return true; + return false; + } +} +endif; + +/** + * Retrieve editable posts from other users. + * + * @deprecated 3.1.0 + * + * @param int $user_id User ID to not retrieve posts from. + * @param string $type Optional, defaults to 'any'. Post type to retrieve, can be 'draft' or 'pending'. + * @return array List of posts from others. + */ +function get_others_unpublished_posts($user_id, $type='any') { + _deprecated_function( __FUNCTION__, '3.1' ); + + global $wpdb; + + $editable = get_editable_user_ids( $user_id ); + + if ( in_array($type, array('draft', 'pending')) ) + $type_sql = " post_status = '$type' "; + else + $type_sql = " ( post_status = 'draft' OR post_status = 'pending' ) "; + + $dir = ( 'pending' == $type ) ? 'ASC' : 'DESC'; + + if ( !$editable ) { + $other_unpubs = ''; + } else { + $editable = join(',', $editable); + $other_unpubs = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_title, post_author FROM $wpdb->posts WHERE post_type = 'post' AND $type_sql AND post_author IN ($editable) AND post_author != %d ORDER BY post_modified $dir", $user_id) ); + } + + return apply_filters('get_others_drafts', $other_unpubs); +} + +/** + * Retrieve drafts from other users. + * + * @deprecated 3.1.0 + * + * @param int $user_id User ID. + * @return array List of drafts from other users. + */ +function get_others_drafts($user_id) { + _deprecated_function( __FUNCTION__, '3.1' ); + + return get_others_unpublished_posts($user_id, 'draft'); +} + +/** + * Retrieve pending review posts from other users. + * + * @deprecated 3.1.0 + * + * @param int $user_id User ID. + * @return array List of posts with pending review post type from other users. + */ +function get_others_pending($user_id) { + _deprecated_function( __FUNCTION__, '3.1' ); + + return get_others_unpublished_posts($user_id, 'pending'); +} diff --git a/wp-admin/includes/export.php b/wp-admin/includes/export.php index a9e8f22d..2efd0405 100644 --- a/wp-admin/includes/export.php +++ b/wp-admin/includes/export.php @@ -11,127 +11,112 @@ * * Bump this when something changes that might affect compatibility. * - * @since unknown - * @var string + * @since 2.5.0 */ -define('WXR_VERSION', '1.0'); +define( 'WXR_VERSION', '1.1' ); /** - * {@internal Missing Short Description}} + * Generates the WXR export file for download * - * @since unknown + * @since 2.1.0 * - * @param unknown_type $args + * @param array $args Filters defining what should be included in the export */ function export_wp( $args = array() ) { - global $wpdb, $post_ids, $post, $wp_taxonomies; + global $wpdb, $post; - if ( ! is_array( $args ) ) - $args = array( 'author' => $args ); - - $defaults = array( 'author' => null, 'taxonomy' => null, 'post_type' => null, 'post_status' => null, 'start_date' => null, 'end_date' => null ); + $defaults = array( 'content' => 'all', 'author' => false, 'category' => false, + 'start_date' => false, 'end_date' => false, 'status' => false, + ); $args = wp_parse_args( $args, $defaults ); - extract($args); - - do_action('export_wp'); + do_action( 'export_wp' ); - if( strlen( $start_date ) > 4 && strlen( $end_date ) > 4 ) - $filename = 'wordpress.' . $start_date . '.' . $end_date . '.xml'; - else - $filename = 'wordpress.' . date( 'Y-m-d' ) . '.xml'; + $sitename = sanitize_key( get_bloginfo( 'name' ) ); + if ( ! empty($sitename) ) $sitename .= '.'; + $filename = $sitename . 'wordpress.' . date( 'Y-m-d' ) . '.xml'; header( 'Content-Description: File Transfer' ); header( 'Content-Disposition: attachment; filename=' . $filename ); header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true ); - if ( $post_type && $post_type != 'all' ) - $where = $wpdb->prepare("WHERE post_type = %s ", $post_type); - else - $where = "WHERE post_type != 'revision' "; + if ( 'all' != $args['content'] && post_type_exists( $args['content'] ) ) { + $ptype = get_post_type_object( $args['content'] ); + if ( ! $ptype->can_export ) + $args['content'] = 'post'; - if ( $author && $author != 'all' ) { - $author_id = (int) $author; - $where .= $wpdb->prepare( "AND post_author = %d ", $author_id ); + $where = $wpdb->prepare( "{$wpdb->posts}.post_type = %s", $args['content'] ); + } else { + $post_types = get_post_types( array( 'can_export' => true ) ); + $esses = array_fill( 0, count($post_types), '%s' ); + $where = $wpdb->prepare( "{$wpdb->posts}.post_type IN (". implode(',',$esses) .")", $post_types ); } - if ( $start_date && $start_date != 'all' ) - $where .= $wpdb->prepare( "AND post_date >= %s ", $start_date ); - - if ( $end_date && $end_date != 'all' ) - $where .= $wpdb->prepare( "AND post_date < %s ", $end_date ); + if ( $args['status'] && ( 'post' == $args['content'] || 'page' == $args['content'] ) ) + $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_status = %s", $args['status'] ); + else + $where .= " AND {$wpdb->posts}.post_status != 'auto-draft'"; - if ( $taxonomy && is_array( $taxonomy ) ) { - foreach ( $taxonomy as $term_id ) { - if ( $term_id != 'all' ) - $where .= $wpdb->prepare( "AND ID IN (SELECT object_id FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d) ", $term_id ); + $join = ''; + if ( $args['category'] && 'post' == $args['content'] ) { + if ( $term = term_exists( $args['category'], 'category' ) ) { + $join = "INNER JOIN {$wpdb->term_relationships} ON ({$wpdb->posts}.ID = {$wpdb->term_relationships}.object_id)"; + $where .= $wpdb->prepare( " AND {$wpdb->term_relationships}.term_taxonomy_id = %d", $term['term_taxonomy_id'] ); } } - if ( $post_status && $post_status != 'all' ) - $where .= $wpdb->prepare( "AND post_status = %s", $post_status ); + if ( 'post' == $args['content'] || 'page' == $args['content'] ) { + if ( $args['author'] ) + $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_author = %d", $args['author'] ); - // grab a snapshot of post IDs, just in case it changes during the export - $post_ids = $wpdb->get_col( "SELECT ID FROM $wpdb->posts $where ORDER BY post_date_gmt ASC" ); + if ( $args['start_date'] ) + $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_date >= %s", date( 'Y-m-d', strtotime($args['start_date']) ) ); - $categories = (array) get_categories( array( 'get' => 'all' ) ); - $tags = (array) get_tags( array( 'get' => 'all' ) ); - - $custom_taxonomies = $wp_taxonomies; - unset( $custom_taxonomies['category'] ); - unset( $custom_taxonomies['post_tag'] ); - unset( $custom_taxonomies['link_category'] ); - $custom_taxonomies = array_keys( $custom_taxonomies ); - $terms = (array) get_terms( $custom_taxonomies, array( 'get' => 'all' ) ); - - /** - * {@internal Missing Short Description}} - * - * @since unknown - * - * @param unknown_type $categories - */ - function wxr_missing_parents( $categories ) { - if ( ! is_array( $categories ) || empty( $categories ) ) - return array(); + if ( $args['end_date'] ) + $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_date < %s", date( 'Y-m-d', strtotime('+1 month', strtotime($args['end_date'])) ) ); + } - foreach ( $categories as $category ){ - $parents[$category->term_id] = $category->parent; + // grab a snapshot of post IDs, just in case it changes during the export + $post_ids = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} $join WHERE $where" ); + + // get the requested terms ready, empty unless posts filtered by category or all content + $cats = $tags = $terms = array(); + if ( isset( $term ) && $term ) { + $cat = get_term( $term['term_id'], 'category' ); + $cats = array( $cat->term_id => $cat ); + unset( $term, $cat ); + } else if ( 'all' == $args['content'] ) { + $categories = (array) get_categories( array( 'get' => 'all' ) ); + $tags = (array) get_tags( array( 'get' => 'all' ) ); + + $custom_taxonomies = get_taxonomies( array( '_builtin' => false ) ); + $custom_terms = (array) get_terms( $custom_taxonomies, array( 'get' => 'all' ) ); + + // put categories in order with no child going before its parent + while ( $cat = array_shift( $categories ) ) { + if ( $cat->parent == 0 || isset( $cats[$cat->parent] ) ) + $cats[$cat->term_id] = $cat; + else + $categories[] = $cat; } - $parents = array_unique( array_diff( $parents, array_keys( $parents ) ) ); - - if ( $zero = array_search( '0', $parents ) ) - unset( $parents[$zero] ); - - return $parents; - } - - while ( $parents = wxr_missing_parents( $categories ) ) { - $found_parents = get_categories( array( 'include' => join( ', ', $parents) ) ); - if ( is_array( $found_parents ) && count( $found_parents ) ) - $categories = array_merge( $categories, $found_parents ); - else - break; - } + // put terms in order with no child going before its parent + while ( $t = array_shift( $custom_terms ) ) { + if ( $t->parent == 0 || isset( $terms[$t->parent] ) ) + $terms[$t->term_id] = $t; + else + $custom_terms[] = $t; + } - // Put them in order to be inserted with no child going before its parent - $pass = 0; - $passes = 1000 + count( $categories ); - while ( ( $cat = array_shift( $categories ) ) && ++$pass < $passes ) { - if ( $cat->parent == 0 || isset( $cats[$cat->parent] ) ) - $cats[$cat->term_id] = $cat; - else - $categories[] = $cat; + unset( $categories, $custom_taxonomies, $custom_terms ); } - unset( $categories ); /** - * Place string in CDATA tag. + * Wrap given string in XML CDATA tag. * - * @since unknown + * @since 2.1.0 * - * @param string $str String to place in XML CDATA tag. + * @param string $str String to wrap in XML CDATA tag. */ function wxr_cdata( $str ) { if ( seems_utf8( $str ) == false ) @@ -144,17 +129,15 @@ function export_wp( $args = array() ) { } /** - * {@internal Missing Short Description}} + * Return the URL of the site * - * @since unknown + * @since 2.5.0 * * @return string Site URL. */ function wxr_site_url() { - global $current_site; - - // mu: the base url - if ( isset( $current_site->domain ) ) + // ms: the base url + if ( is_multisite() ) return network_home_url(); // wp: the blog url else @@ -162,136 +145,172 @@ function export_wp( $args = array() ) { } /** - * {@internal Missing Short Description}} + * Output a cat_name XML tag from a given category object * - * @since unknown + * @since 2.1.0 * - * @param object $c Category Object + * @param object $category Category Object */ - function wxr_cat_name( $c ) { - if ( empty( $c->name ) ) + function wxr_cat_name( $category ) { + if ( empty( $category->name ) ) return; - echo '' . wxr_cdata( $c->name ) . ''; + echo '' . wxr_cdata( $category->name ) . ''; } /** - * {@internal Missing Short Description}} + * Output a category_description XML tag from a given category object * - * @since unknown + * @since 2.1.0 * - * @param object $c Category Object + * @param object $category Category Object */ - function wxr_category_description( $c ) { - if ( empty( $c->description ) ) + function wxr_category_description( $category ) { + if ( empty( $category->description ) ) return; - echo '' . wxr_cdata($c->description) . ''; + echo '' . wxr_cdata( $category->description ) . ''; } /** - * {@internal Missing Short Description}} + * Output a tag_name XML tag from a given tag object * - * @since unknown + * @since 2.3.0 * - * @param object $t Tag Object + * @param object $tag Tag Object */ - function wxr_tag_name( $t ) { - if ( empty( $t->name ) ) + function wxr_tag_name( $tag ) { + if ( empty( $tag->name ) ) return; - echo '' . wxr_cdata($t->name) . ''; + echo '' . wxr_cdata( $tag->name ) . ''; } /** - * {@internal Missing Short Description}} + * Output a tag_description XML tag from a given tag object * - * @since unknown + * @since 2.3.0 * - * @param object $t Tag Object + * @param object $tag Tag Object */ - function wxr_tag_description( $t ) { - if ( empty( $t->description ) ) + function wxr_tag_description( $tag ) { + if ( empty( $tag->description ) ) return; - echo '' . wxr_cdata($t->description) . ''; + echo '' . wxr_cdata( $tag->description ) . ''; } /** - * {@internal Missing Short Description}} + * Output a term_name XML tag from a given term object * - * @since unknown + * @since 2.9.0 * - * @param object $t Term Object + * @param object $term Term Object */ - function wxr_term_name( $t ) { - if ( empty( $t->name ) ) + function wxr_term_name( $term ) { + if ( empty( $term->name ) ) return; - echo '' . wxr_cdata($t->name) . ''; + echo '' . wxr_cdata( $term->name ) . ''; } /** - * {@internal Missing Short Description}} + * Output a term_description XML tag from a given term object * - * @since unknown + * @since 2.9.0 * - * @param object $t Term Object + * @param object $term Term Object */ - function wxr_term_description( $t ) { - if ( empty( $t->description ) ) + function wxr_term_description( $term ) { + if ( empty( $term->description ) ) return; - echo '' . wxr_cdata($t->description) . ''; + echo '' . wxr_cdata( $term->description ) . ''; } /** - * {@internal Missing Short Description}} + * Output list of authors with posts * - * @since unknown + * @since 3.1.0 + */ + function wxr_authors_list() { + global $wpdb; + + $authors = array(); + $results = $wpdb->get_results( "SELECT DISTINCT post_author FROM $wpdb->posts" ); + foreach ( (array) $results as $result ) + $authors[] = get_userdata( $result->post_author ); + + $authors = array_filter( $authors ); + + foreach( $authors as $author ) { + echo "\t"; + echo '' . $author->ID . ''; + echo '' . $author->user_login . ''; + echo '' . $author->user_email . ''; + echo '' . wxr_cdata( $author->display_name ) . ''; + echo '' . wxr_cdata( $author->user_firstname ) . ''; + echo '' . wxr_cdata( $author->user_lastname ) . ''; + echo "\n"; + } + } + + /** + * Ouput all navigation menu terms + * + * @since 3.1.0 + */ + function wxr_nav_menu_terms() { + $nav_menus = wp_get_nav_menus(); + if ( empty( $nav_menus ) || ! is_array( $nav_menus ) ) + return; + + foreach ( $nav_menus as $menu ) { + echo "\t{$menu->term_id}nav_menu{$menu->slug}"; + wxr_term_name( $menu ); + echo "\n"; + } + } + + /** + * Output list of taxonomy terms, in XML tag format, associated with a post + * + * @since 2.3.0 */ function wxr_post_taxonomy() { global $post; - $the_list = ''; - $filter = 'rss'; + $taxonomies = get_object_taxonomies( $post->post_type ); + if ( empty( $taxonomies ) ) + return; + $terms = wp_get_object_terms( $post->ID, $taxonomies ); - $taxonomies = get_object_taxonomies( 'post' ); - $terms = wp_get_post_terms( $post->ID, $taxonomies ); foreach ( (array) $terms as $term ) { - $domain = ( 'post_tag' == $term->taxonomy ) ? 'tag' : $term->taxonomy; - $term_name = sanitize_term_field( 'name', $term->name, $term->term_id, $term->taxonomy, $filter ); - // Back compat. - if ( 'category' == $term->taxonomy ) - $the_list .= "\n\t\t\n"; - elseif ( 'post_tag' == $term->taxonomy ) - $the_list .= "\n\t\t\n"; - // forwards compatibility as above - $the_list .= "\n\t\tslug}\">\n"; + echo "\t\ttaxonomy}\" nicename=\"{$term->slug}\">" . wxr_cdata( $term->name ) . "\n"; } - echo $the_list; } - echo '\n"; + echo '\n"; ?> - - + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + + <?php bloginfo_rss( 'name' ); ?> - - - - http://wordpress.org/?v= + + + - - slug; ?>parent ? $cats[$c->parent]->name : ''; ?> - - - slug; ?> - - - taxonomy; ?>slug; ?>parent ? $custom_taxonomies[$t->parent]->name : ''; ?> - + + + + + term_id ?>slug; ?>parent ? $cats[$c->parent]->slug : ''; ?> + + + term_id ?>slug; ?> + + + term_id ?>taxonomy; ?>slug; ?>parent ? $terms[$t->parent]->slug : ''; ?> + + - in_the_loop = true; // Fake being in the loop. + $wp_query->in_the_loop = true; // Fake being in the loop. // fetch 20 posts at a time rather than loading the entire table into memory while ( $next_posts = array_splice( $post_ids, 0, 20 ) ) { $where = "WHERE ID IN (" . join( ',', $next_posts ) . ")"; - $posts = $wpdb->get_results( "SELECT * FROM $wpdb->posts $where ORDER BY post_date_gmt ASC" ); + $posts = $wpdb->get_results( "SELECT * FROM {$wpdb->posts} $where" ); // Begin Loop - foreach ($posts as $post) { - setup_postdata( $post ); - - $is_sticky = 0; - if ( is_sticky( $post->ID ) ) - $is_sticky = 1; - - ?> + foreach ( $posts as $post ) { + setup_postdata( $post ); + $is_sticky = is_sticky( $post->ID ) ? 1 : 0; +?> <?php echo apply_filters( 'the_title_rss', $post->post_title ); ?> - - - + post_content ) ); ?> @@ -363,41 +379,36 @@ function export_wp( $args = array() ) { post_type; ?> post_password; ?> - post_type == 'attachment' ) { ?> +post_type == 'attachment' ) : ?> ID ); ?> - - get_results( $wpdb->prepare( "SELECT * FROM $wpdb->postmeta WHERE post_id = %d", $post->ID ) ); - if ( $postmeta ) { - ?> - + + +get_results( $wpdb->prepare( "SELECT * FROM $wpdb->postmeta WHERE post_id = %d", $post->ID ) ); + if ( $postmeta ) : foreach( $postmeta as $meta ) : if ( $meta->meta_key != '_edit_lock' ) : ?> - meta_key; ?> - meta_value ); ?> + meta_key; ?> + meta_value ); ?> - - - get_results( $wpdb->prepare( "SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d", $post->ID ) ); - if ( $comments ) { foreach ( $comments as $c ) { ?> + +get_results( $wpdb->prepare( "SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved <> 'spam'", $post->ID ) ); + if ( $comments ) : foreach ( $comments as $c ) : ?> - comment_ID; ?> - comment_author ); ?> - comment_author_email; ?> - comment_author_url ); ?> - comment_author_IP; ?> - comment_date; ?> - comment_date_gmt; ?> - comment_content ) ?> - comment_approved; ?> - comment_type; ?> - comment_parent; ?> - user_id; ?> + comment_ID; ?> + comment_author ); ?> + comment_author_email; ?> + comment_author_url ); ?> + comment_author_IP; ?> + comment_date; ?> + comment_date_gmt; ?> + comment_content ) ?> + comment_approved; ?> + comment_type; ?> + comment_parent; ?> + user_id; ?> - + - @@ -405,5 +416,3 @@ function export_wp( $args = array() ) { diff --git a/wp-admin/includes/file.php b/wp-admin/includes/file.php index d79f2e34..20d13616 100644 --- a/wp-admin/includes/file.php +++ b/wp-admin/includes/file.php @@ -7,10 +7,11 @@ */ /** The descriptions for theme files. */ -$wp_file_descriptions = array ( +$wp_file_descriptions = array( 'index.php' => __( 'Main Index Template' ), 'style.css' => __( 'Stylesheet' ), 'editor-style.css' => __( 'Visual Editor Stylesheet' ), + 'editor-style-rtl.css' => __( 'Visual Editor RTL Stylesheet' ), 'rtl.css' => __( 'RTL Stylesheet' ), 'comments.php' => __( 'Comments' ), 'comments-popup.php' => __( 'Popup Comments' ), @@ -36,15 +37,21 @@ $wp_file_descriptions = array ( 'my-hacks.php' => __( 'my-hacks.php (legacy hacks support)' ), '.htaccess' => __( '.htaccess (for rewrite rules )' ), // Deprecated files - 'wp-layout.css' => __( 'Stylesheet' ), 'wp-comments.php' => __( 'Comments Template' ), 'wp-comments-popup.php' => __( 'Popup Comments Template' )); + 'wp-layout.css' => __( 'Stylesheet' ), + 'wp-comments.php' => __( 'Comments Template' ), + 'wp-comments-popup.php' => __( 'Popup Comments Template' ), +); /** - * {@internal Missing Short Description}} + * Get the description for standard WordPress theme files and other various standard + * WordPress files * - * @since unknown + * @since 1.5.0 * - * @param unknown_type $file - * @return unknown + * @uses _cleanup_header_comment + * @uses $wp_file_descriptions + * @param string $file Filesystem path or filename + * @return string Description of file from $wp_file_descriptions or basename of $file if description doesn't exist */ function get_file_description( $file ) { global $wp_file_descriptions; @@ -55,18 +62,19 @@ function get_file_description( $file ) { elseif ( file_exists( $file ) && is_file( $file ) ) { $template_data = implode( '', file( $file ) ); if ( preg_match( '|Template Name:(.*)$|mi', $template_data, $name )) - return _cleanup_header_comment($name[1]) . ' Page Template'; + return sprintf( __( '%s Page Template' ), _cleanup_header_comment($name[1]) ); } return basename( $file ); } /** - * {@internal Missing Short Description}} + * Get the absolute filesystem path to the root of the WordPress installation * - * @since unknown + * @since 1.5.0 * - * @return unknown + * @uses get_option + * @return string Full filesystem path to the root of the WordPress installation */ function get_home_path() { $home = get_option( 'home' ); @@ -84,12 +92,18 @@ function get_home_path() { } /** - * {@internal Missing Short Description}} + * Get the real file system path to a file to edit within the admin * - * @since unknown + * If the $file is index.php or .htaccess this function will assume it is relative + * to the install root, otherwise it is assumed the file is relative to the wp-content + * directory * - * @param unknown_type $file - * @return unknown + * @since 1.5.0 + * + * @uses get_home_path + * @uses WP_CONTENT_DIR full filesystem path to the wp-content directory + * @param string $file filesystem path relative to the WordPress install directory or to the wp-content directory + * @return string full file system path to edit */ function get_real_file_to_edit( $file ) { if ('index.php' == $file || '.htaccess' == $file ) { @@ -201,13 +215,17 @@ function wp_tempnam($filename = '', $dir = '') { } /** - * {@internal Missing Short Description}} + * Make sure that the file that was requested to edit, is allowed to be edited + * + * Function will die if if you are not allowed to edit the file * - * @since unknown + * @since 1.5.0 * - * @param unknown_type $file - * @param unknown_type $allowed_files - * @return unknown + * @uses wp_die + * @uses validate_file + * @param string $file file the users is attempting to edit + * @param array $allowed_files Array of allowed files to edit, $file must match an entry exactly + * @return null */ function validate_file_to_edit( $file, $allowed_files = '' ) { $code = validate_file( $file, $allowed_files ); @@ -228,10 +246,19 @@ function validate_file_to_edit( $file, $allowed_files = '' ) { } /** - * {@internal Missing Short Description}} + * Handle PHP uploads in WordPress, sanitizing file names, checking extensions for mime type, + * and moving the file to the appropriate directory within the uploads directory. * - * @since unknown + * @since 2.0 * + * @uses wp_handle_upload_error + * @uses apply_filters + * @uses is_multisite + * @uses wp_check_filetype_and_ext + * @uses current_user_can + * @uses wp_upload_dir + * @uses wp_unique_filename + * @uses delete_transient * @param array $file Reference to a single element of $_FILES. Call the function once for each uploaded file. * @param array $overrides Optional. An associative array of names=>values to override default variables with extract( $overrides, EXTR_OVERWRITE ). * @return array On success, returns an associative array of file attributes. On failure, returns $overrides['upload_error_handler'](&$file, $message ) or array( 'error'=>$message ). @@ -315,7 +342,7 @@ function wp_handle_upload( &$file, $overrides = false, $time = null ) { $file['name'] = $proper_filename; if ( ( !$type || !$ext ) && !current_user_can( 'unfiltered_upload' ) ) - return call_user_func($upload_error_handler, $file, __( 'File type does not meet security guidelines. Try another.' )); + return call_user_func($upload_error_handler, $file, __( 'Sorry, this file type is not permitted for security reasons.' )); if ( !$ext ) $ext = ltrim(strrchr($file['name'], '.'), '.'); @@ -352,15 +379,21 @@ function wp_handle_upload( &$file, $overrides = false, $time = null ) { } /** - * {@internal Missing Short Description}} - * - * Pass this function an array similar to that of a $_FILES POST array. + * Handle sideloads, which is the process of retriving a media item from another server instead of + * a traditional media upload. This process involves sanitizing the filename, checking extensions + * for mime type, and moving the file to the appropriate directory within the uploads directory. * - * @since unknown + * @since 2.6.0 * - * @param unknown_type $file - * @param unknown_type $overrides - * @return unknown + * @uses wp_handle_upload_error + * @uses apply_filters + * @uses wp_check_filetype_and_ext + * @uses current_user_can + * @uses wp_upload_dir + * @uses wp_unique_filename + * @param array $file an array similar to that of a PHP $_FILES POST array + * @param array $overrides Optional. An associative array of names=>values to override default variables with extract( $overrides, EXTR_OVERWRITE ). + * @return array On success, returns an associative array of file attributes. On failure, returns $overrides['upload_error_handler'](&$file, $message ) or array( 'error'=>$message ). */ function wp_handle_sideload( &$file, $overrides = false ) { // The default error handler. @@ -429,7 +462,7 @@ function wp_handle_sideload( &$file, $overrides = false ) { $file['name'] = $proper_filename; if ( ( !$type || !$ext ) && !current_user_can( 'unfiltered_upload' ) ) - return $upload_error_handler( $file, __( 'File type does not meet security guidelines. Try another.' )); + return $upload_error_handler( $file, __( 'Sorry, this file type is not permitted for security reasons.' )); if ( !$ext ) $ext = ltrim(strrchr($file['name'], '.'), '.'); @@ -474,9 +507,10 @@ function wp_handle_sideload( &$file, $overrides = false ) { * @since 2.5.0 * * @param string $url the URL of the file to download + * @param int $timeout The timeout for the request to download the file default 300 seconds * @return mixed WP_Error on failure, string Filename on success. */ -function download_url( $url ) { +function download_url( $url, $timeout = 300 ) { //WARNING: The file is not automatically deleted, The script must unlink() the file. if ( ! $url ) return new WP_Error('http_no_url', __('Invalid URL Provided.')); @@ -489,7 +523,7 @@ function download_url( $url ) { if ( ! $handle ) return new WP_Error('http_no_file', __('Could not create Temporary file.')); - $response = wp_remote_get($url, array('timeout' => 300)); + $response = wp_remote_get($url, array('timeout' => $timeout)); if ( is_wp_error($response) ) { fclose($handle); @@ -936,8 +970,8 @@ function request_filesystem_credentials($form_post, $type = '', $error = false, if ( $error ) { $error_string = __('Error: There was an error connecting to the server, Please verify the settings are correct.'); if ( is_wp_error($error) ) - $error_string = $error->get_error_message(); - echo '

      ' . esc_html( $error_string ) . '

      '; + $error_string = esc_html( $error->get_error_message() ); + echo '

      ' . $error_string . '

      '; } $types = array(); @@ -971,7 +1005,7 @@ jQuery(function($){

      '; } +submit_button( __( 'Proceed' ), 'button', 'upgrade' ); ?> -

      - -

      error = __('Cannot load image metadata.'); @@ -492,7 +493,7 @@ function wp_restore_image($post_id) { } function wp_save_image($post_id) { - $return = ''; + $return = new stdClass; $success = $delete = $scaled = $nocrop = false; $post = get_post($post_id); @ini_set('memory_limit', '256M'); diff --git a/wp-admin/includes/import.php b/wp-admin/includes/import.php index c323cdd0..51861bdc 100644 --- a/wp-admin/includes/import.php +++ b/wp-admin/includes/import.php @@ -56,7 +56,7 @@ function wp_import_cleanup( $id ) { * * @since 2.0.0 * - * @return array + * @return array Uploaded file's details on success, error message on failure */ function wp_import_handle_upload() { if ( !isset($_FILES['import']) ) { @@ -73,7 +73,7 @@ function wp_import_handle_upload() { $url = $file['url']; $type = $file['type']; - $file = addslashes( $file['file'] ); + $file = $file['file']; $filename = basename( $file ); // Construct the object array diff --git a/wp-admin/includes/internal-linking.php b/wp-admin/includes/internal-linking.php new file mode 100644 index 00000000..b2e60a20 --- /dev/null +++ b/wp-admin/includes/internal-linking.php @@ -0,0 +1,124 @@ + true ), 'objects' ); + $pt_names = array_keys( $pts ); + + $query = array( + 'post_type' => $pt_names, + 'suppress_filters' => true, + 'update_post_term_cache' => false, + 'update_post_meta_cache' => false, + 'post_status' => 'publish', + 'order' => 'DESC', + 'orderby' => 'post_date', + 'posts_per_page' => 20, + ); + + $args['pagenum'] = isset( $args['pagenum'] ) ? absint( $args['pagenum'] ) : 1; + + if ( isset( $args['s'] ) ) + $query['s'] = $args['s']; + + $query['offset'] = $args['pagenum'] > 1 ? $query['posts_per_page'] * ( $args['pagenum'] - 1 ) : 0; + + // Do main query. + $get_posts = new WP_Query; + $posts = $get_posts->query( $query ); + // Check if any posts were found. + if ( ! $get_posts->post_count ) + return false; + + // Build results. + $results = array(); + foreach ( $posts as $post ) { + if ( 'post' == $post->post_type ) + $info = mysql2date( __( 'Y/m/d' ), $post->post_date ); + else + $info = $pts[ $post->post_type ]->labels->singular_name; + + $results[] = array( + 'ID' => $post->ID, + 'title' => trim( esc_html( strip_tags( get_the_title( $post ) ) ) ), + 'permalink' => get_permalink( $post->ID ), + 'info' => $info, + ); + } + + return $results; +} + +/** + * Dialog for internal linking. + * + * @since 3.1.0 + */ +function wp_link_dialog() { +?> + + \ No newline at end of file diff --git a/wp-admin/includes/list-table.php b/wp-admin/includes/list-table.php new file mode 100644 index 00000000..716e80ac --- /dev/null +++ b/wp-admin/includes/list-table.php @@ -0,0 +1,104 @@ + 'posts', + 'WP_Media_List_Table' => 'media', + 'WP_Terms_List_Table' => 'terms', + 'WP_Users_List_Table' => 'users', + 'WP_Comments_List_Table' => 'comments', + 'WP_Post_Comments_List_Table' => 'comments', + 'WP_Links_List_Table' => 'links', + 'WP_Plugin_Install_List_Table' => 'plugin-install', + 'WP_Themes_List_Table' => 'themes', + 'WP_Theme_Install_List_Table' => 'theme-install', + 'WP_Plugins_List_Table' => 'plugins', + // Network Admin + 'WP_MS_Sites_List_Table' => 'ms-sites', + 'WP_MS_Users_List_Table' => 'ms-users', + 'WP_MS_Themes_List_Table' => 'ms-themes', + ); + + if ( isset( $core_classes[ $class ] ) ) { + require_once( ABSPATH . 'wp-admin/includes/class-wp-' . $core_classes[ $class ] . '-list-table.php' ); + return new $class; + } + + return false; +} + +/** + * Register column headers for a particular screen. + * + * @since 2.7.0 + * + * @param string $screen The handle for the screen to add help to. This is usually the hook name returned by the add_*_page() functions. + * @param array $columns An array of columns with column IDs as the keys and translated column names as the values + * @see get_column_headers(), print_column_headers(), get_hidden_columns() + */ +function register_column_headers($screen, $columns) { + $wp_list_table = new _WP_List_Table_Compat($screen, $columns); +} + +/** + * Prints column headers for a particular screen. + * + * @since 2.7.0 + */ +function print_column_headers($screen, $id = true) { + $wp_list_table = new _WP_List_Table_Compat($screen); + + $wp_list_table->print_column_headers($id); +} + +/** + * Helper class to be used only by back compat functions + * + * @since 3.1.0 + */ +class _WP_List_Table_Compat extends WP_List_Table { + var $_screen; + var $_columns; + + function _WP_List_Table_Compat( $screen, $columns = array() ) { + if ( is_string( $screen ) ) + $screen = convert_to_screen( $screen ); + + $this->_screen = $screen; + + if ( !empty( $columns ) ) { + $this->_columns = $columns; + add_filter( 'manage_' . $screen->id . '_columns', array( &$this, 'get_columns' ), 0 ); + } + } + + function get_column_info() { + $columns = get_column_headers( $this->_screen ); + $hidden = get_hidden_columns( $this->_screen ); + $sortable = array(); + + return array( $columns, $hidden, $sortable ); + } + + function get_columns() { + return $this->_columns; + } +} +?> \ No newline at end of file diff --git a/wp-admin/includes/manifest.php b/wp-admin/includes/manifest.php index 45348765..600b5dbd 100644 --- a/wp-admin/includes/manifest.php +++ b/wp-admin/includes/manifest.php @@ -39,7 +39,6 @@ function &get_manifest() { array('images/icons32.png'), array('images/icons32-vs.png'), array('images/list.png'), - array('images/list-vs.png'), array('images/wpspin_light.gif'), array('images/wpspin_dark.gif'), array('images/logo.gif'), @@ -175,7 +174,6 @@ function &get_manifest() { array('../wp-includes/js/tinymce/plugins/inlinepopups/skins/clearlooks2/img/confirm.gif'), array('../wp-includes/js/tinymce/plugins/inlinepopups/skins/clearlooks2/img/vertical.gif'), array('../wp-includes/js/tinymce/plugins/media/img/flash.gif'), - array('../wp-includes/js/tinymce/plugins/media/img/flv_player.swf'), array('../wp-includes/js/tinymce/plugins/media/img/quicktime.gif'), array('../wp-includes/js/tinymce/plugins/media/img/realmedia.gif'), array('../wp-includes/js/tinymce/plugins/media/img/shockwave.gif'), diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php index 2bebcc86..5a13bcc2 100644 --- a/wp-admin/includes/media.php +++ b/wp-admin/includes/media.php @@ -9,7 +9,7 @@ /** * {@internal Missing Short Description}} * - * @since unknown + * @since 2.5.0 * * @return unknown */ @@ -27,7 +27,7 @@ function media_upload_tabs() { /** * {@internal Missing Short Description}} * - * @since unknown + * @since 2.5.0 * * @param unknown_type $tabs * @return unknown @@ -59,7 +59,7 @@ add_filter('media_upload_tabs', 'update_gallery_tab'); /** * {@internal Missing Short Description}} * - * @since unknown + * @since 2.5.0 */ function the_media_upload_tabs() { global $redir_tab; @@ -89,7 +89,7 @@ function the_media_upload_tabs() { /** * {@internal Missing Short Description}} * - * @since unknown + * @since 2.5.0 * * @param unknown_type $id * @param unknown_type $alt @@ -117,7 +117,7 @@ function get_image_send_to_editor($id, $caption, $title, $align, $url='', $rel = /** * {@internal Missing Short Description}} * - * @since unknown + * @since 2.6.0 * * @param unknown_type $html * @param unknown_type $id @@ -140,6 +140,11 @@ function image_add_caption( $html, $id, $caption, $title, $align, $url, $size, $ $width = $matches[1]; + $caption = str_replace( array( '>', '<', '"', "'" ), + array( '>', '<', '"', ''' ), + $caption + ); + $html = preg_replace( '/(class=["\'][^\'"]*)align(none|left|right|center)\s?/', '$1', $html ); if ( empty($align) ) $align = 'none'; @@ -154,7 +159,7 @@ add_filter( 'image_send_to_editor', 'image_add_caption', 20, 8 ); /** * {@internal Missing Short Description}} * - * @since unknown + * @since 2.5.0 * * @param unknown_type $html */ @@ -175,7 +180,7 @@ win.send_to_editor(''); * * This handles the file upload POST itself, creating the attachment post. * - * @since unknown + * @since 2.5.0 * * @param string $file_id Index into the {@link $_FILES} array of the upload * @param int $post_id The post ID the media is associated with @@ -234,15 +239,15 @@ function media_handle_upload($file_id, $post_id, $post_data = array(), $override } /** - * {@internal Missing Short Description}} + * This handles a sideloaded file in the same way as an uploaded file is handled by {@link media_handle_upload()} * - * @since unknown + * @since 2.6.0 * - * @param unknown_type $file_array - * @param unknown_type $post_id - * @param unknown_type $desc - * @param unknown_type $post_data - * @return unknown + * @param array $file_array Array similar to a {@link $_FILES} upload array + * @param int $post_id The post ID the media is associated with + * @param string $desc Description of the sideloaded file + * @param array $post_data allows you to overwrite some of the attachment + * @return int|object The ID of the attachment or a WP_Error on failure */ function media_handle_sideload($file_array, $post_id, $desc = null, $post_data = array()) { $overrides = array('test_form'=>false); @@ -265,7 +270,7 @@ function media_handle_sideload($file_array, $post_id, $desc = null, $post_data = $content = $image_meta['caption']; } - $title = @$desc; + $title = isset($desc) ? $desc : ''; // Construct the attachment array $attachment = array_merge( array( @@ -278,10 +283,9 @@ function media_handle_sideload($file_array, $post_id, $desc = null, $post_data = // Save the attachment metadata $id = wp_insert_attachment($attachment, $file, $post_id); - if ( !is_wp_error($id) ) { + if ( !is_wp_error($id) ) wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) ); - return $url; - } + return $id; } @@ -291,7 +295,7 @@ function media_handle_sideload($file_array, $post_id, $desc = null, $post_data = * Wrap iframe content (produced by $content_func) in a doctype, html head/body * etc any additional function args will be passed to content_func. * - * @since unknown + * @since 2.5.0 * * @param unknown_type $content_func */ @@ -307,7 +311,8 @@ wp_enqueue_style( 'global' ); wp_enqueue_style( 'wp-admin' ); wp_enqueue_style( 'colors' ); // Check callback name for 'media' -if ( ( is_array( $content_func ) && ! empty( $content_func[1] ) && 0 === strpos( (string) $content_func[1], 'media' ) ) || 0 === strpos( $content_func, 'media' ) ) +if ( ( is_array( $content_func ) && ! empty( $content_func[1] ) && 0 === strpos( (string) $content_func[1], 'media' ) ) + || ( ! is_array( $content_func ) && 0 === strpos( $content_func, 'media' ) ) ) wp_enqueue_style( 'media' ); wp_enqueue_style( 'ie' ); ?> @@ -315,7 +320,8 @@ wp_enqueue_style( 'ie' ); //','uid':'ID; ?>','time':''}; -var ajaxurl = '', pagenow = 'media-upload-popup', adminpage = 'media-upload-popup'; +var ajaxurl = '', pagenow = 'media-upload-popup', adminpage = 'media-upload-popup', +isRtl = ; //]]> $title"; + return "$title"; } function get_upload_iframe_src($type) { @@ -397,7 +403,7 @@ function get_upload_iframe_src($type) { /** * {@internal Missing Short Description}} * - * @since unknown + * @since 2.5.0 * * @return unknown */ @@ -484,7 +490,7 @@ function media_upload_form_handler() { /** * {@internal Missing Short Description}} * - * @since unknown + * @since 2.5.0 * * @return unknown */ @@ -493,7 +499,6 @@ function media_upload_image() { $id = 0; if ( isset($_POST['html-upload']) && !empty($_FILES) ) { - check_admin_referer('media-form'); // Upload File button was clicked $id = media_handle_upload('async-upload', $_REQUEST['post_id']); unset($_FILES); @@ -542,19 +547,19 @@ function media_upload_image() { } /** - * {@internal Missing Short Description}} + * Download an image from the specified URL and attach it to a post. * - * @since unknown + * @since 2.6.0 * - * @param unknown_type $file - * @param unknown_type $post_id - * @param unknown_type $desc - * @return unknown + * @param string $file The URL of the image to download + * @param int $post_id The post ID the media is to be associated with + * @param string $desc Optional. Description of the image + * @return string|WP_Error Populated HTML img tag on success */ function media_sideload_image($file, $post_id, $desc = null) { - if (!empty($file) ) { + if ( ! empty($file) ) { // Download file to temp location - $tmp = download_url($file); + $tmp = download_url( $file ); // Set variables for storage // fix file filename for query strings @@ -563,25 +568,25 @@ function media_sideload_image($file, $post_id, $desc = null) { $file_array['tmp_name'] = $tmp; // If error storing temporarily, unlink - if ( is_wp_error($tmp) ) { + if ( is_wp_error( $tmp ) ) { @unlink($file_array['tmp_name']); $file_array['tmp_name'] = ''; } // do the validation and storage stuff - $id = media_handle_sideload($file_array, $post_id, @$desc); - $src = $id; - + $id = media_handle_sideload( $file_array, $post_id, $desc ); // If error storing permanently, unlink if ( is_wp_error($id) ) { @unlink($file_array['tmp_name']); return $id; } + + $src = wp_get_attachment_url( $id ); } // Finally check to make sure the file has been saved, then return the html - if ( !empty($src) ) { - $alt = @$desc; + if ( ! empty($src) ) { + $alt = isset($desc) ? esc_attr($desc) : ''; $html = "$alt"; return $html; } @@ -590,7 +595,7 @@ function media_sideload_image($file, $post_id, $desc = null) { /** * {@internal Missing Short Description}} * - * @since unknown + * @since 2.5.0 * * @return unknown */ @@ -599,7 +604,6 @@ function media_upload_audio() { $id = 0; if ( isset($_POST['html-upload']) && !empty($_FILES) ) { - check_admin_referer('media-form'); // Upload File button was clicked $id = media_handle_upload('async-upload', $_REQUEST['post_id']); unset($_FILES); @@ -649,7 +653,7 @@ function media_upload_audio() { /** * {@internal Missing Short Description}} * - * @since unknown + * @since 2.5.0 * * @return unknown */ @@ -658,7 +662,6 @@ function media_upload_video() { $id = 0; if ( isset($_POST['html-upload']) && !empty($_FILES) ) { - check_admin_referer('media-form'); // Upload File button was clicked $id = media_handle_upload('async-upload', $_REQUEST['post_id']); unset($_FILES); @@ -708,7 +711,7 @@ function media_upload_video() { /** * {@internal Missing Short Description}} * - * @since unknown + * @since 2.5.0 * * @return unknown */ @@ -717,7 +720,6 @@ function media_upload_file() { $id = 0; if ( isset($_POST['html-upload']) && !empty($_FILES) ) { - check_admin_referer('media-form'); // Upload File button was clicked $id = media_handle_upload('async-upload', $_REQUEST['post_id']); unset($_FILES); @@ -764,7 +766,7 @@ function media_upload_file() { /** * {@internal Missing Short Description}} * - * @since unknown + * @since 2.5.0 * * @return unknown */ @@ -787,7 +789,7 @@ function media_upload_gallery() { /** * {@internal Missing Short Description}} * - * @since unknown + * @since 2.5.0 * * @return unknown */ @@ -808,7 +810,7 @@ function media_upload_library() { /** * Retrieve HTML for the image alignment radio buttons with the specified one checked. * - * @since unknown + * @since 2.7.0 * * @param unknown_type $post * @param unknown_type $checked @@ -836,10 +838,10 @@ function image_align_input_fields( $post, $checked = '' ) { /** * Retrieve HTML for the size radio buttons with the specified one checked. * - * @since unknown + * @since 2.7.0 * * @param unknown_type $post - * @param unknown_type $checked + * @param unknown_type $check * @return unknown */ function image_size_input_fields( $post, $check = '' ) { @@ -891,7 +893,7 @@ function image_size_input_fields( $post, $check = '' ) { /** * Retrieve HTML for the Link URL buttons with the default link type as specified. * - * @since unknown + * @since 2.7.0 * * @param unknown_type $post * @param unknown_type $url_type @@ -922,7 +924,7 @@ function image_link_input_fields($post, $url_type = '') { /** * {@internal Missing Short Description}} * - * @since unknown + * @since 2.5.0 * * @param unknown_type $form_fields * @param unknown_type $post @@ -961,7 +963,7 @@ add_filter('attachment_fields_to_edit', 'image_attachment_fields_to_edit', 10, 2 /** * {@internal Missing Short Description}} * - * @since unknown + * @since 2.5.0 * * @param unknown_type $form_fields * @param unknown_type $post @@ -972,6 +974,15 @@ function media_single_attachment_fields_to_edit( $form_fields, $post ) { return $form_fields; } +/** + * {@internal Missing Short Description}} + * + * @since 2.8.0 + * + * @param unknown_type $form_fields + * @param unknown_type $post + * @return unknown + */ function media_post_single_attachment_fields_to_edit( $form_fields, $post ) { unset($form_fields['image_url']); return $form_fields; @@ -980,7 +991,7 @@ function media_post_single_attachment_fields_to_edit( $form_fields, $post ) { /** * {@internal Missing Short Description}} * - * @since unknown + * @since 2.5.0 * * @param unknown_type $post * @param unknown_type $attachment @@ -1002,7 +1013,7 @@ add_filter('attachment_fields_to_save', 'image_attachment_fields_to_save', 10, 2 /** * {@internal Missing Short Description}} * - * @since unknown + * @since 2.5.0 * * @param unknown_type $html * @param unknown_type $attachment_id @@ -1029,7 +1040,7 @@ add_filter('media_send_to_editor', 'image_media_send_to_editor', 10, 3); /** * {@internal Missing Short Description}} * - * @since unknown + * @since 2.5.0 * * @param unknown_type $post * @param unknown_type $errors @@ -1083,6 +1094,8 @@ function get_attachment_fields_to_edit($post, $errors = null) { foreach ( get_attachment_taxonomies($post) as $taxonomy ) { $t = (array) get_taxonomy($taxonomy); + if ( ! $t['public'] ) + continue; if ( empty($t['label']) ) $t['label'] = $taxonomy; if ( empty($t['args']) ) @@ -1117,7 +1130,7 @@ function get_attachment_fields_to_edit($post, $errors = null) { * component. Will also create link for showing and hiding the form to modify * the image attachment. * - * @since unknown + * @since 2.5.0 * * @param int $post_id Optional. Post ID. * @param array $errors Errors for attachment, if any. @@ -1151,7 +1164,7 @@ function get_media_items( $post_id, $errors ) { /** * Retrieve HTML form for modifying the image attachment. * - * @since unknown + * @since 2.5.0 * * @param int $attachment_id Attachment ID for modification. * @param string|array $args Optional. Override defaults. @@ -1167,8 +1180,9 @@ function get_media_item( $attachment_id, $args = null ) { $post = get_post( $attachment_id ); - $default_args = array( 'errors' => null, 'send' => post_type_supports(get_post_type($post->post_parent), 'editor'), 'delete' => true, 'toggle' => true, 'show_title' => true ); + $default_args = array( 'errors' => null, 'send' => $post->post_parent ? post_type_supports( get_post_type( $post->post_parent ), 'editor' ) : true, 'delete' => true, 'toggle' => true, 'show_title' => true ); $args = wp_parse_args( $args, $default_args ); + $args = apply_filters( 'get_media_item_args', $args ); extract( $args, EXTR_SKIP ); $toggle_on = __( 'Show' ); @@ -1269,7 +1283,7 @@ function get_media_item( $attachment_id, $args = null ) { ); if ( $send ) - $send = ""; + $send = get_submit_button( __( 'Insert into Post' ), 'button', "send[$attachment_id]", false ); if ( $delete && current_user_can( 'delete_post', $attachment_id ) ) { if ( !EMPTY_TRASH_DAYS ) { $delete = "" . __( 'Delete Permanently' ) . ''; @@ -1304,7 +1318,7 @@ function get_media_item( $attachment_id, $args = null ) { $hidden_fields = array(); foreach ( $form_fields as $id => $field ) { - if ( $id{0} == '_' ) + if ( $id[0] == '_' ) continue; if ( !empty( $field['tr'] ) ) { @@ -1329,7 +1343,10 @@ function get_media_item( $attachment_id, $args = null ) { if ( !empty( $field[ $field['input'] ] ) ) $item .= $field[ $field['input'] ]; elseif ( $field['input'] == 'textarea' ) { - $item .= "'; + if ( user_can_richedit() ) { // textarea_escaped when user_can_richedit() = false + $field['value'] = esc_textarea( $field['value'] ); + } + $item .= "'; } else { $item .= ""; } @@ -1373,7 +1390,7 @@ function get_media_item( $attachment_id, $args = null ) { /** * {@internal Missing Short Description}} * - * @since unknown + * @since 2.5.0 */ function media_upload_header() { ?> @@ -1387,12 +1404,12 @@ function media_upload_header() { /** * {@internal Missing Short Description}} * - * @since unknown + * @since 2.5.0 * * @param unknown_type $errors */ function media_upload_form( $errors = null ) { - global $type, $tab; + global $type, $tab, $pagenow; $flash_action_url = admin_url('async-upload.php'); @@ -1444,7 +1461,36 @@ if ( is_multisite() && !is_upload_space_available() ) { do_action('pre-upload-ui'); -if ( $flash ) : ?> +if ( $flash ) : + +// Set the post params, which SWFUpload will post back with the file, and pass +// them through a filter. +$post_params = array( + "post_id" => $post_id, + "auth_cookie" => (is_ssl() ? $_COOKIE[SECURE_AUTH_COOKIE] : $_COOKIE[AUTH_COOKIE]), + "logged_in_cookie" => $_COOKIE[LOGGED_IN_COOKIE], + "_wpnonce" => wp_create_nonce('media-form'), + "type" => $type, + "tab" => $tab, + "short" => "1", +); +$post_params = apply_filters( 'swfupload_post_params', $post_params ); +$p = array(); +foreach ( $post_params as $param => $val ) + $p[] = "\t\t'$param' : '$val'"; +$post_params_str = implode( ", \n", $p ); + +// #8545. wmode=transparent cannot be used with SWFUpload +if ( 'media-new.php' == $pagenow ) { + $upload_image_path = get_user_option( 'admin_color' ); + if ( 'classic' != $upload_image_path ) + $upload_image_path = 'fresh'; + $upload_image_path = admin_url( 'images/upload-' . $upload_image_path . '.png?ver=20101205' ); +} else { + $upload_image_path = includes_url( 'images/upload.png?ver=20100531' ); +} + +?> post_type ); // TODO: ROLE SYSTEM - if ( $post->post_author && !in_array($post->post_author, $authors) ) - $authors[] = $post->post_author; ?> - $authors, 'name' => 'post_author_override', 'selected' => empty($post->ID) ? $user_ID : $post->post_author) ); ?> + 'authors', + 'name' => 'post_author_override', + 'selected' => empty($post->ID) ? $user_ID : $post->post_author, + 'include_selected' => true + ) ); } @@ -578,7 +600,7 @@ function link_submit_meta_box($link) {
      - +
      @@ -862,7 +884,7 @@ function link_advanced_meta_box($link) { - + diff --git a/wp-admin/includes/misc.php b/wp-admin/includes/misc.php index 1ecb3a05..d8ab0fca 100644 --- a/wp-admin/includes/misc.php +++ b/wp-admin/includes/misc.php @@ -9,7 +9,7 @@ /** * {@internal Missing Short Description}} * - * @since unknown + * @since 2.0.0 * * @return unknown */ @@ -21,7 +21,7 @@ function got_mod_rewrite() { /** * {@internal Missing Short Description}} * - * @since unknown + * @since 1.5.0 * * @param unknown_type $filename * @param unknown_type $marker @@ -57,7 +57,7 @@ function extract_from_markers( $filename, $marker ) { * BEGIN and END markers. Replaces existing marked info. Retains surrounding * data. Creates file if none exists. * - * @since unknown + * @since 1.5.0 * * @param unknown_type $filename * @param unknown_type $marker @@ -117,7 +117,7 @@ function insert_with_markers( $filename, $marker, $insertion ) { * Always writes to the file if it exists and is writable to ensure that we * blank out old rules. * - * @since unknown + * @since 1.5.0 */ function save_mod_rewrite_rules() { if ( is_multisite() ) @@ -149,20 +149,21 @@ function save_mod_rewrite_rules() { * @return bool True if web.config was updated successfully */ function iis7_save_url_rewrite_rules(){ + if ( is_multisite() ) + return; + global $wp_rewrite; $home_path = get_home_path(); $web_config_file = $home_path . 'web.config'; // Using win_is_writable() instead of is_writable() because of a bug in Windows PHP - if ( ( ! file_exists($web_config_file) && win_is_writable($home_path) && $wp_rewrite->using_mod_rewrite_permalinks() ) || win_is_writable($web_config_file) ) { - if ( iis7_supports_permalinks() ) { - $rule = $wp_rewrite->iis7_url_rewrite_rules(false, '', ''); - if ( ! empty($rule) ) { - return iis7_add_rewrite_rule($web_config_file, $rule); - } else { - return iis7_delete_rewrite_rule($web_config_file); - } + if ( iis7_supports_permalinks() && ( ( ! file_exists($web_config_file) && win_is_writable($home_path) && $wp_rewrite->using_mod_rewrite_permalinks() ) || win_is_writable($web_config_file) ) ) { + $rule = $wp_rewrite->iis7_url_rewrite_rules(false, '', ''); + if ( ! empty($rule) ) { + return iis7_add_rewrite_rule($web_config_file, $rule); + } else { + return iis7_delete_rewrite_rule($web_config_file); } } return false; @@ -171,7 +172,7 @@ function iis7_save_url_rewrite_rules(){ /** * {@internal Missing Short Description}} * - * @since unknown + * @since 1.5.0 * * @param unknown_type $file */ @@ -193,7 +194,7 @@ function update_recently_edited( $file ) { /** * If siteurl or home changed, flush rewrite rules. * - * @since unknown + * @since 2.1.0 * * @param unknown_type $old_value * @param unknown_type $value @@ -212,12 +213,12 @@ add_action( 'update_option_home', 'update_home_siteurl', 10, 2 ); add_action( 'update_option_siteurl', 'update_home_siteurl', 10, 2 ); /** - * {@internal Missing Short Description}} + * Shorten an URL, to be used as link text * - * @since unknown + * @since 1.2.1 * - * @param unknown_type $url - * @return unknown + * @param string $url + * @return string */ function url_shorten( $url ) { $short_url = str_replace( 'http://', '', stripslashes( $url )); @@ -236,7 +237,7 @@ function url_shorten( $url ) { * in the $vars array to the value of $_POST[$var] or $_GET[$var] or '' * if neither is defined. * - * @since unknown + * @since 2.0.0 * * @param array $vars An array of globals to reset. */ @@ -259,7 +260,7 @@ function wp_reset_vars( $vars ) { /** * {@internal Missing Short Description}} * - * @since unknown + * @since 2.1.0 * * @param unknown_type $message */ @@ -343,12 +344,18 @@ function set_screen_options() { switch ( $map_option ) { case 'edit_per_page': - case 'ms_sites_per_page': - case 'ms_users_per_page': + case 'users_per_page': case 'edit_comments_per_page': case 'upload_per_page': case 'edit_tags_per_page': case 'plugins_per_page': + // Network admin + case 'sites_network_per_page': + case 'users_network_per_page': + case 'site_users_network_per_page': + case 'plugins_network_per_page': + case 'themes_network_per_page': + case 'site_themes_network_per_page': $value = (int) $value; if ( $value < 1 || $value > 999 ) return; @@ -374,34 +381,6 @@ function wp_menu_unfold() { } } -/** - * Check if IIS 7 supports pretty permalinks - * - * @since 2.8.0 - * - * @return bool - */ -function iis7_supports_permalinks() { - global $is_iis7; - - $supports_permalinks = false; - if ( $is_iis7 ) { - /* First we check if the DOMDocument class exists. If it does not exist, - * which is the case for PHP 4.X, then we cannot easily update the xml configuration file, - * hence we just bail out and tell user that pretty permalinks cannot be used. - * This is not a big issue because PHP 4.X is going to be depricated and for IIS it - * is recommended to use PHP 5.X NTS. - * Next we check if the URL Rewrite Module 1.1 is loaded and enabled for the web site. When - * URL Rewrite 1.1 is loaded it always sets a server variable called 'IIS_UrlRewriteModule'. - * Lastly we make sure that PHP is running via FastCGI. This is important because if it runs - * via ISAPI then pretty permalinks will not work. - */ - $supports_permalinks = class_exists('DOMDocument') && isset($_SERVER['IIS_UrlRewriteModule']) && ( php_sapi_name() == 'cgi-fcgi' ); - } - - return apply_filters('iis7_supports_permalinks', $supports_permalinks); -} - /** * Check if rewrite rule for WordPress already exists in the IIS 7 configuration file * @@ -561,29 +540,29 @@ function saveDomDocument($doc, $filename) { * * @since 2.8.0 * - * @param object $path + * @param string $path * @return bool */ -function win_is_writable($path) { +function win_is_writable( $path ) { /* will work in despite of Windows ACLs bug * NOTE: use a trailing slash for folders!!! * see http://bugs.php.net/bug.php?id=27609 * see http://bugs.php.net/bug.php?id=30931 */ - if ( $path{strlen($path)-1} == '/' ) // recursively return a temporary file path - return win_is_writable($path . uniqid(mt_rand()) . '.tmp'); - else if ( is_dir($path) ) - return win_is_writable($path . '/' . uniqid(mt_rand()) . '.tmp'); - // check tmp file for read/write capabilities - $rm = file_exists($path); - $f = @fopen($path, 'a'); - if ($f===false) - return false; - fclose($f); - if ( ! $rm ) - unlink($path); - return true; + if ( $path[strlen( $path ) - 1] == '/' ) // recursively return a temporary file path + return win_is_writable( $path . uniqid( mt_rand() ) . '.tmp'); + else if ( is_dir( $path ) ) + return win_is_writable( $path . '/' . uniqid( mt_rand() ) . '.tmp' ); + // check tmp file for read/write capabilities + $should_delete_tmp_file = !file_exists( $path ); + $f = @fopen( $path, 'a' ); + if ( $f === false ) + return false; + fclose( $f ); + if ( $should_delete_tmp_file ) + unlink( $path ); + return true; } /** diff --git a/wp-admin/includes/ms.php b/wp-admin/includes/ms.php index 8009d7d2..84585264 100644 --- a/wp-admin/includes/ms.php +++ b/wp-admin/includes/ms.php @@ -65,12 +65,12 @@ function wpmu_delete_blog( $blog_id, $drop = false ) { do_action( 'delete_blog', $blog_id, $drop ); - $users = get_users_of_blog( $blog_id ); + $users = get_users( array( 'blog_id' => $blog_id, 'fields' => 'ids' ) ); // Remove users from this blog. if ( ! empty( $users ) ) { - foreach ( $users as $user ) { - remove_user_from_blog( $user->user_id, $blog_id) ; + foreach ( $users as $user_id ) { + remove_user_from_blog( $user_id, $blog_id) ; } } @@ -177,72 +177,6 @@ function wpmu_delete_user( $id ) { return true; } -function confirm_delete_users( $users ) { - $current_user = wp_get_current_user(); - if ( !is_array( $users ) ) - return false; - - screen_icon(); - ?> -

      -

      -
      - - ID'>$current_user->user_login"; - - foreach ( ( $allusers = (array) $_POST['allusers'] ) as $key => $val ) { - if ( $val != '' && $val != '0' ) { - $delete_user = new WP_User( $val ); - - if ( in_array( $delete_user->user_login, $site_admins ) ) - wp_die( sprintf( __( 'Warning! User cannot be deleted. The user %s is a network admnistrator.' ), $delete_user->user_login ) ); - - echo "\n"; - $blogs = get_blogs_of_user( $val, true ); - - if ( !empty( $blogs ) ) { - ?> -

      %s?" ), $delete_user->user_login ); ?>

      - $details ) { - $blog_users = get_users_of_blog( $details->userblog_id ); - if ( is_array( $blog_users ) && !empty( $blog_users ) ) { - $user_site = "{$details->blogname}"; - $user_dropdown = "\n"; - ?> -
        -
      • -
      • -
      • -
      - "; - } - } - } - ?> -

      - - $quota ) - $percentused = '100'; - else - $percentused = ( $used / $quota ) * 100; - $used_color = ( $percentused < 70 ) ? ( ( $percentused >= 40 ) ? 'waiting' : 'approved' ) : 'spam'; - $used = round( $used, 2 ); - $percentused = number_format( $percentused ); - - ?> -

      -
      - - - - - -
      %2$sMB' ), esc_url( admin_url( 'upload.php' ) ), $quota ); ?>
      -
      -
      - - - - - -
      %2$sMB (%3$s%%)' ), esc_url( admin_url( 'upload.php' ) ), $used, $percentused ); ?>
      -
      -
      - update( $wpdb->users, array( $pref => $value ), array( 'ID' => $id ) ); - if ( $refresh == 1 ) - refresh_user_details( $id ); + clean_user_cache( $id ); if ( $pref == 'spam' ) { if ( $value == 1 ) @@ -608,30 +507,13 @@ function redirect_user_to_blog() { $c ++; $blog = get_active_blog_for_user( get_current_user_id() ); - $dashboard_blog = get_dashboard_blog(); + if ( is_object( $blog ) ) { wp_redirect( get_admin_url( $blog->blog_id, '?c=' . $c ) ); // redirect and count to 5, "just in case" - exit; - } - - /* - If the user is a member of only 1 blog and the user's primary_blog isn't set to that blog, - then update the primary_blog record to match the user's blog - */ - $blogs = get_blogs_of_user( get_current_user_id() ); - - if ( !empty( $blogs ) ) { - foreach( $blogs as $blogid => $blog ) { - if ( $blogid != $dashboard_blog->blog_id && get_user_meta( get_current_user_id() , 'primary_blog', true ) == $dashboard_blog->blog_id ) { - update_user_meta( get_current_user_id(), 'primary_blog', $blogid ); - continue; - } - } - $blog = get_blog_details( get_user_meta( get_current_user_id(), 'primary_blog', true ) ); - wp_redirect( get_admin_url( $blog->blog_id, '?c=' . $c ) ); - exit; + } else { + wp_redirect( user_admin_url( '?c=' . $c ) ); // redirect and count to 5, "just in case" } - wp_die( __( 'You do not have sufficient permissions to access this page.' ) ); + exit; } add_action( 'admin_page_access_denied', 'redirect_user_to_blog', 99 ); @@ -693,47 +575,17 @@ function secret_salt_warning() { echo "
      $msg
      "; } } -add_action( 'admin_notices', 'secret_salt_warning' ); - -function admin_notice_feed() { - global $current_screen; - if ( $current_screen->id != 'dashboard' ) - return; - - if ( !empty( $_GET['feed_dismiss'] ) ) { - update_user_option( get_current_user_id(), 'admin_feed_dismiss', $_GET['feed_dismiss'], true ); - return; - } - - $url = get_site_option( 'admin_notice_feed' ); - if ( empty( $url ) ) - return; - - $rss = fetch_feed( $url ); - if ( ! is_wp_error( $rss ) && $item = $rss->get_item() ) { - $title = $item->get_title(); - if ( md5( $title ) == get_user_option( 'admin_feed_dismiss' ) ) - return; - $msg = "

      " . esc_html( $title ) . "

      \n"; - $content = $item->get_description(); - $content = $content ? wp_html_excerpt( $content, 200 ) . ' … ' : ''; - $link = esc_url( strip_tags( $item->get_link() ) ); - $msg .= "

      " . $content . "" . __( 'Read More' ) . " " . __( 'Dismiss' ) . "

      "; - echo "
      $msg
      "; - } elseif ( is_super_admin() ) { - printf( '
      ' . __( 'Your feed at %s is empty.' ) . '
      ', esc_html( $url ) ); - } -} -add_action( 'admin_notices', 'admin_notice_feed' ); +add_action( 'network_admin_notices', 'secret_salt_warning' ); function site_admin_notice() { global $wp_db_version; if ( !is_super_admin() ) return false; if ( get_site_option( 'wpmu_upgrade_site' ) != $wp_db_version ) - echo "
      " . sprintf( __( 'Thank you for Updating! Please visit the Update Network page to update all your sites.' ), esc_url( admin_url( 'ms-upgrade-network.php' ) ) ) . "
      "; + echo "
      " . sprintf( __( 'Thank you for Updating! Please visit the Update Network page to update all your sites.' ), esc_url( network_admin_url( 'upgrade.php' ) ) ) . "
      "; } add_action( 'admin_notices', 'site_admin_notice' ); +add_action( 'network_admin_notices', 'site_admin_notice' ); function avoid_blog_page_permalink_collision( $data, $postarr ) { if ( is_subdomain_install() ) @@ -805,16 +657,6 @@ function choose_primary_blog() { " . sprintf( __( "Warning! The current theme supports Featured Images. You must enable image uploads on the options page for it to work." ), esc_url( admin_url( 'ms-options.php' ) ) ) . "
      "; - } -} -add_action( 'admin_notices', 'show_post_thumbnail_warning' ); - function ms_deprecated_blogs_file() { if ( ! is_super_admin() ) return; @@ -822,24 +664,13 @@ function ms_deprecated_blogs_file() { return; echo '
      ' . sprintf( __( 'The %1$s file is deprecated. Please remove it and update your server rewrite rules to use %2$s instead.' ), 'wp-content/blogs.php', 'wp-includes/ms-files.php' ) . '
      '; } -add_action( 'admin_notices', 'ms_deprecated_blogs_file' ); - -/** - * Outputs the notice message for multisite regarding activation of plugin page. - * - * @since 3.0.0 - * @return none - */ -function _admin_notice_multisite_activate_plugins_page() { - $message = sprintf( __( 'The plugins page is not visible to normal users. It must be activated first. %s' ), '' . __( 'Activate' ) . '' ); - echo "

      $message

      "; -} +add_action( 'network_admin_notices', 'ms_deprecated_blogs_file' ); /** * Grants super admin privileges. * * @since 3.0.0 - * @param $user_id + * @param int $user_id */ function grant_super_admin( $user_id ) { global $super_admins; @@ -867,7 +698,7 @@ function grant_super_admin( $user_id ) { * Revokes super admin privileges. * * @since 3.0.0 - * @param $user_id + * @param int $user_id */ function revoke_super_admin( $user_id ) { global $super_admins; @@ -892,4 +723,41 @@ function revoke_super_admin( $user_id ) { } return false; } + +/** + * Whether or not we can edit this network from this page + * + * By default editing of network is restricted to the Network Admin for that site_id this allows for this to be overridden + * + * @since 3.1.0 + * @param integer $site_id The network/site id to check. + */ +function can_edit_network( $site_id ) { + global $wpdb; + + if ($site_id == $wpdb->siteid ) + $result = true; + else + $result = false; + + return apply_filters( 'can_edit_network', $result, $site_id ); +} + +/** + * Thickbox image paths for Network Admin. + * + * @since 3.1.0 + * @access private + */ +function _thickbox_path_admin_subfolder() { +?> + + diff --git a/wp-admin/includes/nav-menu.php b/wp-admin/includes/nav-menu.php index 8c8e9697..6e929286 100644 --- a/wp-admin/includes/nav-menu.php +++ b/wp-admin/includes/nav-menu.php @@ -13,7 +13,6 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu { * @since 3.0.0 * * @param string $output Passed by reference. - * @param int $depth Depth of page. */ function start_lvl(&$output) {} @@ -22,7 +21,6 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu { * @since 3.0.0 * * @param string $output Passed by reference. - * @param int $depth Depth of page. */ function end_lvl(&$output) { } @@ -34,7 +32,6 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu { * @param string $output Passed by reference. Used to append additional content. * @param object $item Menu item data object. * @param int $depth Depth of menu item. Used for padding. - * @param int $current_page Menu item ID. * @param object $args */ function start_el(&$output, $item, $depth, $args) { @@ -164,7 +161,7 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu {

      @@ -218,7 +215,6 @@ class Walker_Nav_Menu_Checklist extends Walker_Nav_Menu { * @param string $output Passed by reference. Used to append additional content. * @param object $item Menu item data object. * @param int $depth Depth of menu item. Used for padding. - * @param int $current_page Menu item ID. * @param object $args */ function start_el(&$output, $item, $depth, $args) { @@ -249,7 +245,6 @@ class Walker_Nav_Menu_Checklist extends Walker_Nav_Menu { $output .= ''; $output .= ''; $output .= ''; - $output .= ''; $output .= ''; $output .= ''; } @@ -499,7 +494,7 @@ function wp_nav_menu_locations_meta_box() { ?>

      - class="button-primary" name="nav-menu-locations" value="" /> +

      ">
        'post_date', 'order' => 'DESC', 'showposts' => 15 ) ); + $recent_args = array_merge( $args, array( 'orderby' => 'post_date', 'order' => 'DESC', 'posts_per_page' => 15 ) ); $most_recent = $get_posts->query( $recent_args ); $args['walker'] = $walker; echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $most_recent), 0, (object) $args ); @@ -673,9 +668,9 @@ function wp_nav_menu_item_post_type_meta_box( $object, $post_type ) { } ?>

        - + - +

          @@ -900,9 +895,9 @@ function wp_nav_menu_item_taxonomy_meta_box( $object, $taxonomy ) { } ?>

          - + - +

            @@ -1102,7 +1097,6 @@ function wp_get_nav_menu_to_edit( $menu_id = 0 ) { * * @since 3.0.0 * - * @param string $menu_item_id The ID of the menu item to format. * @return string|WP_Error $output The menu formatted to edit or error object on failure. */ function wp_nav_menu_manage_columns() { diff --git a/wp-admin/includes/plugin-install.php b/wp-admin/includes/plugin-install.php index f348e609..beb54676 100644 --- a/wp-admin/includes/plugin-install.php +++ b/wp-admin/includes/plugin-install.php @@ -65,66 +65,20 @@ function plugins_api($action, $args = null) { * @return array */ function install_popular_tags( $args = array() ) { - if ( ! ($cache = wp_cache_get('popular_tags', 'api')) && ! ($cache = get_option('wporg_popular_tags')) ) - add_option('wporg_popular_tags', array(), '', 'no'); ///No autoload. - - if ( $cache && $cache->timeout + 3 * 60 * 60 > time() ) - return $cache->cached; + $key = md5(serialize($args)); + if ( false !== ($tags = get_site_transient('poptags_' . $key) ) ) + return $tags; $tags = plugins_api('hot_tags', $args); if ( is_wp_error($tags) ) return $tags; - $cache = (object) array('timeout' => time(), 'cached' => $tags); - - update_option('wporg_popular_tags', $cache); - wp_cache_set('popular_tags', $cache, 'api'); + set_site_transient('poptags_' . $key, $tags, 10800); // 3 * 60 * 60 = 10800 return $tags; } -add_action('install_plugins_search', 'install_search', 10, 1); - -/** - * Display search results and display as tag cloud. - * - * @since 2.7.0 - * - * @param string $page - */ -function install_search($page) { - $type = isset($_REQUEST['type']) ? stripslashes( $_REQUEST['type'] ) : ''; - $term = isset($_REQUEST['s']) ? stripslashes( $_REQUEST['s'] ) : ''; - - $args = array(); - - switch( $type ){ - case 'tag': - $args['tag'] = sanitize_title_with_dashes($term); - break; - case 'term': - $args['search'] = $term; - break; - case 'author': - $args['author'] = $term; - break; - } - $args['page'] = $page; - - $api = plugins_api('query_plugins', $args); - - if ( is_wp_error($api) ) - wp_die($api); - - add_action('install_plugins_table_header', 'install_search_form'); - - display_plugins_table($api->plugins, $api->info['page'], $api->info['pages']); - - return; -} - -add_action('install_plugins_dashboard', 'install_dashboard'); function install_dashboard() { ?>

            WordPress Plugin Directory or upload a plugin in .zip format via this page.') ?>

            @@ -147,7 +101,7 @@ function install_dashboard() { $tags = array(); foreach ( (array)$api_tags as $tag ) $tags[ $tag['name'] ] = (object) array( - 'link' => esc_url( admin_url('plugin-install.php?tab=search&type=tag&s=' . urlencode($tag['name'])) ), + 'link' => esc_url( self_admin_url('plugin-install.php?tab=search&type=tag&s=' . urlencode($tag['name'])) ), 'name' => $tag['name'], 'id' => sanitize_title_with_dashes($tag['name']), 'count' => $tag['count'] ); @@ -155,6 +109,7 @@ function install_dashboard() { } echo '


            '; } +add_action('install_plugins_dashboard', 'install_dashboard'); /** * Display search form for searching plugins. @@ -165,7 +120,8 @@ function install_search_form(){ $type = isset($_REQUEST['type']) ? stripslashes( $_REQUEST['type'] ) : ''; $term = isset($_REQUEST['s']) ? stripslashes( $_REQUEST['s'] ) : ''; - ?>
            + ?> + - +
            'featured', 'page' => $page); - $api = plugins_api('query_plugins', $args); - if ( is_wp_error($api) ) - wp_die($api->get_error_message() . '

            ' . __('Try again') . ''); - display_plugins_table($api->plugins, $api->info['page'], $api->info['pages']); -} - -add_action('install_plugins_popular', 'install_popular', 10, 1); -/** - * Display popular plugins. - * - * @since 2.7.0 - * - * @param string $page - */ -function install_popular($page = 1) { - $args = array('browse' => 'popular', 'page' => $page); - $api = plugins_api('query_plugins', $args); - if ( is_wp_error($api) ) - wp_die($api->get_error_message() . '

            ' . __('Try again') . ''); - display_plugins_table($api->plugins, $api->info['page'], $api->info['pages']); -} - -add_action('install_plugins_upload', 'install_plugins_upload', 10, 1); /** * Upload from zip * @since 2.8.0 @@ -220,7 +143,7 @@ function install_plugins_upload( $page = 1 ) { ?>

            -
            + @@ -228,193 +151,23 @@ function install_plugins_upload( $page = 1 ) {
            'new', 'page' => $page); - $api = plugins_api('query_plugins', $args); - if ( is_wp_error($api) ) - wp_die($api->get_error_message() . '

            ' . __('Try again') . ''); - display_plugins_table($api->plugins, $api->info['page'], $api->info['pages']); -} -add_action('install_plugins_updated', 'install_updated', 10, 1); - - -/** - * Display recently updated plugins. - * - * @since 2.7.0 - * - * @param string $page - */ -function install_updated($page = 1) { - $args = array('browse' => 'updated', 'page' => $page); - $api = plugins_api('query_plugins', $args); - if ( is_wp_error($api) ) - wp_die($api->get_error_message() . '

            ' . __('Try again') . ''); - display_plugins_table($api->plugins, $api->info['page'], $api->info['pages']); -} +add_action('install_plugins_upload', 'install_plugins_upload', 10, 1); /** * Display plugin content based on plugin list. * * @since 2.7.0 - * - * @param array $plugins List of plugins. - * @param string $page - * @param int $totalpages Number of pages. */ -function display_plugins_table($plugins, $page = 1, $totalpages = 1){ - $type = isset($_REQUEST['type']) ? stripslashes( $_REQUEST['type'] ) : ''; - $term = isset($_REQUEST['s']) ? stripslashes( $_REQUEST['s'] ) : ''; +function display_plugins_table() { + global $wp_list_table; - $plugins_allowedtags = array('a' => array('href' => array(),'title' => array(), 'target' => array()), - 'abbr' => array('title' => array()),'acronym' => array('title' => array()), - 'code' => array(), 'pre' => array(), 'em' => array(),'strong' => array(), - 'ul' => array(), 'ol' => array(), 'li' => array(), 'p' => array(), 'br' => array()); - -?> -

            -
            - -
            - add_query_arg('paged', '%#%', $url), - 'format' => '', - 'prev_text' => __('«'), - 'next_text' => __('»'), - 'total' => $totalpages, - 'current' => $page - )); - - if ( $page_links ) - echo "\t\t
            $page_links
            "; -?> -
            -
            - - - - - - - - - - - - - - - - - - - - - '; - - foreach ( (array) $plugins as $plugin ){ - if ( is_object($plugin) ) - $plugin = (array) $plugin; - - $title = wp_kses($plugin['name'], $plugins_allowedtags); - //Limit description to 400char, and remove any HTML. - $description = strip_tags($plugin['description']); - if ( strlen($description) > 400 ) - $description = mb_substr($description, 0, 400) . '…'; - //remove any trailing entities - $description = preg_replace('/&[^;\s]{0,6}$/', '', $description); - //strip leading/trailing & multiple consecutive lines - $description = trim($description); - $description = preg_replace("|(\r?\n)+|", "\n", $description); - //\n =>
            - $description = nl2br($description); - $version = wp_kses($plugin['version'], $plugins_allowedtags); - - $name = strip_tags($title . ' ' . $version); - - $author = $plugin['author']; - if ( ! empty($plugin['author']) ) - $author = ' ' . sprintf( __('By %s'), $author ) . '.'; - - $author = wp_kses($author, $plugins_allowedtags); - - $action_links = array(); - $action_links[] = '' . __('Details') . ''; - - if ( current_user_can('install_plugins') || current_user_can('update_plugins') ) { - $status = install_plugin_install_status($plugin); - - switch ( $status['status'] ) { - case 'install': - if ( $status['url'] ) - $action_links[] = '' . __('Install Now') . ''; - break; - case 'update_available': - if ( $status['url'] ) - $action_links[] = '' . sprintf( __('Update Now'), $status['version'] ) . ''; - break; - case 'latest_installed': - case 'newer_installed': - $action_links[] = '' . __('Installed') . ''; - break; - } - } - - $action_links = apply_filters( 'plugin_install_action_links', $action_links, $plugin ); - ?> - - - - - - - - -
            ', __('No plugins match your request.'), '
            - - -
            -
            -
            <?php _e('5 stars') ?>
            -
            <?php _e('4 stars') ?>
            -
            <?php _e('3 stars') ?>
            -
            <?php _e('2 stars') ?>
            -
            <?php _e('1 star') ?>
            -
            -
            - -
            - $page_links
            "; ?> -
            - - -display(); } - -add_action('install_plugins_pre_plugin-information', 'install_plugin_information'); +add_action('install_plugins_search', 'display_plugins_table'); +add_action('install_plugins_featured', 'display_plugins_table'); +add_action('install_plugins_popular', 'display_plugins_table'); +add_action('install_plugins_new', 'display_plugins_table'); +add_action('install_plugins_updated', 'display_plugins_table'); /** * Determine the status we can perform on a plugin. @@ -439,7 +192,7 @@ function install_plugin_install_status($api, $loop = false) { $update_file = $file; $version = $plugin->new_version; if ( current_user_can('update_plugins') ) - $url = wp_nonce_url(admin_url('update.php?action=upgrade-plugin&plugin=' . $update_file), 'upgrade-plugin_' . $update_file); + $url = wp_nonce_url(self_admin_url('update.php?action=upgrade-plugin&plugin=' . $update_file), 'upgrade-plugin_' . $update_file); break; } } @@ -450,7 +203,7 @@ function install_plugin_install_status($api, $loop = false) { $installed_plugin = get_plugins('/' . $api->slug); if ( empty($installed_plugin) ) { if ( current_user_can('install_plugins') ) - $url = wp_nonce_url(admin_url('update.php?action=install-plugin&plugin=' . $api->slug), 'install-plugin_' . $api->slug); + $url = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=' . $api->slug), 'install-plugin_' . $api->slug); } else { $key = array_shift( $key = array_keys($installed_plugin) ); //Use the first plugin regardless of the name, Could have issues for multiple-plugins in one directory if they share different version numbers if ( version_compare($api->version, $installed_plugin[ $key ]['Version'], '=') ){ @@ -470,7 +223,7 @@ function install_plugin_install_status($api, $loop = false) { } else { // "install" & no directory with that slug if ( current_user_can('install_plugins') ) - $url = wp_nonce_url(admin_url('update.php?action=install-plugin&plugin=' . $api->slug), 'install-plugin_' . $api->slug); + $url = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=' . $api->slug), 'install-plugin_' . $api->slug); } } if ( isset($_GET['from']) ) @@ -613,3 +366,5 @@ function install_plugin_information() { iframe_footer(); exit; } +add_action('install_plugins_pre_plugin-information', 'install_plugin_information'); + diff --git a/wp-admin/includes/plugin.php b/wp-admin/includes/plugin.php index 98ee2a1b..d10c450b 100644 --- a/wp-admin/includes/plugin.php +++ b/wp-admin/includes/plugin.php @@ -100,13 +100,15 @@ function get_plugin_data( $plugin_file, $markup = true, $translate = true ) { if ( $markup || $translate ) $plugin_data = _get_plugin_data_markup_translate( $plugin_file, $plugin_data, $markup, $translate ); + else + $plugin_data['AuthorName'] = $plugin_data['Author']; return $plugin_data; } function _get_plugin_data_markup_translate($plugin_file, $plugin_data, $markup = true, $translate = true) { - //Translate fields30 + //Translate fields if ( $translate && ! empty($plugin_data['TextDomain']) ) { if ( ! empty( $plugin_data['DomainPath'] ) ) load_plugin_textdomain($plugin_data['TextDomain'], false, dirname($plugin_file). $plugin_data['DomainPath']); @@ -117,28 +119,37 @@ function _get_plugin_data_markup_translate($plugin_file, $plugin_data, $markup = $plugin_data[ $field ] = translate($plugin_data[ $field ], $plugin_data['TextDomain']); } + $plugins_allowedtags = array( + 'a' => array( 'href' => array(), 'title' => array() ), + 'abbr' => array( 'title' => array() ), + 'acronym' => array( 'title' => array() ), + 'code' => array(), + 'em' => array(), + 'strong' => array(), + ); + + $plugin_data['AuthorName'] = $plugin_data['Author'] = wp_kses( $plugin_data['Author'], $plugins_allowedtags ); + //Apply Markup if ( $markup ) { if ( ! empty($plugin_data['PluginURI']) && ! empty($plugin_data['Name']) ) - $plugin_data['Title'] = '' . $plugin_data['Name'] . ''; + $plugin_data['Title'] = '' . $plugin_data['Name'] . ''; else $plugin_data['Title'] = $plugin_data['Name']; if ( ! empty($plugin_data['AuthorURI']) && ! empty($plugin_data['Author']) ) - $plugin_data['Author'] = '' . $plugin_data['Author'] . ''; + $plugin_data['Author'] = '' . $plugin_data['Author'] . ''; $plugin_data['Description'] = wptexturize( $plugin_data['Description'] ); if ( ! empty($plugin_data['Author']) ) $plugin_data['Description'] .= ' ' . sprintf( __('By %s'), $plugin_data['Author'] ) . '.'; } - $plugins_allowedtags = array('a' => array('href' => array(),'title' => array()),'abbr' => array('title' => array()),'acronym' => array('title' => array()),'code' => array(),'em' => array(),'strong' => array()); - - // Sanitize all displayed data - $plugin_data['Title'] = wp_kses($plugin_data['Title'], $plugins_allowedtags); - $plugin_data['Version'] = wp_kses($plugin_data['Version'], $plugins_allowedtags); - $plugin_data['Description'] = wp_kses($plugin_data['Description'], $plugins_allowedtags); - $plugin_data['Author'] = wp_kses($plugin_data['Author'], $plugins_allowedtags); + // Sanitize all displayed data. Author and AuthorName sanitized above. + $plugin_data['Title'] = wp_kses( $plugin_data['Title'], $plugins_allowedtags ); + $plugin_data['Version'] = wp_kses( $plugin_data['Version'], $plugins_allowedtags ); + $plugin_data['Description'] = wp_kses( $plugin_data['Description'], $plugins_allowedtags ); + $plugin_data['Name'] = wp_kses( $plugin_data['Name'], $plugins_allowedtags ); return $plugin_data; } @@ -198,7 +209,7 @@ function get_plugin_files($plugin) { * be split for maintainability. Keep everything in one file for extreme * optimization purposes. * - * @since unknown + * @since 1.5.0 * * @param string $plugin_folder Optional. Relative path to single plugin folder. * @return array Key is the plugin file path and the value is an array of the plugin data. @@ -260,7 +271,7 @@ function get_plugins($plugin_folder = '') { $wp_plugins[plugin_basename( $plugin_file )] = $plugin_data; } - uasort( $wp_plugins, create_function( '$a, $b', 'return strnatcasecmp( $a["Name"], $b["Name"] );' )); + uasort( $wp_plugins, '_sort_uname_callback' ); $cache_plugins[ $plugin_folder ] = $wp_plugins; wp_cache_set('plugins', $cache_plugins, 'plugins'); @@ -312,11 +323,21 @@ function get_mu_plugins() { if ( isset( $wp_plugins['index.php'] ) && filesize( WPMU_PLUGIN_DIR . '/index.php') <= 30 ) // silence is golden unset( $wp_plugins['index.php'] ); - uasort( $wp_plugins, create_function( '$a, $b', 'return strnatcasecmp( $a["Name"], $b["Name"] );' )); + uasort( $wp_plugins, '_sort_uname_callback' ); return $wp_plugins; } +/** + * Callback to sort array by a 'Name' key. + * + * @since 3.1.0 + * @access private + */ +function _sort_uname_callback( $a, $b ) { + return strnatcasecmp( $a['Name'], $b['Name'] ); +} + /** * Check the wp-content directory and retrieve all drop-ins with any plugin data. * @@ -353,7 +374,7 @@ function get_dropins() { $dropins[ $plugin_file ] = $plugin_data; } - uksort( $dropins, create_function( '$a, $b', 'return strnatcasecmp( $a, $b );' )); + uksort( $dropins, 'strnatcasecmp' ); return $dropins; } @@ -400,6 +421,21 @@ function is_plugin_active( $plugin ) { return in_array( $plugin, (array) get_option( 'active_plugins', array() ) ) || is_plugin_active_for_network( $plugin ); } +/** + * Check whether the plugin is inactive. + * + * Reverse of is_plugin_active(). Used as a callback. + * + * @since 3.1.0 + * @see is_plugin_active() + * + * @param string $plugin Base plugin path from plugins directory. + * @return bool True if inactive. False if active. + */ +function is_plugin_inactive( $plugin ) { + return ! is_plugin_active( $plugin ); +} + /** * Check whether the plugin is active for the entire network. * @@ -428,8 +464,8 @@ function is_plugin_active_for_network( $plugin ) { * * @since 3.0.0 * - * @param $file Plugin to check - * $return bool True if plugin is network only, false otherwise. + * @param string $plugin Plugin to check + * @return bool True if plugin is network only, false otherwise. */ function is_network_only_plugin( $plugin ) { $plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ); @@ -456,15 +492,17 @@ function is_network_only_plugin( $plugin ) { * If any errors are found or text is outputted, then it will be captured to * ensure that the success redirection will update the error redirection. * - * @since unknown + * @since 2.5.0 * * @param string $plugin Plugin path to main plugin file with plugin data. * @param string $redirect Optional. URL to redirect to. - * @param bool $network_wide Whether to enable the plugin for all sites in the network or just the current site. Multisite only. Default is false. + * @param bool $network_wide Whether to enable the plugin for all sites in the + * network or just the current site. Multisite only. Default is false. + * @param bool $silent Prevent calling activation hooks. Optional, default is false. * @return WP_Error|null WP_Error on invalid file or null on success. */ -function activate_plugin( $plugin, $redirect = '', $network_wide = false) { - $plugin = plugin_basename( trim( $plugin ) ); +function activate_plugin( $plugin, $redirect = '', $network_wide = false, $silent = false ) { + $plugin = plugin_basename( trim( $plugin ) ); if ( is_multisite() && ( $network_wide || is_network_only_plugin($plugin) ) ) { $network_wide = true; @@ -481,9 +519,13 @@ function activate_plugin( $plugin, $redirect = '', $network_wide = false) { if ( !empty($redirect) ) wp_redirect(add_query_arg('_error_nonce', wp_create_nonce('plugin-activation-error_' . $plugin), $redirect)); // we'll override this later if the plugin can be included without fatal error ob_start(); - include(WP_PLUGIN_DIR . '/' . $plugin); - do_action( 'activate_plugin', trim( $plugin) ); - do_action( 'activate_' . trim( $plugin ) ); + include_once(WP_PLUGIN_DIR . '/' . $plugin); + + if ( ! $silent ) { + do_action( 'activate_plugin', $plugin, $network_wide ); + do_action( 'activate_' . $plugin, $network_wide ); + } + if ( $network_wide ) { $current[$plugin] = time(); update_site_option( 'active_sitewide_plugins', $current ); @@ -492,7 +534,11 @@ function activate_plugin( $plugin, $redirect = '', $network_wide = false) { sort($current); update_option('active_plugins', $current); } - do_action( 'activated_plugin', trim( $plugin) ); + + if ( ! $silent ) { + do_action( 'activated_plugin', $plugin, $network_wide ); + } + if ( ob_get_length() > 0 ) { $output = ob_get_clean(); return new WP_Error('unexpected_output', __('The plugin generated unexpected output.'), $output); @@ -509,40 +555,41 @@ function activate_plugin( $plugin, $redirect = '', $network_wide = false) { * The deactivation hook is disabled by the plugin upgrader by using the $silent * parameter. * - * @since unknown + * @since 2.5.0 * * @param string|array $plugins Single plugin or list of plugins to deactivate. - * @param bool $silent Optional, default is false. Prevent calling deactivate hook. + * @param bool $silent Prevent calling deactivation hooks. Default is false. */ function deactivate_plugins( $plugins, $silent = false ) { - $network_current = get_site_option( 'active_sitewide_plugins', array() ); + if ( is_multisite() ) + $network_current = get_site_option( 'active_sitewide_plugins', array() ); $current = get_option( 'active_plugins', array() ); $do_blog = $do_network = false; foreach ( (array) $plugins as $plugin ) { - $plugin = plugin_basename($plugin); + $plugin = plugin_basename( trim( $plugin ) ); if ( ! is_plugin_active($plugin) ) continue; + + $network_wide = is_plugin_active_for_network( $plugin ); + if ( ! $silent ) - do_action( 'deactivate_plugin', trim( $plugin ) ); + do_action( 'deactivate_plugin', $plugin, $network_wide ); - if ( is_plugin_active_for_network($plugin) ) { - // Deactivate network wide + if ( $network_wide ) { $do_network = true; unset( $network_current[ $plugin ] ); } else { - // Deactivate for this blog only - $key = array_search( $plugin, (array) $current ); + $key = array_search( $plugin, $current ); if ( false !== $key ) { $do_blog = true; array_splice( $current, $key, 1 ); } } - //Used by Plugin updater to internally deactivate plugin, however, not to notify plugins of the fact to prevent plugin output. if ( ! $silent ) { - do_action( 'deactivate_' . trim( $plugin ) ); - do_action( 'deactivated_plugin', trim( $plugin ) ); + do_action( 'deactivate_' . $plugin, $network_wide ); + do_action( 'deactivated_plugin', $plugin, $network_wide ); } } @@ -560,22 +607,23 @@ function deactivate_plugins( $plugins, $silent = false ) { * * The execution will be halted as soon as one of the plugins has an error. * - * @since unknown + * @since 2.6.0 * * @param string|array $plugins * @param string $redirect Redirect to page after successful activation. * @param bool $network_wide Whether to enable the plugin for all sites in the network. + * @param bool $silent Prevent calling activation hooks. Default is false. * @return bool|WP_Error True when finished or WP_Error if there were errors during a plugin activation. */ -function activate_plugins($plugins, $redirect = '', $network_wide) { +function activate_plugins( $plugins, $redirect = '', $network_wide = false, $silent = false ) { if ( !is_array($plugins) ) $plugins = array($plugins); $errors = array(); - foreach ( (array) $plugins as $plugin ) { + foreach ( $plugins as $plugin ) { if ( !empty($redirect) ) $redirect = add_query_arg('plugin', $plugin, $redirect); - $result = activate_plugin($plugin, $redirect, $network_wide); + $result = activate_plugin($plugin, $redirect, $network_wide, $silent); if ( is_wp_error($result) ) $errors[$plugin] = $result; } @@ -592,7 +640,7 @@ function activate_plugins($plugins, $redirect = '', $network_wide) { * If the plugins parameter list is empty, false will be returned. True when * completed. * - * @since unknown + * @since 2.6.0 * * @param array $plugins List of plugin * @param string $redirect Redirect to page when complete. @@ -609,7 +657,7 @@ function delete_plugins($plugins, $redirect = '' ) { $checked[] = 'checked[]=' . $plugin; ob_start(); - $url = wp_nonce_url('plugins.php?action=delete-selected&verify-delete=1&' . implode('&', $checked), 'bulk-manage-plugins'); + $url = wp_nonce_url('plugins.php?action=delete-selected&verify-delete=1&' . implode('&', $checked), 'bulk-plugins'); if ( false === ($credentials = request_filesystem_credentials($url)) ) { $data = ob_get_contents(); ob_end_clean(); @@ -684,7 +732,7 @@ function delete_plugins($plugins, $redirect = '' ) { * Validate all active plugins, deactivates invalid and * returns an array of deactivated ones. * - * @since unknown + * @since 2.5.0 * @return array invalid plugins, plugin as key, error as value */ function validate_active_plugins() { @@ -721,7 +769,7 @@ function validate_active_plugins() { * * Checks that the file exists and {@link validate_file() is valid file}. * - * @since unknown + * @since 2.5.0 * * @param string $plugin Plugin Path * @return WP_Error|int 0 on success, WP_Error on failure. @@ -815,6 +863,8 @@ function uninstall_plugin($plugin) { * @param callback $function The function to be called to output the content for this page. * @param string $icon_url The url to the icon to be used for this menu * @param int $position The position in the menu order this one should appear + * + * @return string The resulting page's hook_suffix */ function add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $icon_url = '', $position = NULL ) { global $menu, $admin_page_hooks, $_registered_pages, $_parent_pages; @@ -863,6 +913,8 @@ function add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $func * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu) * @param callback $function The function to be called to output the content for this page. * @param string $icon_url The url to the icon to be used for this menu + * + * @return string The resulting page's hook_suffix */ function add_object_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $icon_url = '') { global $_wp_last_object_menu; @@ -887,6 +939,8 @@ function add_object_page( $page_title, $menu_title, $capability, $menu_slug, $fu * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu) * @param callback $function The function to be called to output the content for this page. * @param string $icon_url The url to the icon to be used for this menu + * + * @return string The resulting page's hook_suffix */ function add_utility_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $icon_url = '') { global $_wp_last_utility_menu; @@ -911,6 +965,8 @@ function add_utility_page( $page_title, $menu_title, $capability, $menu_slug, $f * @param string $capability The capability required for this menu to be displayed to the user. * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu) * @param callback $function The function to be called to output the content for this page. + * + * @return string The resulting page's hook_suffix */ function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { global $submenu; @@ -961,7 +1017,7 @@ function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, /** * Add sub menu page to the tools main menu. -* + * * This function takes a capability which will be used to determine whether * or not a page is included in the menu. * @@ -973,6 +1029,8 @@ function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, * @param string $capability The capability required for this menu to be displayed to the user. * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu) * @param callback $function The function to be called to output the content for this page. + * + * @return string The resulting page's hook_suffix */ function add_management_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { return add_submenu_page( 'tools.php', $page_title, $menu_title, $capability, $menu_slug, $function ); @@ -980,7 +1038,7 @@ function add_management_page( $page_title, $menu_title, $capability, $menu_slug, /** * Add sub menu page to the options main menu. -* + * * This function takes a capability which will be used to determine whether * or not a page is included in the menu. * @@ -992,6 +1050,8 @@ function add_management_page( $page_title, $menu_title, $capability, $menu_slug, * @param string $capability The capability required for this menu to be displayed to the user. * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu) * @param callback $function The function to be called to output the content for this page. + * + * @return string The resulting page's hook_suffix */ function add_options_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { return add_submenu_page( 'options-general.php', $page_title, $menu_title, $capability, $menu_slug, $function ); @@ -999,7 +1059,7 @@ function add_options_page( $page_title, $menu_title, $capability, $menu_slug, $f /** * Add sub menu page to the themes main menu. -* + * * This function takes a capability which will be used to determine whether * or not a page is included in the menu. * @@ -1011,6 +1071,8 @@ function add_options_page( $page_title, $menu_title, $capability, $menu_slug, $f * @param string $capability The capability required for this menu to be displayed to the user. * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu) * @param callback $function The function to be called to output the content for this page. + * + * @return string The resulting page's hook_suffix */ function add_theme_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { return add_submenu_page( 'themes.php', $page_title, $menu_title, $capability, $menu_slug, $function ); @@ -1018,7 +1080,7 @@ function add_theme_page( $page_title, $menu_title, $capability, $menu_slug, $fun /** * Add sub menu page to the plugins main menu. -* + * * This function takes a capability which will be used to determine whether * or not a page is included in the menu. * @@ -1030,6 +1092,8 @@ function add_theme_page( $page_title, $menu_title, $capability, $menu_slug, $fun * @param string $capability The capability required for this menu to be displayed to the user. * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu) * @param callback $function The function to be called to output the content for this page. + * + * @return string The resulting page's hook_suffix */ function add_plugins_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { return add_submenu_page( 'plugins.php', $page_title, $menu_title, $capability, $menu_slug, $function ); @@ -1037,7 +1101,7 @@ function add_plugins_page( $page_title, $menu_title, $capability, $menu_slug, $f /** * Add sub menu page to the Users/Profile main menu. -* + * * This function takes a capability which will be used to determine whether * or not a page is included in the menu. * @@ -1049,6 +1113,8 @@ function add_plugins_page( $page_title, $menu_title, $capability, $menu_slug, $f * @param string $capability The capability required for this menu to be displayed to the user. * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu) * @param callback $function The function to be called to output the content for this page. + * + * @return string The resulting page's hook_suffix */ function add_users_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { if ( current_user_can('edit_users') ) @@ -1059,7 +1125,7 @@ function add_users_page( $page_title, $menu_title, $capability, $menu_slug, $fun } /** * Add sub menu page to the Dashboard main menu. -* + * * This function takes a capability which will be used to determine whether * or not a page is included in the menu. * @@ -1071,6 +1137,8 @@ function add_users_page( $page_title, $menu_title, $capability, $menu_slug, $fun * @param string $capability The capability required for this menu to be displayed to the user. * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu) * @param callback $function The function to be called to output the content for this page. + * + * @return string The resulting page's hook_suffix */ function add_dashboard_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { return add_submenu_page( 'index.php', $page_title, $menu_title, $capability, $menu_slug, $function ); @@ -1078,7 +1146,7 @@ function add_dashboard_page( $page_title, $menu_title, $capability, $menu_slug, /** * Add sub menu page to the posts main menu. -* + * * This function takes a capability which will be used to determine whether * or not a page is included in the menu. * @@ -1090,6 +1158,8 @@ function add_dashboard_page( $page_title, $menu_title, $capability, $menu_slug, * @param string $capability The capability required for this menu to be displayed to the user. * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu) * @param callback $function The function to be called to output the content for this page. + * + * @return string The resulting page's hook_suffix */ function add_posts_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { return add_submenu_page( 'edit.php', $page_title, $menu_title, $capability, $menu_slug, $function ); @@ -1097,7 +1167,7 @@ function add_posts_page( $page_title, $menu_title, $capability, $menu_slug, $fun /** * Add sub menu page to the media main menu. -* + * * This function takes a capability which will be used to determine whether * or not a page is included in the menu. * @@ -1109,6 +1179,8 @@ function add_posts_page( $page_title, $menu_title, $capability, $menu_slug, $fun * @param string $capability The capability required for this menu to be displayed to the user. * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu) * @param callback $function The function to be called to output the content for this page. + * + * @return string The resulting page's hook_suffix */ function add_media_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { return add_submenu_page( 'upload.php', $page_title, $menu_title, $capability, $menu_slug, $function ); @@ -1116,7 +1188,7 @@ function add_media_page( $page_title, $menu_title, $capability, $menu_slug, $fun /** * Add sub menu page to the links main menu. -* + * * This function takes a capability which will be used to determine whether * or not a page is included in the menu. * @@ -1128,6 +1200,8 @@ function add_media_page( $page_title, $menu_title, $capability, $menu_slug, $fun * @param string $capability The capability required for this menu to be displayed to the user. * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu) * @param callback $function The function to be called to output the content for this page. + * + * @return string The resulting page's hook_suffix */ function add_links_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { return add_submenu_page( 'link-manager.php', $page_title, $menu_title, $capability, $menu_slug, $function ); @@ -1135,7 +1209,7 @@ function add_links_page( $page_title, $menu_title, $capability, $menu_slug, $fun /** * Add sub menu page to the pages main menu. -* + * * This function takes a capability which will be used to determine whether * or not a page is included in the menu. * @@ -1147,14 +1221,16 @@ function add_links_page( $page_title, $menu_title, $capability, $menu_slug, $fun * @param string $capability The capability required for this menu to be displayed to the user. * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu) * @param callback $function The function to be called to output the content for this page. - */ + * + * @return string The resulting page's hook_suffix +*/ function add_pages_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { return add_submenu_page( 'edit.php?post_type=page', $page_title, $menu_title, $capability, $menu_slug, $function ); } /** * Add sub menu page to the comments main menu. -* + * * This function takes a capability which will be used to determine whether * or not a page is included in the menu. * @@ -1166,11 +1242,60 @@ function add_pages_page( $page_title, $menu_title, $capability, $menu_slug, $fun * @param string $capability The capability required for this menu to be displayed to the user. * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu) * @param callback $function The function to be called to output the content for this page. - */ + * + * @return string The resulting page's hook_suffix +*/ function add_comments_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { return add_submenu_page( 'edit-comments.php', $page_title, $menu_title, $capability, $menu_slug, $function ); } + +/** + * Remove a top level admin menu + * + * @since 3.1.0 + * + * @param string $menu_slug The slug of the menu + * @return array|bool The removed menu on success, False if not found + */ +function remove_menu_page( $menu_slug ) { + global $menu; + + foreach ( $menu as $i => $item ) { + if ( $menu_slug == $item[2] ) { + unset( $menu[$i] ); + return $item; + } + } + + return false; +} + +/** + * Remove an admin submenu + * + * @since 3.1.0 + * + * @param string $menu_slug The slug for the parent menu + * @param string $submenu_slug The slug of the submenu + * @return array|bool The removed submenu on success, False if not found + */ +function remove_submenu_page( $menu_slug, $submenu_slug ) { + global $submenu; + + if ( !isset( $submenu[$menu_slug] ) ) + return false; + + foreach ( $submenu[$menu_slug] as $i => $item ) { + if ( $submenu_slug == $item[2] ) { + unset( $submenu[$menu_slug][$i] ); + return $item; + } + } + + return false; +} + /** * Get the url to access a particular menu page based on the slug it was registered with. * @@ -1186,10 +1311,11 @@ function menu_page_url($menu_slug, $echo = true) { global $_parent_pages; if ( isset( $_parent_pages[$menu_slug] ) ) { - if ( $_parent_pages[$menu_slug] ) { - $url = admin_url( add_query_arg( 'page', $menu_slug, $_parent_pages[$menu_slug] ) ); + $parent_slug = $_parent_pages[$menu_slug]; + if ( $parent_slug && ! isset( $_parent_pages[$parent_slug] ) ) { + $url = admin_url( add_query_arg( 'page', $menu_slug, $parent_slug ) ); } else { - $url = admin_url('admin.php?page=' . $menu_slug); + $url = admin_url( 'admin.php?page=' . $menu_slug ); } } else { $url = ''; @@ -1513,7 +1639,7 @@ function unregister_setting( $option_group, $option_name, $sanitize_callback = ' /** * {@internal Missing Short Description}} * - * @since unknown + * @since 2.7.0 * * @param unknown_type $options * @return unknown @@ -1531,7 +1657,7 @@ add_filter( 'whitelist_options', 'option_update_filter' ); /** * {@internal Missing Short Description}} * - * @since unknown + * @since 2.7.0 * * @param unknown_type $new_options * @param unknown_type $options @@ -1562,7 +1688,7 @@ function add_option_whitelist( $new_options, $options = '' ) { /** * {@internal Missing Short Description}} * - * @since unknown + * @since 2.7.0 * * @param unknown_type $del_options * @param unknown_type $options diff --git a/wp-admin/includes/post.php b/wp-admin/includes/post.php index 040cd6ca..12cbaa0f 100644 --- a/wp-admin/includes/post.php +++ b/wp-admin/includes/post.php @@ -15,7 +15,7 @@ * @since 2.6.0 * * @param bool $update Are we updating a pre-existing post? - * @param post_data array Array of post data. Defaults to the contents of $_POST. + * @param array $post_data Array of post data. Defaults to the contents of $_POST. * @return object|bool WP_Error on failure, true on success. */ function _wp_translate_postdata( $update = false, $post_data = null ) { @@ -125,7 +125,7 @@ function _wp_translate_postdata( $update = false, $post_data = null ) { /** * Update an existing post with values provided in $_POST. * - * @since unknown + * @since 1.5.0 * * @param array $post_data Optional. * @return int Post ID. @@ -136,6 +136,8 @@ function edit_post( $post_data = null ) { $post_data = &$_POST; $post_ID = (int) $post_data['post_ID']; + $post = get_post( $post_ID ); + $post_data['post_type'] = $post->post_type; $ptype = get_post_type_object($post_data['post_type']); if ( !current_user_can( $ptype->cap->edit_post, $post_ID ) ) { @@ -156,10 +158,10 @@ function edit_post( $post_data = null ) { } $post_data = _wp_translate_postdata( true, $post_data ); - if ( 'autosave' != $post_data['action'] && 'auto-draft' == $post_data['post_status'] ) - $post_data['post_status'] = 'draft'; if ( is_wp_error($post_data) ) wp_die( $post_data->get_error_message() ); + if ( 'autosave' != $post_data['action'] && 'auto-draft' == $post_data['post_status'] ) + $post_data['post_status'] = 'draft'; if ( isset($post_data['visibility']) ) { switch ( $post_data['visibility'] ) { @@ -177,15 +179,38 @@ function edit_post( $post_data = null ) { } } + // Post Formats + if ( current_theme_supports( 'post-formats' ) && isset( $post_data['post_format'] ) ) { + $formats = get_theme_support( 'post-formats' ); + if ( is_array( $formats ) ) { + $formats = $formats[0]; + if ( in_array( $post_data['post_format'], $formats ) ) { + set_post_format( $post_ID, $post_data['post_format'] ); + } elseif ( '0' == $post_data['post_format'] ) { + set_post_format( $post_ID, false ); + } + } + } + // Meta Stuff if ( isset($post_data['meta']) && $post_data['meta'] ) { - foreach ( $post_data['meta'] as $key => $value ) + foreach ( $post_data['meta'] as $key => $value ) { + if ( !$meta = get_post_meta_by_id( $key ) ) + continue; + if ( $meta->post_id != $post_ID ) + continue; update_meta( $key, $value['key'], $value['value'] ); + } } if ( isset($post_data['deletemeta']) && $post_data['deletemeta'] ) { - foreach ( $post_data['deletemeta'] as $key => $value ) + foreach ( $post_data['deletemeta'] as $key => $value ) { + if ( !$meta = get_post_meta_by_id( $key ) ) + continue; + if ( $meta->post_id != $post_ID ) + continue; delete_meta( $key ); + } } add_meta( $post_ID ); @@ -205,11 +230,11 @@ function edit_post( $post_data = null ) { wp_set_post_lock( $post_ID, $GLOBALS['current_user']->ID ); - if ( current_user_can( 'edit_others_posts' ) ) { - if ( !empty($post_data['sticky']) ) - stick_post($post_ID); + if ( current_user_can( $ptype->cap->edit_others_posts ) ) { + if ( ! empty( $post_data['sticky'] ) ) + stick_post( $post_ID ); else - unstick_post($post_ID); + unstick_post( $post_ID ); } return $post_ID; @@ -336,7 +361,7 @@ function bulk_edit_posts( $post_data = null ) { $post_data['ID'] = $post_ID; $updated[] = wp_update_post( $post_data ); - if ( isset( $post_data['sticky'] ) && current_user_can( 'edit_others_posts' ) ) { + if ( isset( $post_data['sticky'] ) && current_user_can( $ptype->cap->edit_others_posts ) ) { if ( 'sticky' == $post_data['sticky'] ) stick_post( $post_ID ); else @@ -351,9 +376,9 @@ function bulk_edit_posts( $post_data = null ) { /** * Default post information to use when populating the "Write Post" form. * - * @since unknown + * @since 2.0.0 * - *@param string A post type string, defaults to 'post'. + * @param string $post_type A post type string, defaults to 'post'. * @return object stdClass object containing all the default post data as attributes */ function get_default_post_to_edit( $post_type = 'post', $create_in_db = false ) { @@ -378,6 +403,8 @@ function get_default_post_to_edit( $post_type = 'post', $create_in_db = false ) wp_delete_post( $delete, true ); // Force delete $post_id = wp_insert_post( array( 'post_title' => __( 'Auto Draft' ), 'post_type' => $post_type, 'post_status' => 'auto-draft' ) ); $post = get_post( $post_id ); + if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) && get_option( 'default_post_format' ) ) + set_post_format( $post, get_option( 'default_post_format' ) ); } else { $post->ID = 0; $post->post_author = ''; @@ -421,7 +448,7 @@ function get_default_page_to_edit() { /** * Get an existing post and format it for editing. * - * @since unknown + * @since 2.0.0 * * @param unknown_type $id * @return unknown @@ -439,7 +466,7 @@ function get_post_to_edit( $id ) { /** * Determine if a post exists based on title, content, and date * - * @since unknown + * @since 2.0.0 * * @param string $title Post title * @param string $content Optional post content @@ -480,7 +507,7 @@ function post_exists($title, $content = '', $date = '') { /** * Creates a new post from the "Write Post" form using $_POST information. * - * @since unknown + * @since 2.1.0 * * @return unknown */ @@ -577,7 +604,7 @@ function wp_write_post() { /** * Calls wp_write_post() and handles the errors. * - * @since unknown + * @since 2.0.0 * * @return unknown */ @@ -596,7 +623,7 @@ function write_post() { /** * {@internal Missing Short Description}} * - * @since unknown + * @since 1.2.0 * * @param unknown_type $post_ID * @return unknown @@ -628,9 +655,10 @@ function add_meta( $post_ID ) { wp_cache_delete($post_ID, 'post_meta'); $wpdb->insert( $wpdb->postmeta, array( 'post_id' => $post_ID, 'meta_key' => $metakey, 'meta_value' => $metavalue ) ); - do_action( 'added_postmeta', $wpdb->insert_id, $post_ID, $metakey, $metavalue ); + $meta_id = $wpdb->insert_id; + do_action( 'added_postmeta', $meta_id, $post_ID, $metakey, $metavalue ); - return $wpdb->insert_id; + return $meta_id; } return false; } // add_meta @@ -638,7 +666,7 @@ function add_meta( $post_ID ) { /** * {@internal Missing Short Description}} * - * @since unknown + * @since 1.2.0 * * @param unknown_type $mid * @return unknown @@ -660,7 +688,7 @@ function delete_meta( $mid ) { /** * Get a list of previously defined keys. * - * @since unknown + * @since 1.2.0 * * @return unknown */ @@ -679,7 +707,7 @@ function get_meta_keys() { /** * {@internal Missing Short Description}} * - * @since unknown + * @since 2.1.0 * * @param unknown_type $mid * @return unknown @@ -701,7 +729,7 @@ function get_post_meta_by_id( $mid ) { * * Some postmeta stuff. * - * @since unknown + * @since 1.2.0 * * @param unknown_type $postid * @return unknown @@ -718,7 +746,7 @@ function has_meta( $postid ) { /** * {@internal Missing Short Description}} * - * @since unknown + * @since 1.2.0 * * @param unknown_type $meta_id * @param unknown_type $meta_key Expect Slashed @@ -761,7 +789,7 @@ function update_meta( $meta_id, $meta_key, $meta_value ) { /** * Replace hrefs of attachment anchors with up-to-date permalinks. * - * @since unknown + * @since 2.3.0 * @access private * * @param unknown_type $post_ID @@ -817,7 +845,7 @@ function _fix_attachment_links_replace_cb($match) { /** * Move child posts to a new parent. * - * @since unknown + * @since 2.3.0 * @access private * * @param unknown_type $old_ID @@ -882,16 +910,15 @@ function wp_edit_posts_query( $q = false ) { $perm = 'readable'; } - if ( isset($q['post_status']) && 'pending' === $q['post_status'] ) { - $order = 'ASC'; - $orderby = 'modified'; - } elseif ( isset($q['post_status']) && 'draft' === $q['post_status'] ) { - $order = 'DESC'; + if ( isset($q['orderby']) ) + $orderby = $q['orderby']; + elseif ( isset($q['post_status']) && in_array($q['post_status'], array('pending', 'draft')) ) $orderby = 'modified'; - } else { - $order = 'DESC'; - $orderby = 'date'; - } + + if ( isset($q['order']) ) + $order = $q['order']; + elseif ( isset($q['post_status']) && 'pending' == $q['post_status'] ) + $order = 'ASC'; $per_page = 'edit_' . $post_type . '_per_page'; $posts_per_page = (int) get_user_option( $per_page ); @@ -904,13 +931,16 @@ function wp_edit_posts_query( $q = false ) { $query = compact('post_type', 'post_status', 'perm', 'order', 'orderby', 'posts_per_page'); // Hierarchical types require special args. - if ( is_post_type_hierarchical( $post_type ) ) { + if ( is_post_type_hierarchical( $post_type ) && !isset($orderby) ) { $query['orderby'] = 'menu_order title'; $query['order'] = 'asc'; $query['posts_per_page'] = -1; $query['posts_per_archive_page'] = -1; } + if ( ! empty( $q['show_sticky'] ) ) + $query['post__in'] = (array) get_option( 'sticky_posts' ); + wp( $query ); return $avail_post_stati; @@ -936,7 +966,7 @@ function get_post_mime_types() { /** * {@internal Missing Short Description}} * - * @since unknown + * @since 2.5.0 * * @param unknown_type $type * @return unknown @@ -951,7 +981,7 @@ function get_available_post_mime_types($type = 'attachment') { /** * {@internal Missing Short Description}} * - * @since unknown + * @since 2.5.0 * * @param unknown_type $q * @return unknown @@ -975,16 +1005,26 @@ function wp_edit_attachments_query( $q = false ) { if ( isset($q['post_mime_type']) && !array_intersect( (array) $q['post_mime_type'], array_keys($post_mime_types) ) ) unset($q['post_mime_type']); - wp($q); + if ( isset($q['detached']) ) + add_filter('posts_where', '_edit_attachments_query_helper'); + + wp( $q ); + + if ( isset($q['detached']) ) + remove_filter('posts_where', '_edit_attachments_query_helper'); return array($post_mime_types, $avail_post_mime_types); } +function _edit_attachments_query_helper($where) { + return $where .= ' AND post_parent < 1'; +} + /** * {@internal Missing Short Description}} * * @uses get_user_option() - * @since unknown + * @since 2.5.0 * * @param unknown_type $id * @param unknown_type $page @@ -1007,7 +1047,7 @@ function postbox_classes( $id, $page ) { /** * {@internal Missing Short Description}} * - * @since unknown + * @since 2.5.0 * * @param int|object $id Post ID or post object. * @param string $title (optional) Title @@ -1054,7 +1094,7 @@ function get_sample_permalink($id, $title = null, $name = null) { $uri = untrailingslashit($uri); if ( !empty($uri) ) $uri .= '/'; - $permalink = str_replace('%pagename%', "${uri}%pagename%", $permalink); + $permalink = str_replace('%pagename%', "{$uri}%pagename%", $permalink); } $permalink = array($permalink, apply_filters('editable_slug', $post->post_name)); @@ -1071,7 +1111,7 @@ function get_sample_permalink($id, $title = null, $name = null) { * * intended to be used for the inplace editor of the permalink post slug on in the post (and page?) editor. * - * @since unknown + * @since 2.5.0 * * @param int|object $id Post ID or post object. * @param string $new_title (optional) New title @@ -1094,7 +1134,7 @@ function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) { if ( false === strpos($permalink, '%postname%') && false === strpos($permalink, '%pagename%') ) { $return = '' . __('Permalink:') . "\n" . '' . $permalink . "\n"; - if ( current_user_can( 'manage_options' ) && !( 'page' == get_option('show_on_front') && $id == get_option('page_on_front') ) ) + if ( '' == get_option( 'permalink_structure' ) && current_user_can( 'manage_options' ) && !( 'page' == get_option('show_on_front') && $id == get_option('page_on_front') ) ) $return .= '' . __('Change Permalinks') . "\n"; if ( isset($view_post) ) $return .= "$view_post\n"; @@ -1177,13 +1217,17 @@ function wp_check_post_lock( $post_id ) { if ( !$post = get_post( $post_id ) ) return false; - $lock = get_post_meta( $post->ID, '_edit_lock', true ); - $last = get_post_meta( $post->ID, '_edit_last', true ); + if ( !$lock = get_post_meta( $post->ID, '_edit_lock', true ) ) + return false; + + $lock = explode( ':', $lock ); + $time = $lock[0]; + $user = isset( $lock[1] ) ? $lock[1] : get_post_meta( $post->ID, '_edit_last', true ); $time_window = apply_filters( 'wp_check_post_lock_window', AUTOSAVE_INTERVAL * 2 ); - if ( $lock && $lock > time() - $time_window && $last != get_current_user_id() ) - return $last; + if ( $time && $time > time() - $time_window && $user != get_current_user_id() ) + return $user; return false; } @@ -1198,12 +1242,13 @@ function wp_check_post_lock( $post_id ) { function wp_set_post_lock( $post_id ) { if ( !$post = get_post( $post_id ) ) return false; - if ( 0 == get_current_user_id() ) + if ( 0 == ($user_id = get_current_user_id()) ) return false; $now = time(); + $lock = "$now:$user_id"; - update_post_meta( $post->ID, '_edit_lock', $now ); + update_post_meta( $post->ID, '_edit_lock', $lock ); } /** @@ -1214,7 +1259,10 @@ function wp_set_post_lock( $post_id ) { */ function _admin_notice_post_locked() { global $post; - $last_user = get_userdata( get_post_meta( $post->ID, '_edit_last', true ) ); + + $lock = explode( ':', get_post_meta( $post->ID, '_edit_lock', true ) ); + $user = isset( $lock[1] ) ? $lock[1] : get_post_meta( $post->ID, '_edit_last', true ); + $last_user = get_userdata( $user ); $last_user_name = $last_user ? $last_user->display_name : __('Somebody'); switch ($post->post_type) { @@ -1359,10 +1407,10 @@ function wp_tiny_mce( $teeny = false, $settings = false ) { $mce_spellchecker_languages = apply_filters('mce_spellchecker_languages', '+English=en,Danish=da,Dutch=nl,Finnish=fi,French=fr,German=de,Italian=it,Polish=pl,Portuguese=pt,Spanish=es,Swedish=sv'); if ( $teeny ) { - $plugins = apply_filters( 'teeny_mce_plugins', array('safari', 'inlinepopups', 'media', 'fullscreen', 'wordpress') ); + $plugins = apply_filters( 'teeny_mce_plugins', array('inlinepopups', 'fullscreen', 'wordpress', 'wplink', 'wpdialogs') ); $ext_plugins = ''; } else { - $plugins = array( 'safari', 'inlinepopups', 'spellchecker', 'paste', 'wordpress', 'media', 'fullscreen', 'wpeditimage', 'wpgallery', 'tabfocus' ); + $plugins = array( 'inlinepopups', 'spellchecker', 'paste', 'wordpress', 'fullscreen', 'wpeditimage', 'wpgallery', 'tabfocus', 'wplink', 'wpdialogs' ); /* The following filter takes an associative array of external plugins for TinyMCE in the form 'plugin_name' => 'url'. @@ -1443,8 +1491,6 @@ function wp_tiny_mce( $teeny = false, $settings = false ) { } } - $plugins = implode($plugins, ','); - if ( $teeny ) { $mce_buttons = apply_filters( 'teeny_mce_buttons', array('bold, italic, underline, blockquote, separator, strikethrough, bullist, numlist,justifyleft, justifycenter, justifyright, undo, redo, link, unlink, fullscreen') ); $mce_buttons = implode($mce_buttons, ','); @@ -1453,9 +1499,7 @@ function wp_tiny_mce( $teeny = false, $settings = false ) { $mce_buttons = apply_filters('mce_buttons', array('bold', 'italic', 'strikethrough', '|', 'bullist', 'numlist', 'blockquote', '|', 'justifyleft', 'justifycenter', 'justifyright', '|', 'link', 'unlink', 'wp_more', '|', 'spellchecker', 'fullscreen', 'wp_adv' )); $mce_buttons = implode($mce_buttons, ','); - $mce_buttons_2 = array('formatselect', 'underline', 'justifyfull', 'forecolor', '|', 'pastetext', 'pasteword', 'removeformat', '|', 'media', 'charmap', '|', 'outdent', 'indent', '|', 'undo', 'redo', 'wp_help' ); - if ( is_multisite() ) - unset( $mce_buttons_2[ array_search( 'media', $mce_buttons_2 ) ] ); + $mce_buttons_2 = array( 'formatselect', 'underline', 'justifyfull', 'forecolor', '|', 'pastetext', 'pasteword', 'removeformat', '|', 'charmap', '|', 'outdent', 'indent', '|', 'undo', 'redo', 'wp_help' ); $mce_buttons_2 = apply_filters('mce_buttons_2', $mce_buttons_2); $mce_buttons_2 = implode($mce_buttons_2, ','); @@ -1486,6 +1530,21 @@ function wp_tiny_mce( $teeny = false, $settings = false ) { 'theme_advanced_resizing' => true, 'theme_advanced_resize_horizontal' => false, 'dialog_type' => 'modal', + 'formats' => "{ + alignleft : [ + {selector : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li', styles : {textAlign : 'left'}}, + {selector : 'img,table', classes : 'alignleft'} + ], + aligncenter : [ + {selector : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li', styles : {textAlign : 'center'}}, + {selector : 'img,table', classes : 'aligncenter'} + ], + alignright : [ + {selector : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li', styles : {textAlign : 'right'}}, + {selector : 'img,table', classes : 'alignright'} + ], + strikethrough : {inline : 'del'} + }", 'relative_urls' => false, 'remove_script_host' => false, 'convert_urls' => false, @@ -1499,14 +1558,15 @@ function wp_tiny_mce( $teeny = false, $settings = false ) { 'paste_remove_styles' => true, 'paste_remove_spans' => true, 'paste_strip_class_attributes' => 'all', + 'paste_text_use_dialog' => true, 'wpeditimage_disable_captions' => $no_captions, - 'plugins' => $plugins + 'plugins' => implode( ',', $plugins ), ); if ( ! empty( $editor_styles ) && is_array( $editor_styles ) ) { $mce_css = array(); $style_uri = get_stylesheet_directory_uri(); - if ( TEMPLATEPATH == STYLESHEETPATH ) { + if ( ! is_child_theme() ) { foreach ( $editor_styles as $file ) $mce_css[] = "$style_uri/$file"; } else { @@ -1514,10 +1574,10 @@ function wp_tiny_mce( $teeny = false, $settings = false ) { $template_uri = get_template_directory_uri(); $template_dir = get_template_directory(); foreach ( $editor_styles as $file ) { - if ( file_exists( "$style_dir/$file" ) ) - $mce_css[] = "$style_uri/$file"; if ( file_exists( "$template_dir/$file" ) ) $mce_css[] = "$template_uri/$file"; + if ( file_exists( "$style_dir/$file" ) ) + $mce_css[] = "$style_uri/$file"; } } $mce_css = implode( ',', $mce_css ); @@ -1570,8 +1630,18 @@ function wp_tiny_mce( $teeny = false, $settings = false ) { include_once(ABSPATH . WPINC . '/js/tinymce/langs/wp-langs.php'); $mce_options = ''; - foreach ( $initArray as $k => $v ) - $mce_options .= $k . ':"' . $v . '", '; + foreach ( $initArray as $k => $v ) { + if ( is_bool($v) ) { + $val = $v ? 'true' : 'false'; + $mce_options .= $k . ':' . $val . ', '; + continue; + } elseif ( !empty($v) && is_string($v) && ( '{' == $v{0} || '[' == $v{0} ) ) { + $mce_options .= $k . ':' . $v . ', '; + continue; + } + + $mce_options .= $k . ':"' . $v . '", '; + } $mce_options = rtrim( trim($mce_options), '\n\r,' ); ?> @@ -1601,14 +1671,33 @@ tinyMCEPreInit = { + + 'open', 'default_ping_status' => 'open', 'default_pingback_flag' => 1, - 'default_post_edit_rows' => 10, + 'default_post_edit_rows' => 20, 'posts_per_page' => 10, /* translators: default date format, see http://php.net/date */ 'date_format' => __('F j, Y'), @@ -318,6 +318,9 @@ function populate_options() { // 3.0 'page_for_posts' => 0, 'page_on_front' => 0, + + // 3.1 + 'default_post_format' => 0, ); // 3.0 multisite @@ -357,9 +360,8 @@ function populate_options() { if ( !__get_option('home') ) update_option('home', $guessurl); // Delete unused options - $unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog', '_wpnonce', '_wp_http_referer', 'Update', 'action', 'rich_editing', 'autosave_interval', 'deactivated_plugins', 'can_compress_scripts', - 'page_uris', 'update_core', 'update_plugins', 'update_themes', 'doing_cron', 'random_seed', 'rss_excerpt_length', 'secret', 'use_linksupdate', 'default_comment_status_page' ); - foreach ($unusedoptions as $option) + $unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog', '_wpnonce', '_wp_http_referer', 'Update', 'action', 'rich_editing', 'autosave_interval', 'deactivated_plugins', 'can_compress_scripts', 'page_uris', 'update_core', 'update_plugins', 'update_themes', 'doing_cron', 'random_seed', 'rss_excerpt_length', 'secret', 'use_linksupdate', 'default_comment_status_page', 'wporg_popular_tags', 'what_to_show'); + foreach ( $unusedoptions as $option ) delete_option($option); // delete obsolete magpie stuff @@ -668,7 +670,7 @@ function populate_network( $network_id = 1, $domain = '', $email = '', $site_nam if ( !is_multisite() ) { $site_admins = array( $site_user->user_login ); - $users = get_users_of_blog(); + $users = get_users( array( 'fields' => array( 'ID', 'user_login' ) ) ); if ( $users ) { foreach ( $users as $user ) { if ( is_super_admin( $user->ID ) && !in_array( $user->user_login, $site_admins ) ) @@ -715,7 +717,7 @@ Thanks! 'subdomain_install' => intval( $subdomain_install ), 'global_terms_enabled' => global_terms_enabled() ? '1' : '0' ); - if ( !intval( $subdomain_install ) ) + if ( ! $subdomain_install ) $sitemeta['illegal_names'][] = 'blog'; $insert = ''; diff --git a/wp-admin/includes/taxonomy.php b/wp-admin/includes/taxonomy.php index b371ec24..12e231a8 100644 --- a/wp-admin/includes/taxonomy.php +++ b/wp-admin/includes/taxonomy.php @@ -13,7 +13,7 @@ /** * {@internal Missing Short Description}} * - * @since unknown + * @since 2.0.0 * * @param unknown_type $cat_name * @return unknown @@ -28,7 +28,7 @@ function category_exists($cat_name, $parent = 0) { /** * {@internal Missing Short Description}} * - * @since unknown + * @since 2.0.0 * * @param unknown_type $id * @return unknown @@ -41,7 +41,7 @@ function get_category_to_edit( $id ) { /** * {@internal Missing Short Description}} * - * @since unknown + * @since 2.0.0 * * @param unknown_type $cat_name * @param unknown_type $parent @@ -57,7 +57,7 @@ function wp_create_category( $cat_name, $parent = 0 ) { /** * {@internal Missing Short Description}} * - * @since unknown + * @since 2.0.0 * * @param unknown_type $categories * @param unknown_type $post_id @@ -79,25 +79,6 @@ function wp_create_categories($categories, $post_id = '') { return $cat_ids; } -/** - * Deletes one existing category. - * - * @since 2.0.0 - * - * @param int $cat_ID - * @return mixed Returns true if completes delete action; false if term doesnt exist; Zero on attempted deletion of default Category; WP_Error object is also a possibility. - */ -function wp_delete_category($cat_ID) { - $cat_ID = (int) $cat_ID; - $default = get_option('default_category'); - - // Don't delete the default cat - if ( $cat_ID == $default ) - return 0; - - return wp_delete_term($cat_ID, 'category', array('default' => $default)); -} - /** * Updates an existing Category or creates a new Category. * @@ -192,7 +173,31 @@ function wp_update_category($catarr) { /** * {@internal Missing Short Description}} * - * @since unknown + * @since 2.3.0 + * + * @param unknown_type $tag_name + * @return unknown + */ +function tag_exists($tag_name) { + return term_exists($tag_name, 'post_tag'); +} + +/** + * {@internal Missing Short Description}} + * + * @since 2.3.0 + * + * @param unknown_type $tag_name + * @return unknown + */ +function wp_create_tag($tag_name) { + return wp_create_term( $tag_name, 'post_tag'); +} + +/** + * {@internal Missing Short Description}} + * + * @since 2.3.0 * * @param unknown_type $post_id * @return unknown @@ -204,7 +209,7 @@ function get_tags_to_edit( $post_id, $taxonomy = 'post_tag' ) { /** * {@internal Missing Short Description}} * - * @since unknown + * @since 2.8.0 * * @param unknown_type $post_id * @return unknown @@ -234,31 +239,7 @@ function get_terms_to_edit( $post_id, $taxonomy = 'post_tag' ) { /** * {@internal Missing Short Description}} * - * @since unknown - * - * @param unknown_type $tag_name - * @return unknown - */ -function tag_exists($tag_name) { - return term_exists($tag_name, 'post_tag'); -} - -/** - * {@internal Missing Short Description}} - * - * @since unknown - * - * @param unknown_type $tag_name - * @return unknown - */ -function wp_create_tag($tag_name) { - return wp_create_term( $tag_name, 'post_tag'); -} - -/** - * {@internal Missing Short Description}} - * - * @since unknown + * @since 2.8.0 * * @param unknown_type $tag_name * @return unknown diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index fd7e76f9..b345c36b 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -8,169 +8,6 @@ * @subpackage Administration */ -/** - * {@internal Missing Short Description}} - * - * @since 2.7 - * - * Outputs the HTML for the hidden table rows used in Categories, Link Categories and Tags quick edit. - * - * @param string $type "edit-tags", "categoried" or "edit-link-categories" - * @param string $taxonomy The taxonomy of the row. - * @return - */ -function inline_edit_term_row($type, $taxonomy) { - - $tax = get_taxonomy($taxonomy); - if ( ! current_user_can( $tax->cap->edit_terms ) ) - return; - - $columns = get_column_headers($type); - $hidden = array_intersect( array_keys( $columns ), array_filter( get_hidden_columns($type) ) ); - $col_count = count($columns) - count($hidden); - ?> - -
            - -
            -name ); - $edit_link = "link-category.php?action=edit&cat_ID=$category->term_id"; - if ( current_user_can( 'manage_categories' ) ) { - $edit = "name)) . "'>$name
            "; - $actions = array(); - $actions['edit'] = '' . __('Edit') . ''; - $actions['inline hide-if-no-js'] = '' . __('Quick Edit') . ''; - if ( $default_cat_id != $category->term_id ) - $actions['delete'] = "term_id) . "'>" . __('Delete') . ""; - $actions = apply_filters('link_cat_row_actions', $actions, $category); - $action_count = count($actions); - $i = 0; - $edit .= '
            '; - foreach ( $actions as $action => $link ) { - ++$i; - ( $i == $action_count ) ? $sep = '' : $sep = ' | '; - $edit .= "$link$sep"; - } - $edit .= '
            '; - } else { - $edit = $name; - } - - $row_class = 'alternate' == $row_class ? '' : 'alternate'; - $qe_data = get_term_to_edit($category->term_id, 'link_category'); - - $category->count = number_format_i18n( $category->count ); - $count = ( $category->count > 0 ) ? "$category->count" : $category->count; - $output = ""; - $columns = get_column_headers('edit-link-categories'); - $hidden = get_hidden_columns('edit-link-categories'); - foreach ( $columns as $column_name => $column_display_name ) { - $class = "class=\"$column_name column-$column_name\""; - - $style = ''; - if ( in_array($column_name, $hidden) ) - $style = ' style="display:none;"'; - - $attributes = "$class$style"; - - switch ($column_name) { - case 'cb': - $output .= ""; - if ( absint( get_option( 'default_link_category' ) ) != $category->term_id ) { - $output .= ""; - } else { - $output .= " "; - } - $output .= ""; - break; - case 'name': - $output .= "$edit"; - $output .= ''; - break; - case 'description': - $output .= "$category->description"; - break; - case 'slug': - $output .= "" . apply_filters('editable_slug', $category->slug) . ""; - break; - case 'links': - $attributes = 'class="links column-links num"' . $style; - $output .= "$count"; - break; - default: - $output .= ""; - $output .= apply_filters('manage_link_categories_custom_column', '', $column_name, $category->term_id); - $output .= ""; - } - } - $output .= ''; - - return $output; -} // // Category Checklists @@ -179,7 +16,7 @@ function link_cat_row( $category, $name_override = false ) { /** * {@internal Missing Short Description}} * - * @since unknown + * @since 2.5.1 */ class Walker_Category_Checklist extends Walker { var $tree_type = 'category'; @@ -217,7 +54,7 @@ class Walker_Category_Checklist extends Walker { /** * {@internal Missing Short Description}} * - * @since unknown + * @since 2.5.1 * * @param unknown_type $post_id * @param unknown_type $descendants_and_self @@ -239,6 +76,8 @@ function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $select /** * Taxonomy independent version of wp_category_checklist * + * @since 3.0.0 + * * @param int $post_id * @param array $args */ @@ -305,7 +144,7 @@ function wp_terms_checklist($post_id = 0, $args = array()) { /** * {@internal Missing Short Description}} * - * @since unknown + * @since 2.5.0 * * @param unknown_type $taxonomy * @param unknown_type $default @@ -353,7 +192,7 @@ function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $ech /** * {@internal Missing Short Description}} * - * @since unknown + * @since 2.5.1 * * @param unknown_type $link_id */ @@ -374,1849 +213,110 @@ function wp_link_category_checklist( $link_id = 0 ) { if ( empty( $categories ) ) return; - foreach ( $categories as $category ) { - $cat_id = $category->term_id; - $name = esc_html( apply_filters( 'the_category', $category->name ) ); - $checked = in_array( $cat_id, $checked_categories ) ? ' checked="checked"' : ''; - echo '"; - } -} - -// Tag stuff - -// Returns a single tag row (see tag_rows below) -// Note: this is also used in admin-ajax.php! -/** - * {@internal Missing Short Description}} - * - * @since unknown - * - * @param unknown_type $tag - * @param unknown_type $class - * @return unknown - */ -function _tag_row( $tag, $level, $taxonomy = 'post_tag' ) { - global $post_type, $current_screen; - static $row_class = ''; - $row_class = ($row_class == '' ? ' class="alternate"' : ''); - - $count = number_format_i18n( $tag->count ); - $tax = get_taxonomy($taxonomy); - - if ( 'post_tag' == $taxonomy ) { - $tagsel = 'tag'; - } elseif ( 'category' == $taxonomy ) { - $tagsel = 'category_name'; - } elseif ( ! empty($tax->query_var) ) { - $tagsel = $tax->query_var; - } else { - $tagsel = $taxonomy; - } - - $pad = str_repeat( '— ', max(0, $level) ); - $name = apply_filters( 'term_name', $pad . ' ' . $tag->name, $tag ); - $qe_data = get_term($tag->term_id, $taxonomy, object, 'edit'); - $edit_link = "edit-tags.php?action=edit&taxonomy=$taxonomy&post_type=$post_type&tag_ID=$tag->term_id"; - - $out = ''; - $out .= ''; - - - $columns = get_column_headers($current_screen); - $hidden = get_hidden_columns($current_screen); - $default_term = get_option('default_' . $taxonomy); - foreach ( $columns as $column_name => $column_display_name ) { - $class = "class=\"$column_name column-$column_name\""; - - $style = ''; - if ( in_array($column_name, $hidden) ) - $style = ' style="display:none;"'; - - $attributes = "$class$style"; - - switch ($column_name) { - case 'cb': - if ( current_user_can($tax->cap->delete_terms) && $tag->term_id != $default_term ) - $out .= ' '; - else - $out .= ' '; - break; - case 'name': - $out .= '' . $name . '
            '; - $actions = array(); - if ( current_user_can($tax->cap->edit_terms) ) { - $actions['edit'] = '' . __('Edit') . ''; - $actions['inline hide-if-no-js'] = '' . __('Quick Edit') . ''; - } - if ( current_user_can($tax->cap->delete_terms) && $tag->term_id != $default_term ) - $actions['delete'] = "term_id) . "'>" . __('Delete') . ""; - - $actions = apply_filters('tag_row_actions', $actions, $tag); - $actions = apply_filters("${taxonomy}_row_actions", $actions, $tag); - - $action_count = count($actions); - $i = 0; - $out .= '
            '; - foreach ( $actions as $action => $link ) { - ++$i; - ( $i == $action_count ) ? $sep = '' : $sep = ' | '; - $out .= "$link$sep"; - } - $out .= '
            '; - $out .= ''; - break; - case 'description': - $out .= "$tag->description"; - break; - case 'slug': - $out .= "" . apply_filters('editable_slug', $tag->slug) . ""; - break; - case 'posts': - $attributes = 'class="posts column-posts num"' . $style; - $out .= "$count"; - break; - default: - $out .= ""; - $out .= apply_filters("manage_${taxonomy}_custom_column", '', $column_name, $tag->term_id); - $out .= ""; - } - } - - $out .= "\n"; - - return $out; -} - -// Outputs appropriate rows for the Nth page of the Tag Management screen, -// assuming M tags displayed at a time on the page -// Returns the number of tags displayed -/** - * {@internal Missing Short Description}} - * - * @since unknown - * - * @param unknown_type $page - * @param unknown_type $pagesize - * @param unknown_type $searchterms - * @return unknown - */ -function tag_rows( $page = 1, $pagesize = 20, $searchterms = '', $taxonomy = 'post_tag' ) { - - // Get a page worth of tags - $start = ($page - 1) * $pagesize; - - $args = array('offset' => $start, 'number' => $pagesize, 'hide_empty' => 0); - - if ( !empty( $searchterms ) ) - $args['search'] = $searchterms; - - // convert it to table rows - $out = ''; - $count = 0; - if ( is_taxonomy_hierarchical($taxonomy) ) { - // We'll need the full set of terms then. - $args['number'] = $args['offset'] = 0; - - $terms = get_terms( $taxonomy, $args ); - if ( !empty( $searchterms ) ) // Ignore children on searches. - $children = array(); - else - $children = _get_term_hierarchy($taxonomy); - - // Some funky recursion to get the job done(Paging & parents mainly) is contained within, Skip it for non-hierarchical taxonomies for performance sake - $out .= _term_rows($taxonomy, $terms, $children, $page, $pagesize, $count); - } else { - $terms = get_terms( $taxonomy, $args ); - foreach( $terms as $term ) - $out .= _tag_row( $term, 0, $taxonomy ); - $count = $pagesize; // Only displaying a single page. - } - - echo $out; - return $count; -} - -function _term_rows( $taxonomy, $terms, &$children, $page = 1, $per_page = 20, &$count, $parent = 0, $level = 0 ) { - - $start = ($page - 1) * $per_page; - $end = $start + $per_page; - - $output = ''; - foreach ( $terms as $key => $term ) { - - if ( $count >= $end ) - break; - - if ( $term->parent != $parent && empty($_GET['s']) ) - continue; - - // If the page starts in a subtree, print the parents. - if ( $count == $start && $term->parent > 0 && empty($_GET['s']) ) { - $my_parents = $parent_ids = array(); - $p = $term->parent; - while ( $p ) { - $my_parent = get_term( $p, $taxonomy ); - $my_parents[] = $my_parent; - $p = $my_parent->parent; - if ( in_array($p, $parent_ids) ) // Prevent parent loops. - break; - $parent_ids[] = $p; - } - unset($parent_ids); - - $num_parents = count($my_parents); - while ( $my_parent = array_pop($my_parents) ) { - $output .= "\t" . _tag_row( $my_parent, $level - $num_parents, $taxonomy ); - $num_parents--; - } - } - - if ( $count >= $start ) - $output .= "\t" . _tag_row( $term, $level, $taxonomy ); - - ++$count; - - unset($terms[$key]); - - if ( isset($children[$term->term_id]) && empty($_GET['s']) ) - $output .= _term_rows( $taxonomy, $terms, $children, $page, $per_page, $count, $term->term_id, $level + 1 ); - } - - return $output; -} - -// define the columns to display, the syntax is 'internal name' => 'display name' -/** - * {@internal Missing Short Description}} - * - * @since unknown - * - * @return unknown - */ -function wp_manage_posts_columns( $screen = '') { - if ( empty($screen) ) - $post_type = 'post'; - else - $post_type = $screen->post_type; - - $posts_columns = array(); - $posts_columns['cb'] = ''; - /* translators: manage posts column name */ - $posts_columns['title'] = _x('Title', 'column name'); - $posts_columns['author'] = __('Author'); - if ( empty($post_type) || is_object_in_taxonomy($post_type, 'category') ) - $posts_columns['categories'] = __('Categories'); - if ( empty($post_type) || is_object_in_taxonomy($post_type, 'post_tag') ) - $posts_columns['tags'] = __('Tags'); - $post_status = !empty($_REQUEST['post_status']) ? $_REQUEST['post_status'] : 'all'; - if ( !in_array( $post_status, array('pending', 'draft', 'future') ) && ( empty($post_type) || post_type_supports($post_type, 'comments') ) ) - $posts_columns['comments'] = '
            Comments
            '; - $posts_columns['date'] = __('Date'); - - if ( 'page' == $post_type ) - $posts_columns = apply_filters( 'manage_pages_columns', $posts_columns ); - else - $posts_columns = apply_filters( 'manage_posts_columns', $posts_columns, $post_type ); - $posts_columns = apply_filters( "manage_{$post_type}_posts_columns", $posts_columns ); - - return $posts_columns; -} - -// define the columns to display, the syntax is 'internal name' => 'display name' -/** - * {@internal Missing Short Description}} - * - * @since unknown - * - * @return unknown - */ -function wp_manage_media_columns() { - $posts_columns = array(); - $posts_columns['cb'] = ''; - $posts_columns['icon'] = ''; - /* translators: column name */ - $posts_columns['media'] = _x('File', 'column name'); - $posts_columns['author'] = __('Author'); - //$posts_columns['tags'] = _x('Tags', 'column name'); - /* translators: column name */ - $posts_columns['parent'] = _x('Attached to', 'column name'); - $posts_columns['comments'] = '
            Comments
            '; - //$posts_columns['comments'] = __('Comments'); - /* translators: column name */ - $posts_columns['date'] = _x('Date', 'column name'); - $posts_columns = apply_filters('manage_media_columns', $posts_columns); - - return $posts_columns; -} - -/** - * {@internal Missing Short Description}} - * - * @since unknown - * - * @return unknown - */ -function wp_manage_pages_columns() { - return wp_manage_posts_columns(); -} - -/** - * Get the column headers for a screen - * - * @since unknown - * - * @param string|object $screen The screen you want the headers for - * @return array Containing the headers in the format id => UI String - */ -function get_column_headers($screen) { - global $_wp_column_headers; - - if ( !isset($_wp_column_headers) ) - $_wp_column_headers = array(); - - if ( is_string($screen) ) - $screen = convert_to_screen($screen); - - // Store in static to avoid running filters on each call - if ( isset($_wp_column_headers[$screen->id]) ) - return $_wp_column_headers[$screen->id]; - - switch ($screen->base) { - case 'edit': - $_wp_column_headers[$screen->id] = wp_manage_posts_columns( $screen ); - break; - case 'edit-comments': - $_wp_column_headers[$screen->id] = array( - 'cb' => '', - 'author' => __('Author'), - /* translators: column name */ - 'comment' => _x('Comment', 'column name'), - //'date' => __('Submitted'), - 'response' => __('In Response To') - ); - - break; - case 'link-manager': - $_wp_column_headers[$screen->id] = array( - 'cb' => '', - 'name' => __('Name'), - 'url' => __('URL'), - 'categories' => __('Categories'), - 'rel' => __('Relationship'), - 'visible' => __('Visible'), - 'rating' => __('Rating') - ); - - break; - case 'upload': - $_wp_column_headers[$screen->id] = wp_manage_media_columns(); - break; - case 'categories': - $_wp_column_headers[$screen->id] = array( - 'cb' => '', - 'name' => __('Name'), - 'description' => __('Description'), - 'slug' => __('Slug'), - 'posts' => __('Posts') - ); - - break; - case 'edit-link-categories': - $_wp_column_headers[$screen->id] = array( - 'cb' => '', - 'name' => __('Name'), - 'description' => __('Description'), - 'slug' => __('Slug'), - 'links' => __('Links') - ); - - break; - case 'edit-tags': - $_wp_column_headers[$screen->id] = array( - 'cb' => '', - 'name' => __('Name'), - 'description' => __('Description'), - 'slug' => __('Slug'), - 'posts' => __('Posts') - ); - - break; - case 'users': - $_wp_column_headers[$screen->id] = array( - 'cb' => '', - 'username' => __('Username'), - 'name' => __('Name'), - 'email' => __('E-mail'), - 'role' => __('Role'), - 'posts' => __('Posts') - ); - break; - default : - $_wp_column_headers[$screen->id] = array(); - } - - $_wp_column_headers[$screen->id] = apply_filters('manage_' . $screen->id . '_columns', $_wp_column_headers[$screen->id]); - return $_wp_column_headers[$screen->id]; -} - -/** - * {@internal Missing Short Description}} - * - * @since unknown - * - * @param unknown_type $screen - * @param unknown_type $id - */ -function print_column_headers( $screen, $id = true ) { - if ( is_string($screen) ) - $screen = convert_to_screen($screen); - - $columns = get_column_headers( $screen ); - $hidden = get_hidden_columns($screen); - $styles = array(); - - foreach ( $columns as $column_key => $column_display_name ) { - $class = ' class="manage-column'; - - $class .= " column-$column_key"; - - if ( 'cb' == $column_key ) - $class .= ' check-column'; - elseif ( in_array($column_key, array('posts', 'comments', 'links')) ) - $class .= ' num'; - - $class .= '"'; - - $style = ''; - if ( in_array($column_key, $hidden) ) - $style = 'display:none;'; - - if ( isset($styles[$screen->id]) && isset($styles[$screen->id][$column_key]) ) - $style .= ' ' . $styles[$screen>id][$column_key]; - $style = ' style="' . $style . '"'; -?> - > -id] = $columns; -} - -/** - * {@internal Missing Short Description}} - * - * @since unknown - * - * @param unknown_type $screen - */ -function get_hidden_columns($screen) { - if ( is_string($screen) ) - $screen = convert_to_screen($screen); - - return (array) get_user_option( 'manage' . $screen->id. 'columnshidden' ); -} - -/** - * {@internal Missing Short Description}} - * - * Outputs the quick edit and bulk edit table rows for posts and pages - * - * @since 2.7 - * - * @param string $screen - */ -function inline_edit_row( $screen ) { - global $mode; - - if ( is_string($screen) ) { - $screen = array('id' => 'edit-' . $screen, 'base' => 'edit', 'post_type' => $screen ); - $screen = (object) $screen; - } - - $post = get_default_post_to_edit( $screen->post_type ); - $post_type_object = get_post_type_object( $screen->post_type ); - - $taxonomy_names = get_object_taxonomies( $screen->post_type ); - $hierarchical_taxonomies = array(); - $flat_taxonomies = array(); - foreach ( $taxonomy_names as $taxonomy_name ) { - $taxonomy = get_taxonomy( $taxonomy_name); - - if ( !$taxonomy->show_ui ) - continue; - - if ( $taxonomy->hierarchical ) - $hierarchical_taxonomies[] = $taxonomy; - else - $flat_taxonomies[] = $taxonomy; - } - - $columns = wp_manage_posts_columns($screen); - $hidden = array_intersect( array_keys( $columns ), array_filter( get_hidden_columns($screen) ) ); - $col_count = count($columns) - count($hidden); - $m = ( isset($mode) && 'excerpt' == $mode ) ? 'excerpt' : 'list'; - $can_publish = current_user_can($post_type_object->cap->publish_posts); - $core_columns = array( 'cb' => true, 'date' => true, 'title' => true, 'categories' => true, 'tags' => true, 'comments' => true, 'author' => true ); - -?> - -
            - - - post_type "; - echo $bulk ? "bulk-edit-row bulk-edit-row-$hclass bulk-edit-$screen->post_type" : "quick-edit-row quick-edit-row-$hclass inline-edit-$screen->post_type"; - ?>" style="display: none"> - -
            - -
            -

            - - -post_type, 'title' ) ) : - if ( $bulk ) : ?> -
            -
            -
            - - - - - - - - - - - -
            - -
            -
            - -post_type, 'author' ) ) : - $authors = get_editable_user_ids( get_current_user_id(), true, $screen->post_type ); // TODO: ROLE SYSTEM - $authors_dropdown = ''; - if ( $authors && count( $authors ) > 1 ) : - $users_opt = array('include' => $authors, 'name' => 'post_author', 'class'=> 'authors', 'multi' => 1, 'echo' => 0); - if ( $bulk ) - $users_opt['show_option_none'] = __('— No Change —'); - $authors_dropdown = ''; - - endif; // authors -?> - - - -
            - - - - - - -
            - - - -
            - - - -
            - - - - labels->name) ?> - - - - -
              - $taxonomy->name)) ?> -
            - - - -
            - - - -
            - -post_type, 'author' ) && $bulk ) - echo $authors_dropdown; -?> - -hierarchical ) : ?> - - - -post_type, 'page-attributes' ) ) : - if ( !$bulk ) : ?> - - - - - - - -hierarchical ?> - - - - - - - - - - - -post_type, 'comments' ) || post_type_supports( $screen->post_type, 'trackbacks' ) ) : - if ( $bulk ) : ?> - -
            - post_type, 'comments' ) ) : ?> - - post_type, 'trackbacks' ) ) : ?> - - -
            - - - -
            - post_type, 'comments' ) ) : ?> - - post_type, 'trackbacks' ) ) : ?> - - -
            - - - -
            - - -post_type && $can_publish && current_user_can( $post_type_object->cap->edit_others_posts ) ) : ?> - - - - - - - - - - - - - -
            - -
            - - $column_display_name ) { - if ( isset( $core_columns[$column_name] ) ) - continue; - do_action( $bulk ? 'bulk_edit_custom_box' : 'quick_edit_custom_box', $column_name, $screen->post_type ); - } -?> -

            - - - - - - - - - -
            -

            -
            -post_type); - if ( ! current_user_can($post_type_object->cap->edit_post, $post->ID) ) - return; - - $title = htmlspecialchars( trim( $post->post_title ), ENT_QUOTES ); - - echo ' -'; -} - -/** - * {@internal Missing Short Description}} - * - * @since unknown - * - * @param unknown_type $posts - */ -function post_rows( $posts = array() ) { - global $wp_query, $post, $mode; - - add_filter('the_title','esc_html'); - - // Create array of post IDs. - $post_ids = array(); - - if ( empty($posts) ) - $posts = &$wp_query->posts; - - foreach ( $posts as $a_post ) - $post_ids[] = $a_post->ID; - - $comment_pending_count = get_pending_comments_num($post_ids); - - foreach ( $posts as $post ) { - if ( empty($comment_pending_count[$post->ID]) ) - $comment_pending_count[$post->ID] = 0; - - _post_row($post, $comment_pending_count[$post->ID], $mode); - } -} - -/** - * {@internal Missing Short Description}} - * - * @since unknown - * - * @param unknown_type $a_post - * @param unknown_type $pending_comments - * @param unknown_type $mode - */ -function _post_row($a_post, $pending_comments, $mode) { - global $post, $current_screen; - static $rowclass; - - $global_post = $post; - $post = $a_post; - setup_postdata($post); - - $rowclass = 'alternate' == $rowclass ? '' : 'alternate'; - $post_owner = ( get_current_user_id() == $post->post_author ? 'self' : 'other' ); - $edit_link = get_edit_post_link( $post->ID ); - $title = _draft_or_post_title(); - $post_type_object = get_post_type_object($post->post_type); -?> - post_status ); ?> iedit' valign="top"> -$column_display_name ) { - $class = "class=\"$column_name column-$column_name\""; - - $style = ''; - if ( in_array($column_name, $hidden) ) - $style = ' style="display:none;"'; - - $attributes = "$class$style"; - - switch ($column_name) { - - case 'cb': - ?> - cap->edit_post, $post->ID ) ) { ?> - post_date && 'date' == $column_name ) { - $t_time = $h_time = __('Unpublished'); - $time_diff = 0; - } else { - $t_time = get_the_time(__('Y/m/d g:i:s A')); - $m_time = $post->post_date; - $time = get_post_time('G', true, $post); - - $time_diff = time() - $time; - - if ( $time_diff > 0 && $time_diff < 24*60*60 ) - $h_time = sprintf( __('%s ago'), human_time_diff( $time ) ); - else - $h_time = mysql2date(__('Y/m/d'), $m_time); - } - - echo ''; - if ( 'excerpt' == $mode ) - echo apply_filters('post_date_column_time', $t_time, $post, $column_name, $mode); - else - echo '' . apply_filters('post_date_column_time', $h_time, $post, $column_name, $mode) . ''; - echo '
            '; - if ( 'publish' == $post->post_status ) { - _e('Published'); - } elseif ( 'future' == $post->post_status ) { - if ( $time_diff > 0 ) - echo '' . __('Missed schedule') . ''; - else - _e('Scheduled'); - } else { - _e('Last Modified'); - } - echo ''; - break; - - case 'title': - $attributes = 'class="post-title column-title"' . $style; - ?> - >cap->edit_post, $post->ID) && $post->post_status != 'trash' ) { ?> - cap->edit_post, $post->ID) && 'trash' != $post->post_status ) { - $actions['edit'] = '' . __('Edit') . ''; - $actions['inline hide-if-no-js'] = '' . __('Quick Edit') . ''; - } - if ( current_user_can($post_type_object->cap->delete_post, $post->ID) ) { - if ( 'trash' == $post->post_status ) - $actions['untrash'] = "ID) ), 'untrash-' . $post->post_type . '_' . $post->ID ) . "'>" . __('Restore') . ""; - elseif ( EMPTY_TRASH_DAYS ) - $actions['trash'] = "" . __('Trash') . ""; - if ( 'trash' == $post->post_status || !EMPTY_TRASH_DAYS ) - $actions['delete'] = "" . __('Delete Permanently') . ""; - } - if ( in_array($post->post_status, array('pending', 'draft')) ) { - if ( current_user_can($post_type_object->cap->edit_post, $post->ID) ) - $actions['view'] = '' . __('Preview') . ''; - } elseif ( 'trash' != $post->post_status ) { - $actions['view'] = '' . __('View') . ''; - } - $actions = apply_filters('post_row_actions', $actions, $post); - $action_count = count($actions); - $i = 0; - echo '
            '; - foreach ( $actions as $action => $link ) { - ++$i; - ( $i == $action_count ) ? $sep = '' : $sep = ' | '; - echo "$link$sep"; - } - echo '
            '; - - get_inline_data($post); - ?> - - - >post_type}&category_name={$c->slug}'> " . esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'category', 'display')) . ""; - echo join( ', ', $out ); - } else { - _e('Uncategorized'); - } - ?> - - >ID); - if ( !empty( $tags ) ) { - $out = array(); - foreach ( $tags as $c ) - $out[] = " " . esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'post_tag', 'display')) . ""; - echo join( ', ', $out ); - } else { - _e('No Tags'); - } - ?> - - >
            - '; - comments_number("" . /* translators: comment count link */ _x('0', 'comment count') . '', "" . /* translators: comment count link */ _x('1', 'comment count') . '', "" . /* translators: comment count link: % will be substituted by comment count */ _x('%', 'comment count') . ''); - if ( $pending_comments ) - echo ''; - ?> -
            - - > - - - - cap->edit_post, $post->ID) ) { echo "" . __('Edit') . ""; } ?> - - cap->delete_post, $post->ID) ) { echo "ID) . "' class='delete'>" . __('Delete') . ""; } ?> - - >ID); ?> - - -post_parent > 0 ) { - //sent level 0 by accident, by default, or because we don't know the actual level - $find_main_page = (int)$page->post_parent; - while ( $find_main_page > 0 ) { - $parent = get_page($find_main_page); - - if ( is_null($parent) ) - break; - - $level++; - $find_main_page = (int)$parent->post_parent; - - if ( !isset($parent_name) ) - $parent_name = $parent->post_title; - } - } - - $page->post_title = esc_html( $page->post_title ); - $pad = str_repeat( '— ', $level ); - $id = (int) $page->ID; - $rowclass = 'alternate' == $rowclass ? '' : 'alternate'; - $posts_columns = get_column_headers( $current_screen ); - $hidden = get_hidden_columns( $current_screen ); - $title = _draft_or_post_title(); - $post_type = $page->post_type; - $post_type_object = get_post_type_object($post_type); -?> - - $column_display_name ) { - $class = "class=\"$column_name column-$column_name\""; - - $style = ''; - if ( in_array($column_name, $hidden) ) - $style = ' style="display:none;"'; - - $attributes = "$class$style"; - - switch ($column_name) { - - case 'cb': - ?> - cap->edit_post, $page->ID ) ) { ?> - post_date && 'date' == $column_name ) { - $t_time = $h_time = __('Unpublished'); - $time_diff = 0; - } else { - $t_time = get_the_time(__('Y/m/d g:i:s A')); - $m_time = $page->post_date; - $time = get_post_time('G', true); - - $time_diff = time() - $time; - - if ( $time_diff > 0 && $time_diff < 24*60*60 ) - $h_time = sprintf( __('%s ago'), human_time_diff( $time ) ); - else - $h_time = mysql2date(__('Y/m/d'), $m_time); - } - echo ''; - echo '' . apply_filters('post_date_column_time', $h_time, $page, $column_name, '') . ''; - echo '
            '; - if ( 'publish' == $page->post_status ) { - _e('Published'); - } elseif ( 'future' == $page->post_status ) { - if ( $time_diff > 0 ) - echo '' . __('Missed schedule') . ''; - else - _e('Scheduled'); - } else { - _e('Last Modified'); - } - echo ''; - break; - case 'title': - $attributes = 'class="post-title page-title column-title"' . $style; - $edit_link = get_edit_post_link( $page->ID ); - ?> - >cap->edit_post, $page->ID) && $post->post_status != 'trash' ) { ?>labels->parent_item_colon . ' ' . esc_html($parent_name) : ''; ?> - cap->edit_post, $page->ID) && $post->post_status != 'trash' ) { - $actions['edit'] = '' . __('Edit') . ''; - $actions['inline'] = '' . __('Quick Edit') . ''; - } - if ( current_user_can($post_type_object->cap->delete_post, $page->ID) ) { - if ( $post->post_status == 'trash' ) - $actions['untrash'] = "post_type . '_' . $page->ID) . "'>" . __('Restore') . ""; - elseif ( EMPTY_TRASH_DAYS ) - $actions['trash'] = "" . __('Trash') . ""; - if ( $post->post_status == 'trash' || !EMPTY_TRASH_DAYS ) - $actions['delete'] = "post_type . '_' . $page->ID) . "'>" . __('Delete Permanently') . ""; - } - if ( in_array($post->post_status, array('pending', 'draft')) ) { - if ( current_user_can($post_type_object->cap->edit_post, $page->ID) ) - $actions['view'] = '' . __('Preview') . ''; - } elseif ( $post->post_status != 'trash' ) { - $actions['view'] = '' . __('View') . ''; - } - $actions = apply_filters('page_row_actions', $actions, $page); - $action_count = count($actions); - - $i = 0; - echo '
            '; - foreach ( $actions as $action => $link ) { - ++$i; - ( $i == $action_count ) ? $sep = '' : $sep = ' | '; - echo "$link$sep"; - } - echo '
            '; - - get_inline_data($post); - echo ''; - break; - - case 'comments': - ?> - >
            - ID ); - $pending_phrase = sprintf( __('%s pending'), number_format( $left ) ); - if ( $left ) - echo ''; - comments_number("" . /* translators: comment count link */ _x('0', 'comment count') . '', "" . /* translators: comment count link */ _x('1', 'comment count') . '', "" . /* translators: comment count link: % will be substituted by comment count */ _x('%', 'comment count') . ''); - if ( $left ) - echo ''; - ?> -
            - - > - - > - - - - - 'menu_order') ); - - if ( ! $pages ) - return false; - } - - /* - * arrange pages into two parts: top level pages and children_pages - * children_pages is two dimensional array, eg. - * children_pages[10][] contains all sub-pages whose parent is 10. - * It only takes O(N) to arrange this and it takes O(1) for subsequent lookup operations - * If searching, ignore hierarchy and treat everything as top level - */ - if ( empty($_GET['s']) ) { - - $top_level_pages = array(); - $children_pages = array(); - - foreach ( $pages as $page ) { - - // catch and repair bad pages - if ( $page->post_parent == $page->ID ) { - $page->post_parent = 0; - $wpdb->update($wpdb->posts, array('post_parent' => 0), array('ID' => $page->ID)); - clean_page_cache( $page->ID ); - } - - if ( 0 == $page->post_parent ) - $top_level_pages[] = $page; - else - $children_pages[ $page->post_parent ][] = $page; - } - - $pages = &$top_level_pages; - } - - $count = 0; - $start = ($pagenum - 1) * $per_page; - $end = $start + $per_page; - - foreach ( $pages as $page ) { - if ( $count >= $end ) - break; - - if ( $count >= $start ) - echo "\t" . display_page_row( $page, $level ); - - $count++; - - if ( isset($children_pages) ) - _page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page ); - } - - // if it is the last pagenum and there are orphaned pages, display them with paging as well - if ( isset($children_pages) && $count < $end ){ - foreach( $children_pages as $orphans ){ - foreach ( $orphans as $op ) { - if ( $count >= $end ) - break; - if ( $count >= $start ) - echo "\t" . display_page_row( $op, 0 ); - $count++; - } - } - } -} - -/** - * Given a top level page ID, display the nested hierarchy of sub-pages - * together with paging support - * - * @since unknown - * - * @param unknown_type $children_pages - * @param unknown_type $count - * @param unknown_type $parent - * @param unknown_type $level - * @param unknown_type $pagenum - * @param unknown_type $per_page - */ -function _page_rows( &$children_pages, &$count, $parent, $level, $pagenum, $per_page ) { - - if ( ! isset( $children_pages[$parent] ) ) - return; - - $start = ($pagenum - 1) * $per_page; - $end = $start + $per_page; - - foreach ( $children_pages[$parent] as $page ) { - - if ( $count >= $end ) - break; - - // If the page starts in a subtree, print the parents. - if ( $count == $start && $page->post_parent > 0 ) { - $my_parents = array(); - $my_parent = $page->post_parent; - while ( $my_parent) { - $my_parent = get_post($my_parent); - $my_parents[] = $my_parent; - if ( !$my_parent->post_parent ) - break; - $my_parent = $my_parent->post_parent; - } - $num_parents = count($my_parents); - while( $my_parent = array_pop($my_parents) ) { - echo "\t" . display_page_row( $my_parent, $level - $num_parents ); - $num_parents--; - } - } - - if ( $count >= $start ) - echo "\t" . display_page_row( $page, $level ); - - $count++; - - _page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page ); - } - - unset( $children_pages[$parent] ); //required in order to keep track of orphans -} - -/** - * Generate HTML for a single row on the users.php admin panel. - * - * @since 2.1.0 - * - * @param object $user_object - * @param string $style Optional. Attributes added to the TR element. Must be sanitized. - * @param string $role Key for the $wp_roles array. - * @param int $numposts Optional. Post count to display for this user. Defaults to zero, as in, a new user has made zero posts. - * @return string - */ -function user_row( $user_object, $style = '', $role = '', $numposts = 0 ) { - global $wp_roles; - - if ( !( is_object( $user_object) && is_a( $user_object, 'WP_User' ) ) ) - $user_object = new WP_User( (int) $user_object ); - $user_object = sanitize_user_object($user_object, 'display'); - $email = $user_object->user_email; - $url = $user_object->user_url; - $short_url = str_replace( 'http://', '', $url ); - $short_url = str_replace( 'www.', '', $short_url ); - if ('/' == substr( $short_url, -1 )) - $short_url = substr( $short_url, 0, -1 ); - if ( strlen( $short_url ) > 35 ) - $short_url = substr( $short_url, 0, 32 ).'...'; - $checkbox = ''; - // Check if the user for this row is editable - if ( current_user_can( 'list_users' ) ) { - // Set up the user editing link - // TODO: make profile/user-edit determination a separate function - if ( get_current_user_id() == $user_object->ID) { - $edit_link = 'profile.php'; - } else { - $edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( esc_url( stripslashes( $_SERVER['REQUEST_URI'] ) ) ), "user-edit.php?user_id=$user_object->ID" ) ); - } - $edit = "$user_object->user_login
            "; - - // Set up the hover actions for this user - $actions = array(); - - if ( current_user_can('edit_user', $user_object->ID) ) { - $edit = "$user_object->user_login
            "; - $actions['edit'] = '' . __('Edit') . ''; - } else { - $edit = "$user_object->user_login
            "; - } - - if ( !is_multisite() && get_current_user_id() != $user_object->ID && current_user_can('delete_user', $user_object->ID) ) - $actions['delete'] = "" . __('Delete') . ""; - if ( is_multisite() && get_current_user_id() != $user_object->ID && current_user_can('remove_user', $user_object->ID) ) - $actions['remove'] = "" . __('Remove') . ""; - $actions = apply_filters('user_row_actions', $actions, $user_object); - $action_count = count($actions); - $i = 0; - $edit .= '
            '; - foreach ( $actions as $action => $link ) { - ++$i; - ( $i == $action_count ) ? $sep = '' : $sep = ' | '; - $edit .= "$link$sep"; - } - $edit .= '
            '; - - // Set up the checkbox (because the user is editable, otherwise its empty) - $checkbox = ""; - - } else { - $edit = '' . $user_object->user_login . ''; - } - $role_name = isset($wp_roles->role_names[$role]) ? translate_user_role($wp_roles->role_names[$role] ) : __('None'); - $r = ""; - $columns = get_column_headers('users'); - $hidden = get_hidden_columns('users'); - $avatar = get_avatar( $user_object->ID, 32 ); - foreach ( $columns as $column_name => $column_display_name ) { - $class = "class=\"$column_name column-$column_name\""; - - $style = ''; - if ( in_array($column_name, $hidden) ) - $style = ' style="display:none;"'; - - $attributes = "$class$style"; - - switch ($column_name) { - case 'cb': - $r .= "$checkbox"; - break; - case 'username': - $r .= "$avatar $edit"; - break; - case 'name': - $r .= "$user_object->first_name $user_object->last_name"; - break; - case 'email': - $r .= "$email"; - break; - case 'role': - $r .= "$role_name"; - break; - case 'posts': - $attributes = 'class="posts column-posts num"' . $style; - $r .= ""; - if ( $numposts > 0 ) { - $r .= ""; - $r .= $numposts; - $r .= ''; - } else { - $r .= 0; - } - $r .= ""; - break; - default: - $r .= ""; - $r .= apply_filters('manage_users_custom_column', '', $column_name, $user_object->ID); - $r .= ""; - } - } - $r .= ''; - - return $r; + foreach ( $categories as $category ) { + $cat_id = $category->term_id; + $name = esc_html( apply_filters( 'the_category', $category->name ) ); + $checked = in_array( $cat_id, $checked_categories ) ? ' checked="checked"' : ''; + echo '"; + } } /** - * {@internal Missing Short Description}} + * Get the column headers for a screen * - * @since unknown + * @since 2.7.0 * - * @param string $status Comment status (approved, spam, trash, etc) - * @param string $s Term to search for - * @param int $start Offset to start at for pagination - * @param int $num Maximum number of comments to return - * @param int $post Post ID or 0 to return all comments - * @param string $type Comment type (comment, trackback, pingback, etc) - * @return array [0] contains the comments and [1] contains the total number of comments that match (ignoring $start and $num) + * @param string|object $screen The screen you want the headers for + * @return array Containing the headers in the format id => UI String */ -function _wp_get_comment_list( $status = '', $s = false, $start, $num, $post = 0, $type = '' ) { - global $wpdb; - - $start = abs( (int) $start ); - $num = (int) $num; - $post = (int) $post; - $count = wp_count_comments(); - $index = ''; - - if ( 'moderated' == $status ) { - $approved = "c.comment_approved = '0'"; - $total = $count->moderated; - } elseif ( 'approved' == $status ) { - $approved = "c.comment_approved = '1'"; - $total = $count->approved; - } elseif ( 'spam' == $status ) { - $approved = "c.comment_approved = 'spam'"; - $total = $count->spam; - } elseif ( 'trash' == $status ) { - $approved = "c.comment_approved = 'trash'"; - $total = $count->trash; - } else { - $approved = "( c.comment_approved = '0' OR c.comment_approved = '1' )"; - $total = $count->moderated + $count->approved; - $index = 'USE INDEX (c.comment_date_gmt)'; - } - - if ( $post ) { - $total = ''; - $post = " AND c.comment_post_ID = '$post'"; - } else { - $post = ''; - } +function get_column_headers( $screen ) { + if ( is_string( $screen ) ) + $screen = convert_to_screen( $screen ); - $orderby = "ORDER BY c.comment_date_gmt DESC LIMIT $start, $num"; + global $_wp_column_headers; - if ( 'comment' == $type ) - $typesql = "AND c.comment_type = ''"; - elseif ( 'pings' == $type ) - $typesql = "AND ( c.comment_type = 'pingback' OR c.comment_type = 'trackback' )"; - elseif ( 'all' == $type ) - $typesql = ''; - elseif ( !empty($type) ) - $typesql = $wpdb->prepare("AND c.comment_type = %s", $type); - else - $typesql = ''; - - if ( !empty($type) ) - $total = ''; - - $query = "FROM $wpdb->comments c LEFT JOIN $wpdb->posts p ON c.comment_post_ID = p.ID WHERE p.post_status != 'trash' "; - if ( $s ) { - $total = ''; - $s = $wpdb->escape($s); - $query .= "AND - (c.comment_author LIKE '%$s%' OR - c.comment_author_email LIKE '%$s%' OR - c.comment_author_url LIKE ('%$s%') OR - c.comment_author_IP LIKE ('%$s%') OR - c.comment_content LIKE ('%$s%') ) AND - $approved - $typesql"; - } else { - $query .= "AND $approved $post $typesql"; + if ( !isset( $_wp_column_headers[ $screen->id ] ) ) { + $_wp_column_headers[ $screen->id ] = apply_filters( 'manage_' . $screen->id . '_columns', array() ); } - $comments = $wpdb->get_results("SELECT * $query $orderby"); - if ( '' === $total ) - $total = $wpdb->get_var("SELECT COUNT(c.comment_ID) $query"); + return $_wp_column_headers[ $screen->id ]; +} - update_comment_cache($comments); +/** + * Get a list of hidden columns. + * + * @since 2.7.0 + * + * @param string|object $screen The screen you want the hidden columns for + * @return array + */ +function get_hidden_columns( $screen ) { + if ( is_string( $screen ) ) + $screen = convert_to_screen( $screen ); - return array($comments, $total); + return (array) get_user_option( 'manage' . $screen->id . 'columnshidden' ); } +// adds hidden fields with the data for use in the inline editor for posts and pages /** * {@internal Missing Short Description}} * - * @since unknown + * @since 2.7.0 * - * @param unknown_type $comment_id - * @param unknown_type $mode - * @param unknown_type $comment_status - * @param unknown_type $checkbox + * @param unknown_type $post */ -function _wp_comment_row( $comment_id, $mode, $comment_status, $checkbox = true, $from_ajax = false ) { - global $comment, $post, $_comment_pending_count; - $comment = get_comment( $comment_id ); - $post = get_post($comment->comment_post_ID); - $the_comment_status = wp_get_comment_status($comment->comment_ID); +function get_inline_data($post) { $post_type_object = get_post_type_object($post->post_type); - $user_can = current_user_can($post_type_object->cap->edit_post, $post->ID); - - $comment_url = esc_url(get_comment_link($comment->comment_ID)); - $author_url = get_comment_author_url(); - if ( 'http://' == $author_url ) - $author_url = ''; - $author_url_display = preg_replace('|http://(www\.)?|i', '', $author_url); - if ( strlen($author_url_display) > 50 ) - $author_url_display = substr($author_url_display, 0, 49) . '...'; - - $ptime = date('G', strtotime( $comment->comment_date ) ); - if ( ( abs(time() - $ptime) ) < 86400 ) - $ptime = sprintf( __('%s ago'), human_time_diff( $ptime ) ); - else - $ptime = mysql2date(__('Y/m/d \a\t g:i A'), $comment->comment_date ); - - if ( $user_can ) { - $del_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "delete-comment_$comment->comment_ID" ) ); - $approve_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "approve-comment_$comment->comment_ID" ) ); - - $approve_url = esc_url( "comment.php?action=approvecomment&p=$post->ID&c=$comment->comment_ID&$approve_nonce" ); - $unapprove_url = esc_url( "comment.php?action=unapprovecomment&p=$post->ID&c=$comment->comment_ID&$approve_nonce" ); - $spam_url = esc_url( "comment.php?action=spamcomment&p=$post->ID&c=$comment->comment_ID&$del_nonce" ); - $unspam_url = esc_url( "comment.php?action=unspamcomment&p=$post->ID&c=$comment->comment_ID&$del_nonce" ); - $trash_url = esc_url( "comment.php?action=trashcomment&p=$post->ID&c=$comment->comment_ID&$del_nonce" ); - $untrash_url = esc_url( "comment.php?action=untrashcomment&p=$post->ID&c=$comment->comment_ID&$del_nonce" ); - $delete_url = esc_url( "comment.php?action=deletecomment&p=$post->ID&c=$comment->comment_ID&$del_nonce" ); - } + if ( ! current_user_can($post_type_object->cap->edit_post, $post->ID) ) + return; - echo ""; - $columns = get_column_headers('edit-comments'); - $hidden = get_hidden_columns('edit-comments'); - foreach ( $columns as $column_name => $column_display_name ) { - $class = "class=\"$column_name column-$column_name\""; + $title = esc_textarea( trim( $post->post_title ) ); - $style = ''; - if ( in_array($column_name, $hidden) ) - $style = ' style="display:none;"'; - - $attributes = "$class$style"; - - switch ($column_name) { - case 'cb': - if ( !$checkbox ) break; - echo ''; - if ( $user_can ) echo ""; - echo ''; - break; - case 'comment': - echo ""; - echo '
            '; - /* translators: 2: comment date, 3: comment time */ - printf( __( '%2$s at %3$s' ), $comment_url, - /* translators: comment date format. See http://php.net/date */ get_comment_date( __('Y/m/d') ), - /* translators: comment time format. See http://php.net/date */ get_comment_date( get_option( 'time_format' ) ) ); - - if ( $comment->comment_parent ) { - $parent = get_comment( $comment->comment_parent ); - $parent_link = esc_url( get_comment_link( $comment->comment_parent ) ); - $name = apply_filters( 'get_comment_author', $parent->comment_author ); // there's no API function for this - printf( ' | '.__( 'In reply to %2$s.' ), $parent_link, $name ); - } + echo ' +'; - comment_text(); - if ( $user_can ) { ?> - - hierarchical ) + echo '
            ' . $post->post_parent . '
            '; - if ( $user_can ) { - // preorder it: Approve | Reply | Quick Edit | Edit | Spam | Trash - $actions = array( - 'approve' => '', 'unapprove' => '', - 'reply' => '', - 'quickedit' => '', - 'edit' => '', - 'spam' => '', 'unspam' => '', - 'trash' => '', 'untrash' => '', 'delete' => '' - ); - - if ( $comment_status && 'all' != $comment_status ) { // not looking at all comments - if ( 'approved' == $the_comment_status ) - $actions['unapprove'] = "" . __( 'Unapprove' ) . ''; - else if ( 'unapproved' == $the_comment_status ) - $actions['approve'] = "" . __( 'Approve' ) . ''; - } else { - $actions['approve'] = "" . __( 'Approve' ) . ''; - $actions['unapprove'] = "" . __( 'Unapprove' ) . ''; - } + if ( $post->post_type == 'page' ) + echo '
            ' . esc_html( get_post_meta( $post->ID, '_wp_page_template', true ) ) . '
            '; - if ( 'spam' != $the_comment_status && 'trash' != $the_comment_status ) { - $actions['spam'] = "" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . ''; - } elseif ( 'spam' == $the_comment_status ) { - $actions['unspam'] = "" . _x( 'Not Spam', 'comment' ) . ''; - } elseif ( 'trash' == $the_comment_status ) { - $actions['untrash'] = "" . __( 'Restore' ) . ''; - } + if ( $post_type_object->hierarchical ) + echo ''; - if ( 'spam' == $the_comment_status || 'trash' == $the_comment_status || !EMPTY_TRASH_DAYS ) { - $actions['delete'] = "" . __('Delete Permanently') . ''; - } else { - $actions['trash'] = "" . _x('Trash', 'verb') . ''; - } + $taxonomy_names = get_object_taxonomies( $post->post_type ); + foreach ( $taxonomy_names as $taxonomy_name) { + $taxonomy = get_taxonomy( $taxonomy_name ); - if ( 'trash' != $the_comment_status ) { - $actions['edit'] = "". __('Edit') . ''; - $actions['quickedit'] = '' . __('Quick Edit') . ''; - if ( 'spam' != $the_comment_status ) - $actions['reply'] = '' . __('Reply') . ''; - } + if ( $taxonomy->hierarchical && $taxonomy->show_ui ) + echo ''; + elseif ( $taxonomy->show_ui ) + echo '
            ' . esc_html( str_replace( ',', ', ', get_terms_to_edit($post->ID, $taxonomy_name) ) ) . '
            '; + } - $actions = apply_filters( 'comment_row_actions', array_filter($actions), $comment ); - - $i = 0; - echo '
            '; - foreach ( $actions as $action => $link ) { - ++$i; - ( ( ('approve' == $action || 'unapprove' == $action) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | '; - - // Reply and quickedit need a hide-if-no-js span when not added with ajax - if ( ('reply' == $action || 'quickedit' == $action) && ! $from_ajax ) - $action .= ' hide-if-no-js'; - elseif ( ($action == 'untrash' && $the_comment_status == 'trash') || ($action == 'unspam' && $the_comment_status == 'spam') ) { - if ('1' == get_comment_meta($comment_id, '_wp_trash_meta_status', true)) - $action .= ' approve'; - else - $action .= ' unapprove'; - } - - echo "$sep$link"; - } - echo '
            '; - } + if ( !$post_type_object->hierarchical ) + echo '
            ' . (is_sticky($post->ID) ? 'sticky' : '') . '
            '; - echo ''; - break; - case 'author': - echo ""; comment_author(); echo '
            '; - if ( !empty($author_url) ) - echo "$author_url_display
            "; - if ( $user_can ) { - if ( !empty($comment->comment_author_email) ) { - comment_author_email_link(); - echo '
            '; - } - echo ''; - comment_author_IP(); - echo ''; - } //current_user_can - echo ''; - break; - case 'date': - echo "" . get_comment_date(__('Y/m/d \a\t g:ia')) . ''; - break; - case 'response': - if ( 'single' !== $mode ) { - if ( isset( $_comment_pending_count[$post->ID] ) ) { - $pending_comments = $_comment_pending_count[$post->ID]; - } else { - $_comment_pending_count_temp = get_pending_comments_num( array( $post->ID ) ); - $pending_comments = $_comment_pending_count[$post->ID] = $_comment_pending_count_temp[$post->ID]; - } - if ( $user_can ) { - $post_link = ""; - $post_link .= get_the_title($post->ID) . ''; - } else { - $post_link = get_the_title($post->ID); - } - echo "\n"; - echo ''; - if ( 'attachment' == $post->post_type && ( $thumb = wp_get_attachment_image( $post->ID, array(80, 60), true ) ) ) - echo $thumb; - echo ''; - } - break; - default: - echo "\n"; - do_action( 'manage_comments_custom_column', $column_name, $comment->comment_ID ); - echo "\n"; - break; - } - } - echo "\n"; + echo '
            '; } /** * {@internal Missing Short Description}} * - * @since unknown + * @since 2.7.0 * * @param unknown_type $position * @param unknown_type $checkbox @@ -2231,14 +331,16 @@ function wp_comment_reply($position = '1', $checkbox = false, $mode = 'single', return; } - $columns = get_column_headers('edit-comments'); - $hidden = array_intersect( array_keys( $columns ), array_filter( get_hidden_columns('edit-comments') ) ); - $col_count = count($columns) - count($hidden); + if ( $mode == 'single' ) { + $wp_list_table = _get_list_table('WP_Post_Comments_List_Table'); + } else { + $wp_list_table = _get_list_table('WP_Comments_List_Table'); + } ?>
            -'; +} function wp_update_core($current, $feedback = '') { if ( !empty($feedback) ) diff --git a/wp-admin/includes/upgrade.php b/wp-admin/includes/upgrade.php index 7ae2384e..f29f594e 100644 --- a/wp-admin/includes/upgrade.php +++ b/wp-admin/includes/upgrade.php @@ -24,7 +24,7 @@ if ( !function_exists('wp_install') ) : * * {@internal Missing Long Description}} * - * @since unknown + * @since 2.1.0 * * @param string $blog_title Blog title. * @param string $user_name User's username. @@ -64,7 +64,7 @@ function wp_install( $blog_title, $user_name, $user_email, $public, $deprecated $user_password = trim($user_password); $email_password = false; if ( !$user_id && empty($user_password) ) { - $user_password = wp_generate_password(); + $user_password = wp_generate_password( 12, false ); $message = __('Note that password carefully! It is a random password that was generated just for you.'); $user_id = wp_create_user($user_name, $user_password, $user_email); update_user_option($user_id, 'default_password_nag', true, true); @@ -98,7 +98,7 @@ if ( !function_exists('wp_install_defaults') ) : * * {@internal Missing Long Description}} * - * @since unknown + * @since 2.1.0 * * @param int $user_id User ID. */ @@ -243,7 +243,15 @@ function wp_install_defaults($user_id) { )); // First Page - $first_page = __('This is an example of a WordPress page, you could edit this to put information about yourself or your site so readers know where you are coming from. You can create as many pages like this one or sub-pages as you like and manage all of your content inside of WordPress.'); + $first_page = sprintf( __( "This is an example page. It's different from a blog post because it will stay in one place and will show up in your site navigation (in most themes). Most people start with an About page that introduces them to potential site visitors. It might say something like this: + +
            Hi there! I'm a bike messenger by day, aspiring actor by night, and this is my blog. I live in Los Angeles, have a great dog named Jack, and I like piña coladas. (And gettin' caught in the rain.)
            + +...or something like this: + +
            The XYZ Doohickey Company was founded in 1971, and has been providing quality doohickies to the public ever since. Located in Gotham City, XYZ employs over 2,000 people and does all kinds of awesome things for the Gotham community.
            + +As a new WordPress user, you should go to your dashboard to delete this page and create new pages for your content. Have fun!" ), admin_url() ); if ( is_multisite() ) $first_page = get_site_option( 'first_page', $first_page ); $first_post_guid = get_option('home') . '/?page_id=2'; @@ -253,9 +261,9 @@ function wp_install_defaults($user_id) { 'post_date_gmt' => $now_gmt, 'post_content' => $first_page, 'post_excerpt' => '', - 'post_title' => __('About'), + 'post_title' => __( 'Sample Page' ), /* translators: Default page slug */ - 'post_name' => _x('about', 'Default page slug'), + 'post_name' => __( 'sample-page' ), 'post_modified' => $now, 'post_modified_gmt' => $now_gmt, 'guid' => $first_post_guid, @@ -266,7 +274,7 @@ function wp_install_defaults($user_id) { )); $wpdb->insert( $wpdb->postmeta, array( 'post_id' => 2, 'meta_key' => '_wp_page_template', 'meta_value' => 'default' ) ); - // Setup default widgets for default theme. + // Set up default widgets for default theme. update_option( 'widget_search', array ( 2 => array ( 'title' => '' ), '_multiwidget' => 1 ) ); update_option( 'widget_recent-posts', array ( 2 => array ( 'title' => '', 'number' => 5 ), '_multiwidget' => 1 ) ); update_option( 'widget_recent-comments', array ( 2 => array ( 'title' => '', 'number' => 5 ), '_multiwidget' => 1 ) ); @@ -300,7 +308,7 @@ if ( !function_exists('wp_new_blog_notification') ) : * * {@internal Missing Long Description}} * - * @since unknown + * @since 2.1.0 * * @param string $blog_title Blog title. * @param string $blog_url Blog url. @@ -336,7 +344,7 @@ if ( !function_exists('wp_upgrade') ) : * * {@internal Missing Long Description}} * - * @since unknown + * @since 2.1.0 * * @return null */ @@ -375,7 +383,7 @@ endif; * * {@internal Missing Long Description}} * - * @since unknown + * @since 1.0.1 */ function upgrade_all() { global $wp_current_db_version, $wp_db_version, $wp_rewrite; @@ -1187,7 +1195,7 @@ function upgrade_network() { * * {@internal Missing Long Description}} * - * @since unknown + * @since 1.0.0 * * @param string $table_name Database table name to create. * @param string $create_ddl SQL statement to create table. @@ -1210,7 +1218,7 @@ function maybe_create_table($table_name, $create_ddl) { * * {@internal Missing Long Description}} * - * @since unknown + * @since 1.0.1 * * @param string $table Database table name. * @param string $index Index name to drop. @@ -1233,7 +1241,7 @@ function drop_index($table, $index) { * * {@internal Missing Long Description}} * - * @since unknown + * @since 1.0.1 * * @param string $table Database table name. * @param string $index Database table index column. @@ -1296,7 +1304,7 @@ function get_alloptions_110() { /** * Version of get_option that is private to install/upgrade. * - * @since unknown + * @since 1.5.1 * @access private * * @param string $setting Option name. @@ -1333,7 +1341,7 @@ function __get_option($setting) { * * {@internal Missing Long Description}} * - * @since unknown + * @since 1.5.0 * * @param string $content * @return string @@ -1360,7 +1368,7 @@ function deslash($content) { * * {@internal Missing Long Description}} * - * @since unknown + * @since 1.5.0 * * @param unknown_type $queries * @param unknown_type $execute @@ -1567,7 +1575,7 @@ function dbDelta($queries, $execute = true) { * * {@internal Missing Long Description}} * - * @since unknown + * @since 1.5.0 */ function make_db_current() { global $wp_queries; @@ -1583,7 +1591,7 @@ function make_db_current() { * * {@internal Missing Long Description}} * - * @since unknown + * @since 1.5.0 */ function make_db_current_silent() { global $wp_queries; @@ -1596,7 +1604,7 @@ function make_db_current_silent() { * * {@internal Missing Long Description}} * - * @since unknown + * @since 1.5.0 * * @param unknown_type $theme_name * @param unknown_type $template @@ -1656,7 +1664,7 @@ function make_site_theme_from_oldschool($theme_name, $template) { } // Add a theme header. - $header = "/*\nTheme Name: $theme_name\nTheme URI: " . __get_option('siteurl') . "\nDescription: A theme automatically created by the upgrade.\nVersion: 1.0\nAuthor: Moi\n*/\n"; + $header = "/*\nTheme Name: $theme_name\nTheme URI: " . __get_option('siteurl') . "\nDescription: A theme automatically created by the update.\nVersion: 1.0\nAuthor: Moi\n*/\n"; $stylelines = file_get_contents("$site_dir/style.css"); if ($stylelines) { @@ -1675,7 +1683,7 @@ function make_site_theme_from_oldschool($theme_name, $template) { * * {@internal Missing Long Description}} * - * @since unknown + * @since 1.5.0 * * @param unknown_type $theme_name * @param unknown_type $template @@ -1741,7 +1749,7 @@ function make_site_theme_from_default($theme_name, $template) { * * {@internal Missing Long Description}} * - * @since unknown + * @since 1.5.0 * * @return unknown */ @@ -1789,7 +1797,7 @@ function make_site_theme() { /** * Translate user level to user role name. * - * @since unknown + * @since 2.0.0 * * @param int $level User level. * @return string User role name. @@ -1820,7 +1828,7 @@ function translate_level_to_role($level) { * * {@internal Missing Long Description}} * - * @since unknown + * @since 2.1.0 */ function wp_check_mysql_version() { global $wpdb; @@ -1834,7 +1842,7 @@ function wp_check_mysql_version() { * * {@internal Missing Long Description}} * - * @since unknown + * @since 2.2.0 */ function maybe_disable_automattic_widgets() { $plugins = __get_option( 'active_plugins' ); @@ -1850,6 +1858,8 @@ function maybe_disable_automattic_widgets() { /** * Runs before the schema is upgraded. + * + * @since 2.9.0 */ function pre_schema_upgrade() { global $wp_current_db_version, $wp_db_version, $wpdb; diff --git a/wp-admin/includes/user.php b/wp-admin/includes/user.php index b31c38bd..758c065a 100644 --- a/wp-admin/includes/user.php +++ b/wp-admin/includes/user.php @@ -55,14 +55,14 @@ function add_user() { */ function edit_user( $user_id = 0 ) { global $wp_roles, $wpdb; - if ( $user_id != 0 ) { + $user = new stdClass; + if ( $user_id ) { $update = true; $user->ID = (int) $user_id; $userdata = get_userdata( $user_id ); $user->user_login = $wpdb->escape( $userdata->user_login ); } else { $update = false; - $user = ''; } if ( !$update && isset( $_POST['user_login'] ) ) @@ -110,7 +110,7 @@ function edit_user( $user_id = 0 ) { if ( isset( $_POST['description'] ) ) $user->description = trim( $_POST['description'] ); - foreach ( _wp_get_user_contactmethods() as $method => $name ) { + foreach ( _wp_get_user_contactmethods( $user ) as $method => $name ) { if ( isset( $_POST[$method] )) $user->$method = sanitize_text_field( $_POST[$method] ); } @@ -118,6 +118,8 @@ function edit_user( $user_id = 0 ) { if ( $update ) { $user->rich_editing = isset( $_POST['rich_editing'] ) && 'false' == $_POST['rich_editing'] ? 'false' : 'true'; $user->admin_color = isset( $_POST['admin_color'] ) ? sanitize_text_field( $_POST['admin_color'] ) : 'fresh'; + $user->show_admin_bar_front = isset( $_POST['admin_bar_front'] ) ? 'true' : 'false'; + $user->show_admin_bar_admin = isset( $_POST['admin_bar_admin'] ) ? 'true' : 'false'; } $user->comment_shortcuts = isset( $_POST['comment_shortcuts'] ) && 'true' == $_POST['comment_shortcuts'] ? 'true' : ''; @@ -169,7 +171,7 @@ function edit_user( $user_id = 0 ) { $errors->add( 'empty_email', __( 'ERROR: Please enter an e-mail address.' ), array( 'form-field' => 'email' ) ); } elseif ( !is_email( $user->user_email ) ) { $errors->add( 'invalid_email', __( 'ERROR: The e-mail address isn’t correct.' ), array( 'form-field' => 'email' ) ); - } elseif ( ( $owner_id = email_exists($user->user_email) ) && $owner_id != $user->ID ) { + } elseif ( ( $owner_id = email_exists($user->user_email) ) && ( !$update || ( $owner_id != $user->ID ) ) ) { $errors->add( 'email_exists', __('ERROR: This email is already registered, please choose another one.'), array( 'form-field' => 'email' ) ); } @@ -188,86 +190,6 @@ function edit_user( $user_id = 0 ) { return $user_id; } -/** - * {@internal Missing Short Description}} - * - * {@internal Missing Long Description}} - * - * @since unknown - * - * @return array List of user IDs. - */ -function get_author_user_ids() { - global $wpdb; - if ( !is_multisite() ) - $level_key = $wpdb->get_blog_prefix() . 'user_level'; - else - $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels - - return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value != '0'", $level_key) ); -} - -/** - * {@internal Missing Short Description}} - * - * {@internal Missing Long Description}} - * - * @since unknown - * - * @param int $user_id User ID. - * @return array|bool List of editable authors. False if no editable users. - */ -function get_editable_authors( $user_id ) { - global $wpdb; - - $editable = get_editable_user_ids( $user_id ); - - if ( !$editable ) { - return false; - } else { - $editable = join(',', $editable); - $authors = $wpdb->get_results( "SELECT * FROM $wpdb->users WHERE ID IN ($editable) ORDER BY display_name" ); - } - - return apply_filters('get_editable_authors', $authors); -} - -/** - * {@internal Missing Short Description}} - * - * {@internal Missing Long Description}} - * - * @since unknown - * - * @param int $user_id User ID. - * @param bool $exclude_zeros Optional, default is true. Whether to exclude zeros. - * @return unknown - */ -function get_editable_user_ids( $user_id, $exclude_zeros = true, $post_type = 'post' ) { - global $wpdb; - - $user = new WP_User( $user_id ); - $post_type_obj = get_post_type_object($post_type); - - if ( ! $user->has_cap($post_type_obj->cap->edit_others_posts) ) { - if ( $user->has_cap($post_type_obj->cap->edit_posts) || ! $exclude_zeros ) - return array($user->id); - else - return array(); - } - - if ( !is_multisite() ) - $level_key = $wpdb->get_blog_prefix() . 'user_level'; - else - $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels - - $query = $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s", $level_key); - if ( $exclude_zeros ) - $query .= " AND meta_value != '0'"; - - return $wpdb->get_col( $query ); -} - /** * Fetch a filtered list of user roles that the current user is * allowed to edit. @@ -293,85 +215,10 @@ function get_editable_roles() { return $editable_roles; } -/** - * {@internal Missing Short Description}} - * - * {@internal Missing Long Description}} - * - * @since unknown - * - * @return unknown - */ -function get_nonauthor_user_ids() { - global $wpdb; - - if ( !is_multisite() ) - $level_key = $wpdb->get_blog_prefix() . 'user_level'; - else - $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels - - return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value = '0'", $level_key) ); -} - -/** - * Retrieve editable posts from other users. - * - * @since unknown - * - * @param int $user_id User ID to not retrieve posts from. - * @param string $type Optional, defaults to 'any'. Post type to retrieve, can be 'draft' or 'pending'. - * @return array List of posts from others. - */ -function get_others_unpublished_posts($user_id, $type='any') { - global $wpdb; - - $editable = get_editable_user_ids( $user_id ); - - if ( in_array($type, array('draft', 'pending')) ) - $type_sql = " post_status = '$type' "; - else - $type_sql = " ( post_status = 'draft' OR post_status = 'pending' ) "; - - $dir = ( 'pending' == $type ) ? 'ASC' : 'DESC'; - - if ( !$editable ) { - $other_unpubs = ''; - } else { - $editable = join(',', $editable); - $other_unpubs = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_title, post_author FROM $wpdb->posts WHERE post_type = 'post' AND $type_sql AND post_author IN ($editable) AND post_author != %d ORDER BY post_modified $dir", $user_id) ); - } - - return apply_filters('get_others_drafts', $other_unpubs); -} - -/** - * Retrieve drafts from other users. - * - * @since unknown - * - * @param int $user_id User ID. - * @return array List of drafts from other users. - */ -function get_others_drafts($user_id) { - return get_others_unpublished_posts($user_id, 'draft'); -} - -/** - * Retrieve pending review posts from other users. - * - * @since unknown - * - * @param int $user_id User ID. - * @return array List of posts with pending review post type from other users. - */ -function get_others_pending($user_id) { - return get_others_unpublished_posts($user_id, 'pending'); -} - /** * Retrieve user data and filter it. * - * @since unknown + * @since 2.0.5 * * @param int $user_id User ID. * @return object WP_User object with user data. @@ -379,7 +226,7 @@ function get_others_pending($user_id) { function get_user_to_edit( $user_id ) { $user = new WP_User( $user_id ); - $user_contactmethods = _wp_get_user_contactmethods(); + $user_contactmethods = _wp_get_user_contactmethods( $user ); foreach ($user_contactmethods as $method => $name) { if ( empty( $user->{$method} ) ) $user->{$method} = ''; @@ -396,7 +243,7 @@ function get_user_to_edit( $user_id ) { /** * Retrieve the user's drafts. * - * @since unknown + * @since 2.0.0 * * @param int $user_id User ID. * @return array @@ -416,7 +263,7 @@ function get_users_drafts( $user_id ) { * being deleted will be run after the posts are either reassigned or deleted. * The user meta will also be deleted that are for that User ID. * - * @since unknown + * @since 2.0.0 * * @param int $id User ID. * @param int $reassign Optional. Reassign posts and links to new User ID. @@ -471,7 +318,7 @@ function wp_delete_user( $id, $reassign = 'novalue' ) { /** * Remove all capabilities from user. * - * @since unknown + * @since 2.1.0 * * @param int $id User ID. */ @@ -482,344 +329,10 @@ function wp_revoke_user($id) { $user->remove_all_caps(); } -if ( !class_exists('WP_User_Search') ) : +add_action('admin_init', 'default_password_nag_handler'); /** - * WordPress User Search class. - * - * @since unknown + * @since 2.8.0 */ -class WP_User_Search { - - /** - * {@internal Missing Description}} - * - * @since unknown - * @access private - * @var unknown_type - */ - var $results; - - /** - * {@internal Missing Description}} - * - * @since unknown - * @access private - * @var unknown_type - */ - var $search_term; - - /** - * Page number. - * - * @since unknown - * @access private - * @var int - */ - var $page; - - /** - * Role name that users have. - * - * @since unknown - * @access private - * @var string - */ - var $role; - - /** - * Raw page number. - * - * @since unknown - * @access private - * @var int|bool - */ - var $raw_page; - - /** - * Amount of users to display per page. - * - * @since unknown - * @access public - * @var int - */ - var $users_per_page = 50; - - /** - * {@internal Missing Description}} - * - * @since unknown - * @access private - * @var unknown_type - */ - var $first_user; - - /** - * {@internal Missing Description}} - * - * @since unknown - * @access private - * @var int - */ - var $last_user; - - /** - * {@internal Missing Description}} - * - * @since unknown - * @access private - * @var string - */ - var $query_limit; - - /** - * {@internal Missing Description}} - * - * @since 3.0.0 - * @access private - * @var string - */ - var $query_orderby; - - /** - * {@internal Missing Description}} - * - * @since 3.0.0 - * @access private - * @var string - */ - var $query_from; - - /** - * {@internal Missing Description}} - * - * @since 3.0.0 - * @access private - * @var string - */ - var $query_where; - - /** - * {@internal Missing Description}} - * - * @since unknown - * @access private - * @var int - */ - var $total_users_for_query = 0; - - /** - * {@internal Missing Description}} - * - * @since unknown - * @access private - * @var bool - */ - var $too_many_total_users = false; - - /** - * {@internal Missing Description}} - * - * @since unknown - * @access private - * @var unknown_type - */ - var $search_errors; - - /** - * {@internal Missing Description}} - * - * @since unknown - * @access private - * @var unknown_type - */ - var $paging_text; - - /** - * PHP4 Constructor - Sets up the object properties. - * - * @since unknown - * - * @param string $search_term Search terms string. - * @param int $page Optional. Page ID. - * @param string $role Role name. - * @return WP_User_Search - */ - function WP_User_Search ($search_term = '', $page = '', $role = '') { - $this->search_term = $search_term; - $this->raw_page = ( '' == $page ) ? false : (int) $page; - $this->page = (int) ( '' == $page ) ? 1 : $page; - $this->role = $role; - - $this->prepare_query(); - $this->query(); - $this->prepare_vars_for_template_usage(); - $this->do_paging(); - } - - /** - * {@internal Missing Short Description}} - * - * {@internal Missing Long Description}} - * - * @since unknown - * @access public - */ - function prepare_query() { - global $wpdb; - $this->first_user = ($this->page - 1) * $this->users_per_page; - - $this->query_limit = $wpdb->prepare(" LIMIT %d, %d", $this->first_user, $this->users_per_page); - $this->query_orderby = ' ORDER BY user_login'; - - $search_sql = ''; - if ( $this->search_term ) { - $searches = array(); - $search_sql = 'AND ('; - foreach ( array('user_login', 'user_nicename', 'user_email', 'user_url', 'display_name') as $col ) - $searches[] = $col . " LIKE '%$this->search_term%'"; - $search_sql .= implode(' OR ', $searches); - $search_sql .= ')'; - } - - $this->query_from = " FROM $wpdb->users"; - $this->query_where = " WHERE 1=1 $search_sql"; - - if ( $this->role ) { - $this->query_from .= " INNER JOIN $wpdb->usermeta ON $wpdb->users.ID = $wpdb->usermeta.user_id"; - $this->query_where .= $wpdb->prepare(" AND $wpdb->usermeta.meta_key = '{$wpdb->prefix}capabilities' AND $wpdb->usermeta.meta_value LIKE %s", '%' . $this->role . '%'); - } elseif ( is_multisite() ) { - $level_key = $wpdb->prefix . 'capabilities'; // wpmu site admins don't have user_levels - $this->query_from .= ", $wpdb->usermeta"; - $this->query_where .= " AND $wpdb->users.ID = $wpdb->usermeta.user_id AND meta_key = '{$level_key}'"; - } - - do_action_ref_array( 'pre_user_search', array( &$this ) ); - } - - /** - * {@internal Missing Short Description}} - * - * {@internal Missing Long Description}} - * - * @since unknown - * @access public - */ - function query() { - global $wpdb; - - $this->results = $wpdb->get_col("SELECT DISTINCT($wpdb->users.ID)" . $this->query_from . $this->query_where . $this->query_orderby . $this->query_limit); - - if ( $this->results ) - $this->total_users_for_query = $wpdb->get_var("SELECT COUNT(DISTINCT($wpdb->users.ID))" . $this->query_from . $this->query_where); // no limit - else - $this->search_errors = new WP_Error('no_matching_users_found', __('No matching users were found!')); - } - - /** - * {@internal Missing Short Description}} - * - * {@internal Missing Long Description}} - * - * @since unknown - * @access public - */ - function prepare_vars_for_template_usage() { - $this->search_term = stripslashes($this->search_term); // done with DB, from now on we want slashes gone - } - - /** - * {@internal Missing Short Description}} - * - * {@internal Missing Long Description}} - * - * @since unknown - * @access public - */ - function do_paging() { - if ( $this->total_users_for_query > $this->users_per_page ) { // have to page the results - $args = array(); - if( ! empty($this->search_term) ) - $args['usersearch'] = urlencode($this->search_term); - if( ! empty($this->role) ) - $args['role'] = urlencode($this->role); - - $this->paging_text = paginate_links( array( - 'total' => ceil($this->total_users_for_query / $this->users_per_page), - 'current' => $this->page, - 'base' => 'users.php?%_%', - 'format' => 'userspage=%#%', - 'add_args' => $args - ) ); - if ( $this->paging_text ) { - $this->paging_text = sprintf( '' . __( 'Displaying %s–%s of %s' ) . '%s', - number_format_i18n( ( $this->page - 1 ) * $this->users_per_page + 1 ), - number_format_i18n( min( $this->page * $this->users_per_page, $this->total_users_for_query ) ), - number_format_i18n( $this->total_users_for_query ), - $this->paging_text - ); - } - } - } - - /** - * {@internal Missing Short Description}} - * - * {@internal Missing Long Description}} - * - * @since unknown - * @access public - * - * @return unknown - */ - function get_results() { - return (array) $this->results; - } - - /** - * Displaying paging text. - * - * @see do_paging() Builds paging text. - * - * @since unknown - * @access public - */ - function page_links() { - echo $this->paging_text; - } - - /** - * Whether paging is enabled. - * - * @see do_paging() Builds paging text. - * - * @since unknown - * @access public - * - * @return bool - */ - function results_are_paged() { - if ( $this->paging_text ) - return true; - return false; - } - - /** - * Whether there are search terms. - * - * @since unknown - * @access public - * - * @return bool - */ - function is_search() { - if ( $this->search_term ) - return true; - return false; - } -} -endif; - -add_action('admin_init', 'default_password_nag_handler'); function default_password_nag_handler($errors = false) { global $user_ID; if ( ! get_user_option('default_password_nag') ) //Short circuit it. @@ -833,6 +346,9 @@ function default_password_nag_handler($errors = false) { } add_action('profile_update', 'default_password_nag_edit_user', 10, 2); +/** + * @since 2.8.0 + */ function default_password_nag_edit_user($user_ID, $old_data) { if ( ! get_user_option('default_password_nag', $user_ID) ) //Short circuit it. return; @@ -846,14 +362,18 @@ function default_password_nag_edit_user($user_ID, $old_data) { } add_action('admin_notices', 'default_password_nag'); +/** + * @since 2.8.0 + */ function default_password_nag() { - if ( ! get_user_option('default_password_nag') ) //Short circuit it. + global $pagenow; + if ( 'profile.php' == $pagenow || ! get_user_option('default_password_nag') ) //Short circuit it. return; echo '
            '; echo '

            '; echo '' . __('Notice:') . ' '; - _e('You’re using the auto-generated password for your account. Would you like to change it to something you’ll remember easier?'); + _e('You’re using the auto-generated password for your account. Would you like to change it to something easier to remember?'); echo '

            '; printf( '' . __('Yes, take me to my profile page') . ' | ', admin_url('profile.php') . '#password' ); printf( '' . __('No thanks, do not remind me again') . '', '?default_password_nag=0' ); diff --git a/wp-admin/includes/widgets.php b/wp-admin/includes/widgets.php index aef0dbaf..a591c60d 100644 --- a/wp-admin/includes/widgets.php +++ b/wp-admin/includes/widgets.php @@ -7,20 +7,15 @@ */ /** - * Display list of the available widgets, either all or matching search. + * Display list of the available widgets. * - * The search parameter are search terms separated by spaces. - * - * @since unknown - * - * @param string $show Optional, default is all. What to display, can be 'all', 'unused', or 'used'. - * @param string $_search Optional. Search for widgets. Should be unsanitized. + * @since 2.5.0 */ function wp_list_widgets() { global $wp_registered_widgets, $sidebars_widgets, $wp_registered_widget_controls; $sort = $wp_registered_widgets; - usort( $sort, create_function( '$a, $b', 'return strnatcasecmp( $a["name"], $b["name"] );' ) ); + usort( $sort, '_sort_name_callback' ); $done = array(); foreach ( $sort as $widget ) { @@ -51,11 +46,21 @@ function wp_list_widgets() { } } +/** + * Callback to sort array by a 'name' key. + * + * @since 3.1.0 + * @access private + */ +function _sort_name_callback( $a, $b ) { + return strnatcasecmp( $a['name'], $b['name'] ); +} + /** * Show the widgets and their settings for a sidebar. * Used in the the admin widget config screen. * - * @since unknown + * @since 2.5.0 * * @param string $sidebar id slug of the sidebar */ @@ -79,7 +84,7 @@ function wp_list_widget_controls( $sidebar ) { /** * {@internal Missing Short Description}} * - * @since unknown + * @since 2.5.0 * * @param array $params * @return array @@ -93,7 +98,7 @@ function wp_list_widget_controls_dynamic_sidebar( $params ) { $id = isset($params[0]['_temp_id']) ? $params[0]['_temp_id'] : $widget_id; $hidden = isset($params[0]['_hide']) ? ' style="display:none;"' : ''; - $params[0]['before_widget'] = "

            "; + $params[0]['before_widget'] = "
            "; $params[0]['after_widget'] = "
            "; $params[0]['before_title'] = "%BEG_OF_TITLE%"; // deprecated $params[0]['after_title'] = "%END_OF_TITLE%"; // deprecated @@ -123,7 +128,7 @@ function next_widget_id_number($id_base) { * * Called from dynamic_sidebar(). * - * @since unknown + * @since 2.5.0 * * @param array $sidebar_args * @return array @@ -203,7 +208,7 @@ function wp_widget_control( $sidebar_args ) {
            - +

            diff --git a/wp-admin/index-extra.php b/wp-admin/index-extra.php index 22df0d67..efa2526c 100644 --- a/wp-admin/index-extra.php +++ b/wp-admin/index-extra.php @@ -10,7 +10,7 @@ require_once( './admin.php' ); /** Load WordPress Administration Dashboard API */ -require( './includes/dashboard.php' ); +require(ABSPATH . 'wp-admin/includes/dashboard.php' ); @header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) ); send_nosniff_header(); diff --git a/wp-admin/index.php b/wp-admin/index.php index 789835c9..748141e0 100644 --- a/wp-admin/index.php +++ b/wp-admin/index.php @@ -24,25 +24,32 @@ add_thickbox(); $title = __('Dashboard'); $parent_file = 'index.php'; +if ( is_user_admin() ) + add_screen_option('layout_columns', array('max' => 4, 'default' => 1) ); +else + add_screen_option('layout_columns', array('max' => 4, 'default' => 2) ); + add_contextual_help($current_screen, - '

            ' . __('Welcome to your WordPress Dashboard! You will find helpful tips in the Help tab of each screen to assist you as you get to know the application.') . '

            ' . - '

            ' . __('The left-hand navigation menu provides links to the administration screens in your WordPress application. You can expand or collapse navigation sections by clicking on the arrow that appears on the right side of each navigation item when you hover over it. You can also minimize the navigation menu to a narrow icon strip by clicking on the separator lines between navigation sections that end in double arrowheads; when minimized, the submenu items will be displayed on hover.') . '

            ' . - '

            ' . __('You can configure your dashboard by choosing which modules to display, how many columns to display them in, and where each module should be placed. You can hide/show modules and select the number of columns in the Screen Options tab. To rearrange the modules, drag and drop by clicking on the title bar of the selected module and releasing when you see a gray dotted-line box appear in the location you want to place the module. You can also expand or collapse each module by clicking once on the the module’s title bar. In addition, some modules are configurable, and will show a “Configure” link in the title bar when you hover over it.') . '

            ' . - '

            ' . __('The modules on your Dashboard screen are:') . '

            ' . - '

            ' . __('Right Now - Displays a summary of the content on your site and identifies which theme and version of WordPress you are using.') . '

            ' . - '

            ' . __('Recent Comments - Shows the most recent comments on your posts (configurable, up to 30) and allows you to moderate them.') . '

            ' . - '

            ' . __('Incoming Links - Shows links to your site found by Google Blog Search.') . '

            ' . - '

            ' . __('QuickPress - Allows you to create a new post and either publish it or save it as a draft.') . '

            ' . - '

            ' . __('Recent Drafts - Displays links to the 5 most recent draft posts you’ve started.') . '

            ' . - '

            ' . __('Other WordPress News - Shows the feed from WordPress Planet. You can configure it to show a different feed of your choosing.') . '

            ' . - '

            ' . __('Plugins - Features the most popular, newest, and recently updated plugins from the WordPress.org Plugin Directory.') . '

            ' . - '

            ' . __('For more information:') . '

            ' . - '

            ' . __('Dashboard Documentation') . '

            ' . - '

            ' . __('Support Forums') . '

            ' + '

            ' . __( 'Welcome to your WordPress Dashboard! You will find helpful tips in the Help tab of each screen to assist you as you get to know the application.' ) . '

            ' . + '

            ' . __( 'The Admin Bar at the top, new in 3.1, provides quick access to common tasks when you are viewing your site.' ) . '

            ' . + '

            ' . __( 'The left-hand navigation menu provides links to the administration screens in your WordPress application. You can expand or collapse navigation sections by clicking on the arrow that appears on the right side of each navigation item when you hover over it. You can also minimize the navigation menu to a narrow icon strip by clicking on the faint separator lines between the Dashboard and Posts sections, or between Comments and Appearance; when minimized, the submenu items will be displayed on hover.' ) . '

            ' . + '

            ' . __( 'You can configure your dashboard by choosing which boxes, or modules, to display in the work area, how many columns to display them in, and where each box should be placed. You can hide/show boxes and select the number of columns in the Screen Options tab. To rearrange the boxes, drag and drop by clicking on the title bar of the selected box and releasing when you see a gray dotted-line rectangle appear in the location you want to place the box. You can also expand or collapse each box by clicking once on the title bar of the box. In addition, some boxes are configurable, and will show a “Configure” link in the title bar when you hover over it.' ) . '

            ' . + '

            ' . __( 'The boxes on your Dashboard screen are:' ) . '

            ' . + '

            ' . __( 'Right Now - Displays a summary of the content on your site and identifies which theme and version of WordPress you are using.' ) . '

            ' . + '

            ' . __( 'Recent Comments - Shows the most recent comments on your posts (configurable, up to 30) and allows you to moderate them.' ) . '

            ' . + '

            ' . __( 'Incoming Links - Shows links to your site found by Google Blog Search.' ) . '

            ' . + '

            ' . __( 'QuickPress - Allows you to create a new post and either publish it or save it as a draft.' ) . '

            ' . + '

            ' . __( 'Recent Drafts - Displays links to the 5 most recent draft posts you’ve started.' ) . '

            ' . + '

            ' . __( 'WordPress Development Blog - Come here for the latest scoop.' ) . '

            ' . + '

            ' . __( 'Other WordPress News - Shows the feed from WordPress Planet. You can configure it to show a different feed of your choosing.' ) . '

            ' . + '

            ' . __( 'Plugins - Features the most popular, newest, and recently updated plugins from the WordPress.org Plugin Directory.' ) . '

            ' . + '

            ' . __( 'For more information:' ) . '

            ' . + '

            ' . __( 'Documentation on Dashboard' ) . '

            ' . + '

            ' . __( 'Support Forums' ) . '

            ' ); -require_once('./admin-header.php'); +include (ABSPATH . 'wp-admin/admin-header.php'); $today = current_time('mysql', 1); ?> diff --git a/wp-admin/install-helper.php b/wp-admin/install-helper.php index cddbc26a..2970b7cb 100644 --- a/wp-admin/install-helper.php +++ b/wp-admin/install-helper.php @@ -38,14 +38,6 @@ * @subpackage Plugin */ -/** - * @global bool $wp_only_load_config - * @name $wp_only_load_config - * @var bool - * @since unknown - */ -$wp_only_load_config = true; - /** Load WordPress Bootstrap */ require_once(dirname(dirname(__FILE__)).'/wp-load.php'); @@ -54,7 +46,7 @@ require_once(dirname(dirname(__FILE__)).'/wp-load.php'); * @global bool|int $debug * @name $debug * @var bool|int - * @since unknown + * @since 1.0.0 */ $debug = 0; @@ -62,7 +54,7 @@ if ( ! function_exists('maybe_create_table') ) : /** * Create database table, if it doesn't already exist. * - * @since unknown + * @since 1.0.0 * @package WordPress * @subpackage Plugin * @uses $wpdb @@ -94,7 +86,7 @@ if ( ! function_exists('maybe_add_column') ) : /** * Add column to database table, if column doesn't already exist in table. * - * @since unknown + * @since 1.0.0 * @package WordPress * @subpackage Plugin * @uses $wpdb @@ -129,7 +121,7 @@ endif; /** * Drop column from database table, if it exists. * - * @since unknown + * @since 1.0.0 * @package WordPress * @subpackage Plugin * @uses $wpdb @@ -173,7 +165,7 @@ function maybe_drop_column($table_name, $column_name, $drop_ddl) { * Default * Extra * - * @since unknown + * @since 1.0.0 * @package WordPress * @subpackage Plugin * @@ -222,4 +214,4 @@ function check_column($table_name, $col_name, $col_type, $is_null = null, $key = return false; } -?> +?> \ No newline at end of file diff --git a/wp-admin/install.php b/wp-admin/install.php index d23073b6..0b65f523 100644 --- a/wp-admin/install.php +++ b/wp-admin/install.php @@ -246,7 +246,7 @@ switch($step) { - +

            -

            - - - diff --git a/wp-admin/ms-users.php b/wp-admin/ms-users.php index 594406ac..5b4f1c52 100644 --- a/wp-admin/ms-users.php +++ b/wp-admin/ms-users.php @@ -9,370 +9,6 @@ require_once( './admin.php' ); -if ( !is_multisite() ) - wp_die( __( 'Multisite support is not enabled.' ) ); - -if ( ! current_user_can( 'manage_network_users' ) ) - wp_die( __( 'You do not have permission to access this page.' ) ); - -$title = __( 'Users' ); -$parent_file = 'ms-admin.php'; - -add_contextual_help($current_screen, - '

            ' . __('This table shows all users across the network and the sites to which they are assigned.') . '

            ' . - '

            ' . __('Hover over any user on the list to make the edit links appear. The Edit link on the left will take you to his or her Edit User profile page; the Edit link on the right by any site name goes to an Edit Site screen for that site.') . '

            ' . - '

            ' . __('You can also go to the user’s profile page by clicking on the individual username.') . '

            ' . - '

            ' . __('You can sort the table by clicking on any of the bold headings and switch between list and excerpt views by using the icons in the upper right.') . '

            ' . - '

            ' . __('The bulk action will permanently delete selected users, or mark/unmark those selected as spam. Spam users will have posts removed and will be unable to sign up again with the same email addresses.') . '

            ' . - '

            ' . __('Add User will add that person to this table and send them an email.') . '

            ' . - '

            ' . __('Users who are signed up to the network without a site are added as subscribers to the main or primary dashboard site, giving them profile pages to manage their accounts. These users will only see Dashboard and My Sites in the main navigation until a site is created for them.') . '

            ' . - '

            ' . __('You can make an existing user an additional super admin by going to the Edit User profile page and checking the box to grant that privilege.') . '

            ' . - '

            ' . __('For more information:') . '

            ' . - '

            ' . __('Network Users Documentation') . '

            ' . - '

            ' . __('Support Forums') . '

            ' -); - -wp_enqueue_script( 'admin-forms' ); - -require_once( './admin-header.php' ); - -if ( isset( $_GET['updated'] ) && $_GET['updated'] == 'true' && ! empty( $_GET['action'] ) ) { - ?> -

            - -

            - users}"; - - if ( !empty( $like_s ) ) { - $query .= " WHERE user_login LIKE '%$like_s%' OR user_email LIKE '%$like_s%'"; - } - - $order_by = isset( $_GET['sortby'] ) ? $_GET['sortby'] : 'id'; - if ( $order_by == 'email' ) { - $query .= ' ORDER BY user_email '; - } elseif ( $order_by == 'login' ) { - $query .= ' ORDER BY user_login '; - } elseif ( $order_by == 'name' ) { - $query .= ' ORDER BY display_name '; - } elseif ( $order_by == 'registered' ) { - $query .= ' ORDER BY user_registered '; - } else { - $order_by = 'id'; - $query .= ' ORDER BY ID '; - } - - $order = ( isset( $_GET['order'] ) && 'DESC' == $_GET['order'] ) ? 'DESC' : 'ASC'; - $query .= $order; - - $total = $wpdb->get_var( str_replace( 'SELECT *', 'SELECT COUNT(ID)', $query ) ); - - $query .= " LIMIT " . intval( ( $pagenum - 1 ) * $per_page) . ", " . intval( $per_page ); - - $user_list = $wpdb->get_results( $query, ARRAY_A ); - - $num_pages = ceil( $total / $per_page ); - $page_links = paginate_links( array( - 'base' => add_query_arg( 'paged', '%#%' ), - 'format' => '', - 'prev_text' => __( '«' ), - 'next_text' => __( '»' ), - 'total' => $num_pages, - 'current' => $pagenum - )); - - if ( empty( $_GET['mode'] ) ) - $mode = 'list'; - else - $mode = esc_attr( $_GET['mode'] ); - - ?> -
            - -

            - - ' . __( 'Search results for “%s”' ) . '', esc_html( $s ) ); - ?> -

            - -
            - - - -
            - -
            -
            - - - -
            - - -
            - ' . __( 'Displaying %s–%s of %s' ) . '%s', - number_format_i18n( ( $pagenum - 1 ) * $per_page + 1 ), - number_format_i18n( min( $pagenum * $per_page, $total ) ), - number_format_i18n( $total ), - $page_links - ); echo $page_links_text; ?> -
            - - - -
            -
            - - 'display name' - $users_columns = array( - 'id' => __( 'ID' ), - 'login' => __( 'Username' ), - 'name' => __( 'Name' ), - 'email' => __( 'E-mail' ), - 'registered' => _x( 'Registered', 'user' ), - 'blogs' => __( 'Sites' ) - ); - $users_columns = apply_filters( 'wpmu_users_columns', $users_columns ); - ?> -
            '; - if ( ! current_user_can('update_plugins') ) - printf( __('There is a new version of %1$s available. View version %4$s Details.'), $plugin_name, esc_url($details_url), esc_attr($plugin_name), $r->new_version ); - else if ( empty($r->package) ) - printf( __('There is a new version of %1$s available. View version %4$s Details automatic upgrade unavailable for this plugin.'), $plugin_name, esc_url($details_url), esc_attr($plugin_name), $r->new_version ); - else - printf( __('There is a new version of %1$s available. View version %4$s Details or upgrade automatically.'), $plugin_name, esc_url($details_url), esc_attr($plugin_name), $r->new_version, wp_nonce_url('update.php?action=upgrade-plugin&plugin=' . $file, 'upgrade-plugin_' . $file) ); + $wp_list_table = _get_list_table('WP_Plugins_List_Table'); + + if ( is_network_admin() || !is_multisite() ) { + echo '
            '; + if ( ! current_user_can('update_plugins') ) + printf( __('There is a new version of %1$s available. View version %4$s details.'), $plugin_name, esc_url($details_url), esc_attr($plugin_name), $r->new_version ); + else if ( empty($r->package) ) + printf( __('There is a new version of %1$s available. View version %4$s details. Automatic update is unavailable for this plugin.'), $plugin_name, esc_url($details_url), esc_attr($plugin_name), $r->new_version ); + else + printf( __('There is a new version of %1$s available. View version %4$s details or update automatically.'), $plugin_name, esc_url($details_url), esc_attr($plugin_name), $r->new_version, wp_nonce_url( self_admin_url('update.php?action=upgrade-plugin&plugin=') . $file, 'upgrade-plugin_' . $file) ); + } do_action( "in_plugin_update_message-$file", $plugin_data, $r ); @@ -239,6 +245,45 @@ function wp_update_theme($theme, $feedback = '') { return $upgrader->upgrade($theme); } +function wp_theme_update_rows() { + if ( !current_user_can('update_themes' ) ) + return; + + $themes = get_site_transient( 'update_themes' ); + if ( isset($themes->response) && is_array($themes->response) ) { + $themes = array_keys( $themes->response ); + + foreach( $themes as $theme ) { + add_action( "after_theme_row_$theme", 'wp_theme_update_row', 10, 2 ); + } + } +} +add_action( 'admin_init', 'wp_theme_update_rows' ); + +function wp_theme_update_row( $theme_key, $theme ) { + $current = get_site_transient( 'update_themes' ); + if ( !isset( $current->response[ $theme_key ] ) ) + return false; + $r = $current->response[ $theme_key ]; + $themes_allowedtags = array('a' => array('href' => array(),'title' => array()),'abbr' => array('title' => array()),'acronym' => array('title' => array()),'code' => array(),'em' => array(),'strong' => array()); + $theme_name = wp_kses( $theme['Name'], $themes_allowedtags ); + + $details_url = self_admin_url("theme-install.php?tab=theme-information&theme=$theme_key&TB_iframe=true&width=600&height=400"); + + $wp_list_table = _get_list_table('WP_MS_Themes_List_Table'); + + echo '
            '; + if ( ! current_user_can('update_themes') ) + printf( __('There is a new version of %1$s available. View version %4$s details.'), $theme['Name'], esc_url($details_url), esc_attr($theme['Name']), $r->new_version ); + else if ( empty( $r['package'] ) ) + printf( __('There is a new version of %1$s available. View version %4$s details. Automatic update is unavailable for this plugin.'), $theme['Name'], esc_url($details_url), esc_attr($theme['Name']), $r['new_version'] ); + else + printf( __('There is a new version of %1$s available. View version %4$s details or update automatically.'), $theme['Name'], esc_url($details_url), esc_attr($theme['Name']), $r['new_version'], wp_nonce_url( self_admin_url('update.php?action=upgrade-theme&theme=') . $theme_key, 'upgrade-theme_' . $theme_key) ); + + do_action( "in_theme_update_message-$theme_key", $theme, $r ); + + echo '
            - - - - $column_display_name) { - $column_link = " $order2, 'paged' => $pagenum, 'sortby' => $column_id ), remove_query_arg( array( 'action', 'updated' ), $_SERVER['REQUEST_URI'] ) ) ); - $column_link .= "'>{$column_display_name}"; - $col_url .= ''; - } - echo $col_url; ?> - - - - - - - - - - 'site-spammed', 'deleted' => 'site-deleted' ); - - foreach ( $status_list as $status => $col ) { - if ( $user[$status] ) - $class = $col; - } - - ?> - - $column_display_name ) : - switch( $column_name ) { - case 'id': ?> - - - ID == $user['ID'] ) ? 'profile.php' : 'user-edit.php?user_id=' . $user['ID']; - ?> - - - - - - g:i:s a'; - ?> - - - - - - - - - - - - - -
            - - ' . ( $column_id == 'blogs' ? $column_display_name : $column_link ) . '
            - -
            - - - - - -
            -
            - - - | - -
            -
            - $val ) { - $path = ( $val->path == '/' ) ? '' : $val->path; - echo '' . str_replace( '.' . $current_site->domain, '', $val->domain . $path ) . ''; - echo ' '; - - // Edit - echo '' . __( 'Edit' ) . ' | '; - - // View - echo 'userblog_id, 'spam' ) == 1 ) - echo 'style="background-color: #faa" '; - echo 'href="' . esc_url( get_home_url( $val->userblog_id ) ) . '">' . __( 'View' ) . ''; - - echo '
            '; - } - } - ?> -
            - -
            - $page_links_text
            "; - ?> - -
            - - -
            -
            - - - - - - -
            -

            -
            - - - - - - - - - - - - -
            -

            - -

            -
            -
            - - - diff --git a/wp-admin/my-sites.php b/wp-admin/my-sites.php index f38ac1c1..4e13096f 100644 --- a/wp-admin/my-sites.php +++ b/wp-admin/my-sites.php @@ -42,7 +42,7 @@ add_contextual_help($current_screen, '

            ' . __('This screen shows an individual user all of their sites in this network, and also allows that user to set a primary site. He or she can use the links under each site to visit either the frontend or the dashboard for that site.') . '

            ' . '

            ' . __('Up until WordPress version 3.0, what is now called a Multi-site Network had to be installed separately as WordPress MU (multi-user).') . '

            ' . '

            ' . __('For more information:') . '

            ' . - '

            ' . __('My Sites Documentation') . '

            ' . + '

            ' . __('Documentation on My Sites') . '

            ' . '

            ' . __('Support Forums') . '

            ' ); @@ -102,9 +102,7 @@ if ( $updated ) { ?> -

            - -

            +

            ' . __('The current theme does not natively support menus, but you can use the “Custom Menu” widget to add any menus you create here to the theme’s sidebar.') . '

            '; -$help = '

            ' . __('This feature is new in version 3.0; to use a custom menu in place of your theme’s default menus, support for this feature must be registered in the theme’s functions.php file. If your theme does not support the custom menus feature yet (the new default theme, Twenty Ten, does), you can learn about adding support yourself by following the below link.') . '

            '; +$help = '

            ' . __('This feature, introduced in version 3.0, allows you to use a custom menu in place of your theme’s default menus. If your theme does not support the custom menus feature yet (the default theme, Twenty Ten, does), you can learn about adding this support by following the Documentation link in this tab. You can still use the “Custom Menu” widget to add menus to a sidebar.') . '

            '; $help .= '

            ' . __('You can create custom menus for your site. These menus may contain links to pages, categories, custom links or other content types (use the Screen Options tab to decide which ones to show on the screen). You can specify a different navigation label for a menu item as well as other attributes. You can create multiple menus. If your theme includes more than one menu, you can choose which custom menu to associate with each. You can also use custom menus in conjunction with the Custom Menus widget.') . '

            '; -$help .= '

            ' . __('To create a new custom menu, click on the + tab, give the menu a name, and click Create Menu. Next, add menu items from the appropriate boxes. You’ll be able to edit the information for each menu item, and can drag and drop to put them in order. You can also drag a menu item a little to the right to make it a submenu, to create menus with hierarchy. You’ll see when the position of the drop target shifts over to create the nested placement. Don’t forget to click Save when you’re finished.') . '

            '; +$help .= '

            ' . __('To create a new custom menu, click on the + tab, give the menu a name, and click Create Menu. Next, add menu items from the appropriate boxes. You’ll be able to edit the information for each menu item, and can drag and drop to put them in order. You can also drag a menu item a little to the right to make it a submenu, to create menus with hierarchy. Drop the item into its new nested placement when the dotted rectangle target shifts over, also a little to the right. Don’t forget to click Save when you’re finished.') . '

            '; $help .= '

            ' . __('For more information:') . '

            '; -$help .= '

            ' . __('Menus Documentation') . '

            '; +$help .= '

            ' . __('Documentation on Menus') . '

            '; $help .= '

            ' . __('Support Forums') . '

            '; add_contextual_help($current_screen, $help); // Get the admin header -require_once( 'admin-header.php' ); +require_once( './admin-header.php' ); ?>
            @@ -494,7 +494,7 @@ require_once( 'admin-header.php' ); - +
            + @@ -598,4 +605,4 @@ require_once( 'admin-header.php' ); - + diff --git a/wp-admin/network.php b/wp-admin/network.php index a2951641..6a9aca33 100644 --- a/wp-admin/network.php +++ b/wp-admin/network.php @@ -18,8 +18,14 @@ require_once( './admin.php' ); if ( ! is_super_admin() ) wp_die( __( 'You do not have sufficient permissions to manage options for this site.' ) ); -if ( is_multisite() && ! defined( 'MULTISITE' ) ) - wp_die( __( 'The Network creation panel is not for WordPress MU networks.' ) ); +if ( is_multisite() ) { + if ( ! is_network_admin() ) { + wp_redirect( network_admin_url( 'setup.php' ) ); + exit; + } + if ( ! defined( 'MULTISITE' ) ) + wp_die( __( 'The Network creation panel is not for WordPress MU networks.' ) ); +} // We need to create references to ms global tables to enable Network. foreach ( $wpdb->tables( 'ms_global' ) as $table => $prefixed_table ) @@ -89,8 +95,13 @@ function get_clean_basedomain() { if ( ! network_domain_check() && ( ! defined( 'WP_ALLOW_MULTISITE' ) || ! WP_ALLOW_MULTISITE ) ) wp_die( __( 'You must define the WP_ALLOW_MULTISITE constant as true in your wp-config.php file to allow creation of a Network.' ) ); -$title = __( 'Create a Network of WordPress Sites' ); -$parent_file = 'tools.php'; +if ( is_network_admin() ) { + $title = __( 'Network Setup' ); + $parent_file = 'settings.php'; +} else { + $title = __( 'Create a Network of WordPress Sites' ); + $parent_file = 'tools.php'; +} add_contextual_help($current_screen, '

            ' . __('This screen allows you to configure a network as having subdomains (site1.example.com) or subdirectories (example.com/site1). Subdomains require wildcard subdomains to be enabled in Apache and DNS records, if your host allows it.') . '

            ' . @@ -100,15 +111,15 @@ add_contextual_help($current_screen, '

            ' . __('Refreshing your browser will take you to a screen with an archive of those added lines of code. A set of six links under Super Admin will appear at the top of the main left navigation menu. The multisite network is now enabled.') . '

            ' . '

            ' . __('The choice of subdirectory sites is disabled if this setup is more than a month old because of permalink problems with “/blog/” from the main site. This disabling will be addressed soon in a future version.') . '

            ' . '

            ' . __('For more information:') . '

            ' . - '

            ' . __('General Network Creation Documentation') . '

            ' . - '

            ' . __('Tools > Network Documentation') . '

            ' . + '

            ' . __('Documentation on Creating a Network') . '

            ' . + '

            ' . __('Documentation on the Network Screen') . '

            ' . '

            ' . __('Support Forums') . '

            ' ); -include( './admin-header.php' ); +include( ABSPATH . 'wp-admin/admin-header.php' ); ?>
            - +

            ' . __('Error:') . ' ' . sprintf( __( 'Your WordPress address must match your Site address before creating a Network. See General Settings.' ), esc_url( admin_url( 'options-general.php' ) ) ) . '

            '; echo ''; - include ('./admin-footer.php' ); + include ( ABSPATH . 'wp-admin/admin-footer.php' ); + die(); + } + + if ( defined('DO_NOT_UPGRADE_GLOBAL_TABLES') ) { + echo '

            ' . __('Error:') . ' ' . __( 'The constant DO_NOT_UPGRADE_GLOBAL_TABLES cannot be defined when creating a network.' ) . '

            '; + echo ''; + include ( ABSPATH . 'wp-admin/admin-footer.php' ); die(); } @@ -134,7 +152,7 @@ function network_step1( $errors = false ) { if ( ! empty( $active_plugins ) ) { echo '

            ' . __('Warning:') . ' ' . sprintf( __( 'Please deactivate your plugins before enabling the Network feature.' ), admin_url( 'plugins.php?plugin_status=active' ) ) . '

            ' . __( 'Once the network is created, you may reactivate your plugins.' ) . '

            '; echo ''; - include( './admin-footer.php' ); + include( ABSPATH . 'wp-admin/admin-footer.php' ); die(); } @@ -145,7 +163,7 @@ function network_step1( $errors = false ) { echo '

            ' . sprintf( __( 'You cannot use port numbers such as %s.' ), $has_ports ) . '

            '; echo '' . __( 'Return to Dashboard' ) . ''; echo ''; - include( './admin-footer.php' ); + include( ABSPATH . 'wp-admin/admin-footer.php' ); die(); } @@ -275,9 +293,9 @@ function network_step1( $errors = false ) { -

            ' />

            + - ' . $errors->get_error_message() . ''; if ( $_POST ) { - $subdomain_install = allow_subdomain_install() ? ( allow_subdirectory_install() ? ! empty( $_POST['subdomain_install'] ) : true ) : false; + if ( allow_subdomain_install() ) + $subdomain_install = allow_subdirectory_install() ? ! empty( $_POST['subdomain_install'] ) : true; + else + $subdomain_install = false; } else { if ( is_multisite() ) { $subdomain_install = is_subdomain_install(); ?> -

            -

            +get_var( "SELECT meta_value FROM $wpdb->sitemeta WHERE site_id = 1 AND meta_key = 'subdomain_install'" ); ?>

            @@ -314,17 +339,19 @@ function network_step2( $errors = false ) {

            Caution: We recommend you back up your existing wp-config.php file.' ); + if ( file_exists( ABSPATH . '.htaccess' ) ) + printf( __( 'Caution: We recommend you back up your existing wp-config.php and %s files.' ), '.htaccess' ); + elseif ( file_exists( ABSPATH . 'web.config' ) ) + printf( __( 'Caution: We recommend you back up your existing wp-config.php and %s files.' ), 'web.config' ); else - _e( 'Caution: We recommend you back up your existing wp-config.php and .htaccess files.' ); + _e( 'Caution: We recommend you back up your existing wp-config.php file.' ); ?>

            1. blogs.dir directory in %s. This directory is used to stored uploaded media for your additional sites and must be writeable by the web server.' ), WP_CONTENT_DIR ); + printf( __( 'Create a blogs.dir directory at %s/blogs.dir. This directory is used to store uploaded media for your additional sites and must be writeable by the web server.' ), WP_CONTENT_DIR ); if ( WP_CONTENT_DIR != ABSPATH . 'wp-content' ) echo ' ' . __('Warning:') . ' ' . __( 'Networks may not be fully compatible with custom wp-content directories.' ) . '

            2. @@ -344,26 +371,23 @@ define( 'BLOG_ID_CURRENT_SITE', 1 ); unset( $keys_salts[ $c ] ); } if ( ! empty( $keys_salts ) ) { + $keys_salts_str = ''; $from_api = wp_remote_get( 'https://api.wordpress.org/secret-key/1.1/salt/' ); if ( is_wp_error( $from_api ) ) { foreach ( $keys_salts as $c => $v ) { - $keys_salts[ $c ] = wp_generate_password( 64, true, true ); + $keys_salts_str .= "\ndefine( '$c', '" . wp_generate_password( 64, true, true ) . "' );"; } } else { $from_api = explode( "\n", wp_remote_retrieve_body( $from_api ) ); foreach ( $keys_salts as $c => $v ) { - $keys_salts[ $c ] = substr( array_shift( $from_api ), 28, 64 ); + $keys_salts_str .= "\ndefine( '$c', '" . substr( array_shift( $from_api ), 28, 64 ) . "' );"; } } $num_keys_salts = count( $keys_salts ); ?>

              wp-config.php file.', 'These unique authentication keys are also missing from your wp-config.php file.', $num_keys_salts ); ?>

              - + @@ -430,7 +454,7 @@ define( 'BLOG_ID_CURRENT_SITE', 1 ); - + @@ -449,7 +473,7 @@ define( 'BLOG_ID_CURRENT_SITE', 1 ); ?>
            3. web.config file in %s, replacing other WordPress rules:' ), ABSPATH ); ?>

            @@ -471,14 +495,14 @@ RewriteRule ^ - [L]'; // @todo custom content dir. if ( ! $subdomain_install ) - $htaccess_file .= "\nRewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]\nRewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]"; + $htaccess_file .= "\nRewriteRule ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]\nRewriteRule ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]"; $htaccess_file .= "\nRewriteRule . index.php [L]"; ?>
          • .htaccess file in %s, replacing other WordPress rules:' ), ABSPATH ); ?>

          • +
    - + diff --git a/wp-admin/network/admin.php b/wp-admin/network/admin.php new file mode 100644 index 00000000..d4374de0 --- /dev/null +++ b/wp-admin/network/admin.php @@ -0,0 +1,22 @@ + diff --git a/wp-admin/network/edit.php b/wp-admin/network/edit.php new file mode 100644 index 00000000..2d3f9522 --- /dev/null +++ b/wp-admin/network/edit.php @@ -0,0 +1,482 @@ + +

    +

    +
    + + ID'>$current_user->user_login"; + + foreach ( ( $allusers = (array) $_POST['allusers'] ) as $key => $val ) { + if ( $val != '' && $val != '0' ) { + $delete_user = new WP_User( $val ); + + if ( ! current_user_can( 'delete_user', $delete_user->ID ) ) + wp_die( sprintf( __( 'Warning! User %s cannot be deleted.' ), $delete_user->user_login ) ); + + if ( in_array( $delete_user->user_login, $site_admins ) ) + wp_die( sprintf( __( 'Warning! User cannot be deleted. The user %s is a network admnistrator.' ), $delete_user->user_login ) ); + + echo "\n"; + $blogs = get_blogs_of_user( $val, true ); + + if ( !empty( $blogs ) ) { + ?> +

    %s?" ), $delete_user->user_login ); ?>

    + $details ) { + $blog_users = get_users( array( 'blog_id' => $details->userblog_id ) ); + if ( is_array( $blog_users ) && !empty( $blog_users ) ) { + $user_site = "{$details->blogname}"; + $user_dropdown = "\n"; + ?> +
      +
    • +
    • +
    • +
    + "; + } + } + } + + submit_button( __('Confirm Deletion'), 'delete' ); + ?> + + options page.' ), esc_url( admin_url( 'settings.php' ) ) ) ); + + if ( isset($_POST['WPLANG']) && ( '' === $_POST['WPLANG'] || in_array( $_POST['WPLANG'], get_available_languages() ) ) ) + update_site_option( 'WPLANG', $_POST['WPLANG'] ); + + if ( is_email( $_POST['admin_email'] ) ) + update_site_option( 'admin_email', $_POST['admin_email'] ); + + $illegal_names = split( ' ', $_POST['illegal_names'] ); + foreach ( (array) $illegal_names as $name ) { + $name = trim( $name ); + if ( $name != '' ) + $names[] = trim( $name ); + } + update_site_option( 'illegal_names', $names ); + + if ( $_POST['limited_email_domains'] != '' ) { + $limited_email_domains = str_replace( ' ', "\n", $_POST['limited_email_domains'] ); + $limited_email_domains = split( "\n", stripslashes( $limited_email_domains ) ); + $limited_email = array(); + foreach ( (array) $limited_email_domains as $domain ) { + $domain = trim( $domain ); + if ( ! preg_match( '/(--|\.\.)/', $domain ) && preg_match( '|^([a-zA-Z0-9-\.])+$|', $domain ) ) + $limited_email[] = trim( $domain ); + } + update_site_option( 'limited_email_domains', $limited_email ); + } else { + update_site_option( 'limited_email_domains', '' ); + } + + if ( $_POST['banned_email_domains'] != '' ) { + $banned_email_domains = split( "\n", stripslashes( $_POST['banned_email_domains'] ) ); + $banned = array(); + foreach ( (array) $banned_email_domains as $domain ) { + $domain = trim( $domain ); + if ( ! preg_match( '/(--|\.\.)/', $domain ) && preg_match( '|^([a-zA-Z0-9-\.])+$|', $domain ) ) + $banned[] = trim( $domain ); + } + update_site_option( 'banned_email_domains', $banned ); + } else { + update_site_option( 'banned_email_domains', '' ); + } + + $options = array( 'registrationnotification', 'registration', 'add_new_users', 'menu_items', 'mu_media_buttons', 'upload_space_check_disabled', 'blog_upload_space', 'upload_filetypes', 'site_name', 'first_post', 'first_page', 'first_comment', 'first_comment_url', 'first_comment_author', 'welcome_email', 'welcome_user_email', 'fileupload_maxk', 'global_terms_enabled' ); + $checked_options = array( 'mu_media_buttons' => array(), 'menu_items' => array(), 'registrationnotification' => 'no', 'upload_space_check_disabled' => 1, 'add_new_users' => 0 ); + foreach ( $checked_options as $option_name => $option_unchecked_value ) { + if ( ! isset( $_POST[$option_name] ) ) + $_POST[$option_name] = $option_unchecked_value; + } + foreach ( $options as $option_name ) { + if ( ! isset($_POST[$option_name]) ) + continue; + $value = stripslashes_deep( $_POST[$option_name] ); + update_site_option( $option_name, $value ); + } + + // Update more options here + do_action( 'update_wpmu_options' ); + + wp_redirect( add_query_arg( 'updated', 'true', network_admin_url( 'settings.php' ) ) ); + exit(); + break; + + case 'updateblog': + // No longer used. + break; + + case 'deleteblog': + check_admin_referer('deleteblog'); + if ( ! ( current_user_can( 'manage_sites' ) && current_user_can( 'delete_sites' ) ) ) + wp_die( __( 'You do not have permission to access this page.' ) ); + + if ( $id != '0' && $id != $current_site->blog_id && current_user_can( 'delete_site', $id ) ) { + wpmu_delete_blog( $id, true ); + wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'delete' ), wp_get_referer() ) ); + } else { + wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'not_deleted' ), wp_get_referer() ) ); + } + + exit(); + break; + + case 'allblogs': + if ( ( isset( $_POST['action'] ) || isset( $_POST['action2'] ) ) && isset( $_POST['allblogs'] ) ) { + check_admin_referer( 'bulk-sites' ); + + if ( ! current_user_can( 'manage_sites' ) ) + wp_die( __( 'You do not have permission to access this page.' ) ); + + if ( $_GET['action'] != -1 || $_POST['action2'] != -1 ) + $doaction = $_POST['action'] != -1 ? $_POST['action'] : $_POST['action2']; + + $blogfunction = ''; + + foreach ( (array) $_POST['allblogs'] as $key => $val ) { + if ( $val != '0' && $val != $current_site->blog_id ) { + switch ( $doaction ) { + case 'delete': + if ( ! current_user_can( 'delete_site', $val ) ) + wp_die( __( 'You are not allowed to delete the site.' ) ); + $blogfunction = 'all_delete'; + wpmu_delete_blog( $val, true ); + break; + + case 'spam': + $blogfunction = 'all_spam'; + update_blog_status( $val, 'spam', '1' ); + set_time_limit( 60 ); + break; + + case 'notspam': + $blogfunction = 'all_notspam'; + update_blog_status( $val, 'spam', '0' ); + set_time_limit( 60 ); + break; + } + } else { + wp_die( __( 'You are not allowed to change the current site.' ) ); + } + } + + wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => $blogfunction ), wp_get_referer() ) ); + } else { + wp_redirect( network_admin_url( 'sites.php' ) ); + } + exit(); + break; + + case 'archiveblog': + check_admin_referer( 'archiveblog' ); + if ( ! current_user_can( 'manage_sites' ) ) + wp_die( __( 'You do not have permission to access this page.' ) ); + + update_blog_status( $id, 'archived', '1' ); + wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'archive' ), wp_get_referer() ) ); + exit(); + break; + + case 'unarchiveblog': + check_admin_referer( 'unarchiveblog' ); + if ( ! current_user_can( 'manage_sites' ) ) + wp_die( __( 'You do not have permission to access this page.' ) ); + + update_blog_status( $id, 'archived', '0' ); + wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'unarchive' ), wp_get_referer() ) ); + exit(); + break; + + case 'activateblog': + check_admin_referer( 'activateblog' ); + if ( ! current_user_can( 'manage_sites' ) ) + wp_die( __( 'You do not have permission to access this page.' ) ); + + update_blog_status( $id, 'deleted', '0' ); + do_action( 'activate_blog', $id ); + wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'activate' ), wp_get_referer() ) ); + exit(); + break; + + case 'deactivateblog': + check_admin_referer( 'deactivateblog' ); + if ( ! current_user_can( 'manage_sites' ) ) + wp_die( __( 'You do not have permission to access this page.' ) ); + + do_action( 'deactivate_blog', $id ); + update_blog_status( $id, 'deleted', '1' ); + wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'deactivate' ), wp_get_referer() ) ); + exit(); + break; + + case 'unspamblog': + check_admin_referer( 'unspamblog' ); + if ( ! current_user_can( 'manage_sites' ) ) + wp_die( __( 'You do not have permission to access this page.' ) ); + + update_blog_status( $id, 'spam', '0' ); + wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'unspam' ), wp_get_referer() ) ); + exit(); + break; + + case 'spamblog': + check_admin_referer( 'spamblog' ); + if ( ! current_user_can( 'manage_sites' ) ) + wp_die( __( 'You do not have permission to access this page.' ) ); + + update_blog_status( $id, 'spam', '1' ); + wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'spam' ), wp_get_referer() ) ); + exit(); + break; + + case 'unmatureblog': + check_admin_referer( 'unmatureblog' ); + if ( ! current_user_can( 'manage_sites' ) ) + wp_die( __( 'You do not have permission to access this page.' ) ); + + update_blog_status( $id, 'mature', '0' ); + wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'unmature' ), wp_get_referer() ) ); + exit(); + break; + + case 'matureblog': + check_admin_referer( 'matureblog' ); + if ( ! current_user_can( 'manage_sites' ) ) + wp_die( __( 'You do not have permission to access this page.' ) ); + + update_blog_status( $id, 'mature', '1' ); + wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'mature' ), wp_get_referer() ) ); + exit(); + break; + + // Common + case 'confirm': + check_admin_referer( 'confirm' ); + if ( !headers_sent() ) { + nocache_headers(); + header( 'Content-Type: text/html; charset=utf-8' ); + } + if ( $current_site->blog_id == $id ) + wp_die( __( 'You are not allowed to change the current site.' ) ); + ?> + + > + + <?php _e( 'WordPress › Confirm your action' ); ?> + + + + + +

    WordPress

    +
    + + + + +

    + +
    + + + '; + confirm_delete_users( $_POST['allusers'] ); + echo ''; + require_once( '../admin-footer.php' ); + } else { + wp_redirect( network_admin_url( 'users.php' ) ); + } + exit(); + break; + + case 'allusers': + if ( !current_user_can( 'manage_network_users' ) ) + wp_die( __( 'You do not have permission to access this page.' ) ); + + if ( ( isset( $_POST['action']) || isset($_POST['action2'] ) ) && isset( $_POST['allusers'] ) ) { + check_admin_referer( 'bulk-users-network' ); + + if ( $_GET['action'] != -1 || $_POST['action2'] != -1 ) + $doaction = $_POST['action'] != -1 ? $_POST['action'] : $_POST['action2']; + + $userfunction = ''; + + foreach ( (array) $_POST['allusers'] as $key => $val ) { + if ( !empty( $val ) ) { + switch ( $doaction ) { + case 'delete': + if ( ! current_user_can( 'delete_users' ) ) + wp_die( __( 'You do not have permission to access this page.' ) ); + $title = __( 'Users' ); + $parent_file = 'users.php'; + require_once( '../admin-header.php' ); + echo '
    '; + confirm_delete_users( $_POST['allusers'] ); + echo '
    '; + require_once( '../admin-footer.php' ); + exit(); + break; + + case 'spam': + $user = new WP_User( $val ); + if ( in_array( $user->user_login, get_super_admins() ) ) + wp_die( sprintf( __( 'Warning! User cannot be modified. The user %s is a network administrator.' ), esc_html( $user->user_login ) ) ); + + $userfunction = 'all_spam'; + $blogs = get_blogs_of_user( $val, true ); + foreach ( (array) $blogs as $key => $details ) { + if ( $details->userblog_id != $current_site->blog_id ) // main blog not a spam ! + update_blog_status( $details->userblog_id, 'spam', '1' ); + } + update_user_status( $val, 'spam', '1' ); + break; + + case 'notspam': + $userfunction = 'all_notspam'; + $blogs = get_blogs_of_user( $val, true ); + foreach ( (array) $blogs as $key => $details ) + update_blog_status( $details->userblog_id, 'spam', '0' ); + + update_user_status( $val, 'spam', '0' ); + break; + } + } + } + + wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => $userfunction ), wp_get_referer() ) ); + } else { + $location = network_admin_url( 'users.php' ); + + if ( ! empty( $_REQUEST['paged'] ) ) + $location = add_query_arg( 'paged', (int) $_REQUEST['paged'], $location ); + wp_redirect( $location ); + } + exit(); + break; + + case 'dodelete': + check_admin_referer( 'ms-users-delete' ); + if ( ! ( current_user_can( 'manage_network_users' ) && current_user_can( 'delete_users' ) ) ) + wp_die( __( 'You do not have permission to access this page.' ) ); + + if ( ! empty( $_POST['blog'] ) && is_array( $_POST['blog'] ) ) { + foreach ( $_POST['blog'] as $id => $users ) { + foreach ( $users as $blogid => $user_id ) { + if ( ! current_user_can( 'delete_user', $id ) ) + continue; + + if ( ! empty( $_POST['delete'] ) && 'reassign' == $_POST['delete'][$blogid][$id] ) + remove_user_from_blog( $id, $blogid, $user_id ); + else + remove_user_from_blog( $id, $blogid ); + } + } + } + $i = 0; + if ( is_array( $_POST['user'] ) && ! empty( $_POST['user'] ) ) + foreach( $_POST['user'] as $id ) { + if ( ! current_user_can( 'delete_user', $id ) ) + continue; + wpmu_delete_user( $id ); + $i++; + } + + if ( $i == 1 ) + $deletefunction = 'delete'; + else + $deletefunction = 'all_delete'; + + wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => $deletefunction ), network_admin_url( 'users.php' ) ) ); + exit(); + break; + + default: + // Let plugins use us as a post handler easily + do_action( 'network_admin_edit_' . $_GET['action'] ); + wp_redirect( network_admin_url( 'index.php' ) ); + exit(); + break; +} +?> diff --git a/wp-admin/network/index-extra.php b/wp-admin/network/index-extra.php new file mode 100644 index 00000000..17ead786 --- /dev/null +++ b/wp-admin/network/index-extra.php @@ -0,0 +1,13 @@ +' . __('Until WordPress 3.0, running multiple sites required using WordPress MU instead of regular WordPress. In version 3.0, these applications have merged. If you are a former MU user, you should be aware of the following changes:') . '

    ' . + '
    • ' . __('Site Admin is now Super Admin (we highly encourage you to get yourself a cape!).') . '
    • ' . + '
    • ' . __('Blogs are now called Sites; Site is now called Network.') . '
    ' . + '

    ' . __('This screen provides the network administrator with links to the screens for Sites and Users to either create a new site or user, or to search existing users and sites, as well as Dashboard widgets. Those screens are also accessible through the left-hand navigation in the Network Admin section.') . '

    ' . + '

    ' . __('For more information:') . '

    ' . + '

    ' . __('Documentation on the Network Admin') . '

    ' . + '

    ' . __('Support Forums') . '

    ' +); + +wp_dashboard_setup(); + +wp_enqueue_script( 'dashboard' ); +wp_enqueue_script( 'plugin-install' ); +wp_admin_css( 'dashboard' ); +wp_admin_css( 'plugin-install' ); +add_thickbox(); + +add_screen_option('layout_columns', array('max' => 4, 'default' => 2) ); + +require_once( '../admin-header.php' ); + +?> + +
    + +

    + +
    + + + +
    +
    + +
    + + diff --git a/wp-admin/network/menu.php b/wp-admin/network/menu.php new file mode 100644 index 00000000..7fbfb995 --- /dev/null +++ b/wp-admin/network/menu.php @@ -0,0 +1,73 @@ +response) ) + $theme_update_count = count( $update_themes->response ); +$menu[15] = array(sprintf(__('Themes %s'), "" . number_format_i18n($theme_update_count) . "" ), 'manage_network_themes', 'themes.php', '', 'menu-top menu-icon-appearance', 'menu-appearance', 'div'); +$submenu['themes.php'][5] = array( __('Themes'), 'manage_network_themes', 'themes.php' ); +$submenu['themes.php'][10] = array( _x('Add New', 'theme'), 'install_themes', 'theme-install.php' ); +$submenu['themes.php'][15] = array( _x('Editor', 'theme editor'), 'edit_themes', 'theme-editor.php' ); + +$update_plugins = get_site_transient( 'update_plugins' ); +if ( !empty($update_plugins->response) ) + $plugin_update_count = count( $update_plugins->response ); +$menu[20] = array(sprintf( __('Plugins %s'), "" . number_format_i18n($plugin_update_count) . "" ), 'manage_network_plugins', 'plugins.php', '', 'menu-top menu-icon-plugins', 'menu-plugins', 'div'); +$submenu['plugins.php'][5] = array( __('Plugins'), 'manage_network_plugins', 'plugins.php' ); +$submenu['plugins.php'][10] = array( _x('Add New', 'plugin editor'), 'install_plugins', 'plugin-install.php' ); +$submenu['plugins.php'][15] = array( _x('Editor', 'plugin editor'), 'edit_plugins', 'plugin-editor.php' ); + + +$menu[25] = array(__('Settings'), 'manage_network_options', 'settings.php', '', 'menu-top menu-icon-settings', 'menu-settings', 'div'); +if ( defined( 'MULTISITE' ) && defined( 'WP_ALLOW_MULTISITE' ) && WP_ALLOW_MULTISITE ) { + $submenu['settings.php'][5] = array( __('Settings'), 'manage_network_options', 'settings.php' ); + $submenu['settings.php'][10] = array( __('Network Setup'), 'manage_network_options', 'setup.php' ); +} + +$update_wordpress = get_core_updates( array('dismissed' => false) ); +if ( !empty($update_wordpress) && !in_array( $update_wordpress[0]->response, array('development', 'latest') ) ) + $wordpress_update_count = 1; + +$update_count = $plugin_update_count + $theme_update_count + $wordpress_update_count; +$update_title = array(); +if ( $wordpress_update_count ) + $update_title[] = sprintf(__('%d WordPress Update'), $wordpress_update_count); +if ( $plugin_update_count ) + $update_title[] = sprintf(_n('%d Plugin Update', '%d Plugin Updates', $plugin_update_count), $plugin_update_count); +if ( $theme_update_count ) + $update_title[] = sprintf(_n('%d Theme Update', '%d Themes Updates', $theme_update_count), $theme_update_count); + +$update_title = !empty($update_title) ? esc_attr(implode(', ', $update_title)) : ''; + +$menu[30] = array(sprintf( __('Updates %s'), "" . number_format_i18n($update_count) . "" ), 'manage_network', 'upgrade.php', '', 'menu-top menu-icon-tools', 'menu-update', 'div'); +$submenu[ 'upgrade.php' ][10] = array( __( 'Updates' ), 'update_core', 'update-core.php' ); +$submenu[ 'upgrade.php' ][15] = array( __( 'Update Network' ), 'manage_network', 'upgrade.php' ); +unset($plugin_update_count, $theme_update_count, $wordpress_update_count, $update_count, $update_title, $update_themes, $update_plugins, $update_wordpress); + + +$menu[99] = array( '', 'read', 'separator-last', '', 'wp-menu-separator-last' ); + +require_once(ABSPATH . 'wp-admin/includes/menu.php'); + +?> \ No newline at end of file diff --git a/wp-admin/network/plugin-editor.php b/wp-admin/network/plugin-editor.php new file mode 100644 index 00000000..8850aa8f --- /dev/null +++ b/wp-admin/network/plugin-editor.php @@ -0,0 +1,16 @@ +' . __('This screen sets and changes options for the network as a whole. The first site is the main site in the network and network options are pulled from that original site’s options.') . '

    ' . + '

    ' . __('Operational settings has fields for the network’s name and admin email.') . '

    ' . + '

    ' . __('Dashboard Site is an option to give a site to users who do not have a site on the system. Their default role is Subscriber, but that default can be changed. The Admin Notice Feed can provide a notice on all dashboards of the latest post via RSS or Atom, or provide no such notice if left blank.') . '

    ' . + '

    ' . __('Registration settings can disable/enable public signups. If you let others sign up for a site, install spam plugins. Spaces, not commas, should separate names banned as sites for this network.') . '

    ' . + '

    ' . __('New site settings are defaults applied when a new site is created in the network. These include welcome email for when a new site or user account is registered, and what᾿s put in the first post, page, comment, comment author, and comment URL.') . '

    ' . + '

    ' . __('Upload settings control the size of the uploaded files and the amount of available upload space for each site. You can change the default value for specific sites when you edit a particular site. Allowed file types are also listed (space separated only).') . '

    ' . + '

    ' . __('Checkboxes for media upload buttons set which are shown in the visual editor. If unchecked, a generic upload button is still visible; other media types can still be uploaded if on the allowed file types list.') . '

    ' . + '

    ' . __('Menu setting enables/disables the plugin menus from appearing for non super admins, so that only super admins, not site admins, have access to activate plugins.') . '

    ' . + '

    ' . __('Super admins can no longer be added on the Options screen. You must now go to the list of existing users on Super Admin > Users and click on Username or the Edit action link below that name. This goes to an Edit User page where you can check a box to grant super admin privileges.') . '

    ' . + '

    ' . __('For more information:') . '

    ' . + '

    ' . __('Documentation on Network Settings') . '

    ' . + '

    ' . __('Support Forums') . '

    ' +); + +include( '../admin-header.php' ); + +if (isset($_GET['updated'])) { + ?> +

    + + +
    + +

    +
    + +

    + + + + + + + + + + +
    + +
    + +
    + +
    + support@%s is recommended.' ), $current_site->domain ); ?> +
    +

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    +
    +
    +
    + NOBLOGREDIRECT in wp-config.php to a URL you will redirect visitors to if they visit a non-existent site.' ); + ?> +
    + +
    + +
    + " size="45" /> +
    + +
    + + +
    + +
    + +
    + +
    +

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + +
    + +
    + +
    + +
    + +
    + +
    + +
    + +
    + +
    + +
    + +
    + +
    + +
    +

    + + + + + + + + + + + + + + + + + + + + + +

    +
    +
    +
    +
    ' ); ?>
    + + +

    + + + + + +
    + +
    + + +

    + + + + + + + + + + +
    +
    + + diff --git a/wp-admin/network/setup.php b/wp-admin/network/setup.php new file mode 100644 index 00000000..e5d5880f --- /dev/null +++ b/wp-admin/network/setup.php @@ -0,0 +1,16 @@ +' . __('The menu is for editing information specific to individual sites, particularly if the admin area of a site is unavailable.') . '

    ' . + '

    ' . __('Info - The domain and path are rarely edited as this can cause the site to not work properly. The Registered date and Last Updated date are displayed. Network admins can mark a site as archived, spam, deleted and mature, to remove from public listings or disable.') . '

    ' . + '

    ' . __('Users - This displays the users associated with this site. You can also change their role, reset their password, or remove them from the site. Removing the user from the site does not remove the user from the network.') . '

    ' . + '

    ' . sprintf( __('Themes - This area shows themes that are not already enabled across the network. Enabling a theme in this menu makes it accessible to this site. It does not activate the theme, but allows it to show in the site’s Appearance menu. To enable a theme for the entire network, see the Network Themes screen.' ), network_admin_url( 'themes.php' ) ) . '

    ' . + '

    ' . __('Settings - This page shows a list of all settings associated with this site. Some are created by WordPress and others are created by plugins you activate. Note that some fields are grayed out and say Serialized Data. You cannot modify these values due to the way the setting is stored in the database.') . '

    ' . + '

    ' . __('For more information:') . '

    ' . + '

    ' . __('Documentation on Site Management') . '

    ' . + '

    ' . __('Support Forums') . '

    ' +); + +$id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0; + +if ( ! $id ) + wp_die( __('Invalid site ID.') ); + +$details = get_blog_details( $id ); +if ( !can_edit_network( $details->site_id ) ) + wp_die( __( 'You do not have permission to access this page.' ) ); + +$is_main_site = is_main_site( $id ); + +if ( isset($_REQUEST['action']) && 'update-site' == $_REQUEST['action'] ) { + check_admin_referer( 'edit-site' ); + + switch_to_blog( $id ); + + if ( isset( $_POST['update_home_url'] ) && $_POST['update_home_url'] == 'update' ) { + $blog_address = get_blogaddress_by_domain( $_POST['blog']['domain'], $_POST['blog']['path'] ); + if ( get_option( 'siteurl' ) != $blog_address ) + update_option( 'siteurl', $blog_address ); + + if ( get_option( 'home' ) != $blog_address ) + update_option( 'home', $blog_address ); + } + + // rewrite rules can't be flushed during switch to blog + delete_option( 'rewrite_rules' ); + + // update blogs table + $blog_data = stripslashes_deep( $_POST['blog'] ); + $existing_details = get_blog_details( $id, false ); + $blog_data_checkboxes = array( 'public', 'archived', 'spam', 'mature', 'deleted' ); + foreach ( $blog_data_checkboxes as $c ) { + if ( ! in_array( $existing_details->$c, array( 0, 1 ) ) ) + $blog_data[ $c ] = $existing_details->$c; + else + $blog_data[ $c ] = isset( $_POST['blog'][ $c ] ) ? 1 : 0; + } + update_blog_details( $id, $blog_data ); + + restore_current_blog(); + wp_redirect( add_query_arg( array( 'update' => 'updated', 'id' => $id ), 'site-info.php') ); + exit; +} + +if ( isset($_GET['update']) ) { + $messages = array(); + if ( 'updated' == $_GET['update'] ) + $messages[] = __('Site info updated.'); +} + +$title = sprintf( __('Edit Site: %s'), get_blogaddress_by_id($id)); +$parent_file = 'sites.php'; +$submenu_file = 'sites.php'; + +require('../admin-header.php'); + +?> + +
    + +

    + +

    ' . $msg . '

    '; +} ?> +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + __( 'Public' ) ); + if ( ! $is_main_site ) { + $attribute_fields['archived'] = __( 'Archived' ); + $attribute_fields['spam'] = _x( 'Spam', 'site' ); + $attribute_fields['deleted'] = __( 'Deleted' ); + } + $attribute_fields['mature'] = __( 'Mature' ); + ?> + + + + +
    domain ) ?>
    path ) ?> +
    /> siteurl and home as well.' ); ?>
    + $field_label ) : ?> +
    + +
    + +
    + + +' . __('This screen is for Super Admins to add new sites to the network. This is not affected by the registration settings.') . '

    ' . + '

    ' . __('If the admin email for the new site does not exist in the database, a new user will also be created.') . '

    ' . + '

    ' . __('For more information:') . '

    ' . + '

    ' . __('Documentation on Site Management') . '

    ' . + '

    ' . __('Support Forums') . '

    ' +); + +if ( isset($_REQUEST['action']) && 'add-site' == $_REQUEST['action'] ) { + check_admin_referer( 'add-blog', '_wpnonce_add-blog' ); + + if ( ! current_user_can( 'manage_sites' ) ) + wp_die( __( 'You do not have permission to access this page.' ) ); + + if ( ! is_array( $_POST['blog'] ) ) + wp_die( __( 'Can’t create an empty site.' ) ); + $blog = $_POST['blog']; + $domain = ''; + if ( ! preg_match( '/(--)/', $blog['domain'] ) && preg_match( '|^([a-zA-Z0-9-])+$|', $blog['domain'] ) ) + $domain = strtolower( $blog['domain'] ); + + // If not a subdomain install, make sure the domain isn't a reserved word + if ( ! is_subdomain_install() ) { + $subdirectory_reserved_names = apply_filters( 'subdirectory_reserved_names', array( 'page', 'comments', 'blog', 'files', 'feed' ) ); + if ( in_array( $domain, $subdirectory_reserved_names ) ) + wp_die( sprintf( __('The following words are reserved for use by WordPress functions and cannot be used as blog names: %s' ), implode( ', ', $subdirectory_reserved_names ) ) ); + } + + $email = sanitize_email( $blog['email'] ); + $title = $blog['title']; + + if ( empty( $domain ) ) + wp_die( __( 'Missing or invalid site address.' ) ); + if ( empty( $email ) ) + wp_die( __( 'Missing email address.' ) ); + if ( !is_email( $email ) ) + wp_die( __( 'Invalid email address.' ) ); + + if ( is_subdomain_install() ) { + $newdomain = $domain . '.' . preg_replace( '|^www\.|', '', $current_site->domain ); + $path = $base; + } else { + $newdomain = $current_site->domain; + $path = $base . $domain . '/'; + } + + $password = 'N/A'; + $user_id = email_exists($email); + if ( !$user_id ) { // Create a new user with a random password + $password = wp_generate_password( 12, false ); + $user_id = wpmu_create_user( $domain, $password, $email ); + if ( false == $user_id ) + wp_die( __( 'There was an error creating the user.' ) ); + else + wp_new_user_notification( $user_id, $password ); + } + + $wpdb->hide_errors(); + $id = wpmu_create_blog( $newdomain, $path, $title, $user_id , array( 'public' => 1 ), $current_site->id ); + $wpdb->show_errors(); + if ( !is_wp_error( $id ) ) { + if ( !is_super_admin( $user_id ) && !get_user_option( 'primary_blog', $user_id ) ) + update_user_option( $user_id, 'primary_blog', $id, true ); + $content_mail = sprintf( __( "New site created by %1s\n\nAddress: http://%2s\nName: %3s"), $current_user->user_login , $newdomain . $path, stripslashes( $title ) ); + wp_mail( get_site_option('admin_email'), sprintf( __( '[%s] New Site Created' ), $current_site->site_name ), $content_mail, 'From: "Site Admin" <' . get_site_option( 'admin_email' ) . '>' ); + wpmu_welcome_notification( $id, $user_id, $password, $title, array( 'public' => 1 ) ); + wp_redirect( add_query_arg( array('update' => 'added'), 'site-new.php' ) ); + exit; + } else { + wp_die( $id->get_error_message() ); + } +} + +if ( isset($_GET['update']) ) { + $messages = array(); + if ( 'added' == $_GET['update'] ) + $messages[] = __('Site added.'); +} + +$title = __('Add New Site'); +$parent_file = 'sites.php'; + +require('../admin-header.php'); + +?> + +
    + +

    +

    ' . $msg . '

    '; +} ?> +
    + + + + + + + + + + + + + + + + + +
    + + .domain );?> + domain . $current_site->path ?> + ' . __( 'Only the characters a-z and 0-9 recommended.' ) . '

    '; + ?> +

    + +
    + + diff --git a/wp-admin/network/site-settings.php b/wp-admin/network/site-settings.php new file mode 100644 index 00000000..b90bb76d --- /dev/null +++ b/wp-admin/network/site-settings.php @@ -0,0 +1,150 @@ +' . __('The menu is for editing information specific to individual sites, particularly if the admin area of a site is unavailable.') . '

    ' . + '

    ' . __('Info - The domain and path are rarely edited as this can cause the site to not work properly. The Registered date and Last Updated date are displayed. Network admins can mark a site as archived, spam, deleted and mature, to remove from public listings or disable.') . '

    ' . + '

    ' . __('Users - This displays the users associated with this site. You can also change their role, reset their password, or remove them from the site. Removing the user from the site does not remove the user from the network.') . '

    ' . + '

    ' . sprintf( __('Themes - This area shows themes that are not already enabled across the network. Enabling a theme in this menu makes it accessible to this site. It does not activate the theme, but allows it to show in the site’s Appearance menu. To enable a theme for the entire network, see the Network Themes screen.' ), network_admin_url( 'themes.php' ) ) . '

    ' . + '

    ' . __('Settings - This page shows a list of all settings associated with this site. Some are created by WordPress and others are created by plugins you activate. Note that some fields are grayed out and say Serialized Data. You cannot modify these values due to the way the setting is stored in the database.') . '

    ' . + '

    ' . __('For more information:') . '

    ' . + '

    ' . __('Documentation on Site Management') . '

    ' . + '

    ' . __('Support Forums') . '

    ' +); + +$id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0; + +if ( ! $id ) + wp_die( __('Invalid site ID.') ); + +$details = get_blog_details( $id ); +if ( !can_edit_network( $details->site_id ) ) + wp_die( __( 'You do not have permission to access this page.' ) ); + +$is_main_site = is_main_site( $id ); + +if ( isset($_REQUEST['action']) && 'update-site' == $_REQUEST['action'] && is_array( $_POST['option'] ) ) { + check_admin_referer( 'edit-site' ); + + switch_to_blog( $id ); + + $c = 1; + $count = count( $_POST['option'] ); + $skip_options = array( 'allowedthemes' ); // Don't update these options since they are handled elsewhere in the form. + foreach ( (array) $_POST['option'] as $key => $val ) { + if ( $key === 0 || is_array( $val ) || in_array($key, $skip_options) ) + continue; // Avoids "0 is a protected WP option and may not be modified" error when edit blog options + if ( $c == $count ) + update_option( $key, stripslashes( $val ) ); + else + update_option( $key, stripslashes( $val ), false ); // no need to refresh blog details yet + $c++; + } + + do_action( 'wpmu_update_blog_options' ); + restore_current_blog(); + wp_redirect( add_query_arg( array( 'update' => 'updated', 'id' => $id ), 'site-settings.php') ); + exit; +} + +if ( isset($_GET['update']) ) { + $messages = array(); + if ( 'updated' == $_GET['update'] ) + $messages[] = __('Site options updated.'); +} + +$title = sprintf( __('Edit Site: %s'), get_blogaddress_by_id($id)); +$parent_file = 'sites.php'; +$submenu_file = 'sites.php'; + +require('../admin-header.php'); + +?> + +
    + +

    + +

    ' . $msg . '

    '; +} ?> +
    + + + + get_blog_prefix( $id ); + $options = $wpdb->get_results( "SELECT * FROM {$blog_prefix}options WHERE option_name NOT LIKE '\_%' AND option_name NOT LIKE '%user_roles'" ); + foreach ( $options as $option ) { + if ( $option->option_name == 'default_role' ) + $editblog_default_role = $option->option_value; + $disabled = false; + $class = 'all-options'; + if ( is_serialized( $option->option_value ) ) { + if ( is_serialized_string( $option->option_value ) ) { + $option->option_value = esc_html( maybe_unserialize( $option->option_value ), 'single' ); + } else { + $option->option_value = 'SERIALIZED DATA'; + $disabled = true; + $class = 'all-options disabled'; + } + } + if ( strpos( $option->option_value, "\n" ) !== false ) { + ?> + + + + + + + + option_name, array( 'siteurl', 'home' ) ) ) { ?> + + + + + + +
    option_name ) ) ?>
    option_name ) ) ); ?>option_value ) ?> />
    + +
    + + +' . __('The menu is for editing information specific to individual sites, particularly if the admin area of a site is unavailable.') . '

    ' . + '

    ' . __('Info - The domain and path are rarely edited as this can cause the site to not work properly. The Registered date and Last Updated date are displayed. Network admins can mark a site as archived, spam, deleted and mature, to remove from public listings or disable.') . '

    ' . + '

    ' . __('Users - This displays the users associated with this site. You can also change their role, reset their password, or remove them from the site. Removing the user from the site does not remove the user from the network.') . '

    ' . + '

    ' . sprintf( __('Themes - This area shows themes that are not already enabled across the network. Enabling a theme in this menu makes it accessible to this site. It does not activate the theme, but allows it to show in the site’s Appearance menu. To enable a theme for the entire network, see the Network Themes screen.' ), network_admin_url( 'themes.php' ) ) . '

    ' . + '

    ' . __('Settings - This page shows a list of all settings associated with this site. Some are created by WordPress and others are created by plugins you activate. Note that some fields are grayed out and say Serialized Data. You cannot modify these values due to the way the setting is stored in the database.') . '

    ' . + '

    ' . __('For more information:') . '

    ' . + '

    ' . __('Documentation on Site Management') . '

    ' . + '

    ' . __('Support Forums') . '

    ' +); + +$wp_list_table = _get_list_table('WP_MS_Themes_List_Table'); + +$action = $wp_list_table->current_action(); + +$s = isset($_REQUEST['s']) ? $_REQUEST['s'] : ''; + +// Clean up request URI from temporary args for screen options/paging uri's to work as expected. +$temp_args = array( 'enabled', 'disabled', 'error' ); +$_SERVER['REQUEST_URI'] = remove_query_arg( $temp_args, $_SERVER['REQUEST_URI'] ); +$referer = remove_query_arg( $temp_args, wp_get_referer() ); + +$id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0; + +if ( ! $id ) + wp_die( __('Invalid site ID.') ); + +$wp_list_table->prepare_items(); + +$details = get_blog_details( $id ); +if ( !can_edit_network( $details->site_id ) ) + wp_die( __( 'You do not have permission to access this page.' ) ); + +$is_main_site = is_main_site( $id ); + +if ( $action ) { + switch_to_blog( $id ); + $allowed_themes = get_option( 'allowedthemes' ); + + switch ( $action ) { + case 'enable': + check_admin_referer( 'enable-theme_' . $_GET['theme'] ); + $theme = $_GET['theme']; + $action = 'enabled'; + $n = 1; + if ( !$allowed_themes ) + $allowed_themes = array( $theme => true ); + else + $allowed_themes[$theme] = true; + break; + case 'disable': + check_admin_referer( 'disable-theme_' . $_GET['theme'] ); + $theme = $_GET['theme']; + $action = 'disabled'; + $n = 1; + if ( !$allowed_themes ) + $allowed_themes = array(); + else + unset( $allowed_themes[$theme] ); + break; + case 'enable-selected': + check_admin_referer( 'bulk-themes' ); + if ( isset( $_POST['checked'] ) ) { + $themes = (array) $_POST['checked']; + $action = 'enabled'; + $n = count( $themes ); + foreach( (array) $themes as $theme ) + $allowed_themes[ $theme ] = true; + } else { + $action = 'error'; + $n = 'none'; + } + break; + case 'disable-selected': + check_admin_referer( 'bulk-themes' ); + if ( isset( $_POST['checked'] ) ) { + $themes = (array) $_POST['checked']; + $action = 'disabled'; + $n = count( $themes ); + foreach( (array) $themes as $theme ) + unset( $allowed_themes[ $theme ] ); + } else { + $action = 'error'; + $n = 'none'; + } + break; + } + + update_option( 'allowedthemes', $allowed_themes ); + restore_current_blog(); + + wp_redirect( add_query_arg( $action, $n, $referer ) ); + exit; +} + +if ( isset( $_GET['action'] ) && 'update-site' == $_GET['action'] ) { + wp_redirect( $referer ); + exit(); +} + +add_thickbox(); +add_screen_option( 'per_page', array( 'label' => _x( 'Themes', 'themes per page (screen options)' ) ) ); + +$title = sprintf( __('Edit Site: %s'), get_blogaddress_by_id($id)); +$parent_file = 'sites.php'; +$submenu_file = 'sites.php'; + +require('../admin-header.php'); ?> + +
    + +

    +

    ' . sprintf( _n( 'Theme enabled.', '%s themes enabled.', $_GET['enabled'] ), number_format_i18n( $_GET['enabled'] ) ) . '

    '; +} elseif ( isset( $_GET['disabled'] ) ) { + $_GET['disabled'] = absint( $_GET['disabled'] ); + echo '

    ' . sprintf( _n( 'Theme disabled.', '%s themes disabled.', $_GET['disabled'] ), number_format_i18n( $_GET['disabled'] ) ) . '

    '; +} elseif ( isset( $_GET['error'] ) && 'none' == $_GET['error'] ) { + echo '

    ' . __( 'No theme selected.' ) . '

    '; +} ?> + +

    + +
    +search_box( __( 'Search Installed Themes' ), 'theme' ); ?> + +
    + +views(); ?> + +
    + + + +display(); ?> + +
    + + + diff --git a/wp-admin/network/site-users.php b/wp-admin/network/site-users.php new file mode 100644 index 00000000..9366cb93 --- /dev/null +++ b/wp-admin/network/site-users.php @@ -0,0 +1,308 @@ +prepare_items(); + +$action = $wp_list_table->current_action(); + +add_contextual_help($current_screen, + '

    ' . __('The menu is for editing information specific to individual sites, particularly if the admin area of a site is unavailable.') . '

    ' . + '

    ' . __('Info - The domain and path are rarely edited as this can cause the site to not work properly. The Registered date and Last Updated date are displayed. Network admins can mark a site as archived, spam, deleted and mature, to remove from public listings or disable.') . '

    ' . + '

    ' . __('Users - This displays the users associated with this site. You can also change their role, reset their password, or remove them from the site. Removing the user from the site does not remove the user from the network.') . '

    ' . + '

    ' . sprintf( __('Themes - This area shows themes that are not already enabled across the network. Enabling a theme in this menu makes it accessible to this site. It does not activate the theme, but allows it to show in the site’s Appearance menu. To enable a theme for the entire network, see the Network Themes screen.' ), network_admin_url( 'themes.php' ) ) . '

    ' . + '

    ' . __('Settings - This page shows a list of all settings associated with this site. Some are created by WordPress and others are created by plugins you activate. Note that some fields are grayed out and say Serialized Data. You cannot modify these values due to the way the setting is stored in the database.') . '

    ' . + '

    ' . __('For more information:') . '

    ' . + '

    ' . __('Documentation on Site Management') . '

    ' . + '

    ' . __('Support Forums') . '

    ' +); + +$id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0; + +if ( ! $id ) + wp_die( __('Invalid site ID.') ); + +$details = get_blog_details( $id ); +if ( !can_edit_network( $details->site_id ) ) + wp_die( __( 'You do not have permission to access this page.' ) ); + +$is_main_site = is_main_site( $id ); + +// get blog prefix +$blog_prefix = $wpdb->get_blog_prefix( $id ); + +// @todo This is a hack. Eventually, add API to WP_Roles allowing retrieval of roles for a particular blog. +if ( ! empty($wp_roles->use_db) ) { + $editblog_roles = get_blog_option( $id, "{$blog_prefix}user_roles" ); +} else { + // Roles are stored in memory, not the DB. + $editblog_roles = $wp_roles->roles; +} +$default_role = get_blog_option( $id, 'default_role' ); + +$action = $wp_list_table->current_action(); + +if ( $action ) { + switch_to_blog( $id ); + + switch ( $action ) { + case 'newuser': + check_admin_referer( 'add-user', '_wpnonce_add-new-user' ); + $user = $_POST['user']; + if ( !is_array( $_POST['user'] ) || empty( $user['username'] ) || empty( $user['email'] ) ) { + $update = 'err_new'; + } else { + $password = wp_generate_password( 12, false); + $user_id = wpmu_create_user( esc_html( strtolower( $user['username'] ) ), $password, esc_html( $user['email'] ) ); + + if ( false == $user_id ) { + $update = 'err_new_dup'; + } else { + wp_new_user_notification( $user_id, $password ); + add_user_to_blog( $id, $user_id, $_POST['new_role'] ); + $update = 'newuser'; + } + } + break; + + case 'adduser': + check_admin_referer( 'add-user', '_wpnonce_add-user' ); + if ( !empty( $_POST['newuser'] ) ) { + $update = 'adduser'; + $newuser = $_POST['newuser']; + $userid = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . $wpdb->users . " WHERE user_login = %s", $newuser ) ); + if ( $userid ) { + $user = $wpdb->get_var( "SELECT user_id FROM " . $wpdb->usermeta . " WHERE user_id='$userid' AND meta_key='{$blog_prefix}capabilities'" ); + if ( $user == false ) + add_user_to_blog( $id, $userid, $_POST['new_role'] ); + else + $update = 'err_add_member'; + } else { + $update = 'err_add_notfound'; + } + } else { + $update = 'err_add_notfound'; + } + break; + + case 'remove': + if ( !current_user_can('remove_users') ) + die(__('You can’t remove users.')); + check_admin_referer( 'bulk-users' ); + + $update = 'remove'; + if ( isset( $_REQUEST['users'] ) ) { + $userids = $_REQUEST['users']; + + foreach ( $userids as $user_id ) { + $user_id = (int) $user_id; + remove_user_from_blog( $user_id, $id ); + } + } elseif ( isset( $_GET['user'] ) ) { + remove_user_from_blog( $_GET['user'] ); + } else { + $update = 'err_remove'; + } + break; + + case 'promote': + check_admin_referer( 'bulk-users' ); + $editable_roles = get_editable_roles(); + if ( empty( $editable_roles[$_REQUEST['new_role']] ) ) + wp_die(__('You can’t give users that role.')); + + if ( isset( $_REQUEST['users'] ) ) { + $userids = $_REQUEST['users']; + $update = 'promote'; + foreach ( $userids as $user_id ) { + $user_id = (int) $user_id; + + // If the user doesn't already belong to the blog, bail. + if ( !is_user_member_of_blog( $user_id ) ) + wp_die(__('Cheatin’ uh?')); + + $user = new WP_User( $user_id ); + $user->set_role( $_REQUEST['new_role'] ); + } + } else { + $update = 'err_promote'; + } + break; + } + + restore_current_blog(); + wp_redirect( add_query_arg( 'update', $update, wp_get_referer() ) ); + exit(); +} + +if ( isset( $_GET['action'] ) && 'update-site' == $_GET['action'] ) { + wp_redirect( wp_get_referer() ); + exit(); +} + +add_screen_option( 'per_page', array( 'label' => _x( 'Users', 'users per page (screen options)' ) ) ); + +$title = sprintf( __('Edit Site: %s'), get_blogaddress_by_id($id)); +$parent_file = 'sites.php'; +$submenu_file = 'sites.php'; + +require('../admin-header.php'); ?> + +
    + +

    +

    ' . __( 'User added.' ) . '

    '; + break; + case 'err_add_member': + echo '

    ' . __( 'User is already a member of this site.' ) . '

    '; + break; + case 'err_add_notfound': + echo '

    ' . __( 'Enter the username of an existing user.' ) . '

    '; + break; + case 'promote': + echo '

    ' . __( 'Changed roles.' ) . '

    '; + break; + case 'err_promote': + echo '

    ' . __( 'Select a user to change role.' ) . '

    '; + break; + case 'remove': + echo '

    ' . __( 'User removed from this site.' ) . '

    '; + break; + case 'err_remove': + echo '

    ' . __( 'Select a user to remove.' ) . '

    '; + break; + case 'newuser': + echo '

    ' . __( 'User created.' ) . '

    '; + break; + case 'err_new': + echo '

    ' . __( 'Enter the username and email.' ) . '

    '; + break; + case 'err_new_dup': + echo '

    ' . __( 'Duplicated username or email address.' ) . '

    '; + break; + } +endif; ?> + +
    +search_box( __( 'Search Users' ), 'user' ); ?> + +
    + +views(); ?> + +
    + + + +display(); ?> + +
    + + + + +

    + +

    + +

    + +
    +
    + + + + + + + + + + + +
    + + +
    + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    + + +
    + + +get_pagenum(); + +$title = __( 'Sites' ); +$parent_file = 'sites.php'; + +add_screen_option( 'per_page', array('label' => _x( 'Sites', 'sites per page (screen options)' )) ); + +add_contextual_help($current_screen, + '

    ' . __('Add New takes you to the Add New Site screen. You can search for a site by Name, ID number, or IP address. Screen Options allows you to choose how many sites to display on one page.') . '

    ' . + '

    ' . __('This is the main table of all sites on this network. Switch between list and excerpt views by using the icons above the right side of the table.') . '

    ' . + '

    ' . __('Hovering over each site reveals seven options (three for the primary site):') . '

    ' . + '
    • ' . __('An Edit link to a separate Edit Site screen.') . '
    • ' . + '
    • ' . __('Dashboard leads to the Dashboard for that site.') . '
    • ' . + '
    • ' . __('Deactivate, Archive, and Spam which lead to confirmation screens. These actions can be reversed later.') . '
    • ' . + '
    • ' . __('Delete which is a permanent action after the confirmation screens.') . '
    • ' . + '
    • ' . __('Visit to go to the frontend site live.') . '
    ' . + '

    ' . __('The site ID is used internally, and is not shown on the front end of the site or to users/viewers.') . '

    ' . + '

    ' . __('Clicking on bold settings can re-sort this table. The upper right icons switch between list and excerpt views.') . '

    ' . + '

    ' . __('For more information:') . '

    ' . + '

    ' . __('Documentation on Site Management') . '

    ' . + '

    ' . __('Support Forums') . '

    ' +); + +$id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0; + +$msg = ''; +if ( isset( $_REQUEST['updated'] ) && $_REQUEST['updated'] == 'true' && ! empty( $_REQUEST['action'] ) ) { + switch ( $_REQUEST['action'] ) { + case 'all_notspam': + $msg = __( 'Sites removed from spam.' ); + break; + case 'all_spam': + $msg = __( 'Sites marked as spam.' ); + break; + case 'all_delete': + $msg = __( 'Sites deleted.' ); + break; + case 'delete': + $msg = __( 'Site deleted.' ); + break; + case 'not_deleted': + $msg = __( 'You do not have permission to delete that site.' ); + break; + case 'archive': + $msg = __( 'Site archived.' ); + break; + case 'unarchive': + $msg = __( 'Site unarchived.' ); + break; + case 'activate': + $msg = __( 'Site activated.' ); + break; + case 'deactivate': + $msg = __( 'Site deactivated.' ); + break; + case 'unspam': + $msg = __( 'Site removed from spam.' ); + break; + case 'spam': + $msg = __( 'Site marked as spam.' ); + break; + default: + $msg = apply_filters( 'network_sites_updated_message_' . $_REQUEST['action'] , __( 'Settings saved.' ) ); + break; + } + if ( $msg ) + $msg = '

    ' . $msg . '

    '; +} + +$wp_list_table->prepare_items(); + +$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); +if ( $pagenum > $total_pages && $total_pages > 0 ) { + wp_redirect( add_query_arg( 'paged', $total_pages ) ); + exit; +} + +require_once( '../admin-header.php' ); +?> + +
    + +

    + + + + + +' . __( 'Search results for “%s”' ) . '', esc_html( $s ) ); +} ?> +

    + + + +
    + display(); ?> +
    +
    + diff --git a/wp-admin/network/theme-editor.php b/wp-admin/network/theme-editor.php new file mode 100644 index 00000000..f6ac9c2e --- /dev/null +++ b/wp-admin/network/theme-editor.php @@ -0,0 +1,16 @@ +get_pagenum(); + +$action = $wp_list_table->current_action(); + +$s = isset($_REQUEST['s']) ? $_REQUEST['s'] : ''; + +// Clean up request URI from temporary args for screen options/paging uri's to work as expected. +$temp_args = array( 'enabled', 'disabled', 'deleted', 'error' ); +$_SERVER['REQUEST_URI'] = remove_query_arg( $temp_args, $_SERVER['REQUEST_URI'] ); +$referer = remove_query_arg( $temp_args, wp_get_referer() ); + +if ( $action ) { + $allowed_themes = get_site_option( 'allowedthemes' ); + switch ( $action ) { + case 'enable': + check_admin_referer('enable-theme_' . $_GET['theme']); + $allowed_themes[ $_GET['theme'] ] = true; + update_site_option( 'allowedthemes', $allowed_themes ); + wp_redirect( add_query_arg( 'enabled', '1', $referer ) ); + exit; + break; + case 'disable': + check_admin_referer('disable-theme_' . $_GET['theme']); + unset( $allowed_themes[ $_GET['theme'] ] ); + update_site_option( 'allowedthemes', $allowed_themes ); + wp_redirect( add_query_arg( 'disabled', '1', $referer ) ); + exit; + break; + case 'enable-selected': + check_admin_referer('bulk-themes'); + $themes = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array(); + if ( empty($themes) ) { + wp_redirect( add_query_arg( 'error', 'none', $referer ) ); + exit; + } + foreach( (array) $themes as $theme ) + $allowed_themes[ $theme ] = true; + update_site_option( 'allowedthemes', $allowed_themes ); + wp_redirect( add_query_arg( 'enabled', count( $themes ), $referer ) ); + exit; + break; + case 'disable-selected': + check_admin_referer('bulk-themes'); + $themes = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array(); + if ( empty($themes) ) { + wp_redirect( add_query_arg( 'error', 'none', $referer ) ); + exit; + } + foreach( (array) $themes as $theme ) + unset( $allowed_themes[ $theme ] ); + update_site_option( 'allowedthemes', $allowed_themes ); + wp_redirect( add_query_arg( 'disabled', count( $themes ), $referer ) ); + exit; + break; + case 'delete-selected': + if ( ! current_user_can( 'delete_themes' ) ) + wp_die( __('You do not have sufficient permissions to delete themes for this site.') ); + check_admin_referer( 'bulk-themes' ); + + $themes = isset( $_REQUEST['checked'] ) ? (array) $_REQUEST['checked'] : array(); + + if ( isset( $themes[ get_option( 'template' ) ] ) ) + unset( $themes[ get_option( 'template' ) ] ); + if ( isset( $themes[ get_option( 'stylesheet' ) ] ) ) + unset( $themes[ get_option( 'stylesheet' ) ] ); + + if ( empty( $themes ) ) { + wp_redirect( add_query_arg( 'error', 'none', $referer ) ); + exit; + } + + $main_theme = get_current_theme(); + $files_to_delete = $theme_info = array(); + foreach ( $themes as $key => $theme ) { + $data = get_theme_data( WP_CONTENT_DIR . '/themes/' . $theme . '/style.css' ); + if ( $data['Name'] == $main_theme ) { + unset( $themes[$key] ); + } else { + $files_to_delete = array_merge( $files_to_delete, list_files( WP_CONTENT_DIR . "/themes/$theme" ) ); + $theme_info[ $theme ] = $data; + } + } + + if ( empty( $themes ) ) { + wp_redirect( add_query_arg( 'error', 'main', $referer ) ); + exit; + } + + include(ABSPATH . 'wp-admin/update.php'); + + $parent_file = 'themes.php'; + + if ( ! isset( $_REQUEST['verify-delete'] ) ) { + wp_enqueue_script( 'jquery' ); + require_once( ABSPATH . 'wp-admin/admin-header.php' ); + ?> +
    + ' . _n( 'Delete Theme', 'Delete Themes', $themes_to_delete ) . ''; + ?> +

    +

    +
      + ', sprintf( __('%1$s by %2$s' ), esc_html( $theme['Name'] ), esc_html( $theme['AuthorName'] ) ), ''; /* translators: 1: theme name, 2: theme author */ ?> +
    +

    +
    + + + '; + ?> + + +
    +
    + +
    + +

    + +
    + 1), $_SERVER['REQUEST_URI'] ) ) ); + $paged = ( $_REQUEST['paged'] ) ? $_REQUEST['paged'] : 1; + wp_redirect( network_admin_url( "themes.php?deleted=".count( $themes )."&paged=$paged&s=$s" ) ); + exit; + break; + } +} + +$wp_list_table->prepare_items(); + +$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); +if ( $pagenum > $total_pages && $total_pages > 0 ) { + wp_redirect( add_query_arg( 'paged', $total_pages ) ); + exit; +} + +add_thickbox(); + +add_screen_option( 'per_page', array('label' => _x( 'Themes', 'themes per page (screen options)' )) ); + +add_contextual_help($current_screen, + '

    ' . __('This screen enables and disables the inclusion of themes available to choose in the Appearance menu for each site. It does not activate or deactivate which theme a site is currently using.') . '

    ' . + '

    ' . __('If the network admin disables a theme that is in use, it can still remain selected on that site. If another theme is chosen, the disabled theme will not appear in the site’s Appearance > Themes screen.') . '

    ' . + '

    ' . __('Themes can be enabled on a site by site basis by the network admin on the Edit Site screen you go to via the Edit action link on the Sites screen. Only network admins are able to install or edit themes.') . '

    ' . + '

    ' . __('For more information:') . '

    ' . + '

    ' . __('Documentation on Network Themes') . '

    ' . + '

    ' . __('Support Forums') . '

    ' +); + +$title = __('Themes'); +$parent_file = 'themes.php'; + +require_once(ABSPATH . 'wp-admin/admin-header.php'); + +?> + +
    + +

    ' . __('Search results for “%s”') . '', esc_html( $s ) ); ?> +

    + +

    ' . sprintf( _n( 'Theme enabled.', '%s themes enabled.', $_GET['enabled'] ), number_format_i18n( $_GET['enabled'] ) ) . '

    '; +} elseif ( isset( $_GET['disabled'] ) ) { + $_GET['disabled'] = absint( $_GET['disabled'] ); + echo '

    ' . sprintf( _n( 'Theme disabled.', '%s themes disabled.', $_GET['disabled'] ), number_format_i18n( $_GET['disabled'] ) ) . '

    '; +} elseif ( isset( $_GET['deleted'] ) ) { + $_GET['deleted'] = absint( $_GET['deleted'] ); + echo '

    ' . sprintf( _nx( 'Theme deleted.', '%s themes deleted.', $_GET['deleted'], 'network' ), number_format_i18n( $_GET['deleted'] ) ) . '

    '; +} elseif ( isset( $_GET['error'] ) && 'none' == $_GET['error'] ) { + echo '

    ' . __( 'No theme selected.' ) . '

    '; +} elseif ( isset( $_GET['error'] ) && 'main' == $_GET['error'] ) { + echo '

    ' . __( 'You cannot delete a theme while it is active on the main site.' ) . '

    '; +} + +?> + +
    +search_box( __( 'Search Installed Themes' ), 'theme' ); ?> +
    + +views(); ?> + +
    + + + +display(); ?> +
    + + + +' . __('Only use this screen once you have updated to a new version of WordPress through Dashboard > Updates. Clicking the Update Network button will step through each site in the network, five at a time, and make sure any database updates are applied.') . '

    ' . + '

    ' . __('If a version update to core has not happened, clicking this button won’t affect anything.') . '

    ' . + '

    ' . __('If this process fails for any reason, users logging in to their sites will force the same update.') . '

    ' . + '

    ' . __('For more information:') . '

    ' . + '

    ' . __('Documentation on Update Network') . '

    ' . + '

    ' . __('Support Forums') . '

    ' +); + +require_once('../admin-header.php'); + +if ( ! current_user_can( 'manage_network' ) ) + wp_die( __( 'You do not have permission to access this page.' ) ); + +echo '
    '; +screen_icon('tools'); +echo '

    ' . __( 'Update Network' ) . '

    '; + +$action = isset($_GET['action']) ? $_GET['action'] : 'show'; + +switch ( $action ) { + case "upgrade": + $n = ( isset($_GET['n']) ) ? intval($_GET['n']) : 0; + + if ( $n < 5 ) { + global $wp_db_version; + update_site_option( 'wpmu_upgrade_site', $wp_db_version ); + } + + $blogs = $wpdb->get_results( "SELECT * FROM {$wpdb->blogs} WHERE site_id = '{$wpdb->siteid}' AND spam = '0' AND deleted = '0' AND archived = '0' ORDER BY registered DESC LIMIT {$n}, 5", ARRAY_A ); + if ( empty( $blogs ) ) { + echo '

    ' . __( 'All done!' ) . '

    '; + break; + } + echo "
      "; + foreach ( (array) $blogs as $details ) { + $siteurl = get_blog_option( $details['blog_id'], 'siteurl' ); + echo "
    • $siteurl
    • "; + $response = wp_remote_get( trailingslashit( $siteurl ) . "wp-admin/upgrade.php?step=upgrade_db", array( 'timeout' => 120, 'httpversion' => '1.1' ) ); + if ( is_wp_error( $response ) ) + wp_die( sprintf( __( 'Warning! Problem updating %1$s. Your server may not be able to connect to sites running on it. Error message: %2$s' ), $siteurl, $response->get_error_message() ) ); + do_action( 'after_mu_upgrade', $response ); + do_action( 'wpmu_upgrade_site', $details[ 'blog_id' ] ); + } + echo "
    "; + ?>

    +

    +

    +
    + + diff --git a/wp-admin/network/user-edit.php b/wp-admin/network/user-edit.php new file mode 100644 index 00000000..0b2cfd26 --- /dev/null +++ b/wp-admin/network/user-edit.php @@ -0,0 +1,16 @@ +' . __('Add User will set up a new user account on the network and send them an email with their username and password.') . '

    ' . + '

    ' . __('Users who are signed up to the network without a site are added as subscribers to the main or primary dashboard site, giving them profile pages to manage their accounts. These users will only see Dashboard and My Sites in the main navigation until a site is created for them.') . '

    ' . + '

    ' . __('For more information:') . '

    ' . + '

    ' . __('Documentation on Network Users') . '

    ' . + '

    ' . __('Support Forums') . '

    ' +); + +if ( isset($_REQUEST['action']) && 'add-user' == $_REQUEST['action'] ) { + check_admin_referer( 'add-user', '_wpnonce_add-user' ); + if ( ! current_user_can( 'manage_network_users' ) ) + wp_die( __( 'You do not have permission to access this page.' ) ); + + if ( is_array( $_POST['user'] ) == false ) + wp_die( __( 'Cannot create an empty user.' ) ); + $user = $_POST['user']; + if ( empty($user['username']) && empty($user['email']) ) + wp_die( __( 'Missing username and email.' ) ); + elseif ( empty($user['username']) ) + wp_die( __( 'Missing username.' ) ); + elseif ( empty($user['email']) ) + wp_die( __( 'Missing email.' ) ); + + $password = wp_generate_password( 12, false); + $user_id = wpmu_create_user( esc_html( strtolower( $user['username'] ) ), $password, esc_html( $user['email'] ) ); + + if ( false == $user_id ) + wp_die( __( 'Duplicated username or email address.' ) ); + else + wp_new_user_notification( $user_id, $password ); + + wp_redirect( add_query_arg( array('update' => 'added'), 'user-new.php' ) ); + exit; +} + +if ( isset($_GET['update']) ) { + $messages = array(); + if ( 'added' == $_GET['update'] ) + $messages[] = __('User added.'); +} + +$title = __('Add New User'); +$parent_file = 'users.php'; + +require('../admin-header.php'); ?> + +
    + +

    +

    ' . $msg . '

    '; +} ?> +
    + + + + + + + + + + + + +
    + + +
    + + \ No newline at end of file diff --git a/wp-admin/network/users.php b/wp-admin/network/users.php new file mode 100644 index 00000000..6523c989 --- /dev/null +++ b/wp-admin/network/users.php @@ -0,0 +1,96 @@ +get_pagenum(); +$wp_list_table->prepare_items(); +$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); + +if ( $pagenum > $total_pages && $total_pages > 0 ) { + wp_redirect( add_query_arg( 'paged', $total_pages ) ); + exit; +} +$title = __( 'Users' ); +$parent_file = 'users.php'; + +add_screen_option( 'per_page', array('label' => _x( 'Users', 'users per page (screen options)' )) ); + +add_contextual_help($current_screen, + '

    ' . __('This table shows all users across the network and the sites to which they are assigned.') . '

    ' . + '

    ' . __('Hover over any user on the list to make the edit links appear. The Edit link on the left will take you to his or her Edit User profile page; the Edit link on the right by any site name goes to an Edit Site screen for that site.') . '

    ' . + '

    ' . __('You can also go to the user’s profile page by clicking on the individual username.') . '

    ' . + '

    ' . __('You can sort the table by clicking on any of the bold headings and switch between list and excerpt views by using the icons in the upper right.') . '

    ' . + '

    ' . __('The bulk action will permanently delete selected users, or mark/unmark those selected as spam. Spam users will have posts removed and will be unable to sign up again with the same email addresses.') . '

    ' . + '

    ' . __('You can make an existing user an additional super admin by going to the Edit User profile page and checking the box to grant that privilege.') . '

    ' . + '

    ' . __('For more information:') . '

    ' . + '

    ' . __('Documentation on Network Users') . '

    ' . + '

    ' . __('Support Forums') . '

    ' +); + +require_once( '../admin-header.php' ); + +if ( isset( $_REQUEST['updated'] ) && $_REQUEST['updated'] == 'true' && ! empty( $_REQUEST['action'] ) ) { + ?> +

    + +

    + +
    + +

    + ' . __( 'Search results for “%s”' ) . '', esc_html( $usersearch ) ); + ?> +

    + + views(); ?> + +
    + search_box( __( 'Search Users' ), 'user' ); ?> +
    + +
    + display(); ?> +
    +
    + + diff --git a/wp-admin/options-discussion.php b/wp-admin/options-discussion.php index b2110a29..e9bb1a67 100644 --- a/wp-admin/options-discussion.php +++ b/wp-admin/options-discussion.php @@ -19,7 +19,7 @@ add_contextual_help($current_screen, '

    ' . __('This screen provides many options for controlling the management and display of comments and links to your posts/pages. So many, in fact, they won’t all fit here! :) Use the documentation link below to get information on what each discussion setting does.') . '

    ' . '

    ' . __('You must click the Save Changes button at the bottom of the screen for new settings to take effect.') . '

    ' . '

    ' . __('For more information:') . '

    ' . - '

    ' . __('Discussion Settings Documentation') . '

    ' . + '

    ' . __('Documentation on Discussion Settings') . '

    ' . '

    ' . __('Support Forums') . '

    ' ); @@ -60,7 +60,7 @@ include('./admin-header.php');
    @@ -141,7 +141,7 @@ printf( __('Comments should be displayed with the %s comments at the top of each

    - +

    @@ -150,7 +150,7 @@ printf( __('Comments should be displayed with the %s comments at the top of each

    - +

    @@ -212,7 +212,8 @@ $avatar_defaults = array( 'gravatar_default' => __('Gravatar Logo'), 'identicon' => __('Identicon (Generated)'), 'wavatar' => __('Wavatar (Generated)'), - 'monsterid' => __('MonsterID (Generated)') + 'monsterid' => __('MonsterID (Generated)'), + 'retro' => __('Retro (Generated)') ); $avatar_defaults = apply_filters('avatar_defaults', $avatar_defaults); $default = get_option('avatar_default'); @@ -240,9 +241,7 @@ echo apply_filters('default_avatar_select', $avatar_list); -

    - -

    + diff --git a/wp-admin/options-general.php b/wp-admin/options-general.php index 1aaee472..57a1b149 100644 --- a/wp-admin/options-general.php +++ b/wp-admin/options-general.php @@ -21,7 +21,7 @@ $timezone_format = _x('Y-m-d G:i:s', 'timezone date format'); * Display JavaScript on the page. * * @package WordPress - * @subpackage General_Settings_Panel + * @subpackage General_Settings_Screen */ function add_js() { ?> @@ -30,7 +30,7 @@ function add_js() { jQuery(document).ready(function($){ $("input[name='date_format']").click(function(){ if ( "date_format_custom_radio" != $(this).attr("id") ) - $("input[name='date_format_custom']").val( $(this).val() ); + $("input[name='date_format_custom']").val( $(this).val() ).siblings('.example').text( $(this).siblings('span').text() ); }); $("input[name='date_format_custom']").focus(function(){ $("#date_format_custom_radio").attr("checked", "checked"); @@ -38,17 +38,25 @@ function add_js() { $("input[name='time_format']").click(function(){ if ( "time_format_custom_radio" != $(this).attr("id") ) - $("input[name='time_format_custom']").val( $(this).val() ); + $("input[name='time_format_custom']").val( $(this).val() ).siblings('.example').text( $(this).siblings('span').text() ); }); $("input[name='time_format_custom']").focus(function(){ $("#time_format_custom_radio").attr("checked", "checked"); }); + $("input[name='date_format_custom'], input[name='time_format_custom']").change( function() { + var format = $(this); + format.siblings('img').css('visibility','visible'); + $.post(ajaxurl, { + action: 'date_format_custom' == format.attr('name') ? 'date_format' : 'time_format', + date : format.val() + }, function(d) { format.siblings('img').css('visibility','hidden'); format.siblings('.example').text(d); } ); + }); }); //]]> ' . __('The fields on this screen determine some of the basics of your site setup.') . '

    ' . @@ -114,7 +122,7 @@ include('./admin-header.php'); -The new address will not become active until confirmed.
    ') ?> +The new address will not become active until confirmed.') ?> @@ -265,14 +273,14 @@ if ( empty($tzstring) ) { // Create a UTC+- zone if no timezone string exists echo " checked='checked'"; $custom = false; } - echo ' /> ' . date_i18n( $format ) . "
    \n"; + echo ' /> ' . date_i18n( $format ) . "
    \n"; } echo ' ' . date_i18n( get_option('date_format') ) . "\n"; + echo '/> ' . __('Custom:') . ' ' . date_i18n( get_option('date_format') ) . " \n"; - echo "\t

    " . __('Documentation on date formatting. Click “Save Changes” to update sample output.') . "

    \n"; + echo "\t

    " . __('Documentation on date and time formatting.') . "

    \n"; ?> @@ -297,12 +305,13 @@ if ( empty($tzstring) ) { // Create a UTC+- zone if no timezone string exists echo " checked='checked'"; $custom = false; } - echo ' /> ' . date_i18n( $format ) . "
    \n"; + echo ' /> ' . date_i18n( $format ) . "
    \n"; } echo ' ' . date_i18n( get_option('time_format') ) . "\n"; + echo '/> ' . __('Custom:') . ' ' . date_i18n( get_option('time_format') ) . " \n"; + ; ?> @@ -338,9 +347,7 @@ endfor; -

    - -

    + diff --git a/wp-admin/options-head.php b/wp-admin/options-head.php index 965615fd..7f2cc74d 100644 --- a/wp-admin/options-head.php +++ b/wp-admin/options-head.php @@ -11,6 +11,11 @@ wp_reset_vars(array('action', 'standalone', 'option_group_id')); +if ( isset( $_GET['updated'] ) && isset( $_GET['page'] ) ) { + // For backwards compat with plugins that don't use the Settings API and just set updated=1 in the redirect + add_settings_error('general', 'settings_updated', __('Settings saved.'), 'updated'); +} + settings_errors(); ?> \ No newline at end of file diff --git a/wp-admin/options-media.php b/wp-admin/options-media.php index 2e5d10d0..67c30ad4 100644 --- a/wp-admin/options-media.php +++ b/wp-admin/options-media.php @@ -18,7 +18,7 @@ $parent_file = 'options-general.php'; add_contextual_help($current_screen, '

    ' . __('You can set maximum sizes for images inserted into your written content; you can also insert an image as Full Size.') . '

    ' . '

    ' . __('The Embed option allows you embed a video, image, or other media content into your content automatically by typing the URL (of the web page where the file lives) on its own line when you create your content.') . '

    ' . - '

    ' . __('Uploading Options gives you folder and path choices for storing your files in your installation’s directory.') . '

    ' . + ( is_multisite() ? '' : '

    ' . __('Uploading Options gives you folder and path choices for storing your files in your installation’s directory.') . '

    ' ) . '

    ' . __('You must click the Save Changes button at the bottom of the screen for new settings to take effect.') . '

    ' . '

    ' . __('For more information:') . '

    ' . '

    ' . __('Documentation on Media Settings') . '

    ' . @@ -81,8 +81,8 @@ include('./admin-header.php'); -
    - +
    +
    @@ -132,9 +132,7 @@ include('./admin-header.php'); -

    - -

    + diff --git a/wp-admin/options-permalink.php b/wp-admin/options-permalink.php index 35cacf4f..e5f9a751 100644 --- a/wp-admin/options-permalink.php +++ b/wp-admin/options-permalink.php @@ -23,8 +23,8 @@ add_contextual_help($current_screen, '

    ' . __('The Optional fields let you customize the “category” and “tag” base names that will appear in archive URLs. For example, the page listing all posts in the “Uncategorized” category could be /topics/uncategorized instead of /category/uncategorized.') . '

    ' . '

    ' . __('You must click the Save Changes button at the bottom of the screen for new settings to take effect.') . '

    ' . '

    ' . __('For more information:') . '

    ' . - '

    ' . __('Permalinks Settings Documentation') . '

    ' . - '

    ' . __('Using Permalinks Documentation') . '

    ' . + '

    ' . __('Documentation on Permalinks Settings') . '

    ' . + '

    ' . __('Documentation on Using Permalinks') . '

    ' . '

    ' . __('Support Forums') . '

    ' ); @@ -35,48 +35,19 @@ add_contextual_help($current_screen, * @subpackage Permalink_Settings_Panel */ function add_js() { -?> + ?> set_tag_base( $tag_base ); } + + create_initial_taxonomies(); } $permalink_structure = get_option('permalink_structure'); @@ -250,9 +223,7 @@ $structures = array( -

    - -

    + web.config
    file were writable, we could do this automatically, but it isn’t so this is the url rewrite rule you should have in your web.config file. Click in the field and press CTRL + a to select all. Then insert this rule inside of the /<configuration>/<system.webServer>/<rewrite>/<rules> element in web.config file.') ?>

    -

    +

    web.config file writable for us to generate rewrite rules automatically, do not forget to revert the permissions after rule has been saved.') ?>

    writable, we could do this automatically, but it isn’t so this is the url rewrite rule you should have in your web.config file. Create a new file, called web.config in the root directory of your site. Click in the field and press CTRL + a to select all. Then insert this code into the web.config file.') ?>

    -

    +

    web.config file automatically, do not forget to revert the permissions after the file has been created.') ?>

    @@ -278,7 +249,7 @@ $structures = array(

    .htaccess file were writable, we could do this automatically, but it isn’t so these are the mod_rewrite rules you should have in your .htaccess file. Click in the field and press CTRL + a to select all.') ?>

    -

    +

    diff --git a/wp-admin/options-privacy.php b/wp-admin/options-privacy.php index caac6a1d..5f70b9e8 100644 --- a/wp-admin/options-privacy.php +++ b/wp-admin/options-privacy.php @@ -20,7 +20,7 @@ add_contextual_help($current_screen, '

    ' . __('When this setting is in effect a reminder is shown in the header of these administration screens that says, “Search Engines Blocked,” to remind you that your site is not being crawled.') . '

    ' . '

    ' . __('You must click the Save Changes button at the bottom of the screen for new settings to take effect.') . '

    ' . '

    ' . __('For more information:') . '

    ' . - '

    ' . __('Privacy Settings Documentation') . '

    ' . + '

    ' . __('Documentation on Privacy Settings') . '

    ' . '

    ' . __('Support Forums') . '

    ' ); @@ -50,9 +50,7 @@ include('./admin-header.php'); -

    - -

    + diff --git a/wp-admin/options-reading.php b/wp-admin/options-reading.php index 7cd4c463..7c8e1545 100644 --- a/wp-admin/options-reading.php +++ b/wp-admin/options-reading.php @@ -15,13 +15,39 @@ if ( ! current_user_can( 'manage_options' ) ) $title = __( 'Reading Settings' ); $parent_file = 'options-general.php'; +/** + * Display JavaScript on the page. + * + * @package WordPress + * @subpackage Reading_Settings_Screen + */ +function add_js() { +?> + +' . __('This screen contains the settings that affect the display of your content.') . '

    ' . '

    ' . sprintf(__('You can choose what’s displayed on the front page of your site. It can be posts in reverse chronological order (classic blog), or a fixed/static page. To set a static home page, you first need to create two Pages. One will become the front page, and the other will be where your posts are displayed.'), 'post-new.php?post_type=page') . '

    ' . '

    ' . __('You can also control the display of your content in RSS feeds, including the maximum numbers of posts to display, whether to show full text or a summary, and the character set encoding.') . '

    ' . '

    ' . __('You must click the Save Changes button at the bottom of the screen for new settings to take effect.') . '

    ' . '

    ' . __('For more information:') . '

    ' . - '

    ' . __('Reading Settings Documentation') . '

    ' . + '

    ' . __('Documentation on Reading Settings') . '

    ' . '

    ' . __('Support Forums') . '

    ' ); @@ -38,7 +64,12 @@ include( './admin-header.php' ); - @@ -94,9 +125,7 @@ include( './admin-header.php' ); -

    - -

    + diff --git a/wp-admin/options-writing.php b/wp-admin/options-writing.php index dc06459d..a2c55dca 100644 --- a/wp-admin/options-writing.php +++ b/wp-admin/options-writing.php @@ -19,7 +19,7 @@ add_contextual_help($current_screen, '

    ' . __('You can submit content in several different ways; this screen holds the settings for all of them. The top section controls the editor within these administration screens, while the rest control external publishing methods. For more information on any of these methods, use the documentation links below.') . '

    ' . '

    ' . __('You must click the Save Changes button at the bottom of the screen for new settings to take effect.') . '

    ' . '

    ' . __('For more information:') . '

    ' . - '

    ' . __('Writing Settings Documentation') . '

    ' . + '

    ' . __('Documentation on Writing Settings') . '

    ' . '

    ' . __('Support Forums') . '

    ' ); @@ -56,6 +56,23 @@ wp_dropdown_categories(array('hide_empty' => 0, 'name' => 'default_category', 'o ?> + + + + + + @@ -209,7 +209,11 @@ foreach ( (array) $options as $option ) : endforeach; ?>
    + +
    @@ -137,7 +154,7 @@ wp_dropdown_categories(array('hide_empty' => 0, 'name' => 'default_email_categor

    - + @@ -148,9 +165,7 @@ wp_dropdown_categories(array('hide_empty' => 0, 'name' => 'default_email_categor -

    - -

    + diff --git a/wp-admin/options.php b/wp-admin/options.php index 15f489d3..d802057f 100644 --- a/wp-admin/options.php +++ b/wp-admin/options.php @@ -60,7 +60,7 @@ $whitelist_options = array( 'media' => array( 'thumbnail_size_w', 'thumbnail_size_h', 'thumbnail_crop', 'medium_size_w', 'medium_size_h', 'large_size_w', 'large_size_h', 'image_default_size', 'image_default_align', 'image_default_link_type', 'embed_autourls', 'embed_size_w', 'embed_size_h' ), 'privacy' => array( 'blog_public' ), 'reading' => array( 'posts_per_page', 'posts_per_rss', 'rss_use_excerpt', 'blog_charset', 'show_on_front', 'page_on_front', 'page_for_posts' ), - 'writing' => array( 'default_post_edit_rows', 'use_smilies', 'default_category', 'default_email_category', 'use_balanceTags', 'default_link_category', 'enable_app', 'enable_xmlrpc' ), + 'writing' => array( 'default_post_edit_rows', 'use_smilies', 'default_category', 'default_email_category', 'use_balanceTags', 'default_link_category', 'default_post_format', 'enable_app', 'enable_xmlrpc' ), 'options' => array( '' ) ); $mail_options = array('mailserver_url', 'mailserver_port', 'mailserver_login', 'mailserver_pass'); @@ -157,7 +157,7 @@ if ( 'update' == $action ) { /** * Redirect back to the settings page that was submitted */ - $goback = add_query_arg( 'updated', 'true', wp_get_referer() ); + $goback = add_query_arg( 'settings-updated', 'true', wp_get_referer() ); wp_redirect( $goback ); exit; } @@ -201,7 +201,7 @@ foreach ( (array) $options as $option ) :
    "; if ( strpos( $value, "\n" ) !== false ) - echo ""; + echo ""; else echo ""; echo "
    -

    + + + + + diff --git a/wp-admin/plugin-editor.php b/wp-admin/plugin-editor.php index 47437079..7efcecd3 100644 --- a/wp-admin/plugin-editor.php +++ b/wp-admin/plugin-editor.php @@ -9,6 +9,11 @@ /** WordPress Administration Bootstrap */ require_once('./admin.php'); +if ( is_multisite() && ! is_network_admin() ) { + wp_redirect( network_admin_url( 'plugin-editor.php' ) ); + exit(); +} + if ( !current_user_can('edit_plugins') ) wp_die( __('You do not have sufficient permissions to edit plugins for this site.') ); @@ -67,9 +72,9 @@ case 'update': wp_redirect(add_query_arg('_wpnonce', wp_create_nonce('edit-plugin-test_' . $file), "plugin-editor.php?file=$file&liveupdate=1&scrollto=$scrollto&networkwide=" . $network_wide)); exit; } - wp_redirect("plugin-editor.php?file=$file&a=te&scrollto=$scrollto"); + wp_redirect( self_admin_url("plugin-editor.php?file=$file&a=te&scrollto=$scrollto") ); } else { - wp_redirect("plugin-editor.php?file=$file&scrollto=$scrollto"); + wp_redirect( self_admin_url("plugin-editor.php?file=$file&scrollto=$scrollto") ); } exit; @@ -84,10 +89,10 @@ default: if ( is_wp_error($error) ) wp_die( $error ); - if ( ! is_plugin_active($file) ) + if ( ( ! empty( $_GET['networkwide'] ) && ! is_plugin_active_for_network($file) ) || ! is_plugin_active($file) ) activate_plugin($file, "plugin-editor.php?file=$file&phperror=1", ! empty( $_GET['networkwide'] ) ); // we'll override this later if the plugin can be included without fatal error - wp_redirect("plugin-editor.php?file=$file&a=te&scrollto=$scrollto"); + wp_redirect( self_admin_url("plugin-editor.php?file=$file&a=te&scrollto=$scrollto") ); exit; } @@ -111,13 +116,15 @@ default: '

    ' . __('You can use the editor to make changes to any of your plugins’ individual PHP files. Be aware that if you make changes, plugins updates will overwrite your customizations.') . '

    ' . '

    ' . __('Choose a plugin to edit from the menu in the upper right and click the Select button. Click once on any file name to load it in the editor, and make your changes. Don’t forget to save your changes (Update File) when you’re finished.') . '

    ' . '

    ' . __('The Documentation menu below the editor lists the PHP functions recognized in the plugin file. Clicking Lookup takes you to a web page about that particular function.') . '

    ' . - '

    ' . __('If you want to make changes but don’t want them to be overwritten when the plugin is updated, you may be ready to think about writing your own plugin. For information on how to edit a plugin or start from scratch, check out the links below.') . '

    ' . + '

    ' . __('If you want to make changes but don’t want them to be overwritten when the plugin is updated, you may be ready to think about writing your own plugin. For information on how to edit plugins, write your own from scratch, or just better understand their anatomy, check out the links below.') . '

    ' . + ( is_network_admin() ? '

    ' . __('Any edits to files from this screen will be reflected on all sites in the network.') . '

    ' : '' ) . '

    ' . __('For more information:') . '

    ' . '

    ' . __('Documentation on Editing Plugins') . '

    ' . + '

    ' . __('Documentation on Writing Plugins') . '

    ' . '

    ' . __('Support Forums') . '

    ' ); - require_once('./admin-header.php'); + require_once(ABSPATH . 'wp-admin/admin-header.php'); update_recently_edited(WP_PLUGIN_DIR . '/' . $file); @@ -136,7 +143,7 @@ default: } } - $content = htmlspecialchars( $content ); + $content = esc_textarea( $content ); ?>

    @@ -185,7 +192,7 @@ default: } ?> - +
    @@ -229,10 +236,12 @@ foreach ( $plugin_files as $plugin_file ) :

    "; - else - echo ""; + if ( isset($_GET['phperror']) ) { + echo ""; + submit_button( __( 'Update File and Attempt to Reactivate' ), 'primary', 'submit', false, array( 'tabindex' => '2' ) ); + } else { + submit_button( __( 'Update File' ), 'primary', 'submit', false, array( 'tabindex' => '2' ) ); + } ?>

    @@ -252,4 +261,4 @@ jQuery(document).ready(function($){ get_pagenum(); +$wp_list_table->prepare_items(); +$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); +if ( $pagenum > $total_pages && $total_pages > 0 ) { + wp_redirect( add_query_arg( 'paged', $total_pages ) ); + exit; +} $title = __('Install Plugins'); $parent_file = 'plugins.php'; -wp_reset_vars( array('tab', 'paged') ); - -//These are the tabs which are shown on the page, -$tabs = array(); -$tabs['dashboard'] = __('Search'); -if ( 'search' == $tab ) - $tabs['search'] = __('Search Results'); -$tabs['upload'] = __('Upload'); -$tabs['featured'] = _x('Featured','Plugin Installer'); -$tabs['popular'] = _x('Popular','Plugin Installer'); -$tabs['new'] = _x('Newest','Plugin Installer'); -$tabs['updated'] = _x('Recently Updated','Plugin Installer'); - -$nonmenu_tabs = array('plugin-information'); //Valid actions to perform which do not have a Menu item. - -$tabs = apply_filters('install_plugins_tabs', $tabs ); -$nonmenu_tabs = apply_filters('install_plugins_nonmenu_tabs', $nonmenu_tabs); - -//If a non-valid menu tab has been selected, And its not a non-menu action. -if ( empty($tab) || ( ! isset($tabs[ $tab ]) && ! in_array($tab, (array)$nonmenu_tabs) ) ) { - $tab_actions = array_keys($tabs); - $tab = $tab_actions[0]; -} -if ( empty($paged) ) - $paged = 1; - wp_enqueue_style( 'plugin-install' ); wp_enqueue_script( 'plugin-install' ); if ( 'plugin-information' != $tab ) @@ -62,25 +51,17 @@ add_contextual_help($current_screen, '

    ' . __('Support Forums') . '

    ' ); -include('./admin-header.php'); +include(ABSPATH . 'wp-admin/admin-header.php'); ?>

    -
      - $text ) { - $sep = ( end($tabs) != $text ) ? ' | ' : ''; - $class = ( $action == $tab ) ? ' class="current"' : ''; - $href = admin_url('plugin-install.php?tab=' . $action); - echo "\t\t
    • $text$sep
    • \n"; -} -?> -
    -
    - +views(); ?> + +
    +
    get_pagenum(); -$default_status = get_user_option('plugins_last_view'); -if ( empty($default_status) ) - $default_status = 'all'; -$status = isset($_REQUEST['plugin_status']) ? $_REQUEST['plugin_status'] : $default_status; -if ( !in_array($status, array('all', 'active', 'inactive', 'recent', 'upgrade', 'network', 'mustuse', 'dropins', 'search')) ) - $status = 'all'; -if ( $status != $default_status && 'search' != $status ) - update_user_meta($current_user->ID, 'plugins_last_view', $status); +$action = $wp_list_table->current_action(); -$page = isset($_REQUEST['paged']) ? $_REQUEST['paged'] : 1; +$plugin = isset($_REQUEST['plugin']) ? $_REQUEST['plugin'] : ''; +$s = isset($_REQUEST['s']) ? $_REQUEST['s'] : ''; -//Clean up request URI from temporary args for screen options/paging uri's to work as expected. +// Clean up request URI from temporary args for screen options/paging uri's to work as expected. $_SERVER['REQUEST_URI'] = remove_query_arg(array('error', 'deleted', 'activate', 'activate-multi', 'deactivate', 'deactivate-multi', '_error_nonce'), $_SERVER['REQUEST_URI']); -if ( !empty($action) ) { +if ( $action ) { $network_wide = false; if ( ( isset( $_GET['networkwide'] ) || 'network-activate-selected' == $action ) && is_multisite() && current_user_can( 'manage_network_plugins' ) ) $network_wide = true; @@ -57,10 +42,10 @@ if ( !empty($action) ) { check_admin_referer('activate-plugin_' . $plugin); - $result = activate_plugin($plugin, 'plugins.php?error=true&plugin=' . $plugin, $network_wide); + $result = activate_plugin($plugin, self_admin_url('plugins.php?error=true&plugin=' . $plugin), $network_wide); if ( is_wp_error( $result ) ) { if ( 'unexpected_output' == $result->get_error_code() ) { - $redirect = 'plugins.php?error=true&charsout=' . strlen($result->get_error_data()) . '&plugin=' . $plugin; + $redirect = self_admin_url('plugins.php?error=true&charsout=' . strlen($result->get_error_data()) . '&plugin=' . $plugin . "&plugin_status=$status&paged=$page&s=$s"); wp_redirect(add_query_arg('_error_nonce', wp_create_nonce('plugin-activation-error_' . $plugin), $redirect)); exit; } else { @@ -74,9 +59,9 @@ if ( !empty($action) ) { update_option('recently_activated', $recent); } if ( isset($_GET['from']) && 'import' == $_GET['from'] ) { - wp_redirect("import.php?import=" . str_replace('-importer', '', dirname($plugin)) ); // overrides the ?error=true one above and redirects to the Imports page, striping the -importer suffix + wp_redirect( self_admin_url("import.php?import=" . str_replace('-importer', '', dirname($plugin))) ); // overrides the ?error=true one above and redirects to the Imports page, striping the -importer suffix } else { - wp_redirect("plugins.php?activate=true&plugin_status=$status&paged=$page"); // overrides the ?error=true one above + wp_redirect( self_admin_url("plugins.php?activate=true&plugin_status=$status&paged=$page&s=$s") ); // overrides the ?error=true one above } exit; break; @@ -85,16 +70,22 @@ if ( !empty($action) ) { if ( ! current_user_can('activate_plugins') ) wp_die(__('You do not have sufficient permissions to activate plugins for this site.')); - check_admin_referer('bulk-manage-plugins'); + check_admin_referer('bulk-plugins'); $plugins = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array(); - $plugins = array_filter($plugins, create_function('$plugin', 'return !is_plugin_active($plugin);') ); // Only activate plugins which are not already active. + + // Only activate plugins which are not already active. + $check = $network_wide ? 'is_plugin_active_for_network' : 'is_plugin_active'; + foreach ( $plugins as $i => $plugin ) + if ( $check( $plugin ) ) + unset( $plugins[ $i ] ); + if ( empty($plugins) ) { - wp_redirect("plugins.php?plugin_status=$status&paged=$page"); + wp_redirect( self_admin_url("plugins.php?plugin_status=$status&paged=$page&s=$s") ); exit; } - activate_plugins($plugins, 'plugins.php?error=true', $network_wide); + activate_plugins($plugins, self_admin_url('plugins.php?error=true'), $network_wide); $recent = (array)get_option('recently_activated'); foreach ( $plugins as $plugin => $time) @@ -103,12 +94,12 @@ if ( !empty($action) ) { update_option('recently_activated', $recent); - wp_redirect("plugins.php?activate-multi=true&plugin_status=$status&paged=$page"); + wp_redirect( self_admin_url("plugins.php?activate-multi=true&plugin_status=$status&paged=$page&s=$s") ); exit; break; case 'update-selected' : - check_admin_referer( 'bulk-manage-plugins' ); + check_admin_referer( 'bulk-plugins' ); if ( isset( $_GET['plugins'] ) ) $plugins = explode( ',', $_GET['plugins'] ); @@ -117,22 +108,22 @@ if ( !empty($action) ) { else $plugins = array(); - $title = __( 'Upgrade Plugins' ); + $title = __( 'Update Plugins' ); $parent_file = 'plugins.php'; - require_once( './admin-header.php' ); + require_once(ABSPATH . 'wp-admin/admin-header.php'); echo '
    '; screen_icon(); echo '

    ' . esc_html( $title ) . '

    '; - $url = 'update.php?action=update-selected&plugins=' . urlencode( join(',', $plugins) ); + $url = self_admin_url('update.php?action=update-selected&plugins=' . urlencode( join(',', $plugins) )); $url = wp_nonce_url($url, 'bulk-update-plugins'); echo ""; echo '
    '; - require_once( './admin-footer.php' ); + require_once(ABSPATH . 'wp-admin/admin-footer.php'); exit; break; case 'error_scrape': @@ -168,22 +159,22 @@ if ( !empty($action) ) { check_admin_referer('deactivate-plugin_' . $plugin); deactivate_plugins($plugin); update_option('recently_activated', array($plugin => time()) + (array)get_option('recently_activated')); - if (headers_sent()) - echo ""; + if ( headers_sent() ) + echo ""; else - wp_redirect("plugins.php?deactivate=true&plugin_status=$status&paged=$page"); + wp_redirect( self_admin_url("plugins.php?deactivate=true&plugin_status=$status&paged=$page&s=$s") ); exit; break; case 'deactivate-selected': if ( ! current_user_can('activate_plugins') ) wp_die(__('You do not have sufficient permissions to deactivate plugins for this site.')); - check_admin_referer('bulk-manage-plugins'); + check_admin_referer('bulk-plugins'); $plugins = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array(); $plugins = array_filter($plugins, 'is_plugin_active'); //Do not deactivate plugins which are already deactivated. if ( empty($plugins) ) { - wp_redirect("plugins.php?plugin_status=$status&paged=$page"); + wp_redirect( self_admin_url("plugins.php?plugin_status=$status&paged=$page&s=$s") ); exit; } @@ -194,20 +185,25 @@ if ( !empty($action) ) { $deactivated[ $plugin ] = time(); update_option('recently_activated', $deactivated + (array)get_option('recently_activated')); - wp_redirect("plugins.php?deactivate-multi=true&plugin_status=$status&paged=$page"); + wp_redirect( self_admin_url("plugins.php?deactivate-multi=true&plugin_status=$status&paged=$page&s=$s") ); exit; break; case 'delete-selected': if ( ! current_user_can('delete_plugins') ) wp_die(__('You do not have sufficient permissions to delete plugins for this site.')); - check_admin_referer('bulk-manage-plugins'); + check_admin_referer('bulk-plugins'); //$_POST = from the plugin form; $_GET = from the FTP details screen. $plugins = isset( $_REQUEST['checked'] ) ? (array) $_REQUEST['checked'] : array(); - $plugins = array_filter($plugins, create_function('$plugin', 'return !is_plugin_active($plugin);') ); //Do not allow to delete Activated plugins. - if ( empty($plugins) ) { - wp_redirect("plugins.php?plugin_status=$status&paged=$page"); + if ( empty( $plugins ) ) { + wp_redirect( self_admin_url("plugins.php?plugin_status=$status&paged=$page&s=$s") ); + exit; + } + + $plugins = array_filter($plugins, 'is_plugin_inactive'); // Do not allow to delete Activated plugins. + if ( empty( $plugins ) ) { + wp_redirect( self_admin_url( "plugins.php?error=true&main=true&plugin_status=$status&paged=$page&s=$s" ) ); exit; } @@ -217,17 +213,20 @@ if ( !empty($action) ) { if ( ! isset($_REQUEST['verify-delete']) ) { wp_enqueue_script('jquery'); - require_once('./admin-header.php'); + require_once(ABSPATH . 'wp-admin/admin-header.php'); ?>
    $data ) { - $plugin_info[ $plugin_file ] = $data; + $plugin_info[ $plugin_file ] = _get_plugin_data_markup_translate( $plugin_file, $data ); $plugin_info[ $plugin_file ]['is_uninstallable'] = is_uninstallable_plugin( $plugin ); + if ( ! $plugin_info[ $plugin_file ]['Network'] ) + $have_non_network_plugins = true; } } } @@ -248,6 +249,9 @@ if ( !empty($action) ) { $plugins_to_delete = count( $plugin_info ); echo '

    ' . _n( 'Delete Plugin', 'Delete Plugins', $plugins_to_delete ) . '

    '; ?> + +

    +

      ', sprintf( __( '%1$s by %2$s (will also delete its data)' ), esc_html($plugin['Name']), esc_html($plugin['Author']) ), ''; + echo '
    • ', sprintf( __( '%1$s by %2$s (will also delete its data)' ), esc_html($plugin['Name']), esc_html($plugin['AuthorName']) ), '
    • '; $data_to_delete = true; } else { /* translators: 1: plugin name, 2: plugin author */ - echo '
    • ', sprintf( __('%1$s by %2$s' ), esc_html($plugin['Name']), esc_html($plugin['Author']) ), '
    • '; + echo '
    • ', sprintf( __('%1$s by %2$s' ), esc_html($plugin['Name']), esc_html($plugin['AuthorName']) ), '
    • '; } } ?> @@ -274,14 +278,14 @@ if ( !empty($action) ) { '; ?> - - + +
      - +

      @@ -295,13 +299,13 @@ if ( !empty($action) ) {
    prepare_items(); + +$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); +if ( $pagenum > $total_pages && $total_pages > 0 ) { + wp_redirect( add_query_arg( 'paged', $total_pages ) ); + exit; +} + wp_enqueue_script('plugin-install'); add_thickbox(); +add_screen_option( 'per_page', array('label' => _x( 'Plugins', 'plugins per page (screen options)' )) ); + add_contextual_help($current_screen, '

    ' . __('Plugins extend and expand the functionality of WordPress. Once a plugin is installed, you may activate it or deactivate it here.') . '

    ' . '

    ' . sprintf(__('You can find additional plugins for your site by using the Plugin Browser/Installer functionality or by browsing the WordPress Plugin Directory directly and installing new plugins manually. To manually install a plugin you generally just need to upload the plugin file into your /wp-content/plugins directory. Once a plugin has been installed, you can activate it here.'), 'plugin-install.php', 'http://wordpress.org/extend/plugins/') . '

    ' . @@ -324,8 +338,9 @@ add_contextual_help($current_screen, ); $title = __('Plugins'); +$parent_file = 'plugins.php'; -require_once('./admin-header.php'); +require_once(ABSPATH . 'wp-admin/admin-header.php'); $invalid = validate_active_plugins(); if ( !empty($invalid) ) @@ -335,15 +350,17 @@ if ( !empty($invalid) ) unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.'), $_GET['charsout']); else $errmsg = __('Plugin could not be activated because it triggered a fatal error.'); ?>

    - + if ( !isset( $_GET['main'] ) && !isset($_GET['charsout']) && wp_verify_nonce($_GET['_error_nonce'], 'plugin-activation-error_' . $plugin) ) { ?> + @@ -371,415 +388,36 @@ if ( !empty($invalid) )
    -

    - - + +' . __('Search results for “%s”') . '', esc_html( $s ) ); ?> + -$all_plugins = apply_filters( 'all_plugins', get_plugins() ); -$search_plugins = array(); -$active_plugins = array(); -$inactive_plugins = array(); -$recent_plugins = array(); -$recently_activated = get_option('recently_activated', array()); -$upgrade_plugins = array(); -$network_plugins = array(); -$mustuse_plugins = $dropins_plugins = array(); -if ( ! is_multisite() || current_user_can('manage_network_plugins') ) { - if ( apply_filters( 'show_advanced_plugins', true, 'mustuse' ) ) - $mustuse_plugins = get_mu_plugins(); - if ( apply_filters( 'show_advanced_plugins', true, 'dropins' ) ) - $dropins_plugins = get_dropins(); -} + -set_transient( 'plugin_slugs', array_keys($all_plugins), 86400 ); - -// Clean out any plugins which were deactivated over a week ago. -foreach ( $recently_activated as $key => $time ) - if ( $time + (7*24*60*60) < time() ) //1 week - unset($recently_activated[ $key ]); -if ( $recently_activated != get_option('recently_activated') ) //If array changed, update it. - update_option('recently_activated', $recently_activated); -$current = get_site_transient( 'update_plugins' ); - -foreach ( array( 'all_plugins', 'mustuse_plugins', 'dropins_plugins' ) as $plugin_array_name) { - foreach ( (array) $$plugin_array_name as $plugin_file => $plugin_data ) { - // Translate, Apply Markup, Sanitize HTML - $plugin_data = _get_plugin_data_markup_translate($plugin_file, $plugin_data, false, true); - ${$plugin_array_name}[ $plugin_file ] = $plugin_data; - } -} -unset( $plugin_array_name ); - -foreach ( (array) $all_plugins as $plugin_file => $plugin_data) { - // Filter into individual sections - if ( is_multisite() && is_network_only_plugin( $plugin_file ) && !current_user_can( 'manage_network_plugins' ) ) { - unset( $all_plugins[ $plugin_file ] ); - continue; - } elseif ( is_plugin_active_for_network($plugin_file) ) { - $network_plugins[ $plugin_file ] = $plugin_data; - } elseif ( is_plugin_active($plugin_file) ) { - $active_plugins[ $plugin_file ] = $plugin_data; - } else { - if ( isset( $recently_activated[ $plugin_file ] ) ) // Was the plugin recently activated? - $recent_plugins[ $plugin_file ] = $plugin_data; - $inactive_plugins[ $plugin_file ] = $plugin_data; - } +views(); ?> - if ( isset( $current->response[ $plugin_file ] ) ) - $upgrade_plugins[ $plugin_file ] = $plugin_data; -} +
    -if ( !current_user_can('update_plugins') ) - $upgrade_plugins = array(); - -$total_all_plugins = count($all_plugins); -$total_inactive_plugins = count($inactive_plugins); -$total_active_plugins = count($active_plugins); -$total_recent_plugins = count($recent_plugins); -$total_upgrade_plugins = count($upgrade_plugins); -$total_network_plugins = count($network_plugins); -$total_mustuse_plugins = count($mustuse_plugins); -$total_dropins_plugins = count($dropins_plugins); - -// Searching. -if ( !empty($_GET['s']) ) { - function _search_plugins_filter_callback($plugin) { - static $term; - if ( is_null($term) ) - $term = stripslashes($_GET['s']); - if ( stripos($plugin['Name'], $term) !== false || - stripos($plugin['Description'], $term) !== false || - stripos($plugin['Author'], $term) !== false || - stripos($plugin['PluginURI'], $term) !== false || - stripos($plugin['AuthorURI'], $term) !== false || - stripos($plugin['Version'], $term) !== false ) - return true; - else - return false; - } - $status = 'search'; - $search_plugins = array_filter($all_plugins, '_search_plugins_filter_callback'); - $total_search_plugins = count($search_plugins); -} +search_box( __( 'Search Plugins' ), 'plugin' ); ?> -$plugin_array_name = "${status}_plugins"; -if ( empty($$plugin_array_name) && !in_array($status, array('all', 'search')) ) { - $status = 'all'; - $plugin_array_name = "${status}_plugins"; -} - -$plugins = &$$plugin_array_name; - -// Paging. -$total_this_page = "total_{$status}_plugins"; -$total_this_page = $$total_this_page; -$plugins_per_page = (int) get_user_option( 'plugins_per_page' ); -if ( empty( $plugins_per_page ) || $plugins_per_page < 1 ) - $plugins_per_page = 999; -$plugins_per_page = apply_filters( 'plugins_per_page', $plugins_per_page ); - -$start = ($page - 1) * $plugins_per_page; - -$page_links = paginate_links( array( - 'base' => add_query_arg( 'paged', '%#%' ), - 'format' => '', - 'prev_text' => __('«'), - 'next_text' => __('»'), - 'total' => ceil($total_this_page / $plugins_per_page), - 'current' => $page -)); -$page_links_text = sprintf( '' . __( 'Displaying %s–%s of %s' ) . '%s', - number_format_i18n( $start + 1 ), - number_format_i18n( min( $page * $plugins_per_page, $total_this_page ) ), - '' . number_format_i18n( $total_this_page ) . '', - $page_links -); - -/** - * @ignore - * - * @param array $plugins - * @param string $context - */ -function print_plugins_table($plugins, $context = '') { - global $page; - $checkbox = ! in_array( $context, array( 'mustuse', 'dropins' ) ) ? '' : ''; -?> - - - - - - - - - - - - - - - - - - - - - '; - } - foreach ( (array)$plugins as $plugin_file => $plugin_data) { - // preorder - $actions = array( - 'network_deactivate' => '', 'deactivate' => '', - 'network_only' => '', 'activate' => '', - 'network_activate' => '', - 'edit' => '', - 'delete' => '', - ); - - if ( 'mustuse' == $context ) { - $is_active = true; - } elseif ( 'dropins' == $context ) { - $dropins = _get_dropins(); - $plugin_name = $plugin_file; - if ( $plugin_file != $plugin_data['Name'] ) - $plugin_name .= '
    ' . $plugin_data['Name']; - if ( true === ( $dropins[ $plugin_file ][1] ) ) { // Doesn't require a constant - $is_active = true; - $description = '

    ' . $dropins[ $plugin_file ][0] . '

    '; - } elseif ( constant( $dropins[ $plugin_file ][1] ) ) { // Constant is true - $is_active = true; - $description = '

    ' . $dropins[ $plugin_file ][0] . '

    '; - } else { - $is_active = false; - $description = '

    ' . $dropins[ $plugin_file ][0] . ' ' . __('Inactive:') . ' ' . sprintf( __( 'Requires %s in wp-config.php.' ), "define('" . $dropins[ $plugin_file ][1] . "', true);" ) . '

    '; - } - if ( $plugin_data['Description'] ) - $description .= '

    ' . $plugin_data['Description'] . '

    '; - } else { - $is_active_for_network = is_plugin_active_for_network($plugin_file); - $is_active = $is_active_for_network || is_plugin_active( $plugin_file ); - if ( $is_active_for_network && !is_super_admin() ) - continue; - - if ( $is_active ) { - if ( $is_active_for_network ) { - if ( is_super_admin() ) - $actions['network_deactivate'] = '' . __('Network Deactivate') . ''; - } else { - $actions['deactivate'] = '' . __('Deactivate') . ''; - } - } else { - if ( is_multisite() && is_network_only_plugin( $plugin_file ) ) - $actions['network_only'] = '' . __('Network Only') . ''; - else - $actions['activate'] = '' . __('Activate') . ''; - - if ( is_multisite() && current_user_can( 'manage_network_plugins' ) ) - $actions['network_activate'] = '' . __('Network Activate') . ''; - - if ( current_user_can('delete_plugins') ) - $actions['delete'] = '' . __('Delete') . ''; - } // end if $is_active - - if ( current_user_can('edit_plugins') && is_writable(WP_PLUGIN_DIR . '/' . $plugin_file) ) - $actions['edit'] = '' . __('Edit') . ''; - } // end if $context - - $actions = apply_filters( 'plugin_action_links', array_filter( $actions ), $plugin_file, $plugin_data, $context ); - $actions = apply_filters( "plugin_action_links_$plugin_file", $actions, $plugin_file, $plugin_data, $context ); - - $class = $is_active ? 'active' : 'inactive'; - $checkbox = in_array( $context, array( 'mustuse', 'dropins' ) ) ? '' : ""; - if ( 'dropins' != $context ) { - $description = '

    ' . $plugin_data['Description'] . '

    '; - $plugin_name = $plugin_data['Name']; - } - echo " - - - - - - - - - - \n"; - - do_action( 'after_plugin_row', $plugin_file, $plugin_data, $context ); - do_action( "after_plugin_row_$plugin_file", $plugin_file, $plugin_data, $context ); - } -?> - -
    ' . __('No plugins to show') . '
    $checkbox$plugin_name$description
    "; - echo '
    '; - foreach ( $actions as $action => $link ) { - $sep = end($actions) == $link ? '' : ' | '; - echo "$link$sep"; - } - echo "
    "; - $plugin_meta = array(); - if ( !empty($plugin_data['Version']) ) - $plugin_meta[] = sprintf(__('Version %s'), $plugin_data['Version']); - if ( !empty($plugin_data['Author']) ) { - $author = $plugin_data['Author']; - if ( !empty($plugin_data['AuthorURI']) ) - $author = '' . $plugin_data['Author'] . ''; - $plugin_meta[] = sprintf( __('By %s'), $author ); - } - if ( ! empty($plugin_data['PluginURI']) ) - $plugin_meta[] = '' . __('Visit plugin site') . ''; - - $plugin_meta = apply_filters('plugin_row_meta', $plugin_meta, $plugin_file, $plugin_data, $context); - echo implode(' | ', $plugin_meta); - echo "
    - -
    - - - - - -
    - - - - -
    - - - -
    - - -

    ' . __( 'Files in the /wp-content/mu-plugins directory are executed automatically.' ) . '

    '; + echo '

    ' . __( 'Files in the /wp-content/mu-plugins directory are executed automatically.' ) . '

    '; elseif ( 'dropins' == $status ) - echo '

    ' . __( 'Drop-ins are advanced plugins in the /wp-content directory that replace WordPress functionality when present.' ) . '

    '; - -if ( !empty( $plugins ) && ( ! in_array( $status, array( 'mustuse', 'dropins' ) ) || $page_links ) ) : + echo '

    ' . __( 'Drop-ins are advanced plugins in the /wp-content directory that replace WordPress functionality when present.' ) . '

    '; ?> -
    -', $page_links_text, '
    '; -print_plugin_actions($status); -?> -
    -
    - $plugins_per_page ) - $plugins = array_slice($plugins, $start, $plugins_per_page); - -print_plugins_table($plugins, $status); - -if ( !empty( $plugins ) && ! in_array( $status, array( 'mustuse', 'dropins' ) ) || $page_links ) { -?> -
    -$page_links_text
    "; - -print_plugin_actions($status, "action2"); -?> - - +display(); ?> - -
    -

    - - +include(ABSPATH . 'wp-admin/admin-footer.php'); diff --git a/wp-admin/post-new.php b/wp-admin/post-new.php index 93c4ffbc..ed123a46 100644 --- a/wp-admin/post-new.php +++ b/wp-admin/post-new.php @@ -30,27 +30,14 @@ $title = $post_type_object->labels->add_new_item; $editing = true; -if ( 'post' == $post_type && !current_user_can('edit_posts') ) { - include('./admin-header.php'); ?> -
    -

    edit_posts capability to your user, in order to be authorized to post.
    -You can also e-mail the admin to ask for a promotion.
    -When you’re promoted, just reload this page and you’ll be able to blog. :)'), get_option('admin_email')); ?> -

    -
    -cap->edit_posts ) ) + wp_die( __( 'Cheatin’ uh?' ) ); wp_enqueue_script('autosave'); // Show post form. -if ( current_user_can($post_type_object->cap->edit_posts) ) { - $post = get_default_post_to_edit( $post_type, true ); - $post_ID = $post->ID; - include('edit-form-advanced.php'); -} - +$post = get_default_post_to_edit( $post_type, true ); +$post_ID = $post->ID; +include('edit-form-advanced.php'); include('./admin-footer.php'); -?> \ No newline at end of file +?> diff --git a/wp-admin/post.php b/wp-admin/post.php index 548007f7..0dae46dd 100644 --- a/wp-admin/post.php +++ b/wp-admin/post.php @@ -51,12 +51,7 @@ if ( $post_id ) { * @param int $post_id Optional. Post ID. */ function redirect_post($post_id = '') { - if ( !empty($_POST['mode']) && 'sidebar' == $_POST['mode'] ) { - if ( isset($_POST['saveasdraft']) ) - $location = 'sidebar.php?a=c'; - elseif ( isset($_POST['publish']) ) - $location = 'sidebar.php?a=b'; - } elseif ( isset($_POST['save']) || isset($_POST['publish']) ) { + if ( isset($_POST['save']) || isset($_POST['publish']) ) { $status = get_post_status( $post_id ); if ( isset( $_POST['publish'] ) ) { @@ -90,6 +85,7 @@ function redirect_post($post_id = '') { } wp_redirect( apply_filters( 'redirect_post_location', $location, $post_id ) ); + exit; } if ( isset( $_POST['deletepost'] ) ) @@ -143,7 +139,7 @@ case 'edit': $editing = true; if ( empty( $post_id ) ) { - wp_redirect("post.php"); + wp_redirect( admin_url('post.php') ); exit(); } @@ -166,7 +162,10 @@ case 'edit': $parent_file = "edit.php"; $submenu_file = "edit.php"; } else { - $parent_file = "edit.php?post_type=$post_type"; + if ( isset( $post_type_object ) && $post_type_object->show_in_menu && $post_type_object->show_in_menu !== true ) + $parent_file = $post_type_object->show_in_menu; + else + $parent_file = "edit.php?post_type=$post_type"; $submenu_file = "edit.php?post_type=$post_type"; } @@ -270,7 +269,7 @@ case 'preview': break; default: - wp_redirect('edit.php'); + wp_redirect( admin_url('edit.php') ); exit(); break; } // end switch diff --git a/wp-admin/press-this.php b/wp-admin/press-this.php index 04f8d0f5..aa4eb47f 100644 --- a/wp-admin/press-this.php +++ b/wp-admin/press-this.php @@ -6,8 +6,11 @@ * @subpackage Press_This */ +define('IFRAME_REQUEST' , true); + /** WordPress Administration Bootstrap */ require_once('./admin.php'); + header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset')); if ( ! current_user_can('edit_posts') ) @@ -24,6 +27,7 @@ if ( ! current_user_can('edit_posts') ) */ function press_it() { // define some basic variables + $quick = array(); $quick['post_status'] = 'draft'; // set as draft first $quick['post_category'] = isset($_POST['post_category']) ? $_POST['post_category'] : null; $quick['tax_input'] = isset($_POST['tax_input']) ? $_POST['tax_input'] : null; @@ -52,18 +56,25 @@ function press_it() { } } // set the post_content and status - if ( isset( $_POST['publish'] ) && current_user_can( 'publish_posts' ) ) - $quick['post_status'] = 'publish'; - elseif ( isset( $_POST['review'] ) ) - $quick['post_status'] = 'pending'; - else - $quick['post_status'] = 'draft'; + $quick['post_status'] = isset($_POST['publish']) ? 'publish' : 'draft'; $quick['post_content'] = $content; // error handling for media_sideload if ( is_wp_error($upload) ) { wp_delete_post($post_ID); wp_die($upload); } else { + // Post formats + if ( current_theme_supports( 'post-formats' ) && isset( $_POST['post_format'] ) ) { + $post_formats = get_theme_support( 'post-formats' ); + if ( is_array( $post_formats ) ) { + $post_formats = $post_formats[0]; + if ( in_array( $_POST['post_format'], $post_formats ) ) + set_post_format( $post_ID, $_POST['post_format'] ); + elseif ( '0' == $_POST['post_format'] ) + set_post_format( $post_ID, false ); + } + } + $quick['ID'] = $post_ID; wp_update_post($quick); } @@ -115,7 +126,7 @@ if ( !empty($_REQUEST['ajax']) ) {

    - +

    @@ -322,7 +333,7 @@ die; //','uid':'ID; ?>','time':''}; -var ajaxurl = '', pagenow = 'press-this'; +var ajaxurl = '', pagenow = 'press-this', isRtl = ; var photostorage = false; //]]> @@ -332,8 +343,10 @@ var photostorage = false; do_action('admin_print_scripts'); do_action('admin_head'); - if ( user_can_richedit() ) + if ( user_can_richedit() ) { wp_tiny_mce( true, array( 'height' => '370' ) ); + add_action( 'admin_print_footer_scripts', 'wp_tiny_mce_preload_dialogs', 30 ); + } ?> diff --git a/wp-admin/user-new.php b/wp-admin/user-new.php index 12da9e19..b9d87256 100644 --- a/wp-admin/user-new.php +++ b/wp-admin/user-new.php @@ -9,25 +9,24 @@ /** WordPress Administration Bootstrap */ require_once('./admin.php'); -if ( !current_user_can('create_users') ) - wp_die(__('Cheatin’ uh?')); - -if ( is_multisite() && !get_site_option( 'add_new_users' ) ) - wp_die( __('Page disabled by the administrator') ); - -/** WordPress Registration API */ -require_once( ABSPATH . WPINC . '/registration.php'); +if ( is_multisite() ) { + if ( ! current_user_can( 'create_users' ) && ! current_user_can( 'promote_users' ) ) + wp_die( __( 'Cheatin’ uh?' ) ); +} elseif ( ! current_user_can( 'create_users' ) ) { + wp_die( __( 'Cheatin’ uh?' ) ); +} if ( is_multisite() ) { function admin_created_user_email( $text ) { - return sprintf( __( "Hi, -You've been invited to join '%s' at -%s as a %s. + /* translators: 1: Site name, 2: site URL, 3: role */ + return sprintf( __( 'Hi, +You\'ve been invited to join \'%1$s\' at +%2$s as a %3$s. If you do not want to join this site please ignore this email. This invitation will expire in a few days. Please click the following link to activate your user account: -%%s" ), get_bloginfo('name'), site_url(), esc_html( $_REQUEST[ 'role' ] ) ); +%%s' ), get_bloginfo('name'), site_url(), esc_html( $_REQUEST[ 'role' ] ) ); } add_filter( 'wpmu_signup_user_notification_email', 'admin_created_user_email' ); @@ -37,7 +36,54 @@ Please click the following link to activate your user account: } if ( isset($_REQUEST['action']) && 'adduser' == $_REQUEST['action'] ) { - check_admin_referer('add-user'); + check_admin_referer( 'add-user', '_wpnonce_add-user' ); + + $user_details = null; + if ( false !== strpos($_REQUEST[ 'email' ], '@') ) { + $user_details = get_user_by('email', $_REQUEST[ 'email' ]); + } else { + if ( is_super_admin() ) { + $user_details = get_user_by('login', $_REQUEST[ 'email' ]); + } else { + wp_redirect( add_query_arg( array('update' => 'enter_email'), 'user-new.php' ) ); + die(); + } + } + + if ( !$user_details ) { + wp_redirect( add_query_arg( array('update' => 'does_not_exist'), 'user-new.php' ) ); + die(); + } + + if ( ! current_user_can('promote_user', $user_details->ID) ) + wp_die(__('Cheatin’ uh?')); + + // Adding an existing user to this blog + $new_user_email = esc_html(trim($_REQUEST['email'])); + $redirect = 'user-new.php'; + $username = $user_details->user_login; + $user_id = $user_details->ID; + if ( ( $username != null && !is_super_admin( $user_id ) ) && ( array_key_exists($blog_id, get_blogs_of_user($user_id)) ) ) { + $redirect = add_query_arg( array('update' => 'addexisting'), 'user-new.php' ); + } else { + if ( isset( $_POST[ 'noconfirmation' ] ) && is_super_admin() ) { + add_existing_user_to_blog( array( 'user_id' => $user_id, 'role' => $_REQUEST[ 'role' ] ) ); + $redirect = add_query_arg( array('update' => 'addnoconfirmation'), 'user-new.php' ); + } else { + $newuser_key = substr( md5( $user_id ), 0, 5 ); + add_option( 'new_user_' . $newuser_key, array( 'user_id' => $user_id, 'email' => $user_details->user_email, 'role' => $_REQUEST[ 'role' ] ) ); + $message = __("Hi,\n\nYou have been invited to join '%s' at\n%s as a %s.\nPlease click the following link to confirm the invite:\n%s\n"); + wp_mail( $new_user_email, sprintf( __( '[%s] Joining confirmation' ), get_option( 'blogname' ) ), sprintf($message, get_option('blogname'), site_url(), $_REQUEST[ 'role' ], site_url("/newbloguser/$newuser_key/"))); + $redirect = add_query_arg( array('update' => 'add'), 'user-new.php' ); + } + } + wp_redirect( $redirect ); + die(); +} elseif ( isset($_REQUEST['action']) && 'createuser' == $_REQUEST['action'] ) { + check_admin_referer( 'create-user', '_wpnonce_create-user' ); + + if ( ! current_user_can('create_users') ) + wp_die(__('Cheatin’ uh?')); if ( !is_multisite() ) { $user_id = add_user(); @@ -55,59 +101,38 @@ if ( isset($_REQUEST['action']) && 'adduser' == $_REQUEST['action'] ) { die(); } } else { - $user_login = preg_replace( "/\s+/", '', sanitize_user( $_REQUEST[ 'user_login' ], true ) ); - $user_details = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->users} WHERE user_login = %s AND user_email = %s", $user_login, $_REQUEST[ 'email' ] ) ); - if ( $user_details ) { - // Adding an existing user to this blog - $new_user_email = esc_html(trim($_REQUEST['email'])); - $redirect = 'user-new.php'; - $username = $user_details->user_login; - $user_id = $user_details->ID; - if ( ( $username != null && !is_super_admin( $user_id ) ) && ( array_key_exists($blog_id, get_blogs_of_user($user_id)) ) ) { - $redirect = add_query_arg( array('update' => 'addexisting'), 'user-new.php' ); + // Adding a new user to this blog + $user_details = wpmu_validate_user_signup( $_REQUEST[ 'user_login' ], $_REQUEST[ 'email' ] ); + unset( $user_details[ 'errors' ]->errors[ 'user_email_used' ] ); + if ( is_wp_error( $user_details[ 'errors' ] ) && !empty( $user_details[ 'errors' ]->errors ) ) { + $add_user_errors = $user_details[ 'errors' ]; + } else { + $new_user_login = apply_filters('pre_user_login', sanitize_user(stripslashes($_REQUEST['user_login']), true)); + if ( isset( $_POST[ 'noconfirmation' ] ) && is_super_admin() ) { + add_filter( 'wpmu_signup_user_notification', '__return_false' ); // Disable confirmation email + } + wpmu_signup_user( $new_user_login, $_REQUEST[ 'email' ], array( 'add_to_blog' => $wpdb->blogid, 'new_role' => $_REQUEST[ 'role' ] ) ); + if ( isset( $_POST[ 'noconfirmation' ] ) && is_super_admin() ) { + $key = $wpdb->get_var( $wpdb->prepare( "SELECT activation_key FROM {$wpdb->signups} WHERE user_login = %s AND user_email = %s", $new_user_login, $_REQUEST[ 'email' ] ) ); + wpmu_activate_signup( $key ); + $redirect = add_query_arg( array('update' => 'addnoconfirmation'), 'user-new.php' ); } else { - if ( isset( $_POST[ 'noconfirmation' ] ) && is_super_admin() ) { - add_existing_user_to_blog( array( 'user_id' => $user_id, 'role' => $_REQUEST[ 'role' ] ) ); - $redirect = add_query_arg( array('update' => 'addnoconfirmation'), 'user-new.php' ); - } else { - $newuser_key = substr( md5( $user_id ), 0, 5 ); - add_option( 'new_user_' . $newuser_key, array( 'user_id' => $user_id, 'email' => $user_details->user_email, 'role' => $_REQUEST[ 'role' ] ) ); - $message = __("Hi,\n\nYou have been invited to join '%s' at\n%s as a %s.\nPlease click the following link to confirm the invite:\n%s\n"); - wp_mail( $new_user_email, sprintf( __( '[%s] Joining confirmation' ), get_option( 'blogname' ) ), sprintf($message, get_option('blogname'), site_url(), $_REQUEST[ 'role' ], site_url("/newbloguser/$newuser_key/"))); - $redirect = add_query_arg( array('update' => 'add'), 'user-new.php' ); - } + $redirect = add_query_arg( array('update' => 'newuserconfimation'), 'user-new.php' ); } wp_redirect( $redirect ); die(); - } else { - // Adding a new user to this blog - $user_details = wpmu_validate_user_signup( $_REQUEST[ 'user_login' ], $_REQUEST[ 'email' ] ); - unset( $user_details[ 'errors' ]->errors[ 'user_email_used' ] ); - if ( is_wp_error( $user_details[ 'errors' ] ) && !empty( $user_details[ 'errors' ]->errors ) ) { - $add_user_errors = $user_details[ 'errors' ]; - } else { - $new_user_login = apply_filters('pre_user_login', sanitize_user(stripslashes($_REQUEST['user_login']), true)); - if ( isset( $_POST[ 'noconfirmation' ] ) && is_super_admin() ) { - add_filter( 'wpmu_signup_user_notification', '__return_false' ); // Disable confirmation email - } - wpmu_signup_user( $new_user_login, $_REQUEST[ 'email' ], array( 'add_to_blog' => $wpdb->blogid, 'new_role' => $_REQUEST[ 'role' ] ) ); - if ( isset( $_POST[ 'noconfirmation' ] ) && is_super_admin() ) { - $key = $wpdb->get_var( $wpdb->prepare( "SELECT activation_key FROM {$wpdb->signups} WHERE user_login = %s AND user_email = %s", $new_user_login, $_REQUEST[ 'email' ] ) ); - wpmu_activate_signup( $key ); - $redirect = add_query_arg( array('update' => 'addnoconfirmation'), 'user-new.php' ); - } else { - $redirect = add_query_arg( array('update' => 'newuserconfimation'), 'user-new.php' ); - } - wp_redirect( $redirect ); - die(); - } } } } + $title = __('Add New User'); $parent_file = 'users.php'; +$do_both = false; +if ( is_multisite() && current_user_can('promote_users') && current_user_can('create_users') ) + $do_both = true; + add_contextual_help($current_screen, '

    ' . __('To add a new user to your site, fill in the form on this screen. If you’re not sure which role to assign, you can use the link below to review the different roles and their capabilities. Here is a basic overview of roles:') . '

    ' . '
      ' . @@ -127,7 +152,6 @@ add_contextual_help($current_screen, wp_enqueue_script('wp-ajax-response'); wp_enqueue_script('user-profile'); -wp_enqueue_script('password-strength-meter'); require_once ('admin-header.php'); @@ -147,6 +171,12 @@ if ( isset($_GET['update']) ) { case "addexisting": $messages[] = __('That user is already a member of this site.'); break; + case "does_not_exist": + $messages[] = __('The requested user does not exist.'); + break; + case "does_not_exist": + $messages[] = __('Please enter a valid email address.'); + break; } } else { if ( 'add' == $_GET['update'] ) @@ -156,7 +186,13 @@ if ( isset($_GET['update']) ) { ?>
      -

      +

      +

      @@ -185,32 +221,70 @@ if ( ! empty( $messages ) ) {
      ' . sprintf(__('Users can register themselves or you can manually create users here.'), site_url('wp-register.php')) . '

      '; - else - echo '

      ' . sprintf(__('Users cannot currently register themselves, but you can manually create users here.'), admin_url('options-general.php#users_can_register')) . '

      '; -} else { - echo '

      ' . __( 'You can add new users to your site in two ways:' ) . '

      1. ' . __( 'Enter the username and email address of an existing user on this site.' ) . '
      2. ' . __( 'Enter the username and the email address of a person who is not already a member of this site. Choose the username carefully, it cannot be changed.' ) . '

      '; - echo '

      ' . __( 'That person will be sent an email asking them to click a link confirming the invite. New users will then be sent an email with a randomly generated password and a login link.' ) . '

      '; -} +if ( is_multisite() ) { + if ( $do_both ) + echo '

      ' . __('Add Existing User') . '

      '; + if ( !is_super_admin() ) { + _e( 'Enter the email address of an existing user on this network to invite them to this site. That person will be sent an email asking them to confirm the invite.' ); + $label = __('E-mail'); + } else { + _e( 'Enter the email address or username of an existing user on this network to invite them to this site. That person will be sent an email asking them to confirm the invite.' ); + $label = __('E-mail or Username'); + } ?> -
      > - +> + + + + + + + + + + + + + + + + + + +
      +
      + 'addusersub' ) ); ?> +
      +' . __( 'Add New User' ) . ''; +?> +

      +
      > + + 'login', 'first_name' => 'firstname', 'last_name' => 'lastname', - 'email' => 'email', 'url' => 'uri', 'role' => 'role') as $post_field => $var ) { +// Load up the passed data, else set to a default. +foreach ( array( 'user_login' => 'login', 'first_name' => 'firstname', 'last_name' => 'lastname', + 'email' => 'email', 'url' => 'uri', 'role' => 'role', 'send_password' => 'send_password', 'noconfirmation' => 'ignore_pass' ) as $post_field => $var ) { $var = "new_user_$var"; - if ( ! isset($$var) ) - $$var = isset($_POST[$post_field]) ? stripslashes($_POST[$post_field]) : ''; + if( isset( $_POST['createuser'] ) ) { + if ( ! isset($$var) ) + $$var = isset( $_POST[$post_field] ) ? stripslashes( $_POST[$post_field] ) : ''; + } else { + $$var = false; + } } -$new_user_send_password = !$_POST || isset($_POST['send_password']); + ?> - + @@ -243,7 +317,7 @@ $new_user_send_password = !$_POST || isset($_POST['send_password']); - + @@ -261,15 +335,15 @@ $new_user_send_password = !$_POST || isset($_POST['send_password']); - +
      -
      -

      - -

      -
      + 'createusersub' ) ); ?> + + +
      diff --git a/wp-admin/user/index-extra.php b/wp-admin/user/index-extra.php new file mode 100644 index 00000000..48812635 --- /dev/null +++ b/wp-admin/user/index-extra.php @@ -0,0 +1,12 @@ + \ No newline at end of file diff --git a/wp-admin/user/profile.php b/wp-admin/user/profile.php new file mode 100644 index 00000000..4857a508 --- /dev/null +++ b/wp-admin/user/profile.php @@ -0,0 +1,12 @@ +get_pagenum(); $title = __('Users'); $parent_file = 'users.php'; +add_screen_option( 'per_page', array('label' => _x( 'Users', 'users per page (screen options)' )) ); + // contextual help - choose Help on the top right of admin panel to preview this. add_contextual_help($current_screen, - '

      ' . __('This screen lists all the existing users for your site. Each user has one of five defined roles as set by the site admin: Site Administrator, Editor, Author, Contributor, or Subscriber. Users with roles other than Administrator will see fewer options when they are logged in, based on their role.') . '

      ' . + '

      ' . __('This screen lists all the existing users for your site. Each user has one of five defined roles as set by the site admin: Site Administrator, Editor, Author, Contributor, or Subscriber. Users with roles other than Administrator will see fewer options in the dashboard navigation when they are logged in, based on their role.') . '

      ' . '

      ' . __('You can customize the display of information on this screen as you can on other screens, by using the Screen Options tab and the on-screen filters.') . '

      ' . '

      ' . __('To add a new user for your site, click the Add New button at the top of the screen or Add New in the Users menu section.') . '

      ' . '

      ' . __('For more information:') . '

      ' . - '

      ' . __('Documentation on Authors and Users') . '

      ' . - '

      ' . __('Roles and Capabilities Descriptions') . '

      ' . + '

      ' . __('Documentation on Managing Users') . '

      ' . + '

      ' . __('Descriptions of Roles and Capabilities') . '

      ' . '

      ' . __('Support Forums') . '

      ' ); -$update = $doaction = ''; -if ( isset($_REQUEST['action']) ) - $doaction = $_REQUEST['action'] ? $_REQUEST['action'] : $_REQUEST['action2']; - -if ( empty($doaction) ) { - if ( isset($_GET['changeit']) && !empty($_GET['new_role']) ) - $doaction = 'promote'; -} - if ( empty($_REQUEST) ) { $referer = ''; } elseif ( isset($_REQUEST['wp_http_referer']) ) { @@ -48,12 +40,17 @@ if ( empty($_REQUEST) ) { $referer = ''; } -switch ($doaction) { +$update = ''; + +switch ( $wp_list_table->current_action() ) { /* Bulk Dropdown menu Role changes */ case 'promote': check_admin_referer('bulk-users'); + if ( ! current_user_can( 'promote_users' ) ) + wp_die( __( 'You can’t edit that user.' ) ); + if ( empty($_REQUEST['users']) ) { wp_redirect($redirect); exit(); @@ -178,18 +175,6 @@ case 'delete': $go_delete = true; } } - // @todo Delete is always for !is_multisite(). Use API. - if ( !is_multisite() ) { - $all_logins = $wpdb->get_results("SELECT ID, user_login FROM $wpdb->users ORDER BY user_login"); - } else { - // WPMU only searches users of current blog - $all_logins = $wpdb->get_results("SELECT ID, user_login FROM $wpdb->users, $wpdb->usermeta WHERE $wpdb->users.ID = $wpdb->usermeta.user_id AND meta_key = '".$wpdb->prefix."capabilities' ORDER BY user_login"); - } - $user_dropdown = ''; ?>
    @@ -198,10 +183,11 @@ case 'delete':
  • - '.__('Attribute all posts and links to:')." $user_dropdown"; ?>
  • + '.__('Attribute all posts and links to:').''; + wp_dropdown_users( array( 'name' => 'reassign_user', 'exclude' => array_diff( $userids, array($current_user->ID) ) ) ); ?>
    -

    +

    @@ -214,13 +200,16 @@ break; case 'doremove': check_admin_referer('remove-users'); + if ( ! is_multisite() ) + wp_die( __( 'You can’t remove users.' ) ); + if ( empty($_REQUEST['users']) ) { wp_redirect($redirect); exit; } - if ( !current_user_can('remove_users') ) - die(__('You can’t remove users.')); + if ( ! current_user_can( 'remove_users' ) ) + wp_die( __( 'You can’t remove users.' ) ); $userids = $_REQUEST['users']; @@ -248,6 +237,9 @@ case 'remove': check_admin_referer('bulk-users'); + if ( ! is_multisite() ) + wp_die( __( 'You can’t remove users.' ) ); + if ( empty($_REQUEST['users']) && empty($_REQUEST['user']) ) { wp_redirect($redirect); exit(); @@ -289,7 +281,7 @@ case 'remove': ?> -

    +

    @@ -306,21 +298,14 @@ default: exit; } + $wp_list_table->prepare_items(); + $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); + if ( $pagenum > $total_pages && $total_pages > 0 ) { + wp_redirect( add_query_arg( 'paged', $total_pages ) ); + exit; + } include('./admin-header.php'); - $usersearch = isset($_GET['usersearch']) ? $_GET['usersearch'] : null; - $userspage = isset($_GET['userspage']) ? $_GET['userspage'] : null; - $role = isset($_GET['role']) ? $_GET['role'] : null; - - // Query the user IDs for this page - $wp_user_search = new WP_User_Search($usersearch, $userspage, $role); - - // Query the post counts for this page - $post_counts = count_many_users_posts($wp_user_search->get_results()); - - // Query the users for this page - cache_users($wp_user_search->get_results()); - $messages = array(); if ( isset($_GET['update']) ) : switch($_GET['update']) { @@ -371,153 +356,27 @@ if ( ! empty($messages) ) {
    -

    ' . __('Search results for “%s”') . '', esc_html( $_GET['usersearch'] ) ); ?> -

    - -
    -
    -
      +

      " . sprintf( _nx( 'All (%s)', 'All (%s)', $total_users, 'users' ), number_format_i18n( $total_users ) ) . ''; -foreach ( $wp_roles->get_names() as $this_role => $name ) { - if ( !isset($avail_roles[$this_role]) ) - continue; - - $class = ''; - - if ( $this_role == $role ) { - $current_role = $role; - $class = ' class="current"'; - } - - $name = translate_user_role( $name ); - /* translators: User role name with count */ - $name = sprintf( __('%1$s (%2$s)'), $name, $avail_roles[$this_role] ); - $role_links[] = "
    • $name"; -} -echo implode( " |
    • \n", $role_links) . ''; -unset($role_links); -?> -

    -
    -
    - -
    - -
    - -
    -
    - -results_are_paged() ) : ?> -
    page_links(); ?>
    - - -
    - - - - - -
    - -
    -
    - - search_errors ) ) : ?> -
    -
      - search_errors->get_error_messages() as $message ) - echo "
    • $message
    • "; - ?> -
    -
    - - - -get_results() ) : ?> - - is_search() ) : ?> -

    - - - - - - - - - - - - - - - - -get_results() as $userid ) { - $user_object = new WP_User($userid); - $roles = $user_object->roles; - $role = array_shift($roles); - - if ( is_multisite() && empty( $role ) ) - continue; - - $style = ( ' class="alternate"' == $style ) ? '' : ' class="alternate"'; - echo "\n\t", user_row( $user_object, $style, $role, $post_counts[ $userid ] ); -} -?> - -
    - -
    - -results_are_paged() ) : ?> -
    page_links(); ?>
    - +echo esc_html( $title ); +if ( current_user_can( 'create_users' ) ) { ?> + + + +' . __('Search results for “%s”') . '', esc_html( $usersearch ) ); ?> + -
    - - -
    +views(); ?> -
    -
    + - +search_box( __( 'Search Users' ), 'user' ); ?> +display(); ?>
    -

    + diff --git a/wp-admin/widgets.php b/wp-admin/widgets.php index d3c401b1..4ae5478f 100644 --- a/wp-admin/widgets.php +++ b/wp-admin/widgets.php @@ -35,14 +35,14 @@ $parent_file = 'themes.php'; $help = '

    ' . __('Widgets are independent sections of content that can be placed into any widgetized area provided by your theme (commonly called sidebars). To populate your sidebars/widget areas with individual widgets, drag and drop the title bars into the desired area. By default, only the first widget area is expanded. To populate additional widget areas, click on their title bars to expand them.') . '

    -

    ' . __('Available Widgets section contains all the widgets you can choose from. Once you drag a widget into a sidebar, it will open to allow you to configure its settings. When you are happy with the widget settings, click the Save button and the widget will go live on your site. If you click Delete, it will remove the widget.') . '

    +

    ' . __('The Available Widgets section contains all the widgets you can choose from. Once you drag a widget into a sidebar, it will open to allow you to configure its settings. When you are happy with the widget settings, click the Save button and the widget will go live on your site. If you click Delete, it will remove the widget.') . '

    ' . __('If you want to remove the widget but save its setting for possible future use, just drag it into the Inactive Widgets area. You can add them back anytime from there. This is especially helpful when you switch to a theme with fewer or different widget areas.') . '

    ' . __('Widgets may be used multiple times. You can give each widget a title, to display on your site, but it’s not required.') . '

    ' . __('Enabling Accessibility Mode, via Screen Options, allows you to use Add and Edit buttons instead of using drag and drop.') . '

    ' . __('Many themes show some sidebar widgets by default until you edit your sidebars, but they are not automatically displayed in your sidebar management tool. After you make your first widget change, you can re-add the default widgets by adding them from the Available Widgets area.') . '

    '; $help .= '

    ' . __('For more information:') . '

    '; -$help .= '

    ' . __('Widgets Documentation') . '

    '; +$help .= '

    ' . __('Documentation on Widgets') . '

    '; $help .= '

    ' . __('Support Forums') . '

    '; add_contextual_help($current_screen, $help); @@ -175,7 +175,7 @@ if ( isset($_POST['savewidget']) || isset($_POST['removewidget']) ) { if ( isset($_POST['removewidget']) && $_POST['removewidget'] ) { if ( !in_array($widget_id, $sidebar, true) ) { - wp_redirect('widgets.php?error=0'); + wp_redirect( admin_url('widgets.php?error=0') ); exit; } @@ -208,7 +208,7 @@ if ( isset($_POST['savewidget']) || isset($_POST['removewidget']) ) { } wp_set_sidebars_widgets($sidebars_widgets); - wp_redirect('widgets.php?message=0'); + wp_redirect( admin_url('widgets.php?message=0') ); exit; } @@ -306,12 +306,14 @@ if ( isset($_GET['editwidget']) && $_GET['editwidget'] ) {
    - + - - - - + diff --git a/wp-app.php b/wp-app.php index f21c3c06..6de52882 100644 --- a/wp-app.php +++ b/wp-app.php @@ -387,7 +387,7 @@ EOD; * @since 2.2.0 */ function create_post() { - global $blog_id, $user_ID; + global $user_ID; $this->get_accepted_content_type($this->atom_content_types); $parser = new AtomParser(); @@ -419,7 +419,7 @@ EOD; if ( !current_user_can($cap) ) $this->auth_required(__('Sorry, you do not have the right to edit/publish new posts.')); - $blog_ID = (int ) $blog_id; + $blog_ID = get_current_blog_id(); $post_status = ($publish) ? 'publish' : 'draft'; $post_author = (int) $user_ID; $post_title = $entry->title[1]; @@ -712,7 +712,7 @@ EOD; $filetype = wp_check_filetype($location); if ( !isset($location) || 'attachment' != $entry['post_type'] || empty($filetype['ext']) ) - $this->internal_error(__('Error ocurred while accessing post metadata for file location.')); + $this->internal_error(__('Error occurred while accessing post metadata for file location.')); // delete file @unlink($location); @@ -749,7 +749,7 @@ EOD; $filetype = wp_check_filetype($location); if ( !isset($location) || 'attachment' != $entry['post_type'] || empty($filetype['ext']) ) - $this->internal_error(__('Error ocurred while accessing post metadata for file location.')); + $this->internal_error(__('Error occurred while accessing post metadata for file location.')); status_header('200'); header('Content-Type: ' . $entry['post_mime_type']); @@ -801,7 +801,7 @@ EOD; $location = "{$upload_dir['basedir']}/{$location}"; if (!isset($location) || 'attachment' != $entry['post_type'] || empty($filetype['ext'])) - $this->internal_error(__('Error ocurred while accessing post metadata for file location.')); + $this->internal_error(__('Error occurred while accessing post metadata for file location.')); $fp = fopen("php://input", "rb"); $localfp = fopen($location, "w+"); diff --git a/wp-atom.php b/wp-atom.php index f7221f3f..a83ac7db 100644 --- a/wp-atom.php +++ b/wp-atom.php @@ -8,5 +8,5 @@ require( './wp-load.php' ); wp_redirect( get_bloginfo( 'atom_url' ), 301 ); - -?> \ No newline at end of file +exit; +?> diff --git a/wp-comments-post.php b/wp-comments-post.php index e2e12f76..9c17a355 100644 --- a/wp-comments-post.php +++ b/wp-comments-post.php @@ -101,5 +101,5 @@ $location = empty($_POST['redirect_to']) ? get_comment_link($comment_id) : $_POS $location = apply_filters('comment_post_redirect', $location, $comment); wp_redirect($location); - +exit; ?> diff --git a/wp-commentsrss2.php b/wp-commentsrss2.php index 1c146b14..280766ed 100644 --- a/wp-commentsrss2.php +++ b/wp-commentsrss2.php @@ -8,5 +8,5 @@ require( './wp-load.php' ); wp_redirect( get_bloginfo( 'comments_rss2_url' ), 301 ); - -?> \ No newline at end of file +exit; +?> diff --git a/wp-config-sample.php b/wp-config-sample.php index 69cd75e5..e47e1b5a 100644 --- a/wp-config-sample.php +++ b/wp-config-sample.php @@ -64,12 +64,12 @@ $table_prefix = 'wp_'; /** * WordPress Localized Language, defaults to English. * - * Change this to localize WordPress. A corresponding MO file for the chosen + * Change this to localize WordPress. A corresponding MO file for the chosen * language must be installed to wp-content/languages. For example, install - * de.mo to wp-content/languages and set WPLANG to 'de' to enable German + * de_DE.mo to wp-content/languages and set WPLANG to 'de_DE' to enable German * language support. */ -define ('WPLANG', ''); +define('WPLANG', ''); /** * For developers: WordPress debugging mode. diff --git a/wp-content/plugins/akismet/admin.php b/wp-content/plugins/akismet/admin.php index a1954039..91cedb29 100644 --- a/wp-content/plugins/akismet/admin.php +++ b/wp-content/plugins/akismet/admin.php @@ -7,11 +7,11 @@ function akismet_admin_init() { global $wp_version; // all admin functions are disabled in old versions - if ( version_compare( $wp_version, '3.0', '<' ) ) { + if ( !function_exists('is_multisite') && version_compare( $wp_version, '3.0', '<' ) ) { function akismet_version_warning() { echo " -

    ".sprintf(__('Akismet %s required WordPress 3.0 or higher.'), AKISMET_VERSION) ." ".sprintf(__('Please upgrade WordPress to a current version, or downgrade to version 2.4 of the Akismet plugin.'), 'http://codex.wordpress.org/Upgrading_WordPress', 'http://wordpress.org/extend/plugins/akismet/download/'). "

    +

    ".sprintf(__('Akismet %s requires WordPress 3.0 or higher.'), AKISMET_VERSION) ." ".sprintf(__('Please upgrade WordPress to a current version, or downgrade to version 2.4 of the Akismet plugin.'), 'http://codex.wordpress.org/Upgrading_WordPress', 'http://wordpress.org/extend/plugins/akismet/download/'). "

    "; } add_action('admin_notices', 'akismet_version_warning'); @@ -24,7 +24,11 @@ function akismet_admin_init() { else $hook = 'dashboard_page_akismet-stats-display'; add_action('admin_head-'.$hook, 'akismet_stats_script'); - add_meta_box('akismet-status', __('Akismet Status'), 'akismet_comment_status_meta_box', 'comment', 'normal'); + add_meta_box('akismet-status', __('Comment History'), 'akismet_comment_status_meta_box', 'comment', 'normal'); + wp_register_style('akismet.css', AKISMET_PLUGIN_URL . 'akismet.css'); + wp_enqueue_style('akismet.css'); + wp_register_script('akismet.js', AKISMET_PLUGIN_URL . 'akismet.js', array('jquery')); + wp_enqueue_script('akismet.js'); } add_action('admin_init', 'akismet_admin_init'); @@ -34,9 +38,18 @@ $akismet_nonce = 'akismet-update-key'; function akismet_config_page() { if ( function_exists('add_submenu_page') ) add_submenu_page('plugins.php', __('Akismet Configuration'), __('Akismet Configuration'), 'manage_options', 'akismet-key-config', 'akismet_conf'); +} + +function akismet_plugin_action_links( $links, $file ) { + if ( $file == plugin_basename( dirname(__FILE__).'/akismet.php' ) ) { + $links[] = ''.__('Settings').''; + } + return $links; } +add_filter( 'plugin_action_links', 'akismet_plugin_action_links', 10, 2 ); + function akismet_conf() { global $akismet_nonce, $wpcom_api_key; @@ -46,11 +59,15 @@ function akismet_conf() { check_admin_referer( $akismet_nonce ); $key = preg_replace( '/[^a-h0-9]/i', '', $_POST['key'] ); + $home_url = parse_url( get_bloginfo('url') ); if ( empty($key) ) { $key_status = 'empty'; $ms[] = 'new_key_empty'; delete_option('wordpress_api_key'); + } elseif ( empty($home_url['host']) ) { + $key_status = 'empty'; + $ms[] = 'bad_home_url'; } else { $key_status = akismet_verify_key( $key ); } @@ -68,6 +85,12 @@ function akismet_conf() { update_option( 'akismet_discard_month', 'true' ); else update_option( 'akismet_discard_month', 'false' ); + + if ( isset( $_POST['akismet_show_user_comments_approved'] ) ) + update_option( 'akismet_show_user_comments_approved', 'true' ); + else + update_option( 'akismet_show_user_comments_approved', 'false' ); + } elseif ( isset($_POST['check']) ) { akismet_get_server_connectivity(0); } @@ -97,19 +120,24 @@ function akismet_conf() { $messages = array( 'new_key_empty' => array('color' => 'aa0', 'text' => __('Your key has been cleared.')), - 'new_key_valid' => array('color' => '2d2', 'text' => __('Your key has been verified. Happy blogging!')), - 'new_key_invalid' => array('color' => 'd22', 'text' => __('The key you entered is invalid. Please double-check it.')), - 'new_key_failed' => array('color' => 'd22', 'text' => __('The key you entered could not be verified because a connection to akismet.com could not be established. Please check your server configuration.')), - 'no_connection' => array('color' => 'd22', 'text' => __('There was a problem connecting to the Akismet server. Please check your server configuration.')), + 'new_key_valid' => array('color' => '4AB915', 'text' => __('Your key has been verified. Happy blogging!')), + 'new_key_invalid' => array('color' => '888', 'text' => __('The key you entered is invalid. Please double-check it.')), + 'new_key_failed' => array('color' => '888', 'text' => __('The key you entered could not be verified because a connection to akismet.com could not be established. Please check your server configuration.')), + 'no_connection' => array('color' => '888', 'text' => __('There was a problem connecting to the Akismet server. Please check your server configuration.')), 'key_empty' => array('color' => 'aa0', 'text' => sprintf(__('Please enter an API key. (Get your key.)'), 'http://akismet.com/get/')), - 'key_valid' => array('color' => '2d2', 'text' => __('This key is valid.')), - 'key_failed' => array('color' => 'aa0', 'text' => __('The key below was previously validated but a connection to akismet.com can not be established at this time. Please check your server configuration.'))); + 'key_valid' => array('color' => '4AB915', 'text' => __('This key is valid.')), + 'key_failed' => array('color' => 'aa0', 'text' => __('The key below was previously validated but a connection to akismet.com can not be established at this time. Please check your server configuration.')), + 'bad_home_url' => array('color' => '888', 'text' => sprintf( __('Your WordPress home URL %s is invalid. Please fix the home option.'), esc_html( get_bloginfo('url') ), admin_url('options.php#home') ) ), + ); ?>

    + +

    Sign up success! Please check your email for your Akismet API Key and enter it below.' ); ?>

    +
    @@ -126,7 +154,8 @@ function akismet_conf() { -

    +

    +

    @@ -136,7 +165,7 @@ function akismet_conf() { -

    +

    fsockopen or gethostbynamel functions. Akismet cannot work correctly until this is fixed. Please contact your web host or firewall administrator and give them this information about Akismet\'s system requirements.'), 'http://blog.akismet.com/akismet-hosting-faq/'); ?>

    0 ) { ?> -

    +

    Akismet cannot work correctly until this is fixed. Please contact your web host or firewall administrator and give them this information about Akismet and firewalls.'), 'http://blog.akismet.com/akismet-hosting-faq/'); ?>

    -

    +

    -

    +

    Akismet cannot work correctly until this is fixed. Please contact your web host or firewall administrator and give them this information about Akismet and firewalls.'), 'http://blog.akismet.com/akismet-hosting-faq/'); ?>

    $status ) { - $color = ( $status ? '#2d2' : '#d22'); + $color = ( $status ? '#4AB915' : '#888'); ?> - +

    +

    Click here to confirm that Akismet.com is up.'), 'http://status.automattic.com/9931/136079/Akismet-API', 'http://status.automattic.com/9931/136079/Akismet-API' ); ?>

    @@ -206,11 +236,8 @@ function akismet_stats_script() { ?> -
    - -
    - '.__('Spam').''; - global $submenu; - if ( isset( $submenu['edit-comments.php'] ) ) - $link = 'edit-comments.php'; - else - $link = 'edit.php'; - echo '

    '.sprintf(__('Akismet has protected your site from %3$s spam comments.'), 'http://akismet.com/', clean_url("$link?page=akismet-admin"), number_format_i18n($count) ).'

    '; -} -add_action('activity_box_end', 'akismet_stats'); - function akismet_get_key() { global $wpcom_api_key; if ( !empty($wpcom_api_key) ) @@ -316,104 +81,11 @@ function akismet_verify_key( $key, $ip = null ) { return $response[1]; } -// Check connectivity between the WordPress blog and Akismet's servers. -// Returns an associative array of server IP addresses, where the key is the IP address, and value is true (available) or false (unable to connect). -function akismet_check_server_connectivity() { - global $akismet_api_host, $akismet_api_port, $wpcom_api_key; - - $test_host = 'rest.akismet.com'; - - // Some web hosts may disable one or both functions - if ( !function_exists('fsockopen') || !function_exists('gethostbynamel') ) - return array(); - - $ips = gethostbynamel($test_host); - if ( !$ips || !is_array($ips) || !count($ips) ) - return array(); - - $servers = array(); - foreach ( $ips as $ip ) { - $response = akismet_verify_key( akismet_get_key(), $ip ); - // even if the key is invalid, at least we know we have connectivity - if ( $response == 'valid' || $response == 'invalid' ) - $servers[$ip] = true; - else - $servers[$ip] = false; - } - - return $servers; -} - -// Check the server connectivity and store the results in an option. -// Cached results will be used if not older than the specified timeout in seconds; use $cache_timeout = 0 to force an update. -// Returns the same associative array as akismet_check_server_connectivity() -function akismet_get_server_connectivity( $cache_timeout = 86400 ) { - $servers = get_option('akismet_available_servers'); - if ( (time() - get_option('akismet_connectivity_time') < $cache_timeout) && $servers !== false ) - return $servers; - - // There's a race condition here but the effect is harmless. - $servers = akismet_check_server_connectivity(); - update_option('akismet_available_servers', $servers); - update_option('akismet_connectivity_time', time()); - return $servers; -} - -// Returns true if server connectivity was OK at the last check, false if there was a problem that needs to be fixed. -function akismet_server_connectivity_ok() { - // skip the check on WPMU because the status page is hidden - global $wpcom_api_key; - if ( $wpcom_api_key ) +// if we're in debug or test modes, use a reduced service level so as not to polute training or stats data +function akismet_test_mode() { + if ( defined('AKISMET_TEST_MODE') && AKISMET_TEST_MODE ) return true; - $servers = akismet_get_server_connectivity(); - return !( empty($servers) || !count($servers) || count( array_filter($servers) ) < count($servers) ); -} - -function akismet_admin_warnings() { - global $wpcom_api_key; - if ( !get_option('wordpress_api_key') && !$wpcom_api_key && !isset($_POST['submit']) ) { - function akismet_warning() { - echo " -

    ".__('Akismet is almost ready.')." ".sprintf(__('You must enter your Akismet API key for it to work.'), "plugins.php?page=akismet-key-config")."

    - "; - } - add_action('admin_notices', 'akismet_warning'); - return; - } elseif ( get_option('akismet_connectivity_time') && empty($_POST) && is_admin() && !akismet_server_connectivity_ok() ) { - function akismet_warning() { - echo " -

    ".__('Akismet has detected a problem.')." ".sprintf(__('A server or network problem is preventing Akismet from working correctly. Click here for more information about how to fix the problem.'), "plugins.php?page=akismet-key-config")."

    - "; - } - add_action('admin_notices', 'akismet_warning'); - return; - } -} - -function akismet_get_host($host) { - // if all servers are accessible, just return the host name. - // if not, return an IP that was known to be accessible at the last check. - if ( akismet_server_connectivity_ok() ) { - return $host; - } else { - $ips = akismet_get_server_connectivity(); - // a firewall may be blocking access to some Akismet IPs - if ( count($ips) > 0 && count(array_filter($ips)) < count($ips) ) { - // use DNS to get current IPs, but exclude any known to be unreachable - $dns = (array)gethostbynamel( rtrim($host, '.') . '.' ); - $dns = array_filter($dns); - foreach ( $dns as $ip ) { - if ( array_key_exists( $ip, $ips ) && empty( $ips[$ip] ) ) - unset($dns[$ip]); - } - // return a random IP from those available - if ( count($dns) ) - return $dns[ array_rand($dns) ]; - - } - } - // if all else fails try the host name - return $host; + return false; } // return a comma-separated list of role names for the given user @@ -428,42 +100,76 @@ function akismet_get_user_roles($user_id ) { if ( isset($comment_user->roles) ) $roles = join(',', $comment_user->roles); } - + + if ( is_multisite() && is_super_admin( $user_id ) ) { + if ( empty( $roles ) ) { + $roles = 'super_admin'; + } else { + $comment_user->roles[] = 'super_admin'; + $roles = join( ',', $comment_user->roles ); + } + } + return $roles; } // Returns array with headers in $response[0] and body in $response[1] function akismet_http_post($request, $host, $path, $port = 80, $ip=null) { global $wp_version; - - $akismet_version = constant('AKISMET_VERSION'); - - $http_request = "POST $path HTTP/1.0\r\n"; - $http_request .= "Host: $host\r\n"; - $http_request .= "Content-Type: application/x-www-form-urlencoded; charset=" . get_option('blog_charset') . "\r\n"; - $http_request .= "Content-Length: " . strlen($request) . "\r\n"; - $http_request .= "User-Agent: WordPress/$wp_version | Akismet/$akismet_version\r\n"; - $http_request .= "\r\n"; - $http_request .= $request; - + + $akismet_ua = "WordPress/{$wp_version} | "; + $akismet_ua .= 'Akismet/' . constant( 'AKISMET_VERSION' ); + + $content_length = strlen( $request ); + $http_host = $host; - // use a specific IP if provided - needed by akismet_check_server_connectivity() - if ( $ip && long2ip(ip2long($ip)) ) { + // use a specific IP if provided + // needed by akismet_check_server_connectivity() + if ( $ip && long2ip( ip2long( $ip ) ) ) { $http_host = $ip; } else { - $http_host = akismet_get_host($host); + $http_host = $host; } - - $response = ''; - if( false != ( $fs = @fsockopen($http_host, $port, $errno, $errstr, 10) ) ) { - fwrite($fs, $http_request); - - while ( !feof($fs) ) - $response .= fgets($fs, 1160); // One TCP-IP packet - fclose($fs); - $response = explode("\r\n\r\n", $response, 2); + + // use the WP HTTP class if it is available + if ( function_exists( 'wp_remote_post' ) ) { + $http_args = array( + 'body' => $request, + 'headers' => array( + 'Content-Type' => 'application/x-www-form-urlencoded; ' . + 'charset=' . get_option( 'blog_charset' ), + 'Host' => $host, + 'User-Agent' => $akismet_ua + ), + 'httpversion' => '1.0', + 'timeout' => 15 + ); + $akismet_url = "http://{$http_host}{$path}"; + $response = wp_remote_post( $akismet_url, $http_args ); + if ( is_wp_error( $response ) ) + return ''; + + return array( $response['headers'], $response['body'] ); + } else { + $http_request = "POST $path HTTP/1.0\r\n"; + $http_request .= "Host: $host\r\n"; + $http_request .= 'Content-Type: application/x-www-form-urlencoded; charset=' . get_option('blog_charset') . "\r\n"; + $http_request .= "Content-Length: {$content_length}\r\n"; + $http_request .= "User-Agent: {$akismet_ua}\r\n"; + $http_request .= "\r\n"; + $http_request .= $request; + + $response = ''; + if( false != ( $fs = @fsockopen( $http_host, $port, $errno, $errstr, 10 ) ) ) { + fwrite( $fs, $http_request ); + + while ( !feof( $fs ) ) + $response .= fgets( $fs, 1160 ); // One TCP-IP packet + fclose( $fs ); + $response = explode( "\r\n\r\n", $response, 2 ); + } + return $response; } - return $response; } // filter handler used to return a spam result to pre_comment_approved @@ -471,11 +177,122 @@ function akismet_result_spam( $approved ) { // bump the counter here instead of when the filter is added to reduce the possibility of overcounting if ( $incr = apply_filters('akismet_spam_count_incr', 1) ) update_option( 'akismet_spam_count', get_option('akismet_spam_count') + $incr ); + // this is a one-shot deal + remove_filter( 'pre_comment_approved', 'akismet_result_spam' ); return 'spam'; } +function akismet_result_hold( $approved ) { + // once only + remove_filter( 'pre_comment_approved', 'akismet_result_hold' ); + return '0'; +} + +// how many approved comments does this author have? +function akismet_get_user_comments_approved( $user_id, $comment_author_email, $comment_author, $comment_author_url ) { + global $wpdb; + + if ( !empty($user_id) ) + return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->comments WHERE user_id = %d AND comment_approved = 1", $user_id ) ); + + if ( !empty($comment_author_email) ) + return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_author_email = %s AND comment_author = %s AND comment_author_url = %s AND comment_approved = 1", $comment_author_email, $comment_author, $comment_author_url ) ); + + return 0; +} + +function akismet_microtime() { + $mtime = explode( ' ', microtime() ); + return $mtime[1] + $mtime[0]; +} + +// log an event for a given comment, storing it in comment_meta +function akismet_update_comment_history( $comment_id, $message, $event=null ) { + global $current_user; + + // failsafe for old WP versions + if ( !function_exists('add_comment_meta') ) + return false; + + $user = ''; + if ( is_object($current_user) && isset($current_user->user_login) ) + $user = $current_user->user_login; + + $event = array( + 'time' => akismet_microtime(), + 'message' => $message, + 'event' => $event, + 'user' => $user, + ); + + // $unique = false so as to allow multiple values per comment + $r = add_comment_meta( $comment_id, 'akismet_history', $event, false ); +} + +// get the full comment history for a given comment, as an array in reverse chronological order +function akismet_get_comment_history( $comment_id ) { + + // failsafe for old WP versions + if ( !function_exists('add_comment_meta') ) + return false; + + $history = get_comment_meta( $comment_id, 'akismet_history', false ); + usort( $history, 'akismet_cmp_time' ); + return $history; +} + +function akismet_cmp_time( $a, $b ) { + return $a['time'] > $b['time'] ? -1 : 1; +} + +// this fires on wp_insert_comment. we can't update comment_meta when akismet_auto_check_comment() runs +// because we don't know the comment ID at that point. +function akismet_auto_check_update_meta( $id, $comment ) { + global $akismet_last_comment; + + // failsafe for old WP versions + if ( !function_exists('add_comment_meta') ) + return false; + + // wp_insert_comment() might be called in other contexts, so make sure this is the same comment + // as was checked by akismet_auto_check_comment + if ( is_object($comment) && !empty($akismet_last_comment) && is_array($akismet_last_comment) ) { + if ( intval($akismet_last_comment['comment_post_ID']) == intval($comment->comment_post_ID) + && $akismet_last_comment['comment_author'] == $comment->comment_author + && $akismet_last_comment['comment_author_email'] == $comment->comment_author_email ) { + // normal result: true or false + if ( $akismet_last_comment['akismet_result'] == 'true' ) { + update_comment_meta( $comment->comment_ID, 'akismet_result', 'true' ); + akismet_update_comment_history( $comment->comment_ID, __('Akismet caught this comment as spam'), 'check-spam' ); + if ( $comment->comment_approved != 'spam' ) + akismet_update_comment_history( $comment->comment_ID, sprintf( __('Comment status was changed to %s'), $comment->comment_approved), 'status-changed'.$comment->comment_approved ); + } elseif ( $akismet_last_comment['akismet_result'] == 'false' ) { + update_comment_meta( $comment->comment_ID, 'akismet_result', 'false' ); + akismet_update_comment_history( $comment->comment_ID, __('Akismet cleared this comment'), 'check-ham' ); + if ( $comment->comment_approved == 'spam' ) { + if ( wp_blacklist_check($comment->comment_author, $comment->comment_author_email, $comment->comment_author_url, $comment->comment_content, $comment->comment_author_IP, $comment->comment_agent) ) + akismet_update_comment_history( $comment->comment_ID, __('Comment was caught by wp_blacklist_check'), 'wp-blacklisted' ); + else + akismet_update_comment_history( $comment->comment_ID, sprintf( __('Comment status was changed to %s'), $comment->comment_approved), 'status-changed-'.$comment->comment_approved ); + } + // abnormal result: error + } else { + update_comment_meta( $comment->comment_ID, 'akismet_error', time() ); + akismet_update_comment_history( $comment->comment_ID, sprintf( __('Akismet was unable to check this comment (response: %s), will automatically retry again later.'), $akismet_last_comment['akismet_result']), 'check-error' ); + } + + // record the complete original data as submitted for checking + if ( isset($akismet_last_comment['comment_as_submitted']) ) + update_comment_meta( $comment->comment_ID, 'akismet_as_submitted', $akismet_last_comment['comment_as_submitted'] ); + } + } +} + +add_action( 'wp_insert_comment', 'akismet_auto_check_update_meta', 10, 2 ); + + function akismet_auto_check_comment( $commentdata ) { - global $akismet_api_host, $akismet_api_port; + global $akismet_api_host, $akismet_api_port, $akismet_last_comment; $comment = $commentdata; $comment['user_ip'] = $_SERVER['REMOTE_ADDR']; @@ -488,17 +305,41 @@ function akismet_auto_check_comment( $commentdata ) { $comment['user_role'] = akismet_get_user_roles($comment['user_ID']); + $akismet_nonce_option = apply_filters( 'akismet_comment_nonce', get_option( 'akismet_comment_nonce' ) ); + $comment['akismet_comment_nonce'] = 'inactive'; + if ( $akismet_nonce_option == 'true' || $akismet_nonce_option == '' ) { + $comment['akismet_comment_nonce'] = 'failed'; + if ( isset( $_POST['akismet_comment_nonce'] ) && wp_verify_nonce( $_POST['akismet_comment_nonce'], 'akismet_comment_nonce_' . $comment['comment_post_ID'] ) ) + $comment['akismet_comment_nonce'] = 'passed'; + + // comment reply in wp-admin + if ( isset( $_POST['_ajax_nonce-replyto-comment'] ) && check_ajax_referer( 'replyto-comment', '_ajax_nonce-replyto-comment' ) ) + $comment['akismet_comment_nonce'] = 'passed'; + + } + + if ( akismet_test_mode() ) + $comment['is_test'] = 'true'; + + foreach ($_POST as $key => $value ) { + if ( is_string($value) ) + $comment["POST_{$key}"] = $value; + } + $ignore = array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' ); - foreach ( $_SERVER as $key => $value ) + foreach ( $_SERVER as $key => $value ) { if ( !in_array( $key, $ignore ) && is_string($value) ) $comment["$key"] = $value; else $comment["$key"] = ''; + } $query_string = ''; foreach ( $comment as $key => $data ) $query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&'; + + $commentdata['comment_as_submitted'] = $comment; $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port); $commentdata['akismet_result'] = $response[1]; @@ -517,10 +358,17 @@ function akismet_auto_check_comment( $commentdata ) { // akismet_result_spam() won't be called so bump the counter here if ( $incr = apply_filters('akismet_spam_count_incr', 1) ) update_option( 'akismet_spam_count', get_option('akismet_spam_count') + $incr ); - die; + wp_redirect( $_SERVER['HTTP_REFERER'] ); + die(); } } + // if the response is neither true nor false, hold the comment for moderation and schedule a recheck + if ( 'true' != $response[1] && 'false' != $response[1] ) { + add_filter('pre_comment_approved', 'akismet_result_hold'); + wp_schedule_single_event( time() + 1200, 'akismet_schedule_cron_recheck' ); + } + if ( function_exists('wp_next_scheduled') && function_exists('wp_schedule_event') ) { // WP 2.1+: delete old comments daily if ( !wp_next_scheduled('akismet_scheduled_delete') ) @@ -529,18 +377,25 @@ function akismet_auto_check_comment( $commentdata ) { // WP 2.0: run this one time in ten akismet_delete_old(); } + $akismet_last_comment = $commentdata; return $commentdata; } +add_action('preprocess_comment', 'akismet_auto_check_comment', 1); + function akismet_delete_old() { global $wpdb; $now_gmt = current_time('mysql', 1); $comment_ids = $wpdb->get_col("SELECT comment_id FROM $wpdb->comments WHERE DATE_SUB('$now_gmt', INTERVAL 15 DAY) > comment_date_gmt AND comment_approved = 'spam'"); if ( empty( $comment_ids ) ) return; + + $comma_comment_ids = implode( ', ', array_map('intval', $comment_ids) ); do_action( 'delete_comment', $comment_ids ); - $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_id IN ( " . implode( ', ', $comment_ids ) . " )"); + $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_id IN ( $comma_comment_ids )"); + $wpdb->query("DELETE FROM $wpdb->commentmeta WHERE comment_id IN ( $comma_comment_ids )"); + clean_comment_cache( $comment_ids ); $n = mt_rand(1, 5000); if ( apply_filters('akismet_optimize_table', ($n == 11)) ) // lucky number $wpdb->query("OPTIMIZE TABLE $wpdb->comments"); @@ -549,341 +404,109 @@ function akismet_delete_old() { add_action('akismet_scheduled_delete', 'akismet_delete_old'); -function akismet_submit_nonspam_comment ( $comment_id ) { - global $wpdb, $akismet_api_host, $akismet_api_port, $current_user, $current_site; - $comment_id = (int) $comment_id; +function akismet_check_db_comment( $id, $recheck_reason = 'recheck_queue' ) { + global $wpdb, $akismet_api_host, $akismet_api_port; - $comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID = '$comment_id'"); - if ( !$comment ) // it was deleted - return; - $comment->blog = get_option('home'); - $comment->blog_lang = get_locale(); - $comment->blog_charset = get_option('blog_charset'); - $comment->permalink = get_permalink($comment->comment_post_ID); - if ( is_object($current_user) ) { - $comment->reporter = $current_user->user_login; - } - if ( is_object($current_site) ) { - $comment->site_domain = $current_site->domain; - } - - $comment->user_role = ''; - if ( isset( $comment->user_ID ) ) - $comment->user_role = akismet_get_user_roles($comment->user_ID); - - $query_string = ''; - foreach ( $comment as $key => $data ) - $query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&'; - - $response = akismet_http_post($query_string, $akismet_api_host, "/1.1/submit-ham", $akismet_api_port); - do_action('akismet_submit_nonspam_comment', $comment_id, $response[1]); -} - -function akismet_submit_spam_comment ( $comment_id ) { - global $wpdb, $akismet_api_host, $akismet_api_port, $current_user, $current_site; - $comment_id = (int) $comment_id; - - $comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID = '$comment_id'"); - if ( !$comment ) // it was deleted - return; - if ( 'spam' != $comment->comment_approved ) - return; - $comment->blog = get_option('home'); - $comment->blog_lang = get_locale(); - $comment->blog_charset = get_option('blog_charset'); - $comment->permalink = get_permalink($comment->comment_post_ID); - if ( is_object($current_user) ) { - $comment->reporter = $current_user->user_login; - } - if ( is_object($current_site) ) { - $comment->site_domain = $current_site->domain; - } - - $comment->user_role = ''; - if ( !isset( $comment->user_id ) ) - $comment->user_role = akismet_get_user_roles($comment->user_ID); + $id = (int) $id; + $c = $wpdb->get_row( "SELECT * FROM $wpdb->comments WHERE comment_ID = '$id'", ARRAY_A ); + if ( !$c ) + return; - $query_string = ''; - foreach ( $comment as $key => $data ) - $query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&'; - - $response = akismet_http_post($query_string, $akismet_api_host, "/1.1/submit-spam", $akismet_api_port); - do_action('akismet_submit_spam_comment', $comment_id, $response[1]); -} + $c['user_ip'] = $c['comment_author_IP']; + $c['user_agent'] = $c['comment_agent']; + $c['referrer'] = ''; + $c['blog'] = get_option('home'); + $c['blog_lang'] = get_locale(); + $c['blog_charset'] = get_option('blog_charset'); + $c['permalink'] = get_permalink($c['comment_post_ID']); + $id = $c['comment_ID']; + if ( akismet_test_mode() ) + $c['is_test'] = 'true'; + $c['recheck_reason'] = $recheck_reason; -add_action('preprocess_comment', 'akismet_auto_check_comment', 1); + $query_string = ''; + foreach ( $c as $key => $data ) + $query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&'; -// For old versions of WP only -function akismet_set_comment_status( $comment_id, $status ) { - if ( $status == 'spam' ) { - akismet_submit_spam_comment( $comment_id ); - } elseif ( $status == 'approve' ) { - akismet_submit_nonspam_comment( $comment_id ); - } + $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port); + return $response[1]; } -// For WP 2.7+ -function akismet_transition_comment_status( $new_status, $old_status, $comment ) { - if ( $new_status == $old_status ) - return; - - if ( $new_status == 'spam' ) { - akismet_submit_spam_comment( $comment->comment_ID ); - } elseif ( $old_status == 'spam' && ( $new_status == 'approved' || $new_status == 'unapproved' ) ) { - akismet_submit_nonspam_comment( $comment->comment_ID ); - } -} - -function akismet_spamtoham( $comment ) { akismet_submit_nonspam_comment( $comment->comment_ID ); } - -if ( function_exists( 'wp_transition_comment_status' ) ) { - add_action( 'transition_comment_status', 'akismet_transition_comment_status', 10, 3 ); -} else { - add_action('wp_set_comment_status', 'akismet_set_comment_status', 10, 2); - add_action('edit_comment', 'akismet_submit_spam_comment'); - add_filter( 'comment_spam_to_approved', 'akismet_spamtoham' ); - add_filter( 'comment_spam_to_unapproved', 'akismet_spamtoham' ); -} -// Total spam in queue -// get_option( 'akismet_spam_count' ) is the total caught ever -function akismet_spam_count( $type = false ) { +function akismet_cron_recheck() { global $wpdb; - if ( !$type ) { // total - $count = wp_cache_get( 'akismet_spam_count', 'widget' ); - if ( false === $count ) { - if ( function_exists('wp_count_comments') ) { - $count = wp_count_comments(); - $count = $count->spam; - } else { - $count = (int) $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_approved = 'spam'"); + delete_option('akismet_available_servers'); + + $comment_errors = $wpdb->get_col( " + SELECT comment_id + FROM {$wpdb->prefix}commentmeta + WHERE meta_key = 'akismet_error' + LIMIT 100 + " ); + + foreach ( (array) $comment_errors as $comment_id ) { + // if the comment no longer exists, remove the meta entry from the queue to avoid getting stuck + if ( !get_comment( $comment_id ) ) { + delete_comment_meta( $comment_id, 'akismet_error' ); + continue; + } + + add_comment_meta( $comment_id, 'akismet_rechecking', true ); + $status = akismet_check_db_comment( $comment_id, 'retry' ); + + $msg = ''; + if ( $status == 'true' ) { + $msg = __( 'Akismet caught this comment as spam during an automatic retry.' ); + } elseif ( $status == 'false' ) { + $msg = __( 'Akismet cleared this comment during an automatic retry.' ); + } + + // If we got back a legit response then update the comment history + // other wise just bail now and try again later. No point in + // re-trying all the comments once we hit one failure. + if ( !empty( $msg ) ) { + delete_comment_meta( $comment_id, 'akismet_error' ); + akismet_update_comment_history( $comment_id, $msg, 'cron-retry' ); + update_comment_meta( $comment_id, 'akismet_result', $status ); + // make sure the comment status is still pending. if it isn't, that means the user has already moved it elsewhere. + $comment = get_comment( $comment_id ); + if ( $comment && 'unapproved' == wp_get_comment_status( $comment_id ) ) { + if ( $status == 'true' ) { + wp_spam_comment( $comment_id ); + } elseif ( $status == 'false' ) { + // comment is good, but it's still in the pending queue. depending on the moderation settings + // we may need to change it to approved. + if ( check_comment($comment->comment_author, $comment->comment_author_email, $comment->comment_author_url, $comment->comment_content, $comment->comment_author_IP, $comment->comment_agent, $comment->comment_type) ) + wp_set_comment_status( $comment_id, 1 ); + } } - wp_cache_set( 'akismet_spam_count', $count, 'widget', 3600 ); + } else { + delete_comment_meta( $comment_id, 'akismet_rechecking' ); + wp_schedule_single_event( time() + 1200, 'akismet_schedule_cron_recheck' ); + return; } - return $count; - } elseif ( 'comments' == $type || 'comment' == $type ) { // comments - $type = ''; - } else { // pingback, trackback, ... - $type = $wpdb->escape( $type ); - } - - return (int) $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_approved = 'spam' AND comment_type='$type'"); -} - - -// WP 2.5+ -function akismet_rightnow() { - global $submenu, $wp_db_version; - - // clean_url was deprecated in WP 3.0 - $esc_url = 'clean_url'; - if ( function_exists( 'esc_url' ) ) - $esc_url = 'esc_url'; - - if ( 8645 < $wp_db_version ) // 2.7 - $link = 'edit-comments.php?comment_status=spam'; - elseif ( isset( $submenu['edit-comments.php'] ) ) - $link = 'edit-comments.php?page=akismet-admin'; - else - $link = 'edit.php?page=akismet-admin'; - - if ( $count = get_option('akismet_spam_count') ) { - $intro = sprintf( __ngettext( - 'Akismet has protected your site from %2$s spam comment already,', - 'Akismet has protected your site from %2$s spam comments already,', - $count - ), 'http://akismet.com/', number_format_i18n( $count ) ); - } else { - $intro = sprintf( __('Akismet blocks spam from getting to your blog,'), 'http://akismet.com/' ); } - - if ( $queue_count = akismet_spam_count() ) { - $queue_text = sprintf( __ngettext( - 'and there\'s %1$s comment in your spam queue right now.', - 'and there are %1$s comments in your spam queue right now.', - $queue_count - ), number_format_i18n( $queue_count ), clean_url($link) ); - } else { - $queue_text = sprintf( __( "but there's nothing in your spam queue at the moment." ), $esc_url($link) ); - } - - // _c was deprecated in WP 2.9.0 - if ( function_exists( '_x' ) ) - $text = sprintf( _x( '%1$s %2$s', 'akismet_rightnow' ), $intro, $queue_text ); - else - $text = sprintf( _c( '%1$s %2$s|akismet_rightnow' ), $intro, $queue_text ); - - echo "

    $text

    \n"; -} -add_action('rightnow_end', 'akismet_rightnow'); - - -// For WP >= 2.5 -function akismet_check_for_spam_button($comment_status) { - if ( 'approved' == $comment_status ) - return; - if ( function_exists('plugins_url') ) - $link = 'admin.php?action=akismet_recheck_queue'; - else - $link = 'edit-comments.php?page=akismet-admin&recheckqueue=true&noheader=true'; - echo "
    " . __('Check for Spam') . ""; -} -add_action('manage_comments_nav', 'akismet_check_for_spam_button'); - -function akismet_recheck_queue() { - global $wpdb, $akismet_api_host, $akismet_api_port; - - if ( ! ( isset( $_GET['recheckqueue'] ) || ( isset( $_REQUEST['action'] ) && 'akismet_recheck_queue' == $_REQUEST['action'] ) ) ) - return; - - $moderation = $wpdb->get_results( "SELECT * FROM $wpdb->comments WHERE comment_approved = '0'", ARRAY_A ); - foreach ( (array) $moderation as $c ) { - $c['user_ip'] = $c['comment_author_IP']; - $c['user_agent'] = $c['comment_agent']; - $c['referrer'] = ''; - $c['blog'] = get_option('home'); - $c['blog_lang'] = get_locale(); - $c['blog_charset'] = get_option('blog_charset'); - $c['permalink'] = get_permalink($c['comment_post_ID']); - - $c['user_role'] = ''; - if ( isset( $c['user_ID'] ) ) - $c['user_role'] = akismet_get_user_roles($c['user_ID']); - - $id = (int) $c['comment_ID']; - - $query_string = ''; - foreach ( $c as $key => $data ) - $query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&'; - - $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port); - if ( 'true' == $response[1] ) { - if ( function_exists('wp_set_comment_status') ) - wp_set_comment_status($id, 'spam'); - else - $wpdb->query("UPDATE $wpdb->comments SET comment_approved = 'spam' WHERE comment_ID = $id"); - - } + $remaining = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->commentmeta WHERE meta_key = 'akismet_error'" ) ); + if ( $remaining && !wp_next_scheduled('akismet_schedule_cron_recheck') ) { + wp_schedule_single_event( time() + 1200, 'akismet_schedule_cron_recheck' ); } - wp_redirect( $_SERVER['HTTP_REFERER'] ); - exit; } +add_action( 'akismet_schedule_cron_recheck', 'akismet_cron_recheck' ); -add_action('admin_action_akismet_recheck_queue', 'akismet_recheck_queue'); - -function akismet_check_db_comment( $id ) { - global $wpdb, $akismet_api_host, $akismet_api_port; - - $id = (int) $id; - $c = $wpdb->get_row( "SELECT * FROM $wpdb->comments WHERE comment_ID = '$id'", ARRAY_A ); - if ( !$c ) - return; - - $c['user_ip'] = $c['comment_author_IP']; - $c['user_agent'] = $c['comment_agent']; - $c['referrer'] = ''; - $c['blog'] = get_option('home'); - $c['blog_lang'] = get_locale(); - $c['blog_charset'] = get_option('blog_charset'); - $c['permalink'] = get_permalink($c['comment_post_ID']); - $id = $c['comment_ID']; - - $query_string = ''; - foreach ( $c as $key => $data ) - $query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&'; - - $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port); - return $response[1]; +function akismet_add_comment_nonce( $post_id ) { + echo '

    '; + wp_nonce_field( 'akismet_comment_nonce_' . $post_id, 'akismet_comment_nonce', FALSE ); + echo '

    '; } -// Widget stuff -function widget_akismet_register() { - if ( function_exists('register_sidebar_widget') ) : - function widget_akismet($args) { - extract($args); - $options = get_option('widget_akismet'); - $count = number_format_i18n(get_option('akismet_spam_count')); - ?> - - - - - - - -

    - - - - - - diff --git a/wp-content/plugins/akismet/readme.txt b/wp-content/plugins/akismet/readme.txt index db8234fc..fbd3513b 100644 --- a/wp-content/plugins/akismet/readme.txt +++ b/wp-content/plugins/akismet/readme.txt @@ -1,10 +1,10 @@ === Akismet === -Contributors: matt, ryan, andy, mdawaffe, tellyworth, automattic +Contributors: matt, ryan, andy, mdawaffe, tellyworth, josephscott, lessbloat, automattic Tags: akismet, comments, spam -Requires at least: 2.0 -Tested up to: 3.0 -Stable tag: 2.4.0 -License: GPLv2 +Requires at least: 3.0 +Tested up to: 3.1 +Stable tag: 2.5.3 +License: GPLv2 or later Akismet checks your comments against the Akismet web service to see if they look like spam or not. @@ -13,11 +13,15 @@ Akismet checks your comments against the Akismet web service to see if they look Akismet checks your comments against the Akismet web service to see if they look like spam or not and lets you review the spam it catches under your blog's "Comments" admin screen. -Want to show off how much spam Akismet has caught for you? Just put `` in your template. +Major new features in Akismet 2.5 include: -See also: [WP Stats plugin](http://wordpress.org/extend/plugins/stats/). +* A comment status history, so you can easily see which comments were caught or cleared by Akismet, and which were spammed or unspammed by a moderator +* Links are highlighted in the comment body, to reveal hidden or misleading links +* If your web host is unable to reach Akismet's servers, the plugin will automatically retry when your connection is back up +* Moderators can see the number of approved comments for each user +* Spam and Unspam reports now include more information, to help improve accuracy -PS: You'll need an [Akismet.com API key](http://akismet.com/get/) to use it. +PS: You'll need an [Akismet.com API key](http://akismet.com/get/) to use it. Keys are free for personal blogs, with paid subscriptions available for businesses and commercial sites. == Installation == @@ -27,6 +31,53 @@ Upload the Akismet plugin to your blog, Activate it, then enter your [Akismet.co == Changelog == += 2.5.3 = +* Specify the license is GPL v2 or later +* Fix a bug that could result in orphaned commentmeta entries +* Include hotfix for WordPress 3.0.5 filter issue + += 2.5.2 = + +* Properly format the comment count for author counts +* Look for super admins on multisite installs when looking up user roles +* Increase the HTTP request timeout +* Removed padding for author approved count +* Fix typo in function name +* Set Akismet stats iframe height to fixed 2500px. Better to have one tall scroll bar than two side by side. + += 2.5.1 = + +* Fix a bug that caused the "Auto delete" option to fail to discard comments correctly +* Remove the comment nonce form field from the 'Akismet Configuration' page in favor of using a filter, akismet_comment_nonce +* Fixed padding bug in "author" column of posts screen +* Added margin-top to "cleared by ..." badges on dashboard +* Fix possible error when calling akismet_cron_recheck() +* Fix more PHP warnings +* Clean up XHTML warnings for comment nonce +* Fix for possible condition where scheduled comment re-checks could get stuck +* Clean up the comment meta details after deleting a comment +* Only show the status badge if the comment status has been changed by someone/something other than Akismet +* Show a 'History' link in the row-actions +* Translation fixes +* Reduced font-size on author name +* Moved "flagged by..." notification to top right corner of comment container and removed heavy styling +* Hid "flagged by..." notification while on dashboard + += 2.5.0 = + +* Track comment actions under 'Akismet Status' on the edit comment screen +* Fix a few remaining deprecated function calls ( props Mike Glendinning ) +* Use HTTPS for the stats IFRAME when wp-admin is using HTTPS +* Use the WordPress HTTP class if available +* Move the admin UI code to a separate file, only loaded when needed +* Add cron retry feature, to replace the old connectivity check +* Display Akismet status badge beside each comment +* Record history for each comment, and display it on the edit page +* Record the complete comment as originally submitted in comment_meta, to use when reporting spam and ham +* Highlight links in comment content +* New option, "Show the number of comments you've approved beside each comment author." +* New option, "Use a nonce on the comment form." + = 2.4.0 = * Spell out that the license is GPLv2 diff --git a/wp-content/plugins/akismet/widget.php b/wp-content/plugins/akismet/widget.php new file mode 100644 index 00000000..e9a3f626 --- /dev/null +++ b/wp-content/plugins/akismet/widget.php @@ -0,0 +1,90 @@ + + + + + + + + +

    + + + +
    ', '', $count ), number_format_i18n( $count ) ); +} diff --git a/wp-content/plugins/hello.php b/wp-content/plugins/hello.php index 2877f083..d2287e24 100644 --- a/wp-content/plugins/hello.php +++ b/wp-content/plugins/hello.php @@ -1,14 +1,14 @@ Hello, Dolly in the upper right of your admin screen on every page. Author: Matt Mullenweg -Version: 1.5.1 +Version: 1.6 Author URI: http://ma.tt/ */ @@ -44,10 +44,10 @@ Dolly'll never go away Dolly'll never go away again"; // Here we split it into lines - $lyrics = explode("\n", $lyrics); + $lyrics = explode( "\n", $lyrics ); // And then randomly choose a line - return wptexturize( $lyrics[ mt_rand(0, count($lyrics) - 1) ] ); + return wptexturize( $lyrics[ mt_rand( 0, count( $lyrics ) - 1 ) ] ); } // This just echoes the chosen line, we'll position it later @@ -56,28 +56,27 @@ function hello_dolly() { echo "

    $chosen

    "; } -// Now we set that function up to execute when the admin_footer action is called -add_action('admin_footer', 'hello_dolly'); +// Now we set that function up to execute when the admin_notices action is called +add_action( 'admin_notices', 'hello_dolly' ); // We need some CSS to position the paragraph function dolly_css() { - // This makes sure that the posinioning is also good for right-to-left languages - $x = ( is_rtl() ) ? 'left' : 'right'; + // This makes sure that the positioning is also good for right-to-left languages + $x = is_rtl() ? 'left' : 'right'; echo " "; } -add_action('admin_head', 'dolly_css'); +add_action( 'admin_head', 'dolly_css' ); ?> diff --git a/wp-content/themes/twentyten/archive.php b/wp-content/themes/twentyten/archive.php index 52baaa70..0707e186 100644 --- a/wp-content/themes/twentyten/archive.php +++ b/wp-content/themes/twentyten/archive.php @@ -32,9 +32,9 @@ get_header(); ?> %s', 'twentyten' ), get_the_date() ); ?> - %s', 'twentyten' ), get_the_date('F Y') ); ?> + %s', 'twentyten' ), get_the_date( 'F Y' ) ); ?> - %s', 'twentyten' ), get_the_date('Y') ); ?> + %s', 'twentyten' ), get_the_date( 'Y' ) ); ?> @@ -49,7 +49,7 @@ get_header(); ?> /* Run the loop for the archives page to output the posts. * If you want to overload this in a child theme then include a file - * called loop-archives.php and that will be used instead. + * called loop-archive.php and that will be used instead. */ get_template_part( 'loop', 'archive' ); ?> diff --git a/wp-content/themes/twentyten/attachment.php b/wp-content/themes/twentyten/attachment.php index f805bcdb..5b35936e 100644 --- a/wp-content/themes/twentyten/attachment.php +++ b/wp-content/themes/twentyten/attachment.php @@ -12,105 +12,13 @@ get_header(); ?>
    - - - post_parent ) ) : ?> -

    ← %s', 'twentyten' ), get_the_title( $post->post_parent ) ); - ?>

    - - -
    > -

    - - - -
    -
    - $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID' ) ) ); - foreach ( $attachments as $k => $attachment ) { - if ( $attachment->ID == $post->ID ) - break; - } - $k++; - // If there is more than 1 image attachment in a gallery - if ( count( $attachments ) > 1 ) { - if ( isset( $attachments[ $k ] ) ) - // get the URL of the next image attachment - $next_attachment_url = get_attachment_link( $attachments[ $k ]->ID ); - else - // or get the URL of the first image attachment - $next_attachment_url = get_attachment_link( $attachments[ 0 ]->ID ); - } else { - // or, if there's only 1 image attachment, get the URL of the image - $next_attachment_url = wp_get_attachment_url(); - } -?> -

    ID, array( $attachment_size, 9999 ) ); // filterable image width with, essentially, no limit for image height. - ?>

    - - - - - -
    -
    post_excerpt ) ) the_excerpt(); ?>
    - -→', 'twentyten' ) ); ?> - '' ) ); ?> - -
    - -
    - - ', '' ); ?> -
    -
    - - - - +
    diff --git a/wp-content/themes/twentyten/editor-style.css b/wp-content/themes/twentyten/editor-style.css index 31ea0d5b..7d051355 100644 --- a/wp-content/themes/twentyten/editor-style.css +++ b/wp-content/themes/twentyten/editor-style.css @@ -1,15 +1,13 @@ /* Theme Name: Twenty Ten -*/ -/* -Used to style the TinyMCE editor. +Description: Used to style the TinyMCE editor. */ html .mceContentBody { - max-width:640px; + max-width: 640px; } * { - font-family: Georgia, "Bitstream Charter", serif; color: #444; + font-family: Georgia, "Bitstream Charter", serif; line-height: 1.5; } p, @@ -40,10 +38,10 @@ body, input, textarea { } hr { background-color: #e7e7e7; - border:0; + border: 0; + clear: both; height: 1px; margin-bottom: 18px; - clear:both; } /* Text elements */ p { @@ -58,22 +56,22 @@ ol { margin: 0 0 18px 1.5em; } ol ol { - list-style:upper-alpha; + list-style: upper-alpha; } ol ol ol { - list-style:lower-roman; + list-style: lower-roman; } ol ol ol ol { - list-style:lower-alpha; + list-style: lower-alpha; } ul ul, ol ol, ul ol, ol ul { - margin-bottom:0; + margin-bottom: 0; } dl { - margin:0 0 24px 0; + margin: 0 0 24px 0; } dt { font-weight: bold; @@ -82,20 +80,20 @@ dd { margin-bottom: 18px; } strong { - font-weight: bold; color: #000; + font-weight: bold; } cite, em, i { - font-style: italic; border: none; + font-style: italic; } big { font-size: 131.25%; } ins { - background: #ffffcc; + background: #ffc; border: none; color: #333; } @@ -129,11 +127,11 @@ ins { } sup, sub { + font-size: 10px; height: 0; line-height: 1; - vertical-align: baseline; position: relative; - font-size: 10px; + vertical-align: baseline; } sup { bottom: 1ex; @@ -142,10 +140,10 @@ sub { top: .5ex; } a:link { - color:#0066cc; + color: #06c; } a:visited { - color:#743399; + color: #743399; } a:active, a:hover { @@ -157,13 +155,13 @@ ol, dd, pre, hr { - margin-bottom:24px; + margin-bottom: 24px; } ul ul, ol ol, ul ol, ol ul { - margin-bottom:0; + margin-bottom: 0; } pre, kbd, @@ -188,9 +186,9 @@ h4, h5, h6 { color: #000; - margin: 0 0 20px 0; - line-height: 1.5em; font-weight: normal; + line-height: 1.5em; + margin: 0 0 20px 0; } h1 { font-size: 2.4em; @@ -212,11 +210,11 @@ h6 { } table { border: 1px solid #e7e7e7 !important; - text-align: left; - margin: 0 -1px 24px 0; - width: 100%; border-collapse: collapse; border-spacing: 0; + margin: 0 -1px 24px 0; + text-align: left; + width: 100%; } tr th, thead th { @@ -232,11 +230,15 @@ tr td { border-top: 1px solid #e7e7e7 !important; padding: 6px 24px; } - - img { margin: 0; - max-width: 640px; +} +img.size-auto, +img.size-large, +img.size-full, +img.size-medium { + max-width: 100%; + height: auto; } .alignleft, img.alignleft { @@ -265,18 +267,19 @@ img.aligncenter { margin-bottom: 12px; } .wp-caption { - border: none; background: #f1f1f1; + border: none; + -khtml-border-radius: 0; + -moz-border-radius: 0; + -webkit-border-radius: 0; + border-radius: 0; color: #888; font-size: 12px; line-height: 18px; - text-align: center; margin-bottom: 20px; + max-width: 632px !important; /* prevent too-wide images from breaking layout */ padding: 4px; - -moz-border-radius: 0; - -khtml-border-radius: 0; - -webkit-border-radius: 0; - border-radius: 0; + text-align: center; } .wp-caption img { margin: 5px; @@ -285,5 +288,5 @@ img.aligncenter { margin: 0 0 4px; } .wp-smiley { - margin:0; + margin: 0; } \ No newline at end of file diff --git a/wp-content/themes/twentyten/footer.php b/wp-content/themes/twentyten/footer.php index 61f2d948..6d0d1ab5 100644 --- a/wp-content/themes/twentyten/footer.php +++ b/wp-content/themes/twentyten/footer.php @@ -23,17 +23,14 @@ ?>
    - - - +
    diff --git a/wp-content/themes/twentyten/functions.php b/wp-content/themes/twentyten/functions.php index d7a127a2..36f55066 100644 --- a/wp-content/themes/twentyten/functions.php +++ b/wp-content/themes/twentyten/functions.php @@ -77,6 +77,9 @@ function twentyten_setup() { // This theme styles the visual editor with editor-style.css to match the theme style. add_editor_style(); + // Post Format support. You can also use the legacy "gallery" or "asides" (note the plural) categories. + add_theme_support( 'post-formats', array( 'aside', 'gallery' ) ); + // This theme uses post thumbnails add_theme_support( 'post-thumbnails' ); @@ -101,9 +104,12 @@ function twentyten_setup() { add_custom_background(); // Your changeable header business starts here - define( 'HEADER_TEXTCOLOR', '' ); + if ( ! defined( 'HEADER_TEXTCOLOR' ) ) + define( 'HEADER_TEXTCOLOR', '' ); + // No CSS, just IMG call. The %s is a placeholder for the theme template directory URI. - define( 'HEADER_IMAGE', '%s/images/headers/path.jpg' ); + if ( ! defined( 'HEADER_IMAGE' ) ) + define( 'HEADER_IMAGE', '%s/images/headers/path.jpg' ); // The height and width of your custom header. You can hook into the theme's own filters to change these values. // Add a filter to twentyten_header_image_width and twentyten_header_image_height to change these values. @@ -116,7 +122,8 @@ function twentyten_setup() { set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true ); // Don't support text inside the header image. - define( 'NO_HEADER_TEXT', true ); + if ( ! defined( 'NO_HEADER_TEXT' ) ) + define( 'NO_HEADER_TEXT', true ); // Add a way for the custom header to be styled in the admin panel that controls // custom headers. See twentyten_admin_header_style(), below. @@ -275,15 +282,30 @@ add_filter( 'get_the_excerpt', 'twentyten_custom_excerpt_more' ); /** * Remove inline styles printed when the gallery shortcode is used. * - * Galleries are styled by the theme in Twenty Ten's style.css. + * Galleries are styled by the theme in Twenty Ten's style.css. This is just + * a simple filter call that tells WordPress to not use the default styles. + * + * @since Twenty Ten 1.2 + */ +add_filter( 'use_default_gallery_style', '__return_false' ); + +/** + * Deprecated way to remove inline styles printed when the gallery shortcode is used. + * + * This function is no longer needed or used. Use the use_default_gallery_style + * filter instead, as seen above. * * @since Twenty Ten 1.0 + * @deprecated Deprecated in Twenty Ten 1.2 for WordPress 3.1 + * * @return string The gallery style filter, with the styles themselves removed. */ function twentyten_remove_gallery_css( $css ) { return preg_replace( "##s", '', $css ); } -add_filter( 'gallery_style', 'twentyten_remove_gallery_css' ); +// Backwards compatibility with WordPress 3.0. +if ( version_compare( $GLOBALS['wp_version'], '3.1', '<' ) ) + add_filter( 'gallery_style', 'twentyten_remove_gallery_css' ); if ( ! function_exists( 'twentyten_comment' ) ) : /** @@ -308,7 +330,7 @@ function twentyten_comment( $comment, $args, $depth ) { says:', 'twentyten' ), sprintf( '%s', get_comment_author_link() ) ); ?> comment_approved == '0' ) : ?> - +
    @@ -332,7 +354,7 @@ function twentyten_comment( $comment, $args, $depth ) { case 'trackback' : ?>
  • -

    +

    widgets['WP_Widget_Recent_Comments'], 'recent_comments_style' ) ); + add_filter( 'show_recent_comments_widget_style', '__return_false' ); } add_action( 'widgets_init', 'twentyten_remove_recent_comments_style' ); if ( ! function_exists( 'twentyten_posted_on' ) ) : /** - * Prints HTML with meta information for the current post—date/time and author. + * Prints HTML with meta information for the current post-date/time and author. * * @since Twenty Ten 1.0 */ diff --git a/wp-content/themes/twentyten/header.php b/wp-content/themes/twentyten/header.php index fa4b7279..54971c93 100644 --- a/wp-content/themes/twentyten/header.php +++ b/wp-content/themes/twentyten/header.php @@ -67,13 +67,13 @@ ID ) && ( /* $src, $width, $height */ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'post-thumbnail' ) ) && $image[1] >= HEADER_IMAGE_WIDTH ) : // Houston, we have a new header image! - echo get_the_post_thumbnail( $post->ID, 'post-thumbnail' ); - else : ?> + echo get_the_post_thumbnail( $post->ID ); + elseif ( get_header_image() ) : ?> diff --git a/wp-content/themes/twentyten/index.php b/wp-content/themes/twentyten/index.php index 9f7d240c..7bc3fd46 100644 --- a/wp-content/themes/twentyten/index.php +++ b/wp-content/themes/twentyten/index.php @@ -4,7 +4,7 @@ * * This is the most generic template file in a WordPress theme * and one of the two required files for a theme (the other being style.css). - * It is used to display a page when nothing more specific matches a query. + * It is used to display a page when nothing more specific matches a query. * E.g., it puts together the home page when no home.php file exists. * Learn more: http://codex.wordpress.org/Template_Hierarchy * diff --git a/wp-content/themes/twentyten/languages/twentyten.pot b/wp-content/themes/twentyten/languages/twentyten.pot index 1febb300..403d43e4 100644 --- a/wp-content/themes/twentyten/languages/twentyten.pot +++ b/wp-content/themes/twentyten/languages/twentyten.pot @@ -2,9 +2,9 @@ # This file is distributed under the same license as the Twenty Ten package. msgid "" msgstr "" -"Project-Id-Version: Twenty Ten 1.1\n" +"Project-Id-Version: Twenty Ten 1.2\n" "Report-Msgid-Bugs-To: http://wordpress.org/tag/twentyten\n" -"POT-Creation-Date: 2011-01-01 21:26:51+00:00\n" +"POT-Creation-Date: 2011-02-22 08:27:25+00:00\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -12,17 +12,58 @@ msgstr "" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" -#. #-#-#-#-# twentyten.pot (Twenty Ten 1.1) #-#-#-#-# +#: loop-attachment.php:21 +msgid "Return to %s" +msgstr "" + +#: loop-attachment.php:23 +msgid " %s" +msgstr "" + +#: loop-attachment.php:32 +msgid "By %2$s" +msgstr "" + +#: loop-attachment.php:36 functions.php:476 +msgid "View all posts by %s" +msgstr "" + +#: loop-attachment.php:43 +msgid "Published %2$s" +msgstr "" + +#: loop-attachment.php:53 +msgid "Full size is %s pixels" +msgstr "" + +#: loop-attachment.php:56 +msgid "Link to full-size image" +msgstr "" + +#: loop-attachment.php:63 loop-attachment.php:111 loop.php:100 loop.php:123 +#: loop.php:165 loop-page.php:30 loop-single.php:56 +msgid "Edit" +msgstr "" + +#: loop-attachment.php:104 loop.php:115 loop.php:143 functions.php:248 +msgid "Continue reading " +msgstr "" + +#: loop-attachment.php:105 loop.php:144 loop-page.php:29 loop-single.php:34 +msgid "Pages:" +msgstr "" + +#. #-#-#-#-# twentyten.pot (Twenty Ten 1.2) #-#-#-#-# #. Theme URI of the plugin/theme #: footer.php:33 msgid "http://wordpress.org/" msgstr "" -#: footer.php:34 +#: footer.php:33 msgid "Semantic Personal Publishing Platform" msgstr "" -#: footer.php:35 +#: footer.php:33 msgid "Proudly powered by %s." msgstr "" @@ -75,11 +116,11 @@ msgid "" "will help." msgstr "" -#: loop.php:25 loop.php:173 +#: loop.php:25 loop.php:178 msgid " Older posts" msgstr "" -#: loop.php:26 loop.php:174 +#: loop.php:26 loop.php:179 msgid "Newer posts " msgstr "" @@ -89,193 +130,181 @@ msgid "" "searching will help find a related post." msgstr "" -#: loop.php:60 loop.php:92 +#: loop.php:60 loop.php:95 loop.php:96 msgctxt "gallery category slug" msgid "gallery" msgstr "" -#: loop.php:62 loop.php:83 loop.php:126 +#: loop.php:62 loop.php:83 loop.php:131 msgid "Permalink to %s" msgstr "" #: loop.php:82 -msgid "This gallery contains %2$s photos." -msgstr "" +msgid "This gallery contains %2$s photo." +msgid_plural "This gallery contains %2$s photos." +msgstr[0] "" +msgstr[1] "" -#: loop.php:92 -msgid "View posts in the Gallery category" +#: loop.php:93 +msgid "View Galleries" msgstr "" -#: loop.php:92 +#: loop.php:93 loop.php:96 msgid "More Galleries" msgstr "" -#: loop.php:94 loop.php:117 loop.php:159 +#: loop.php:96 +msgid "View posts in the Gallery category" +msgstr "" + +#: loop.php:99 loop.php:122 loop.php:164 msgid "Leave a comment" msgstr "" -#: loop.php:94 loop.php:117 loop.php:159 +#: loop.php:99 loop.php:122 loop.php:164 msgid "1 Comment" msgstr "" -#: loop.php:94 loop.php:117 loop.php:159 +#: loop.php:99 loop.php:122 loop.php:164 msgid "% Comments" msgstr "" -#: loop.php:95 loop.php:118 loop.php:160 page.php:32 attachment.php:60 -#: attachment.php:107 onecolumn-page.php:27 single.php:53 -msgid "Edit" -msgstr "" - -#: loop.php:101 +#: loop.php:106 msgctxt "asides category slug" msgid "asides" msgstr "" -#: loop.php:110 loop.php:138 functions.php:241 attachment.php:100 -msgid "Continue reading " -msgstr "" - -#: loop.php:139 page.php:31 attachment.php:101 onecolumn-page.php:26 -#: single.php:31 -msgid "Pages:" -msgstr "" - -#: loop.php:146 +#: loop.php:151 msgid "Posted in %2$s" msgstr "" -#: loop.php:155 +#: loop.php:160 msgid "Tagged %2$s" msgstr "" -#: functions.php:97 +#: functions.php:100 msgid "Primary Navigation" msgstr "" -#: functions.php:133 +#: functions.php:140 msgid "Berries" msgstr "" -#: functions.php:139 +#: functions.php:146 msgid "Cherry Blossoms" msgstr "" -#: functions.php:145 +#: functions.php:152 msgid "Concave" msgstr "" -#: functions.php:151 +#: functions.php:158 msgid "Fern" msgstr "" -#: functions.php:157 +#: functions.php:164 msgid "Forest Floor" msgstr "" -#: functions.php:163 +#: functions.php:170 msgid "Inkwell" msgstr "" -#: functions.php:169 +#: functions.php:176 msgid "Path" msgstr "" -#: functions.php:175 +#: functions.php:182 msgid "Sunset" msgstr "" -#: functions.php:308 +#: functions.php:330 msgid "%s says:" msgstr "" -#: functions.php:311 +#: functions.php:333 msgid "Your comment is awaiting moderation." msgstr "" -#: functions.php:318 +#: functions.php:340 msgid "%1$s at %2$s" msgstr "" -#: functions.php:318 functions.php:335 +#: functions.php:340 functions.php:357 msgid "(Edit)" msgstr "" -#: functions.php:335 +#: functions.php:357 msgid "Pingback:" msgstr "" -#: functions.php:354 +#: functions.php:376 msgid "Primary Widget Area" msgstr "" -#: functions.php:356 +#: functions.php:378 msgid "The primary widget area" msgstr "" -#: functions.php:365 +#: functions.php:387 msgid "Secondary Widget Area" msgstr "" -#: functions.php:367 +#: functions.php:389 msgid "The secondary widget area" msgstr "" -#: functions.php:376 +#: functions.php:398 msgid "First Footer Widget Area" msgstr "" -#: functions.php:378 +#: functions.php:400 msgid "The first footer widget area" msgstr "" -#: functions.php:387 +#: functions.php:409 msgid "Second Footer Widget Area" msgstr "" -#: functions.php:389 +#: functions.php:411 msgid "The second footer widget area" msgstr "" -#: functions.php:398 +#: functions.php:420 msgid "Third Footer Widget Area" msgstr "" -#: functions.php:400 +#: functions.php:422 msgid "The third footer widget area" msgstr "" -#: functions.php:409 +#: functions.php:431 msgid "Fourth Footer Widget Area" msgstr "" -#: functions.php:411 +#: functions.php:433 msgid "The fourth footer widget area" msgstr "" -#: functions.php:442 +#: functions.php:467 msgid "" "Posted on %2$s by %3$s" msgstr "" -#: functions.php:451 attachment.php:33 -msgid "View all posts by %s" -msgstr "" - -#: functions.php:468 +#: functions.php:493 msgid "" "This entry was posted in %1$s and tagged %2$s. Bookmark the permalink." msgstr "" -#: functions.php:470 +#: functions.php:495 msgid "" "This entry was posted in %1$s. Bookmark the permalink." msgstr "" -#: functions.php:472 +#: functions.php:497 msgid "" "Bookmark the permalink." @@ -293,34 +322,10 @@ msgstr "" msgid "Author Archives: %s" msgstr "" -#: author.php:37 single.php:40 +#: author.php:37 loop-single.php:43 msgid "About %s" msgstr "" -#: attachment.php:18 -msgid "Return to %s" -msgstr "" - -#: attachment.php:20 -msgid " %s" -msgstr "" - -#: attachment.php:29 -msgid "By %2$s" -msgstr "" - -#: attachment.php:40 -msgid "Published %2$s" -msgstr "" - -#: attachment.php:50 -msgid "Full size is %s pixels" -msgstr "" - -#: attachment.php:53 -msgid "Link to full-size image" -msgstr "" - #: search.php:16 msgid "Search Results for: %s" msgstr "" @@ -335,6 +340,20 @@ msgid "" "different keywords." msgstr "" +#: loop-single.php:21 loop-single.php:61 +msgctxt "Previous post link" +msgid "←" +msgstr "" + +#: loop-single.php:22 loop-single.php:62 +msgctxt "Next post link" +msgid "→" +msgstr "" + +#: loop-single.php:47 +msgid "View all posts by %s " +msgstr "" + #: archive.php:33 msgid "Daily Archives: %s" msgstr "" @@ -351,20 +370,6 @@ msgstr "" msgid "Blog Archives" msgstr "" -#: single.php:18 single.php:58 -msgctxt "Previous post link" -msgid "←" -msgstr "" - -#: single.php:19 single.php:59 -msgctxt "Next post link" -msgid "→" -msgstr "" - -#: single.php:44 -msgid "View all posts by %s " -msgstr "" - #. Theme Name of the plugin/theme msgid "Twenty Ten" msgstr "" @@ -389,5 +394,5 @@ msgstr "" msgid "" "black, blue, white, two-columns, fixed-width, custom-header, custom-" "background, threaded-comments, sticky-post, translation-ready, microformats, " -"rtl-language-support, editor-style" +"rtl-language-support, editor-style, custom-menu" msgstr "" diff --git a/wp-content/themes/twentyten/loop-attachment.php b/wp-content/themes/twentyten/loop-attachment.php new file mode 100644 index 00000000..20794fba --- /dev/null +++ b/wp-content/themes/twentyten/loop-attachment.php @@ -0,0 +1,117 @@ + + + + + post_parent ) ) : ?> +

    ← %s', 'twentyten' ), get_the_title( $post->post_parent ) ); + ?>

    + + +
    > +

    + + + +
    +
    + $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID' ) ) ); + foreach ( $attachments as $k => $attachment ) { + if ( $attachment->ID == $post->ID ) + break; + } + $k++; + // If there is more than 1 image attachment in a gallery + if ( count( $attachments ) > 1 ) { + if ( isset( $attachments[ $k ] ) ) + // get the URL of the next image attachment + $next_attachment_url = get_attachment_link( $attachments[ $k ]->ID ); + else + // or get the URL of the first image attachment + $next_attachment_url = get_attachment_link( $attachments[ 0 ]->ID ); + } else { + // or, if there's only 1 image attachment, get the URL of the image + $next_attachment_url = wp_get_attachment_url(); + } +?> +

    ID, array( $attachment_width, $attachment_height ) ); // filterable image width with, essentially, no limit for image height. + ?>

    + + + + + +
    +
    post_excerpt ) ) the_excerpt(); ?>
    + +→', 'twentyten' ) ); ?> + '' ) ); ?> + +
    + +
    + + ', '' ); ?> +
    +
    + + + + \ No newline at end of file diff --git a/wp-content/themes/twentyten/loop-page.php b/wp-content/themes/twentyten/loop-page.php new file mode 100644 index 00000000..252a1d0e --- /dev/null +++ b/wp-content/themes/twentyten/loop-page.php @@ -0,0 +1,36 @@ + + + + +
    > + +

    + +

    + + +
    + + '' ) ); ?> + ', '' ); ?> +
    +
    + + + + \ No newline at end of file diff --git a/wp-content/themes/twentyten/loop-single.php b/wp-content/themes/twentyten/loop-single.php new file mode 100644 index 00000000..50860e24 --- /dev/null +++ b/wp-content/themes/twentyten/loop-single.php @@ -0,0 +1,67 @@ + + + + + + +
    > +

    + + + +
    + + '' ) ); ?> +
    + + +
    +
    + +
    + +
    + + +
    + + ', '' ); ?> +
    +
    + + + + + + \ No newline at end of file diff --git a/wp-content/themes/twentyten/loop.php b/wp-content/themes/twentyten/loop.php index c0d746f3..9dc6297d 100644 --- a/wp-content/themes/twentyten/loop.php +++ b/wp-content/themes/twentyten/loop.php @@ -55,9 +55,9 @@ */ ?> - + - + ID ) ) || in_category( _x( 'gallery', 'gallery category slug', 'twentyten' ) ) ) : ?>
    >

    @@ -68,8 +68,8 @@
    - - + $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order', 'order' => 'ASC', 'numberposts' => 999 ) ); if ( $images ) : $total_images = count( $images ); @@ -79,9 +79,9 @@ -

    %2$s photos.', 'twentyten' ), +

    %2$s photo.', 'This gallery contains %2$s photos.', $total_images, 'twentyten' ), 'href="' . get_permalink() . '" title="' . sprintf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ) . '" rel="bookmark"', - $total_images + number_format_i18n( $total_images ) ); ?>

    @@ -89,16 +89,21 @@
    - + ID ) ) : ?> + + | + + | + | ', '' ); ?>
    - + - + ID ) ) || in_category( _x( 'asides', 'asides category slug', 'twentyten' ) ) ) : ?>
    > diff --git a/wp-content/themes/twentyten/onecolumn-page.php b/wp-content/themes/twentyten/onecolumn-page.php index 90b1abf3..1a8d5b7e 100644 --- a/wp-content/themes/twentyten/onecolumn-page.php +++ b/wp-content/themes/twentyten/onecolumn-page.php @@ -17,20 +17,13 @@ get_header(); ?>
    - - -
    > -

    -
    - - '' ) ); ?> - ', '' ); ?> -
    -
    - - - - +
    diff --git a/wp-content/themes/twentyten/page.php b/wp-content/themes/twentyten/page.php index a6081c80..1a550423 100644 --- a/wp-content/themes/twentyten/page.php +++ b/wp-content/themes/twentyten/page.php @@ -17,25 +17,13 @@ get_header(); ?>
    - - -
    > - -

    - -

    - - -
    - - '' ) ); ?> - ', '' ); ?> -
    -
    - - - - +
    diff --git a/wp-content/themes/twentyten/rtl.css b/wp-content/themes/twentyten/rtl.css index 4ae54e4d..339e6e52 100644 --- a/wp-content/themes/twentyten/rtl.css +++ b/wp-content/themes/twentyten/rtl.css @@ -94,7 +94,7 @@ input[type=submit] { -------------------------------------------------------------- */ /* Text elements */ -ul { +ul, ol { margin: 0 1.5em 18px 0; } blockquote { @@ -120,6 +120,9 @@ blockquote { float: left; font-style: normal; } +#branding img { + float: right; +} /* =Menu -------------------------------------------------------------- */ diff --git a/wp-content/themes/twentyten/sidebar.php b/wp-content/themes/twentyten/sidebar.php index 7e2565b8..8a1664f3 100644 --- a/wp-content/themes/twentyten/sidebar.php +++ b/wp-content/themes/twentyten/sidebar.php @@ -18,7 +18,7 @@ * some default sidebar stuff just in case. */ if ( ! dynamic_sidebar( 'primary-widget-area' ) ) : ?> - +
  • diff --git a/wp-content/themes/twentyten/single.php b/wp-content/themes/twentyten/single.php index f97fd460..a0dea11f 100644 --- a/wp-content/themes/twentyten/single.php +++ b/wp-content/themes/twentyten/single.php @@ -12,56 +12,13 @@ get_header(); ?>
    - - - - -
    > -

    - - - -
    - - '' ) ); ?> -
    - - -
    -
    - -
    - -
    - - -
    - - ', '' ); ?> -
    -
    - - - - - - +
    diff --git a/wp-content/themes/twentyten/style.css b/wp-content/themes/twentyten/style.css index 5dbf6317..ee5d61d4 100644 --- a/wp-content/themes/twentyten/style.css +++ b/wp-content/themes/twentyten/style.css @@ -3,8 +3,10 @@ Theme Name: Twenty Ten Theme URI: http://wordpress.org/ Description: The 2010 theme for WordPress is stylish, customizable, simple, and readable -- make it yours with a custom menu, header image, and background. Twenty Ten supports six widgetized areas (two in the sidebar, four in the footer) and featured images (thumbnails for gallery posts and custom header images for posts and pages). It includes stylesheets for print and the admin Visual Editor, special styles for posts in the "Asides" and "Gallery" categories, and has an optional one-column page template that removes the sidebar. Author: the WordPress team -Version: 1.1 -Tags: black, blue, white, two-columns, fixed-width, custom-header, custom-background, threaded-comments, sticky-post, translation-ready, microformats, rtl-language-support, editor-style +Version: 1.2 +License: GNU General Public License +License URI: license.txt +Tags: black, blue, white, two-columns, fixed-width, custom-header, custom-background, threaded-comments, sticky-post, translation-ready, microformats, rtl-language-support, editor-style, custom-menu */ @@ -139,7 +141,9 @@ h3#reply-title, .pingback p, .reply, .widget-title, -.wp-caption-text, +.wp-caption-text { + font-family: "Helvetica Neue", Arial, Helvetica, "Nimbus Sans L", sans-serif; +} input[type=submit] { font-family: "Helvetica Neue", Arial, Helvetica, "Nimbus Sans L", sans-serif; } @@ -350,7 +354,7 @@ a:hover { clear: right; float: right; font-style: italic; - margin: 14px 0 18px 0; + margin: 15px 0 18px 0; width: 220px; } @@ -358,8 +362,8 @@ a:hover { #branding img { border-top: 4px solid #000; border-bottom: 1px solid #000; - clear: both; display: block; + float: left; } @@ -636,6 +640,7 @@ div.menu li { width: 33%; } .page-link { + clear: both; color: #000; font-weight: bold; margin: 0 0 22px 0; @@ -710,15 +715,18 @@ body.page .edit-link { /* =Asides -------------------------------------------------------------- */ +.home #content .format-aside p, .home #content .category-asides p { font-size: 14px; line-height: 20px; margin-bottom: 10px; margin-top: 0; } +.home .hentry.format-aside, .home .hentry.category-asides { padding: 0; } +.home #content .format-aside .entry-content, .home #content .category-asides .entry-content { padding-top: 0; } @@ -727,15 +735,18 @@ body.page .edit-link { /* =Gallery listing -------------------------------------------------------------- */ +.format-gallery .size-thumbnail img, .category-gallery .size-thumbnail img { border: 10px solid #f1f1f1; margin-bottom: 0; } +.format-gallery .gallery-thumb, .category-gallery .gallery-thumb { float: left; margin-right: 20px; margin-top: -4px; } +.home #content .format-gallery .entry-utility, .home #content .category-gallery .entry-utility { padding-top: 4px; } @@ -759,86 +770,105 @@ body.page .edit-link { /* =Images -------------------------------------------------------------- */ -#content img { - margin: 0; - height: auto; - max-width: 640px; - width: auto; -} -#content .attachment img { - max-width: 900px; -} -#content .alignleft, -#content img.alignleft { +/* +Resize images to fit the main content area. +- Applies only to images uploaded via WordPress by targeting size-* classes. +- Other images will be left alone. Use "size-auto" class to apply to other images. +*/ +img.size-auto, +img.size-full, +img.size-large, +img.size-medium, +.attachment img { + max-width: 100%; /* When images are too wide for containing element, force them to fit. */ + height: auto; /* Override height to match resized width for correct aspect ratio. */ +} +.alignleft, +img.alignleft { display: inline; float: left; margin-right: 24px; margin-top: 4px; } -#content .alignright, -#content img.alignright { +.alignright, +img.alignright { display: inline; float: right; margin-left: 24px; margin-top: 4px; } -#content .aligncenter, -#content img.aligncenter { +.aligncenter, +img.aligncenter { clear: both; display: block; margin-left: auto; margin-right: auto; } -#content img.alignleft, -#content img.alignright, -#content img.aligncenter { +img.alignleft, +img.alignright, +img.aligncenter { margin-bottom: 12px; } -#content .wp-caption { +.wp-caption { background: #f1f1f1; line-height: 18px; margin-bottom: 20px; + max-width: 632px !important; /* prevent too-wide images from breaking layout */ padding: 4px; text-align: center; } -#content .wp-caption img { +.wp-caption img { margin: 5px 5px 0; } -#content .wp-caption p.wp-caption-text { +.wp-caption p.wp-caption-text { color: #888; font-size: 12px; margin: 5px; } -#content .wp-smiley { +.wp-smiley { margin: 0; } -#content .gallery { +.gallery { margin: 0 auto 18px; } -#content .gallery .gallery-item { +.gallery .gallery-item { float: left; margin-top: 0; text-align: center; width: 33%; } -#content .gallery img { +.gallery-columns-2 .gallery-item { + width: 50%; +} +.gallery-columns-4 .gallery-item { + width: 25%; +} +.gallery img { border: 2px solid #cfcfcf; } -#content .gallery .gallery-caption { +.gallery-columns-2 .attachment-medium { + max-width: 92%; + height: auto; +} +.gallery-columns-4 .attachment-thumbnail { + max-width: 84%; + height: auto; +} +.gallery .gallery-caption { color: #888; font-size: 12px; margin: 0 0 12px; } -#content .gallery dl { +.gallery dl { margin: 0; } -#content .gallery img { +.gallery img { border: 10px solid #f1f1f1; } -#content .gallery br+br { +.gallery br+br { display: none; } -#content .attachment img { /* single attachment images should be centered */ +#content .attachment img {/* single attachment images should be centered */ display: block; margin: 0 auto; } @@ -1087,6 +1117,9 @@ h3#reply-title { list-style: square; margin-left: 1.3em; } +.widget-area select { + max-width: 100%; +} .widget_search #s {/* This keeps the search inputs in line */ width: 60%; } diff --git a/wp-feed.php b/wp-feed.php index 24cd8d67..afce8cd4 100644 --- a/wp-feed.php +++ b/wp-feed.php @@ -8,5 +8,5 @@ require( './wp-load.php' ); wp_redirect( get_bloginfo( get_default_feed() . '_url' ), 301 ); - -?> \ No newline at end of file +exit; +?> diff --git a/wp-includes/admin-bar.php b/wp-includes/admin-bar.php new file mode 100644 index 00000000..a3f84ad5 --- /dev/null +++ b/wp-includes/admin-bar.php @@ -0,0 +1,378 @@ +initialize(); + $wp_admin_bar->add_menus(); + + return true; +} +add_action( 'init', '_wp_admin_bar_init' ); // Don't remove. Wrong way to disable. + +/** + * Render the admin bar to the page based on the $wp_admin_bar->menu member var. + * This is called very late on the footer actions so that it will render after anything else being + * added to the footer. + * + * It includes the action "admin_bar_menu" which should be used to hook in and + * add new menus to the admin bar. That way you can be sure that you are adding at most optimal point, + * right before the admin bar is rendered. This also gives you access to the $post global, among others. + * + * @since 3.1.0 + */ +function wp_admin_bar_render() { + global $wp_admin_bar; + + if ( ! is_admin_bar_showing() || ! is_object( $wp_admin_bar ) ) + return false; + + $wp_admin_bar->load_user_locale_translations(); + + do_action_ref_array( 'admin_bar_menu', array( &$wp_admin_bar ) ); + + do_action( 'wp_before_admin_bar_render' ); + + $wp_admin_bar->render(); + + do_action( 'wp_after_admin_bar_render' ); + + $wp_admin_bar->unload_user_locale_translations(); +} +add_action( 'wp_footer', 'wp_admin_bar_render', 1000 ); +add_action( 'admin_footer', 'wp_admin_bar_render', 1000 ); + +/** + * Add the "My Account" menu and all submenus. + * + * @since 3.1.0 + */ +function wp_admin_bar_my_account_menu() { + global $wp_admin_bar, $user_identity; + + $user_id = get_current_user_id(); + + if ( 0 != $user_id ) { + /* Add the 'My Account' menu */ + $avatar = get_avatar( get_current_user_id(), 16 ); + $id = ( ! empty( $avatar ) ) ? 'my-account-with-avatar' : 'my-account'; + + $wp_admin_bar->add_menu( array( 'id' => $id, 'title' => $avatar . $user_identity, 'href' => get_edit_profile_url( $user_id ) ) ); + + /* Add the "My Account" sub menus */ + $wp_admin_bar->add_menu( array( 'parent' => $id, 'title' => __( 'Edit My Profile' ), 'href' => get_edit_profile_url( $user_id ) ) ); + if ( is_multisite() ) + $wp_admin_bar->add_menu( array( 'parent' => $id, 'title' => __( 'Dashboard' ), 'href' => get_dashboard_url( $user_id ) ) ); + else + $wp_admin_bar->add_menu( array( 'parent' => $id, 'title' => __( 'Dashboard' ), 'href' => admin_url() ) ); + $wp_admin_bar->add_menu( array( 'parent' => $id, 'title' => __( 'Log Out' ), 'href' => wp_logout_url() ) ); + } +} + +/** + * Add the "My Sites/[Site Name]" menu and all submenus. + * + * @since 3.1.0 + */ +function wp_admin_bar_my_sites_menu() { + global $wpdb, $wp_admin_bar; + + /* Add the 'My Sites' menu if the user has more than one site. */ + if ( count( $wp_admin_bar->user->blogs ) <= 1 ) + return; + + $wp_admin_bar->add_menu( array( 'id' => 'my-blogs', 'title' => __( 'My Sites' ), 'href' => admin_url( 'my-sites.php' ) ) ); + + $default = includes_url('images/wpmini-blue.png'); + + foreach ( (array) $wp_admin_bar->user->blogs as $blog ) { + // @todo Replace with some favicon lookup. + //$blavatar = 'Blavatar'; + $blavatar = '' . esc_attr__( 'Blavatar' ) . ''; + + $blogname = empty( $blog->blogname ) ? $blog->domain : $blog->blogname; + + $wp_admin_bar->add_menu( array( 'parent' => 'my-blogs', 'id' => 'blog-' . $blog->userblog_id, 'title' => $blavatar . $blogname, 'href' => get_admin_url($blog->userblog_id) ) ); + $wp_admin_bar->add_menu( array( 'parent' => 'blog-' . $blog->userblog_id, 'id' => 'blog-' . $blog->userblog_id . '-d', 'title' => __( 'Dashboard' ), 'href' => get_admin_url($blog->userblog_id) ) ); + + if ( current_user_can_for_blog( $blog->userblog_id, 'edit_posts' ) ) { + $wp_admin_bar->add_menu( array( 'parent' => 'blog-' . $blog->userblog_id, 'id' => 'blog-' . $blog->userblog_id . '-n', 'title' => __( 'New Post' ), 'href' => get_admin_url($blog->userblog_id, 'post-new.php') ) ); + $wp_admin_bar->add_menu( array( 'parent' => 'blog-' . $blog->userblog_id, 'id' => 'blog-' . $blog->userblog_id . '-c', 'title' => __( 'Manage Comments' ), 'href' => get_admin_url($blog->userblog_id, 'edit-comments.php') ) ); + } + + $wp_admin_bar->add_menu( array( 'parent' => 'blog-' . $blog->userblog_id, 'id' => 'blog-' . $blog->userblog_id . '-v', 'title' => __( 'Visit Site' ), 'href' => get_home_url($blog->userblog_id) ) ); + } +} + +/** + * Provide a shortlink. + * + * @since 3.1.0 + */ +function wp_admin_bar_shortlink_menu() { + global $wp_admin_bar; + + $short = wp_get_shortlink( 0, 'query' ); + $id = 'get-shortlink'; + + if ( empty( $short ) ) + return; + + $html = ''; + + $wp_admin_bar->add_menu( array( + 'id' => $id, + 'title' => __( 'Shortlink' ), + 'href' => $short, + 'meta' => array( 'html' => $html ), + ) ); +} + +/** + * Provide an edit link for posts and terms. + * + * @since 3.1.0 + */ +function wp_admin_bar_edit_menu () { + global $wp_admin_bar; + + $current_object = get_queried_object(); + + if ( empty($current_object) ) + return; + + if ( ! empty( $current_object->post_type ) && ( $post_type_object = get_post_type_object( $current_object->post_type ) ) && current_user_can( $post_type_object->cap->edit_post, $current_object->ID ) && $post_type_object->show_ui ) { + $wp_admin_bar->add_menu( array( 'id' => 'edit', 'title' => $post_type_object->labels->edit_item, 'href' => get_edit_post_link( $current_object->ID ) ) ); + } elseif ( ! empty( $current_object->taxonomy ) && ( $tax = get_taxonomy( $current_object->taxonomy ) ) && current_user_can( $tax->cap->edit_terms ) && $tax->show_ui ) { + $wp_admin_bar->add_menu( array( 'id' => 'edit', 'title' => $tax->labels->edit_item, 'href' => get_edit_term_link( $current_object->term_id, $current_object->taxonomy ) ) ); + } +} + +/** + * Add "Add New" menu. + * + * @since 3.1.0 + */ +function wp_admin_bar_new_content_menu() { + global $wp_admin_bar; + + $actions = array(); + foreach ( (array) get_post_types( array( 'show_ui' => true ), 'objects' ) as $ptype_obj ) { + if ( true !== $ptype_obj->show_in_menu || ! current_user_can( $ptype_obj->cap->edit_posts ) ) + continue; + + $actions[ 'post-new.php?post_type=' . $ptype_obj->name ] = array( $ptype_obj->labels->singular_name, $ptype_obj->cap->edit_posts, 'new-' . $ptype_obj->name ); + } + + if ( empty( $actions ) ) + return; + + $wp_admin_bar->add_menu( array( 'id' => 'new-content', 'title' => _x( 'Add New', 'admin bar menu group label' ), 'href' => admin_url( array_shift( array_keys( $actions ) ) ) ) ); + + foreach ( $actions as $link => $action ) { + $wp_admin_bar->add_menu( array( 'parent' => 'new-content', 'id' => $action[2], 'title' => $action[0], 'href' => admin_url($link) ) ); + } +} + +/** + * Add edit comments link with awaiting moderation count bubble. + * + * @since 3.1.0 + */ +function wp_admin_bar_comments_menu() { + global $wp_admin_bar; + + if ( !current_user_can('edit_posts') ) + return; + + $awaiting_mod = wp_count_comments(); + $awaiting_mod = $awaiting_mod->moderated; + + $awaiting_mod = $awaiting_mod ? "" . number_format_i18n( $awaiting_mod ) . "" : ''; + $wp_admin_bar->add_menu( array( 'id' => 'comments', 'title' => sprintf( __('Comments %s'), $awaiting_mod ), 'href' => admin_url('edit-comments.php') ) ); +} + +/** + * Add "Appearance" menu with widget and nav menu submenu. + * + * @since 3.1.0 + */ +function wp_admin_bar_appearance_menu() { + global $wp_admin_bar; + + if ( !current_user_can('switch_themes') ) + return; + + $wp_admin_bar->add_menu( array( 'id' => 'appearance', 'title' => __('Appearance'), 'href' => admin_url('themes.php') ) ); + + if ( !current_user_can('edit_theme_options') ) + return; + + if ( current_theme_supports( 'widgets' ) ) + $wp_admin_bar->add_menu( array( 'parent' => 'appearance', 'id' => 'widgets', 'title' => __('Widgets'), 'href' => admin_url('widgets.php') ) ); + + if ( current_theme_supports( 'menus' ) || current_theme_supports( 'widgets' ) ) + $wp_admin_bar->add_menu( array( 'parent' => 'appearance', 'id' => 'menus', 'title' => __('Menus'), 'href' => admin_url('nav-menus.php') ) ); +} + +/** + * Provide an update link if theme/plugin/core updates are available. + * + * @since 3.1.0 + */ +function wp_admin_bar_updates_menu() { + global $wp_admin_bar; + + if ( !current_user_can('install_plugins') ) + return; + + $plugin_update_count = $theme_update_count = $wordpress_update_count = 0; + $update_plugins = get_site_transient( 'update_plugins' ); + if ( !empty($update_plugins->response) ) + $plugin_update_count = count( $update_plugins->response ); + $update_themes = get_site_transient( 'update_themes' ); + if ( !empty($update_themes->response) ) + $theme_update_count = count( $update_themes->response ); + /* @todo get_core_updates() is only available on admin page loads + $update_wordpress = get_core_updates( array('dismissed' => false) ); + if ( !empty($update_wordpress) && !in_array( $update_wordpress[0]->response, array('development', 'latest') ) ) + $wordpress_update_count = 1; + */ + + $update_count = $plugin_update_count + $theme_update_count + $wordpress_update_count; + + if ( !$update_count ) + return; + + $update_title = array(); + if ( $wordpress_update_count ) + $update_title[] = sprintf(__('%d WordPress Update'), $wordpress_update_count); + if ( $plugin_update_count ) + $update_title[] = sprintf(_n('%d Plugin Update', '%d Plugin Updates', $plugin_update_count), $plugin_update_count); + if ( $theme_update_count ) + $update_title[] = sprintf(_n('%d Theme Update', '%d Themes Updates', $theme_update_count), $theme_update_count); + + $update_title = !empty($update_title) ? esc_attr(implode(', ', $update_title)) : ''; + + $update_title = ""; + $update_title .= sprintf( __('Updates %s'), "" . number_format_i18n($update_count) . '' ); + $update_title .= ''; + + $wp_admin_bar->add_menu( array( 'id' => 'updates', 'title' => $update_title, 'href' => network_admin_url( 'update-core.php' ) ) ); +} + +/** + * Style and scripts for the admin bar. + * + * @since 3.1.0 + * + */ +function wp_admin_bar_header() { ?> + + + + \ No newline at end of file diff --git a/wp-includes/author-template.php b/wp-includes/author-template.php index bc44349f..641b69d4 100644 --- a/wp-includes/author-template.php +++ b/wp-includes/author-template.php @@ -102,6 +102,8 @@ function get_the_author_meta($field = '', $user_id = false) { else $authordata = get_userdata( $user_id ); + // Keys used as object vars cannot have dashes. + $field = str_replace('-', '', $field); $field = strtolower($field); $user_field = "user_$field"; @@ -211,7 +213,7 @@ function the_author_posts_link($deprecated = '') { } /** - * Retrieve the URL to the author page of the author of the current post. + * Retrieve the URL to the author page for the user with the ID provided. * * @since 2.1.0 * @uses $wp_rewrite WP_Rewrite @@ -223,7 +225,7 @@ function get_author_posts_url($author_id, $author_nicename = '') { $link = $wp_rewrite->get_author_permastruct(); if ( empty($link) ) { - $file = home_url() . '/'; + $file = home_url( '/' ); $link = $file . '?author=' . $auth_ID; } else { if ( '' == $author_nicename ) { @@ -232,7 +234,7 @@ function get_author_posts_url($author_id, $author_nicename = '') { $author_nicename = $user->user_nicename; } $link = str_replace('%author%', $author_nicename, $link); - $link = home_url() . trailingslashit($link); + $link = home_url( user_trailingslashit( $link ) ); } $link = apply_filters('author_link', $link, $author_id, $author_nicename); @@ -257,7 +259,7 @@ function get_author_posts_url($author_id, $author_nicename = '') { * echoing. *
  • style (string) ('list'): Whether to display list of authors in list form * or as a string.
  • - *
  • html (bool) (true): Whether to list the items in html for or plaintext. + *
  • html (bool) (true): Whether to list the items in html form or plaintext. *
  • * * @@ -270,101 +272,97 @@ function wp_list_authors($args = '') { global $wpdb; $defaults = array( + 'orderby' => 'name', 'order' => 'ASC', 'number' => '', 'optioncount' => false, 'exclude_admin' => true, 'show_fullname' => false, 'hide_empty' => true, 'feed' => '', 'feed_image' => '', 'feed_type' => '', 'echo' => true, 'style' => 'list', 'html' => true ); - $r = wp_parse_args( $args, $defaults ); - extract($r, EXTR_SKIP); + $args = wp_parse_args( $args, $defaults ); + extract( $args, EXTR_SKIP ); + $return = ''; - /** @todo Move select to get_authors(). */ - $users = get_users_of_blog(); - $author_ids = array(); - foreach ( (array) $users as $user ) - $author_ids[] = $user->user_id; - if ( count($author_ids) > 0 ) { - $author_ids = implode(',', $author_ids ); - $authors = $wpdb->get_results( "SELECT ID, user_nicename from $wpdb->users WHERE ID IN($author_ids) " . ($exclude_admin ? "AND user_login <> 'admin' " : '') . "ORDER BY display_name" ); - } else { - $authors = array(); - } + $query_args = wp_array_slice_assoc( $args, array( 'orderby', 'order', 'number' ) ); + $query_args['fields'] = 'ids'; + $authors = get_users( $query_args ); $author_count = array(); foreach ( (array) $wpdb->get_results("SELECT DISTINCT post_author, COUNT(ID) AS count FROM $wpdb->posts WHERE post_type = 'post' AND " . get_private_posts_cap_sql( 'post' ) . " GROUP BY post_author") as $row ) $author_count[$row->post_author] = $row->count; - foreach ( (array) $authors as $author ) { + foreach ( $authors as $author_id ) { + $author = get_userdata( $author_id ); - $link = ''; + if ( $exclude_admin && 'admin' == $author->display_name ) + continue; - $author = get_userdata( $author->ID ); - $posts = (isset($author_count[$author->ID])) ? $author_count[$author->ID] : 0; - $name = $author->display_name; + $posts = isset( $author_count[$author->ID] ) ? $author_count[$author->ID] : 0; - if ( $show_fullname && ($author->first_name != '' && $author->last_name != '') ) + if ( !$posts && $hide_empty ) + continue; + + $link = ''; + + if ( $show_fullname && $author->first_name && $author->last_name ) $name = "$author->first_name $author->last_name"; + else + $name = $author->display_name; - if( !$html ) { - if ( $posts == 0 ) { - if ( ! $hide_empty ) - $return .= $name . ', '; - } else - $return .= $name . ', '; + if ( !$html ) { + $return .= $name . ', '; - // No need to go further to process HTML. - continue; + continue; // No need to go further to process HTML. } - if ( !($posts == 0 && $hide_empty) && 'list' == $style ) + if ( 'list' == $style ) { $return .= '
  • '; - if ( $posts == 0 ) { - if ( ! $hide_empty ) - $link = $name; - } else { - $link = 'display_name) ) . '">' . $name . ''; - - if ( (! empty($feed_image)) || (! empty($feed)) ) { - $link .= ' '; - if (empty($feed_image)) - $link .= '('; - $link .= ''; - else - $link .= $name; - - $link .= ''; - - if ( empty($feed_image) ) - $link .= ')'; + } + + $link = 'display_name) ) . '">' . $name . ''; + + if ( !empty( $feed_image ) || !empty( $feed ) ) { + $link .= ' '; + if ( empty( $feed_image ) ) { + $link .= '('; + } + + $link .= ''; + else + $link .= $name; + + $link .= ''; + if ( empty( $feed_image ) ) + $link .= ')'; } - if ( $posts || ! $hide_empty ) - $return .= $link . ( ( 'list' == $style ) ? '
  • ' : ', ' ); + if ( $optioncount ) + $link .= ' ('. $posts . ')'; + + $return .= $link; + $return .= ( 'list' == $style ) ? '' : ', '; } - $return = trim($return, ', '); + $return = rtrim($return, ', '); - if ( ! $echo ) + if ( !$echo ) return $return; + echo $return; } diff --git a/wp-includes/bookmark.php b/wp-includes/bookmark.php index 641ae3b4..8b0fe487 100644 --- a/wp-includes/bookmark.php +++ b/wp-includes/bookmark.php @@ -7,12 +7,12 @@ */ /** - * Retrieve Bookmark data based on ID + * Retrieve Bookmark data * * @since 2.1.0 * @uses $wpdb Database Object * - * @param int $bookmark_id + * @param mixed $bookmark * @param string $output Optional. Either OBJECT, ARRAY_N, or ARRAY_A constant * @param string $filter Optional, default is 'raw'. * @return array|object Type returned depends on $output value. @@ -334,11 +334,10 @@ function sanitize_bookmark_field($field, $value, $bookmark_id, $context) { return $value; if ( 'edit' == $context ) { - $format_to_edit = array('link_notes'); $value = apply_filters("edit_$field", $value, $bookmark_id); - if ( in_array($field, $format_to_edit) ) { - $value = format_to_edit($value); + if ( 'link_notes' == $field ) { + $value = esc_html( $value ); // textarea_escaped } else { $value = esc_attr($value); } diff --git a/wp-includes/cache.php b/wp-includes/cache.php index 62438662..895c4316 100644 --- a/wp-includes/cache.php +++ b/wp-includes/cache.php @@ -110,7 +110,7 @@ function wp_cache_init() { * @uses $wp_object_cache Object Cache Class * @see WP_Object_Cache::replace() * - * @param int|string $id What to call the contents in the cache + * @param int|string $key What to call the contents in the cache * @param mixed $data The contents to store in the cache * @param string $flag Where to group the cache contents * @param int $expire When to expire the cache contents @@ -129,7 +129,7 @@ function wp_cache_replace($key, $data, $flag = '', $expire = 0) { * @uses $wp_object_cache Object Cache Class * @see WP_Object_Cache::set() * - * @param int|string $id What to call the contents in the cache + * @param int|string $key What to call the contents in the cache * @param mixed $data The contents to store in the cache * @param string $flag Where to group the cache contents * @param int $expire When to expire the cache contents @@ -171,8 +171,6 @@ function wp_cache_add_non_persistent_groups( $groups ) { * this function instructs the backend to reset those keys and perform any cleanup since blog or site IDs have changed since cache init. * * @since 2.6.0 - * - * @param string|array $groups A group or an array of groups to add */ function wp_cache_reset() { global $wp_object_cache; @@ -451,15 +449,11 @@ class WP_Object_Cache { echo "Cache Hits: {$this->cache_hits}
    "; echo "Cache Misses: {$this->cache_misses}
    "; echo "

    "; - + echo '
      '; foreach ($this->cache as $group => $cache) { - echo "

      "; - echo "Group: $group
      "; - echo "Cache:"; - echo "

      ";
      -			print_r($cache);
      -			echo "
      "; + echo "
    • Group: $group - ( " . number_format( strlen( serialize( $cache ) ) / 1024, 2 ) . 'k )
    • '; } + echo '
    '; } /** diff --git a/wp-includes/canonical.php b/wp-includes/canonical.php index 91b394b9..36411968 100644 --- a/wp-includes/canonical.php +++ b/wp-includes/canonical.php @@ -34,10 +34,10 @@ * @return null|false|string Null, if redirect not needed. False, if redirect * not needed or the string of the URL */ -function redirect_canonical($requested_url=null, $do_redirect=true) { - global $wp_rewrite, $is_IIS, $wp_query, $wpdb; +function redirect_canonical( $requested_url = null, $do_redirect = true ) { + global $wp_rewrite, $is_iis7, $wp_query, $wpdb; - if ( is_trackback() || is_search() || is_comments_popup() || is_admin() || $is_IIS || ( isset($_POST) && count($_POST) ) || is_preview() || is_robots() ) + if ( is_trackback() || is_search() || is_comments_popup() || is_admin() || !empty($_POST) || is_preview() || is_robots() || ( $is_iis7 && !iis7_supports_permalinks() ) ) return; if ( !$requested_url ) { @@ -146,26 +146,24 @@ function redirect_canonical($requested_url=null, $do_redirect=true) { } elseif ( is_category() || is_tag() || is_tax() ) { // Terms (Tags/categories) $term_count = 0; - foreach ( array('category__in', 'category__not_in', 'category__and', 'post__in', 'post__not_in', - 'tag__in', 'tag__not_in', 'tag__and', 'tag_slug__in', 'tag_slug__and') as $key ) - $term_count += count($wp_query->query_vars[$key]); + foreach ( $wp_query->tax_query->queries as $tax_query ) + $term_count += count( $tax_query['terms'] ); $obj = $wp_query->get_queried_object(); - - if ( $term_count <= 1 && !empty($obj->term_id) && ( $tax_url = get_term_link((int)$obj->term_id, $obj->taxonomy) ) - && !is_wp_error($tax_url) && $redirect['query'] ) { - if ( is_category() ) { - $redirect['query'] = remove_query_arg( array( 'category_name', 'category', 'cat'), $redirect['query']); - } elseif ( is_tag() ) { - $redirect['query'] = remove_query_arg( array( 'tag', 'tag_id'), $redirect['query']); - } elseif ( is_tax() ) { // Custom taxonomies will have a custom query var, remove those too: - $tax = get_taxonomy( $obj->taxonomy ); - if ( false !== $tax->query_var) - $redirect['query'] = remove_query_arg($tax->query_var, $redirect['query']); - else - $redirect['query'] = remove_query_arg( array( 'term', 'taxonomy'), $redirect['query']); + if ( $term_count <= 1 && !empty($obj->term_id) && ( $tax_url = get_term_link((int)$obj->term_id, $obj->taxonomy) ) && !is_wp_error($tax_url) ) { + if ( !empty($redirect['query']) ) { + if ( is_category() ) { + $redirect['query'] = remove_query_arg( array( 'category_name', 'category', 'cat'), $redirect['query']); + } elseif ( is_tag() ) { + $redirect['query'] = remove_query_arg( array( 'tag', 'tag_id'), $redirect['query']); + } elseif ( is_tax() ) { // Custom taxonomies will have a custom query var, remove those too: + $tax = get_taxonomy( $obj->taxonomy ); + if ( false !== $tax->query_var) + $redirect['query'] = remove_query_arg($tax->query_var, $redirect['query']); + else + $redirect['query'] = remove_query_arg( array( 'term', 'taxonomy'), $redirect['query']); + } } - $tax_url = parse_url($tax_url); if ( ! empty($tax_url['query']) ) { // Custom taxonomies may only be accessable via ?taxonomy=..&term=.. parse_str($tax_url['query'], $query_vars); @@ -173,7 +171,6 @@ function redirect_canonical($requested_url=null, $do_redirect=true) { } else { // Taxonomy is accessable via a "pretty-URL" $redirect['path'] = $tax_url['path']; } - } } elseif ( is_single() && strpos($wp_rewrite->permalink_structure, '%category%') !== false ) { $category = get_category_by_path(get_query_var('category_name')); @@ -190,14 +187,11 @@ function redirect_canonical($requested_url=null, $do_redirect=true) { // paging and feeds if ( get_query_var('paged') || is_feed() || get_query_var('cpage') ) { - if ( !$redirect_url ) - $redirect_url = $requested_url; - $paged_redirect = @parse_url($redirect_url); - while ( preg_match( '#/page/?[0-9]+?(/+)?$#', $paged_redirect['path'] ) || preg_match( '#/(comments/?)?(feed|rss|rdf|atom|rss2)(/+)?$#', $paged_redirect['path'] ) || preg_match( '#/comment-page-[0-9]+(/+)?$#', $paged_redirect['path'] ) ) { + while ( preg_match( "#/$wp_rewrite->pagination_base/?[0-9]+?(/+)?$#", $redirect['path'] ) || preg_match( '#/(comments/?)?(feed|rss|rdf|atom|rss2)(/+)?$#', $redirect['path'] ) || preg_match( '#/comment-page-[0-9]+(/+)?$#', $redirect['path'] ) ) { // Strip off paging and feed - $paged_redirect['path'] = preg_replace('#/page/?[0-9]+?(/+)?$#', '/', $paged_redirect['path']); // strip off any existing paging - $paged_redirect['path'] = preg_replace('#/(comments/?)?(feed|rss2?|rdf|atom)(/+|$)#', '/', $paged_redirect['path']); // strip off feed endings - $paged_redirect['path'] = preg_replace('#/comment-page-[0-9]+?(/+)?$#', '/', $paged_redirect['path']); // strip off any existing comment paging + $redirect['path'] = preg_replace("#/$wp_rewrite->pagination_base/?[0-9]+?(/+)?$#", '/', $redirect['path']); // strip off any existing paging + $redirect['path'] = preg_replace('#/(comments/?)?(feed|rss2?|rdf|atom)(/+|$)#', '/', $redirect['path']); // strip off feed endings + $redirect['path'] = preg_replace('#/comment-page-[0-9]+?(/+)?$#', '/', $redirect['path']); // strip off any existing comment paging } $addl_path = ''; @@ -214,7 +208,7 @@ function redirect_canonical($requested_url=null, $do_redirect=true) { $redirect['query'] = remove_query_arg( 'paged', $redirect['query'] ); if ( !is_feed() ) { if ( $paged > 1 && !is_single() ) { - $addl_path = ( !empty( $addl_path ) ? trailingslashit($addl_path) : '' ) . user_trailingslashit("page/$paged", 'paged'); + $addl_path = ( !empty( $addl_path ) ? trailingslashit($addl_path) : '' ) . user_trailingslashit("$wp_rewrite->pagination_base/$paged", 'paged'); } elseif ( !is_single() ) { $addl_path = !empty( $addl_path ) ? trailingslashit($addl_path) : ''; } @@ -228,24 +222,29 @@ function redirect_canonical($requested_url=null, $do_redirect=true) { $redirect['query'] = remove_query_arg( 'cpage', $redirect['query'] ); } - $paged_redirect['path'] = user_trailingslashit( preg_replace('|/index.php/?$|', '/', $paged_redirect['path']) ); // strip off trailing /index.php/ - if ( !empty( $addl_path ) && $wp_rewrite->using_index_permalinks() && strpos($paged_redirect['path'], '/index.php/') === false ) - $paged_redirect['path'] = trailingslashit($paged_redirect['path']) . 'index.php/'; + $redirect['path'] = user_trailingslashit( preg_replace('|/index.php/?$|', '/', $redirect['path']) ); // strip off trailing /index.php/ + if ( !empty( $addl_path ) && $wp_rewrite->using_index_permalinks() && strpos($redirect['path'], '/index.php/') === false ) + $redirect['path'] = trailingslashit($redirect['path']) . 'index.php/'; if ( !empty( $addl_path ) ) - $paged_redirect['path'] = trailingslashit($paged_redirect['path']) . $addl_path; - $redirect_url = $paged_redirect['scheme'] . '://' . $paged_redirect['host'] . $paged_redirect['path']; - $redirect['path'] = $paged_redirect['path']; + $redirect['path'] = trailingslashit($redirect['path']) . $addl_path; + $redirect_url = $redirect['scheme'] . '://' . $redirect['host'] . $redirect['path']; } } // tack on any additional query vars $redirect['query'] = preg_replace( '#^\??&*?#', '', $redirect['query'] ); if ( $redirect_url && !empty($redirect['query']) ) { - if ( strpos($redirect_url, '?') !== false ) - $redirect_url .= '&'; - else - $redirect_url .= '?'; - $redirect_url .= $redirect['query']; + parse_str( $redirect['query'], $_parsed_query ); + $redirect = @parse_url($redirect_url); + + if ( ! empty( $_parsed_query['name'] ) && ! empty( $redirect['query'] ) ) { + parse_str( $redirect['query'], $_parsed_redirect_query ); + + if ( empty( $_parsed_redirect_query['name'] ) ) + unset( $_parsed_query['name'] ); + } + + $redirect_url = add_query_arg( $_parsed_query, $redirect_url ); } if ( $redirect_url ) @@ -345,13 +344,13 @@ function redirect_canonical($requested_url=null, $do_redirect=true) { if ( !$redirect_url || $redirect_url == $requested_url ) return false; - - // Hex encoded octets are case-insensitive. + + // Hex encoded octets are case-insensitive. if ( false !== strpos($requested_url, '%') ) { if ( !function_exists('lowercase_octets') ) { - function lowercase_octets($matches) { - return strtolower( $matches[0] ); - } + function lowercase_octets($matches) { + return strtolower( $matches[0] ); + } } $requested_url = preg_replace_callback('|%[a-fA-F0-9][a-fA-F0-9]|', 'lowercase_octets', $requested_url); } @@ -392,7 +391,7 @@ function redirect_guess_404_permalink() { if ( !get_query_var('name') ) return false; - $where = $wpdb->prepare("post_name LIKE %s", get_query_var('name') . '%'); + $where = $wpdb->prepare("post_name LIKE %s", like_escape( get_query_var('name') ) . '%'); // if any of post_type, year, monthnum, or day are set, use them to refine the query if ( get_query_var('post_type') ) diff --git a/wp-includes/capabilities.php b/wp-includes/capabilities.php index 57a7cd78..7d8a00d7 100644 --- a/wp-includes/capabilities.php +++ b/wp-includes/capabilities.php @@ -471,9 +471,10 @@ class WP_User { * * @param int|string $id User's ID or username * @param int $name Optional. User's username + * @param int $blog_id Optional Blog ID, defaults to current blog. * @return WP_User */ - function WP_User( $id, $name = '' ) { + function WP_User( $id, $name = '', $blog_id = '' ) { if ( empty( $id ) && empty( $name ) ) return; @@ -496,7 +497,7 @@ class WP_User { } $this->id = $this->ID; - $this->_init_caps(); + $this->for_blog( $blog_id ); } /** @@ -604,6 +605,10 @@ class WP_User { function set_role( $role ) { foreach ( (array) $this->roles as $oldrole ) unset( $this->caps[$oldrole] ); + + if ( 1 == count( $this->roles ) && $role == $this->roles[0] ) + return; + if ( !empty( $role ) ) { $this->caps[$role] = true; $this->roles = array( $role => true ); @@ -736,6 +741,7 @@ class WP_User { // Must have ALL requested caps $capabilities = apply_filters( 'user_has_cap', $this->allcaps, $caps, $args ); + $capabilities['exist'] = true; // Everyone is allowed to exist foreach ( (array) $caps as $cap ) { //echo "Checking cap $cap
    "; if ( empty( $capabilities[$cap] ) || !$capabilities[$cap] ) @@ -815,19 +821,23 @@ function map_meta_cap( $cap, $user_id ) { $caps[] = 'edit_users'; // Explicit due to primitive fall through break; case 'delete_post': + case 'delete_page': $author_data = get_userdata( $user_id ); - //echo "post ID: {$args[0]}
    "; $post = get_post( $args[0] ); $post_type = get_post_type_object( $post->post_type ); - if ( $post_type && 'post' != $post_type->capability_type ) { - $args = array_merge( array( $post_type->cap->delete_post, $user_id ), $args ); - return call_user_func_array( 'map_meta_cap', $args ); + + if ( ! $post_type->map_meta_cap ) { + $caps[] = $post_type->cap->$cap; + // Prior to 3.1 we would re-call map_meta_cap here. + if ( 'delete_post' == $cap ) + $cap = $post_type->cap->$cap; + break; } if ( '' != $post->post_author ) { $post_author_data = get_userdata( $post->post_author ); } else { - //No author set yet so default to current user for cap checks + // No author set yet, so default to current user for cap checks. $post_author_data = $author_data; } @@ -835,157 +845,107 @@ function map_meta_cap( $cap, $user_id ) { if ( is_object( $post_author_data ) && $user_id == $post_author_data->ID ) { // If the post is published... if ( 'publish' == $post->post_status ) { - $caps[] = 'delete_published_posts'; + $caps[] = $post_type->cap->delete_published_posts; } elseif ( 'trash' == $post->post_status ) { if ('publish' == get_post_meta($post->ID, '_wp_trash_meta_status', true) ) - $caps[] = 'delete_published_posts'; + $caps[] = $post_type->cap->delete_published_posts; } else { // If the post is draft... - $caps[] = 'delete_posts'; + $caps[] = $post_type->cap->delete_posts; } } else { // The user is trying to edit someone else's post. - $caps[] = 'delete_others_posts'; + $caps[] = $post_type->cap->delete_others_posts; // The post is published, extra cap required. if ( 'publish' == $post->post_status ) - $caps[] = 'delete_published_posts'; + $caps[] = $post_type->cap->delete_published_posts; elseif ( 'private' == $post->post_status ) - $caps[] = 'delete_private_posts'; - } - break; - case 'delete_page': - $author_data = get_userdata( $user_id ); - //echo "post ID: {$args[0]}
    "; - $page = get_page( $args[0] ); - $page_author_data = get_userdata( $page->post_author ); - //echo "current user id : $user_id, page author id: " . $page_author_data->ID . "
    "; - // If the user is the author... - - if ('' != $page->post_author) { - $page_author_data = get_userdata( $page->post_author ); - } else { - //No author set yet so default to current user for cap checks - $page_author_data = $author_data; - } - - if ( is_object( $page_author_data ) && $user_id == $page_author_data->ID ) { - // If the page is published... - if ( $page->post_status == 'publish' ) { - $caps[] = 'delete_published_pages'; - } elseif ( 'trash' == $page->post_status ) { - if ('publish' == get_post_meta($page->ID, '_wp_trash_meta_status', true) ) - $caps[] = 'delete_published_pages'; - } else { - // If the page is draft... - $caps[] = 'delete_pages'; - } - } else { - // The user is trying to edit someone else's page. - $caps[] = 'delete_others_pages'; - // The page is published, extra cap required. - if ( $page->post_status == 'publish' ) - $caps[] = 'delete_published_pages'; - elseif ( $page->post_status == 'private' ) - $caps[] = 'delete_private_pages'; + $caps[] = $post_type->cap->delete_private_posts; } break; // edit_post breaks down to edit_posts, edit_published_posts, or // edit_others_posts case 'edit_post': + case 'edit_page': $author_data = get_userdata( $user_id ); - //echo "post ID: {$args[0]}
    "; $post = get_post( $args[0] ); $post_type = get_post_type_object( $post->post_type ); - if ( $post_type && 'post' != $post_type->capability_type ) { - $args = array_merge( array( $post_type->cap->edit_post, $user_id ), $args ); - return call_user_func_array( 'map_meta_cap', $args ); + + if ( ! $post_type->map_meta_cap ) { + $caps[] = $post_type->cap->$cap; + // Prior to 3.1 we would re-call map_meta_cap here. + if ( 'edit_post' == $cap ) + $cap = $post_type->cap->$cap; + break; } - $post_author_data = get_userdata( $post->post_author ); + + if ( '' != $post->post_author ) { + $post_author_data = get_userdata( $post->post_author ); + } else { + // No author set yet, so default to current user for cap checks. + $post_author_data = $author_data; + } + //echo "current user id : $user_id, post author id: " . $post_author_data->ID . "
    "; // If the user is the author... if ( is_object( $post_author_data ) && $user_id == $post_author_data->ID ) { // If the post is published... if ( 'publish' == $post->post_status ) { - $caps[] = 'edit_published_posts'; + $caps[] = $post_type->cap->edit_published_posts; } elseif ( 'trash' == $post->post_status ) { if ('publish' == get_post_meta($post->ID, '_wp_trash_meta_status', true) ) - $caps[] = 'edit_published_posts'; + $caps[] = $post_type->cap->edit_published_posts; } else { // If the post is draft... - $caps[] = 'edit_posts'; + $caps[] = $post_type->cap->edit_posts; } } else { // The user is trying to edit someone else's post. - $caps[] = 'edit_others_posts'; + $caps[] = $post_type->cap->edit_others_posts; // The post is published, extra cap required. if ( 'publish' == $post->post_status ) - $caps[] = 'edit_published_posts'; + $caps[] = $post_type->cap->edit_published_posts; elseif ( 'private' == $post->post_status ) - $caps[] = 'edit_private_posts'; - } - break; - case 'edit_page': - $author_data = get_userdata( $user_id ); - //echo "post ID: {$args[0]}
    "; - $page = get_page( $args[0] ); - $page_author_data = get_userdata( $page->post_author ); - //echo "current user id : $user_id, page author id: " . $page_author_data->ID . "
    "; - // If the user is the author... - if ( is_object( $page_author_data ) && $user_id == $page_author_data->ID ) { - // If the page is published... - if ( 'publish' == $page->post_status ) { - $caps[] = 'edit_published_pages'; - } elseif ( 'trash' == $page->post_status ) { - if ('publish' == get_post_meta($page->ID, '_wp_trash_meta_status', true) ) - $caps[] = 'edit_published_pages'; - } else { - // If the page is draft... - $caps[] = 'edit_pages'; - } - } else { - // The user is trying to edit someone else's page. - $caps[] = 'edit_others_pages'; - // The page is published, extra cap required. - if ( 'publish' == $page->post_status ) - $caps[] = 'edit_published_pages'; - elseif ( 'private' == $page->post_status ) - $caps[] = 'edit_private_pages'; + $caps[] = $post_type->cap->edit_private_posts; } break; case 'read_post': + case 'read_page': + $author_data = get_userdata( $user_id ); $post = get_post( $args[0] ); $post_type = get_post_type_object( $post->post_type ); - if ( $post_type && 'post' != $post_type->capability_type ) { - $args = array_merge( array( $post_type->cap->read_post, $user_id ), $args ); - return call_user_func_array( 'map_meta_cap', $args ); + + if ( ! $post_type->map_meta_cap ) { + $caps[] = $post_type->cap->$cap; + // Prior to 3.1 we would re-call map_meta_cap here. + if ( 'read_post' == $cap ) + $cap = $post_type->cap->$cap; + break; } if ( 'private' != $post->post_status ) { - $caps[] = 'read'; + $caps[] = $post_type->cap->read; break; } - $author_data = get_userdata( $user_id ); - $post_author_data = get_userdata( $post->post_author ); + if ( '' != $post->post_author ) { + $post_author_data = get_userdata( $post->post_author ); + } else { + // No author set yet, so default to current user for cap checks. + $post_author_data = $author_data; + } + if ( is_object( $post_author_data ) && $user_id == $post_author_data->ID ) - $caps[] = 'read'; + $caps[] = $post_type->cap->read; else - $caps[] = 'read_private_posts'; + $caps[] = $post_type->cap->read_private_posts; break; - case 'read_page': - $page = get_page( $args[0] ); + case 'edit_comment': + $comment = get_comment( $args[0] ); + $post = get_post( $comment->comment_post_ID ); + $post_type_object = get_post_type_object( $post->post_type ); - if ( 'private' != $page->post_status ) { - $caps[] = 'read'; - break; - } - - $author_data = get_userdata( $user_id ); - $page_author_data = get_userdata( $page->post_author ); - if ( is_object( $page_author_data ) && $user_id == $page_author_data->ID ) - $caps[] = 'read'; - else - $caps[] = 'read_private_pages'; + $caps = map_meta_cap( $post_type_object->cap->edit_post, $user_id, $post->ID ); break; case 'unfiltered_upload': if ( defined('ALLOW_UNFILTERED_UPLOADS') && ALLOW_UNFILTERED_UPLOADS && ( !is_multisite() || is_super_admin( $user_id ) ) ) @@ -1034,12 +994,21 @@ function map_meta_cap( $cap, $user_id ) { } break; case 'create_users': - if ( is_multisite() && !get_site_option( 'add_new_users' ) ) - $caps[] = 'do_not_allow'; - else + if ( !is_multisite() ) + $caps[] = $cap; + elseif ( is_super_admin() || get_site_option( 'add_new_users' ) ) $caps[] = $cap; + else + $caps[] = 'do_not_allow'; break; default: + // Handle meta capabilities for custom post types. + $post_type_meta_caps = _post_type_meta_capabilities(); + if ( isset( $post_type_meta_caps[ $cap ] ) ) { + $args = array_merge( array( $post_type_meta_caps[ $cap ], $user_id ), $args ); + return call_user_func_array( 'map_meta_cap', $args ); + } + // If no meta caps match, return the original cap. $caps[] = $cap; } @@ -1118,6 +1087,28 @@ function author_can( $post, $capability ) { return call_user_func_array( array( &$author, 'has_cap' ), $args ); } +/** + * Whether a particular user has capability or role. + * + * @since 3.1.0 + * + * @param int|object $user User ID or object. + * @param string $capability Capability or role name. + * @return bool + */ +function user_can( $user, $capability ) { + if ( ! is_object( $user ) ) + $user = new WP_User( $user ); + + if ( ! $user || ! $user->ID ) + return false; + + $args = array_slice( func_get_args(), 2 ); + $args = array_merge( array( $capability ), $args ); + + return call_user_func_array( array( &$user, 'has_cap' ), $args ); +} + /** * Retrieve role object. * @@ -1144,7 +1135,7 @@ function get_role( $role ) { * * @param string $role Role name. * @param string $display_name Display name for role. - * @param array $capabilities List of capabilities. + * @param array $capabilities List of capabilities, e.g. array( 'edit_posts' => true, 'delete_posts' => false ); * @return null|WP_Role WP_Role object if role is added, null if already exists. */ function add_role( $role, $display_name, $capabilities = array() ) { @@ -1201,16 +1192,14 @@ function get_super_admins() { * @return bool True if the user is a site admin. */ function is_super_admin( $user_id = false ) { - if ( ! $user_id ) { - $current_user = wp_get_current_user(); - $user_id = ! empty($current_user) ? $current_user->id : 0; - } + if ( $user_id ) + $user = new WP_User( $user_id ); + else + $user = wp_get_current_user(); - if ( ! $user_id ) + if ( empty( $user->id ) ) return false; - $user = new WP_User($user_id); - if ( is_multisite() ) { $super_admins = get_super_admins(); if ( is_array( $super_admins ) && in_array( $user->user_login, $super_admins ) ) diff --git a/wp-includes/category-template.php b/wp-includes/category-template.php index db55a12c..382488de 100644 --- a/wp-includes/category-template.php +++ b/wp-includes/category-template.php @@ -10,32 +10,21 @@ * Retrieve category link URL. * * @since 1.0.0 - * @uses apply_filters() Calls 'category_link' filter on category link and category ID. + * @see get_term_link() * - * @param int $category_id Category ID. - * @return string + * @param int|object $category Category ID or object. + * @return string Link on success, empty string if category does not exist. */ -function get_category_link( $category_id ) { - global $wp_rewrite; - $catlink = $wp_rewrite->get_category_permastruct(); +function get_category_link( $category ) { + if ( ! is_object( $category ) ) + $category = (int) $category; - if ( empty( $catlink ) ) { - $catlink = home_url('?cat=' . $category_id); - } else { - $category = &get_category( $category_id ); - if ( is_wp_error( $category ) ) - return $category; - $category_nicename = $category->slug; - - if ( $category->parent == $category_id ) // recursive recursion - $category->parent = 0; - elseif ($category->parent != 0 ) - $category_nicename = get_category_parents( $category->parent, false, '/', true ) . $category_nicename; - - $catlink = str_replace( '%category%', $category_nicename, $catlink ); - $catlink = home_url( user_trailingslashit( $catlink, 'category' ) ); - } - return apply_filters( 'category_link', $catlink, $category_id ); + $category = get_term_link( $category, 'category' ); + + if ( is_wp_error( $category ) ) + return ''; + + return $category; } /** @@ -59,7 +48,7 @@ function get_category_parents( $id, $link = false, $separator = '/', $nicename = if ( $nicename ) $name = $parent->slug; else - $name = $parent->cat_name; + $name = $parent->name; if ( $parent->parent && ( $parent->parent != $parent->term_id ) && !in_array( $parent->parent, $visited ) ) { $visited[] = $parent->parent; @@ -67,7 +56,7 @@ function get_category_parents( $id, $link = false, $separator = '/', $nicename = } if ( $link ) - $chain .= 'cat_name ) ) . '">'.$name.'' . $separator; + $chain .= 'name ) ) . '">'.$name.'' . $separator; else $chain .= $name.$separator; return $chain; @@ -83,28 +72,18 @@ function get_category_parents( $id, $link = false, $separator = '/', $nicename = * @return array */ function get_the_category( $id = false ) { - global $post; - - $id = (int) $id; - if ( !$id ) - $id = (int) $post->ID; - - $categories = get_object_term_cache( $id, 'category' ); - if ( false === $categories ) { - $categories = wp_get_object_terms( $id, 'category' ); - wp_cache_add($id, $categories, 'category_relationships'); - } - - if ( !empty( $categories ) ) - usort( $categories, '_usort_terms_by_name' ); - else + $categories = get_the_terms( $id, 'category' ); + if ( ! $categories ) $categories = array(); - foreach ( (array) array_keys( $categories ) as $key ) { + $categories = array_values( $categories ); + + foreach ( array_keys( $categories ) as $key ) { _make_cat_compat( $categories[$key] ); } - return $categories; + // Filter name is plural because we return alot of categories not just one + return apply_filters( 'get_the_categories', $categories ); } /** @@ -202,7 +181,7 @@ function get_the_category_list( $separator = '', $parents='', $post_id = false ) break; case '': default: - $thelist .= 'name ) ) . '" ' . $rel . '>' . $category->cat_name.''; + $thelist .= 'name ) ) . '" ' . $rel . '>' . $category->name.''; } } $thelist .= ''; @@ -215,13 +194,13 @@ function get_the_category_list( $separator = '', $parents='', $post_id = false ) case 'multiple': if ( $category->parent ) $thelist .= get_category_parents( $category->parent, true, $separator ); - $thelist .= 'name ) ) . '" ' . $rel . '>' . $category->cat_name.''; + $thelist .= 'name ) ) . '" ' . $rel . '>' . $category->name.''; break; case 'single': $thelist .= 'name ) ) . '" ' . $rel . '>'; if ( $category->parent ) $thelist .= get_category_parents( $category->parent, false, $separator ); - $thelist .= "$category->cat_name"; + $thelist .= "$category->name"; break; case '': default: @@ -248,29 +227,15 @@ function get_the_category_list( $separator = '', $parents='', $post_id = false ) * * @since 1.2.0 * - * @uses is_object_in_term() - * - * @param int|string|array $category. Category ID, name or slug, or array of said. - * @param int|post object Optional. Post to check instead of the current post. @since 2.7.0 + * @param int|string|array $category Category ID, name or slug, or array of said. + * @param int|object $_post Optional. Post to check instead of the current post. (since 2.7.0) * @return bool True if the current post is in any of the given categories. */ -function in_category( $category, $_post = null ) { +function in_category( $category, $post = null ) { if ( empty( $category ) ) return false; - if ( $_post ) { - $_post = get_post( $_post ); - } else { - $_post =& $GLOBALS['post']; - } - - if ( !$_post ) - return false; - - $r = is_object_in_term( $_post->ID, 'category', $category ); - if ( is_wp_error( $r ) ) - return false; - return $r; + return has_term( $category, 'category', $post ); } /** @@ -489,7 +454,7 @@ function wp_list_categories( $args = '' ) { $output = ''; if ( $title_li && 'list' == $style ) - $output = '
  • ' . $title_li . '
      '; + $output = '
    • ' . $title_li . '
        '; if ( empty( $categories ) ) { if ( ! empty( $show_option_none ) ) { @@ -499,16 +464,17 @@ function wp_list_categories( $args = '' ) { $output .= $show_option_none; } } else { - global $wp_query; - if( !empty( $show_option_all ) ) if ( 'list' == $style ) $output .= '
      • ' . $show_option_all . '
      • '; else $output .= '' . $show_option_all . ''; - if ( empty( $r['current_category'] ) && ( is_category() || is_tax() ) ) - $r['current_category'] = $wp_query->get_queried_object_id(); + if ( empty( $r['current_category'] ) && ( is_category() || is_tax() || is_tag() ) ) { + $current_term_object = get_queried_object(); + if ( $r['taxonomy'] == $current_term_object->taxonomy ) + $r['current_category'] = get_queried_object_id(); + } if ( $hierarchical ) $depth = $r['depth']; @@ -572,9 +538,9 @@ function wp_tag_cloud( $args = '' ) { foreach ( $tags as $key => $tag ) { if ( 'edit' == $args['link'] ) - $link = get_edit_tag_link( $tag->term_id, $args['taxonomy'] ); + $link = get_edit_tag_link( $tag->term_id, $tag->taxonomy ); else - $link = get_term_link( intval($tag->term_id), $args['taxonomy'] ); + $link = get_term_link( intval($tag->term_id), $tag->taxonomy ); if ( is_wp_error( $link ) ) return false; @@ -712,7 +678,7 @@ function wp_generate_tag_cloud( $tags, $args = '' ) { $tag_link = '#' != $tag->link ? esc_url( $tag->link ) : '#'; $tag_id = isset($tags[ $key ]->id) ? $tags[ $key ]->id : $key; $tag_name = $tags[ $key ]->name; - $a[] = "$tag_name"; } @@ -731,12 +697,32 @@ function wp_generate_tag_cloud( $tags, $args = '' ) { break; endswitch; - if ( $filter ) + if ( $filter ) return apply_filters( 'wp_generate_tag_cloud', $return, $tags, $args ); - else + else return $return; } +/** + * Callback for comparing tags based on name + * + * @since 3.1.0 + * @access private + */ +function _wp_tag_cloud_name_sort_cb( $a, $b ) { + return strnatcasecmp( $a->name, $b->name ); +} + +/** + * Callback for comparing tags based on count + * + * @since 3.1.0 + * @access private + */ +function _wp_tag_cloud_count_sort_cb( $a, $b ) { + return ( $a->count > $b->count ); +} + // // Helper functions // @@ -777,6 +763,205 @@ function walk_category_dropdown_tree() { return call_user_func_array(array( &$walker, 'walk' ), $args ); } +/** + * Create HTML list of categories. + * + * @package WordPress + * @since 2.1.0 + * @uses Walker + */ +class Walker_Category extends Walker { + /** + * @see Walker::$tree_type + * @since 2.1.0 + * @var string + */ + var $tree_type = 'category'; + + /** + * @see Walker::$db_fields + * @since 2.1.0 + * @todo Decouple this + * @var array + */ + var $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); + + /** + * @see Walker::start_lvl() + * @since 2.1.0 + * + * @param string $output Passed by reference. Used to append additional content. + * @param int $depth Depth of category. Used for tab indentation. + * @param array $args Will only append content if style argument value is 'list'. + */ + function start_lvl(&$output, $depth, $args) { + if ( 'list' != $args['style'] ) + return; + + $indent = str_repeat("\t", $depth); + $output .= "$indent
          \n"; + } + + /** + * @see Walker::end_lvl() + * @since 2.1.0 + * + * @param string $output Passed by reference. Used to append additional content. + * @param int $depth Depth of category. Used for tab indentation. + * @param array $args Will only append content if style argument value is 'list'. + */ + function end_lvl(&$output, $depth, $args) { + if ( 'list' != $args['style'] ) + return; + + $indent = str_repeat("\t", $depth); + $output .= "$indent
        \n"; + } + + /** + * @see Walker::start_el() + * @since 2.1.0 + * + * @param string $output Passed by reference. Used to append additional content. + * @param object $category Category data object. + * @param int $depth Depth of category in reference to parents. + * @param array $args + */ + function start_el(&$output, $category, $depth, $args) { + extract($args); + + $cat_name = esc_attr( $category->name ); + $cat_name = apply_filters( 'list_cats', $cat_name, $category ); + $link = 'description) ) + $link .= 'title="' . esc_attr( sprintf(__( 'View all posts filed under %s' ), $cat_name) ) . '"'; + else + $link .= 'title="' . esc_attr( strip_tags( apply_filters( 'category_description', $category->description, $category ) ) ) . '"'; + $link .= '>'; + $link .= $cat_name . ''; + + if ( !empty($feed_image) || !empty($feed) ) { + $link .= ' '; + + if ( empty($feed_image) ) + $link .= '('; + + $link .= ''; + + $link .= ''; + + if ( empty($feed_image) ) + $link .= ')'; + } + + if ( !empty($show_count) ) + $link .= ' (' . intval($category->count) . ')'; + + if ( !empty($show_date) ) + $link .= ' ' . gmdate('Y-m-d', $category->last_update_timestamp); + + if ( 'list' == $args['style'] ) { + $output .= "\tterm_id; + if ( !empty($current_category) ) { + $_current_category = get_term( $current_category, $category->taxonomy ); + if ( $category->term_id == $current_category ) + $class .= ' current-cat'; + elseif ( $category->term_id == $_current_category->parent ) + $class .= ' current-cat-parent'; + } + $output .= ' class="' . $class . '"'; + $output .= ">$link\n"; + } else { + $output .= "\t$link
        \n"; + } + } + + /** + * @see Walker::end_el() + * @since 2.1.0 + * + * @param string $output Passed by reference. Used to append additional content. + * @param object $page Not used. + * @param int $depth Depth of category. Not used. + * @param array $args Only uses 'list' for whether should append to output. + */ + function end_el(&$output, $page, $depth, $args) { + if ( 'list' != $args['style'] ) + return; + + $output .= "\n"; + } + +} + +/** + * Create HTML dropdown list of Categories. + * + * @package WordPress + * @since 2.1.0 + * @uses Walker + */ +class Walker_CategoryDropdown extends Walker { + /** + * @see Walker::$tree_type + * @since 2.1.0 + * @var string + */ + var $tree_type = 'category'; + + /** + * @see Walker::$db_fields + * @since 2.1.0 + * @todo Decouple this + * @var array + */ + var $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); + + /** + * @see Walker::start_el() + * @since 2.1.0 + * + * @param string $output Passed by reference. Used to append additional content. + * @param object $category Category data object. + * @param int $depth Depth of category. Used for padding. + * @param array $args Uses 'selected', 'show_count', and 'show_last_update' keys, if they exist. + */ + function start_el(&$output, $category, $depth, $args) { + $pad = str_repeat(' ', $depth * 3); + + $cat_name = apply_filters('list_cats', $category->name, $category); + $output .= "\t\n"; + } +} + // // Tags // @@ -785,28 +970,21 @@ function walk_category_dropdown_tree() { * Retrieve the link to the tag. * * @since 2.3.0 - * @uses apply_filters() Calls 'tag_link' with tag link and tag ID as parameters. + * @see get_term_link() * - * @param int $tag_id Tag (term) ID. - * @return string + * @param int|object $tag Tag ID or object. + * @return string Link on success, empty string if tag does not exist. */ -function get_tag_link( $tag_id ) { - global $wp_rewrite; - $taglink = $wp_rewrite->get_tag_permastruct(); +function get_tag_link( $tag ) { + if ( ! is_object( $tag ) ) + $tag = (int) $tag; + + $tag = get_term_link( $tag, 'post_tag' ); - $tag = &get_term( $tag_id, 'post_tag' ); if ( is_wp_error( $tag ) ) - return $tag; - $slug = $tag->slug; + return ''; - if ( empty( $taglink ) ) { - $file = get_option( 'home' ) . '/'; - $taglink = $file . '?tag=' . $slug; - } else { - $taglink = str_replace( '%tag%', $slug, $taglink ); - $taglink = get_option( 'home' ) . user_trailingslashit( $taglink, 'category' ); - } - return apply_filters( 'tag_link', $taglink, $tag_id ); + return $tag; } /** @@ -875,8 +1053,7 @@ function tag_description( $tag = 0 ) { */ function term_description( $term = 0, $taxonomy = 'post_tag' ) { if ( !$term && ( is_tax() || is_tag() || is_category() ) ) { - global $wp_query; - $term = $wp_query->get_queried_object(); + $term = get_queried_object(); $taxonomy = $term->taxonomy; $term = $term->term_id; } @@ -908,8 +1085,12 @@ function get_the_terms( $id = 0, $taxonomy ) { } $terms = get_object_term_cache( $id, $taxonomy ); - if ( false === $terms ) + if ( false === $terms ) { $terms = wp_get_object_terms( $id, $taxonomy ); + wp_cache_add($id, $terms, $taxonomy . '_relationships'); + } + + $terms = apply_filters( 'get_the_terms', $terms, $id, $taxonomy ); if ( empty( $terms ) ) return false; @@ -955,14 +1136,14 @@ function get_the_term_list( $id = 0, $taxonomy, $before = '', $sep = '', $after * * @since 2.5.0 * - * @param int $id Term ID. + * @param int $id Post ID. * @param string $taxonomy Taxonomy name. * @param string $before Optional. Before list. * @param string $sep Optional. Separate items using this. * @param string $after Optional. After list. * @return null|bool False on WordPress error. Returns null when displaying. */ -function the_terms( $id, $taxonomy, $before = '', $sep = ', ', $after = '' ) { +function the_terms( $id = 0, $taxonomy, $before = '', $sep = ', ', $after = '' ) { $term_list = get_the_term_list( $id, $taxonomy, $before, $sep, $after ); if ( is_wp_error( $term_list ) ) @@ -971,6 +1152,20 @@ function the_terms( $id, $taxonomy, $before = '', $sep = ', ', $after = '' ) { echo apply_filters('the_terms', $term_list, $taxonomy, $before, $sep, $after); } + +/** + * Check if the current post has any of given category. + * + * @since 3.1.0 + * + * @param string|int|array $tag Optional. The category name/term_id/slug or array of them to check for. + * @param int|object $post Optional. Post to check instead of the current post. + * @return bool True if the current post has any of the given categories (or any category, if no category specified). + */ +function has_category( $category = '', $post = null ) { + return has_term( $category, 'category', $post ); +} + /** * Check if the current post has any of given tags. * @@ -984,26 +1179,39 @@ function the_terms( $id, $taxonomy, $before = '', $sep = ', ', $after = '' ) { * * @since 2.6.0 * - * @uses is_object_in_term() - * * @param string|int|array $tag Optional. The tag name/term_id/slug or array of them to check for. - * @param int|post object Optional. Post to check instead of the current post. @since 2.7.0 - * @return bool True if the current post has any of the the given tags (or any tag, if no tag specified). + * @param int|object $post Optional. Post to check instead of the current post. (since 2.7.0) + * @return bool True if the current post has any of the given tags (or any tag, if no tag specified). */ -function has_tag( $tag = '', $_post = null ) { - if ( $_post ) { - $_post = get_post( $_post ); - } else { - $_post =& $GLOBALS['post']; - } +function has_tag( $tag = '', $post = null ) { + return has_term( $tag, 'post_tag', $post ); +} - if ( !$_post ) +/** + * Check if the current post has any of given terms. + * + * The given terms are checked against the post's terms' term_ids, names and slugs. + * Terms given as integers will only be checked against the post's terms' term_ids. + * If no terms are given, determines if post has any terms. + * + * @since 3.1.0 + * + * @param string|int|array $term Optional. The term name/term_id/slug or array of them to check for. + * @param string $taxonomy Taxonomy name + * @param int|object $post Optional. Post to check instead of the current post. + * @return bool True if the current post has any of the given tags (or any tag, if no tag specified). + */ +function has_term( $term = '', $taxonomy = '', $post = null ) { + $post = get_post($post); + + if ( !$post ) return false; - $r = is_object_in_term( $_post->ID, 'post_tag', $tag ); + $r = is_object_in_term( $post->ID, $taxonomy, $term ); if ( is_wp_error( $r ) ) return false; + return $r; } -?> \ No newline at end of file +?> diff --git a/wp-includes/category.php b/wp-includes/category.php index 1f665185..4d022774 100644 --- a/wp-includes/category.php +++ b/wp-includes/category.php @@ -305,22 +305,6 @@ function &get_tag( $tag, $output = OBJECT, $filter = 'raw' ) { /* Cache */ -/** - * Update the categories cache. - * - * This function does not appear to be used anymore or does not appear to be - * needed. It might be a legacy function left over from when there was a need - * for updating the category cache. - * - * @since 1.5.0 - * - * @return bool Always return True - */ -function update_category_cache() { - return true; -} - - /** * Remove the category cache data based on ID. * diff --git a/wp-includes/class-IXR.php b/wp-includes/class-IXR.php index 49f80b0c..9d89f0c5 100644 --- a/wp-includes/class-IXR.php +++ b/wp-includes/class-IXR.php @@ -1,16 +1,42 @@ data = $data; if (!$type) { $type = $this->calculateType(); } $this->type = $type; if ($type == 'struct') { - /* Turn all the values in the array in to new IXR_Value objects */ + // Turn all the values in the array in to new IXR_Value objects foreach ($this->data as $key => $value) { $this->data[$key] = new IXR_Value($value); } @@ -42,7 +69,8 @@ class IXR_Value { } } - function calculateType() { + function calculateType() + { if ($this->data === true || $this->data === false) { return 'boolean'; } @@ -52,6 +80,7 @@ class IXR_Value { if (is_double($this->data)) { return 'double'; } + // Deal with IXR object types base64 and date if (is_object($this->data) && is_a($this->data, 'IXR_Date')) { return 'date'; @@ -59,16 +88,17 @@ class IXR_Value { if (is_object($this->data) && is_a($this->data, 'IXR_Base64')) { return 'base64'; } + // If it is a normal PHP object convert it in to a struct if (is_object($this->data)) { - $this->data = get_object_vars($this->data); return 'struct'; } if (!is_array($this->data)) { return 'string'; } - /* We have an array - is it an array or a struct ? */ + + // We have an array - is it an array or a struct? if ($this->isStruct($this->data)) { return 'struct'; } else { @@ -76,8 +106,9 @@ class IXR_Value { } } - function getXml() { - /* Return XML for this value */ + function getXml() + { + // Return XML for this value switch ($this->type) { case 'boolean': return ''.(($this->data) ? '1' : '0').''; @@ -117,8 +148,14 @@ class IXR_Value { return false; } - function isStruct($array) { - /* Nasty function to check if an array is a struct or not */ + /** + * Checks whether or not the supplied array is a struct or not + * + * @param unknown_type $array + * @return boolean + */ + function isStruct($array) + { $expected = 0; foreach ($array as $key => $value) { if ((string)$key != (string)$expected) { @@ -131,18 +168,21 @@ class IXR_Value { } /** - * IXR_Message + * IXR_MESSAGE * * @package IXR * @since 1.5 + * */ -class IXR_Message { +class IXR_Message +{ var $message; var $messageType; // methodCall / methodResponse / fault var $faultCode; var $faultString; var $methodName; var $params; + // Current variable stacks var $_arraystructs = array(); // The stack used to keep track of the current array/struct var $_arraystructstypes = array(); // Stack keeping track of if things are structs or array @@ -153,44 +193,55 @@ class IXR_Message { var $_currentTagContents; // The XML parser var $_parser; - function IXR_Message (&$message) { - $this->message = &$message; - } - function parse() { - // first remove the XML declaration - // this method avoids the RAM usage of preg_replace on very large messages - $header = preg_replace( '/<\?xml.*?\?'.'>/', '', substr( $this->message, 0, 100 ), 1 ); - $this->message = substr_replace($this->message, $header, 0, 100); + + function IXR_Message($message) + { + $this->message =& $message; + } + + function parse() + { + // first remove the XML declaration + // merged from WP #10698 - this method avoids the RAM usage of preg_replace on very large messages + $header = preg_replace( '/<\?xml.*?\?'.'>/', '', substr($this->message, 0, 100), 1); + $this->message = substr_replace($this->message, $header, 0, 100); if (trim($this->message) == '') { return false; - } + } $this->_parser = xml_parser_create(); // Set XML parser to take the case of tags in to account xml_parser_set_option($this->_parser, XML_OPTION_CASE_FOLDING, false); // Set XML parser callback functions xml_set_object($this->_parser, $this); xml_set_element_handler($this->_parser, 'tag_open', 'tag_close'); - xml_set_character_data_handler($this->_parser, 'cdata'); - $chunk_size = 262144; // 256Kb, parse in chunks to avoid the RAM usage on very large messages - do { - if ( strlen($this->message) <= $chunk_size ) - $final=true; - $part = substr( $this->message, 0, $chunk_size ); - $this->message = substr( $this->message, $chunk_size ); - if ( !xml_parse( $this->_parser, $part, $final ) ) - return false; - if ( $final ) - break; - } while ( true ); - xml_parser_free($this->_parser); + xml_set_character_data_handler($this->_parser, 'cdata'); + $chunk_size = 262144; // 256Kb, parse in chunks to avoid the RAM usage on very large messages + $final = false; + do { + if (strlen($this->message) <= $chunk_size) { + $final = true; + } + $part = substr($this->message, 0, $chunk_size); + $this->message = substr($this->message, $chunk_size); + if (!xml_parse($this->_parser, $part, $final)) { + return false; + } + if ($final) { + break; + } + } while (true); + xml_parser_free($this->_parser); + // Grab the error messages, if any if ($this->messageType == 'fault') { $this->faultCode = $this->params[0]['faultCode']; $this->faultString = $this->params[0]['faultString']; - } + } return true; } - function tag_open($parser, $tag, $attr) { + + function tag_open($parser, $tag, $attr) + { $this->_currentTagContents = ''; $this->currentTag = $tag; switch($tag) { @@ -199,7 +250,7 @@ class IXR_Message { case 'fault': $this->messageType = $tag; break; - /* Deal with stacks of arrays and structs */ + /* Deal with stacks of arrays and structs */ case 'data': // data is to all intents and puposes more interesting than array $this->_arraystructstypes[] = 'array'; $this->_arraystructs[] = array(); @@ -210,28 +261,31 @@ class IXR_Message { break; } } - function cdata($parser, $cdata) { + + function cdata($parser, $cdata) + { $this->_currentTagContents .= $cdata; } - function tag_close($parser, $tag) { + + function tag_close($parser, $tag) + { $valueFlag = false; switch($tag) { case 'int': case 'i4': - $value = (int) trim($this->_currentTagContents); + $value = (int)trim($this->_currentTagContents); $valueFlag = true; break; case 'double': - $value = (double) trim($this->_currentTagContents); + $value = (double)trim($this->_currentTagContents); $valueFlag = true; break; case 'string': - $value = $this->_currentTagContents; + $value = (string)trim($this->_currentTagContents); $valueFlag = true; break; case 'dateTime.iso8601': $value = new IXR_Date(trim($this->_currentTagContents)); - // $value = $iso->getTimestamp(); $valueFlag = true; break; case 'value': @@ -242,14 +296,14 @@ class IXR_Message { } break; case 'boolean': - $value = (boolean) trim($this->_currentTagContents); + $value = (boolean)trim($this->_currentTagContents); $valueFlag = true; break; case 'base64': - $value = base64_decode( trim( $this->_currentTagContents ) ); + $value = base64_decode($this->_currentTagContents); $valueFlag = true; break; - /* Deal with stacks of arrays and structs */ + /* Deal with stacks of arrays and structs */ case 'data': case 'struct': $value = array_pop($this->_arraystructs); @@ -266,6 +320,7 @@ class IXR_Message { $this->methodName = trim($this->_currentTagContents); break; } + if ($valueFlag) { if (count($this->_arraystructs) > 0) { // Add value to struct or array @@ -291,27 +346,40 @@ class IXR_Message { * @package IXR * @since 1.5 */ -class IXR_Server { +class IXR_Server +{ var $data; var $callbacks = array(); var $message; var $capabilities; - function IXR_Server($callbacks = false, $data = false) { + + function IXR_Server($callbacks = false, $data = false, $wait = false) + { $this->setCapabilities(); if ($callbacks) { $this->callbacks = $callbacks; } $this->setCallbacks(); - $this->serve($data); + if (!$wait) { + $this->serve($data); + } } - function serve($data = false) { + + function serve($data = false) + { if (!$data) { + if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] !== 'POST') { + header('Content-Type: text/plain'); // merged from WP #9093 + die('XML-RPC server accepts POST requests only.'); + } + global $HTTP_RAW_POST_DATA; - if (!$HTTP_RAW_POST_DATA) { - header( 'Content-Type: text/plain' ); - die('XML-RPC server accepts POST requests only.'); + if (empty($HTTP_RAW_POST_DATA)) { + // workaround for a bug in PHP 5.2.2 - http://bugs.php.net/bug.php?id=41293 + $data = file_get_contents('php://input'); + } else { + $data =& $HTTP_RAW_POST_DATA; } - $data = &$HTTP_RAW_POST_DATA; } $this->message = new IXR_Message($data); if (!$this->message->parse()) { @@ -321,75 +389,83 @@ class IXR_Server { $this->error(-32600, 'server error. invalid xml-rpc. not conforming to spec. Request must be a methodCall'); } $result = $this->call($this->message->methodName, $this->message->params); + // Is the result an error? if (is_a($result, 'IXR_Error')) { $this->error($result); } + // Encode the result $r = new IXR_Value($result); $resultxml = $r->getXml(); + // Create the XML $xml = << - $resultxml + $resultxml EOD; - // Send it - $this->output($xml); + // Send it + $this->output($xml); } - function call($methodname, $args) { + + function call($methodname, $args) + { if (!$this->hasMethod($methodname)) { - return new IXR_Error(-32601, 'server error. requested method '. - $methodname.' does not exist.'); + return new IXR_Error(-32601, 'server error. requested method '.$methodname.' does not exist.'); } $method = $this->callbacks[$methodname]; + // Perform the callback and send the response if (count($args) == 1) { // If only one paramater just send that instead of the whole array $args = $args[0]; } + // Are we dealing with a function or a method? - if ( is_string( $method ) && substr($method, 0, 5) == 'this:' ) { + if (is_string($method) && substr($method, 0, 5) == 'this:') { // It's a class method - check it exists $method = substr($method, 5); if (!method_exists($this, $method)) { - return new IXR_Error(-32601, 'server error. requested class method "'. - $method.'" does not exist.'); + return new IXR_Error(-32601, 'server error. requested class method "'.$method.'" does not exist.'); } - // Call the method + + //Call the method $result = $this->$method($args); } else { // It's a function - does it exist? if (is_array($method)) { - if (!method_exists($method[0], $method[1])) { - return new IXR_Error(-32601, 'server error. requested object method "'. - $method[1].'" does not exist.'); + if (!is_callable(array($method[0], $method[1]))) { + return new IXR_Error(-32601, 'server error. requested object method "'.$method[1].'" does not exist.'); } } else if (!function_exists($method)) { - return new IXR_Error(-32601, 'server error. requested function "'. - $method.'" does not exist.'); + return new IXR_Error(-32601, 'server error. requested function "'.$method.'" does not exist.'); } + // Call the function $result = call_user_func($method, $args); } return $result; } - function error($error, $message = false) { + function error($error, $message = false) + { // Accepts either an error object or an error code and message if ($message && !is_object($error)) { $error = new IXR_Error($error, $message); } $this->output($error->getXml()); } - function output($xml) { + + function output($xml) + { $xml = ''."\n".$xml; $length = strlen($xml); header('Connection: close'); @@ -399,40 +475,52 @@ EOD; echo $xml; exit; } - function hasMethod($method) { + + function hasMethod($method) + { return in_array($method, array_keys($this->callbacks)); } - function setCapabilities() { + + function setCapabilities() + { // Initialises capabilities array $this->capabilities = array( 'xmlrpc' => array( 'specUrl' => 'http://www.xmlrpc.com/spec', 'specVersion' => 1 - ), + ), 'faults_interop' => array( 'specUrl' => 'http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php', 'specVersion' => 20010516 - ), + ), 'system.multicall' => array( 'specUrl' => 'http://www.xmlrpc.com/discuss/msgReader$1208', 'specVersion' => 1 - ), + ), ); } - function getCapabilities($args) { + + function getCapabilities($args) + { return $this->capabilities; } - function setCallbacks() { + + function setCallbacks() + { $this->callbacks['system.getCapabilities'] = 'this:getCapabilities'; $this->callbacks['system.listMethods'] = 'this:listMethods'; $this->callbacks['system.multicall'] = 'this:multiCall'; } - function listMethods($args) { + + function listMethods($args) + { // Returns a list of methods - uses array_reverse to ensure user defined // methods are listed before server defined methods return array_reverse(array_keys($this->callbacks)); } - function multiCall($methodcalls) { + + function multiCall($methodcalls) + { // See http://www.xmlrpc.com/discuss/msgReader$1208 $return = array(); foreach ($methodcalls as $call) { @@ -462,11 +550,14 @@ EOD; * @package IXR * @since 1.5 */ -class IXR_Request { +class IXR_Request +{ var $method; var $args; var $xml; - function IXR_Request($method, $args) { + + function IXR_Request($method, $args) + { $this->method = $method; $this->args = $args; $this->xml = <<xml .= ''; } - function getLength() { + + function getLength() + { return strlen($this->xml); } - function getXml() { + + function getXml() + { return $this->xml; } } @@ -497,26 +592,32 @@ EOD; * * @package IXR * @since 1.5 + * */ -class IXR_Client { +class IXR_Client +{ var $server; var $port; var $path; var $useragent; - var $headers; var $response; var $message = false; var $debug = false; var $timeout; + var $headers = array(); + // Storage place for an error message var $error = false; - function IXR_Client($server, $path = false, $port = 80, $timeout = false) { + + function IXR_Client($server, $path = false, $port = 80, $timeout = 15) + { if (!$path) { // Assume we have been given a URL instead $bits = parse_url($server); $this->server = $bits['host']; $this->port = isset($bits['port']) ? $bits['port'] : 80; $this->path = isset($bits['path']) ? $bits['path'] : '/'; + // Make absolutely sure we have a path if (!$this->path) { $this->path = '/'; @@ -529,7 +630,9 @@ class IXR_Client { $this->useragent = 'The Incutio XML-RPC PHP Library'; $this->timeout = $timeout; } - function query() { + + function query() + { $args = func_get_args(); $method = array_shift($args); $request = new IXR_Request($method, $args); @@ -538,33 +641,36 @@ class IXR_Client { $r = "\r\n"; $request = "POST {$this->path} HTTP/1.0$r"; - $this->headers['Host'] = $this->server; - $this->headers['Content-Type'] = 'text/xml'; - $this->headers['User-Agent'] = $this->useragent; - $this->headers['Content-Length']= $length; + // Merged from WP #8145 - allow custom headers + $this->headers['Host'] = $this->server; + $this->headers['Content-Type'] = 'text/xml'; + $this->headers['User-Agent'] = $this->useragent; + $this->headers['Content-Length']= $length; - foreach( $this->headers as $header => $value ) { - $request .= "{$header}: {$value}{$r}"; - } - $request .= $r; + foreach( $this->headers as $header => $value ) { + $request .= "{$header}: {$value}{$r}"; + } + $request .= $r; $request .= $xml; + // Now send the request if ($this->debug) { echo '
        '.htmlspecialchars($request)."\n
        \n\n"; } + if ($this->timeout) { $fp = @fsockopen($this->server, $this->port, $errno, $errstr, $this->timeout); } else { $fp = @fsockopen($this->server, $this->port, $errno, $errstr); } if (!$fp) { - $this->error = new IXR_Error(-32300, "transport error - could not open socket: $errno $errstr"); + $this->error = new IXR_Error(-32300, 'transport error - could not open socket'); return false; } fputs($fp, $request); $contents = ''; - $debug_contents = ''; + $debugContents = ''; $gotFirstLine = false; $gettingHeaders = true; while (!feof($fp)) { @@ -572,7 +678,7 @@ class IXR_Client { if (!$gotFirstLine) { // Check line for '200' if (strstr($line, '200') === false) { - $this->error = new IXR_Error(-32301, 'transport error - HTTP status code was not 200'); + $this->error = new IXR_Error(-32300, 'transport error - HTTP status code was not 200'); return false; } $gotFirstLine = true; @@ -581,16 +687,17 @@ class IXR_Client { $gettingHeaders = false; } if (!$gettingHeaders) { - // WP#12559 remove trim so as to not strip newlines from received response. + // merged from WP #12559 - remove trim $contents .= $line; } if ($this->debug) { - $debug_contents .= $line; + $debugContents .= $line; } } if ($this->debug) { - echo '
        '.htmlspecialchars($debug_contents)."\n
        \n\n"; + echo '
        '.htmlspecialchars($debugContents)."\n
        \n\n"; } + // Now parse what we've got back $this->message = new IXR_Message($contents); if (!$this->message->parse()) { @@ -598,44 +705,59 @@ class IXR_Client { $this->error = new IXR_Error(-32700, 'parse error. not well formed'); return false; } + // Is the message a fault? if ($this->message->messageType == 'fault') { $this->error = new IXR_Error($this->message->faultCode, $this->message->faultString); return false; } + // Message must be OK return true; } - function getResponse() { + + function getResponse() + { // methodResponses can only have one param - return that return $this->message->params[0]; } - function isError() { + + function isError() + { return (is_object($this->error)); } - function getErrorCode() { + + function getErrorCode() + { return $this->error->code; } - function getErrorMessage() { + + function getErrorMessage() + { return $this->error->message; } } + /** * IXR_Error * * @package IXR * @since 1.5 */ -class IXR_Error { +class IXR_Error +{ var $code; var $message; - function IXR_Error($code, $message) { + + function IXR_Error($code, $message) + { $this->code = $code; - // WP adds htmlspecialchars(). See #5666 $this->message = htmlspecialchars($message); } - function getXml() { + + function getXml() + { $xml = << @@ -673,7 +795,9 @@ class IXR_Date { var $minute; var $second; var $timezone; - function IXR_Date($time) { + + function IXR_Date($time) + { // $time can be a PHP timestamp or an ISO one if (is_numeric($time)) { $this->parseTimestamp($time); @@ -681,34 +805,41 @@ class IXR_Date { $this->parseIso($time); } } - function parseTimestamp($timestamp) { + + function parseTimestamp($timestamp) + { $this->year = date('Y', $timestamp); $this->month = date('m', $timestamp); $this->day = date('d', $timestamp); $this->hour = date('H', $timestamp); $this->minute = date('i', $timestamp); $this->second = date('s', $timestamp); - // WP adds timezone. See #2036 $this->timezone = ''; } - function parseIso($iso) { + + function parseIso($iso) + { $this->year = substr($iso, 0, 4); $this->month = substr($iso, 4, 2); $this->day = substr($iso, 6, 2); $this->hour = substr($iso, 9, 2); $this->minute = substr($iso, 12, 2); $this->second = substr($iso, 15, 2); - // WP adds timezone. See #2036 $this->timezone = substr($iso, 17); } - function getIso() { - // WP adds timezone. See #2036 + + function getIso() + { return $this->year.$this->month.$this->day.'T'.$this->hour.':'.$this->minute.':'.$this->second.$this->timezone; } - function getXml() { + + function getXml() + { return ''.$this->getIso().''; } - function getTimestamp() { + + function getTimestamp() + { return mktime($this->hour, $this->minute, $this->second, $this->month, $this->day, $this->year); } } @@ -719,12 +850,17 @@ class IXR_Date { * @package IXR * @since 1.5 */ -class IXR_Base64 { +class IXR_Base64 +{ var $data; - function IXR_Base64($data) { + + function IXR_Base64($data) + { $this->data = $data; } - function getXml() { + + function getXml() + { return ''.base64_encode($this->data).''; } } @@ -735,10 +871,13 @@ class IXR_Base64 { * @package IXR * @since 1.5 */ -class IXR_IntrospectionServer extends IXR_Server { +class IXR_IntrospectionServer extends IXR_Server +{ var $signatures; var $help; - function IXR_IntrospectionServer() { + + function IXR_IntrospectionServer() + { $this->setCallbacks(); $this->setCapabilities(); $this->capabilities['introspection'] = array( @@ -770,16 +909,21 @@ class IXR_IntrospectionServer extends IXR_Server { 'Returns a documentation string for the specified method' ); } - function addCallback($method, $callback, $args, $help) { + + function addCallback($method, $callback, $args, $help) + { $this->callbacks[$method] = $callback; $this->signatures[$method] = $args; $this->help[$method] = $help; } - function call($methodname, $args) { + + function call($methodname, $args) + { // Make sure it's in an array if ($args && !is_array($args)) { $args = array($args); } + // Over-rides default call method, adds signature check if (!$this->hasMethod($methodname)) { return new IXR_Error(-32601, 'server error. requested method "'.$this->message->methodName.'" not specified.'); @@ -787,10 +931,12 @@ class IXR_IntrospectionServer extends IXR_Server { $method = $this->callbacks[$methodname]; $signature = $this->signatures[$methodname]; $returnType = array_shift($signature); + // Check the number of arguments if (count($args) != count($signature)) { return new IXR_Error(-32602, 'server error. wrong number of method parameters'); } + // Check the argument types $ok = true; $argsbackup = $args; @@ -835,7 +981,9 @@ class IXR_IntrospectionServer extends IXR_Server { // It passed the test - run the "real" method call return parent::call($methodname, $argsbackup); } - function methodSignature($method) { + + function methodSignature($method) + { if (!$this->hasMethod($method)) { return new IXR_Error(-32601, 'server error. requested method "'.$method.'" not specified.'); } @@ -873,7 +1021,9 @@ class IXR_IntrospectionServer extends IXR_Server { } return $return; } - function methodHelp($method) { + + function methodHelp($method) + { return $this->help[$method]; } } @@ -884,13 +1034,18 @@ class IXR_IntrospectionServer extends IXR_Server { * @package IXR * @since 1.5 */ -class IXR_ClientMulticall extends IXR_Client { +class IXR_ClientMulticall extends IXR_Client +{ var $calls = array(); - function IXR_ClientMulticall($server, $path = false, $port = 80) { + + function IXR_ClientMulticall($server, $path = false, $port = 80) + { parent::IXR_Client($server, $path, $port); $this->useragent = 'The Incutio XML-RPC PHP Library (multicall client)'; } - function addCall() { + + function addCall() + { $args = func_get_args(); $methodName = array_shift($args); $struct = array( @@ -899,7 +1054,9 @@ class IXR_ClientMulticall extends IXR_Client { ); $this->calls[] = $struct; } - function query() { + + function query() + { // Prepare multicall, then call the parent::query() method return parent::query('system.multicall', $this->calls); } diff --git a/wp-includes/class-http.php b/wp-includes/class-http.php index 3e808692..5d7f83d8 100644 --- a/wp-includes/class-http.php +++ b/wp-includes/class-http.php @@ -238,39 +238,39 @@ class WP_Http { if ( false !== $pre ) return $pre; - $arrURL = parse_url($url); + $arrURL = parse_url( $url ); if ( empty( $url ) || empty( $arrURL['scheme'] ) ) return new WP_Error('http_request_failed', __('A valid URL was not provided.')); if ( $this->block_request( $url ) ) - return new WP_Error('http_request_failed', __('User has blocked requests through HTTP.')); + return new WP_Error( 'http_request_failed', __( 'User has blocked requests through HTTP.' ) ); // Determine if this is a https call and pass that on to the transport functions // so that we can blacklist the transports that do not support ssl verification $r['ssl'] = $arrURL['scheme'] == 'https' || $arrURL['scheme'] == 'ssl'; // Determine if this request is to OUR install of WordPress - $homeURL = parse_url( get_bloginfo('url') ); + $homeURL = parse_url( get_bloginfo( 'url' ) ); $r['local'] = $homeURL['host'] == $arrURL['host'] || 'localhost' == $arrURL['host']; - unset($homeURL); + unset( $homeURL ); if ( is_null( $r['headers'] ) ) $r['headers'] = array(); - if ( ! is_array($r['headers']) ) { - $processedHeaders = WP_Http::processHeaders($r['headers']); + if ( ! is_array( $r['headers'] ) ) { + $processedHeaders = WP_Http::processHeaders( $r['headers'] ); $r['headers'] = $processedHeaders['headers']; } - if ( isset($r['headers']['User-Agent']) ) { + if ( isset( $r['headers']['User-Agent'] ) ) { $r['user-agent'] = $r['headers']['User-Agent']; - unset($r['headers']['User-Agent']); + unset( $r['headers']['User-Agent'] ); } - if ( isset($r['headers']['user-agent']) ) { + if ( isset( $r['headers']['user-agent'] ) ) { $r['user-agent'] = $r['headers']['user-agent']; - unset($r['headers']['user-agent']); + unset( $r['headers']['user-agent'] ); } // Construct Cookie: header if any cookies are set @@ -280,45 +280,46 @@ class WP_Http { $r['headers']['Accept-Encoding'] = WP_Http_Encoding::accept_encoding(); if ( empty($r['body']) ) { + $r['body'] = null; // Some servers fail when sending content without the content-length header being set. // Also, to fix another bug, we only send when doing POST and PUT and the content-length // header isn't already set. - if( ($r['method'] == 'POST' || $r['method'] == 'PUT') && ! isset($r['headers']['Content-Length']) ) + if ( ($r['method'] == 'POST' || $r['method'] == 'PUT') && ! isset( $r['headers']['Content-Length'] ) ) $r['headers']['Content-Length'] = 0; // The method is ambiguous, because we aren't talking about HTTP methods, the "get" in // this case is simply that we aren't sending any bodies and to get the transports that // don't support sending bodies along with those which do. - $transports = WP_Http::_getTransport($r); + $transports = WP_Http::_getTransport( $r ); } else { if ( is_array( $r['body'] ) || is_object( $r['body'] ) ) { if ( ! version_compare(phpversion(), '5.1.2', '>=') ) - $r['body'] = _http_build_query($r['body'], null, '&'); + $r['body'] = _http_build_query( $r['body'], null, '&' ); else - $r['body'] = http_build_query($r['body'], null, '&'); - $r['headers']['Content-Type'] = 'application/x-www-form-urlencoded; charset=' . get_option('blog_charset'); - $r['headers']['Content-Length'] = strlen($r['body']); + $r['body'] = http_build_query( $r['body'], null, '&' ); + $r['headers']['Content-Type'] = 'application/x-www-form-urlencoded; charset=' . get_option( 'blog_charset' ); + $r['headers']['Content-Length'] = strlen( $r['body'] ); } if ( ! isset( $r['headers']['Content-Length'] ) && ! isset( $r['headers']['content-length'] ) ) - $r['headers']['Content-Length'] = strlen($r['body']); + $r['headers']['Content-Length'] = strlen( $r['body'] ); // The method is ambiguous, because we aren't talking about HTTP methods, the "post" in // this case is simply that we are sending HTTP body and to get the transports that do // support sending the body. Not all do, depending on the limitations of the PHP core // limitations. - $transports = WP_Http::_postTransport($r); + $transports = WP_Http::_postTransport( $r ); } do_action( 'http_api_debug', $transports, 'transports_list' ); $response = array( 'headers' => array(), 'body' => '', 'response' => array('code' => false, 'message' => false), 'cookies' => array() ); foreach ( (array) $transports as $transport ) { - $response = $transport->request($url, $r); + $response = $transport->request( $url, $r ); - do_action( 'http_api_debug', $response, 'response', get_class($transport) ); + do_action( 'http_api_debug', $response, 'response', get_class( $transport ) ); - if ( ! is_wp_error($response) ) + if ( ! is_wp_error( $response ) ) return apply_filters( 'http_response', $response, $r, $url ); } @@ -453,7 +454,7 @@ class WP_Http { } else { $newheaders[$key] = trim( $value ); } - if ( 'set-cookie' == strtolower( $key ) ) + if ( 'set-cookie' == $key ) $cookies[] = new WP_Http_Cookie( $value ); } } @@ -540,10 +541,12 @@ class WP_Http { * You block external URL requests by defining WP_HTTP_BLOCK_EXTERNAL as true in your wp-config.php * file and this will only allow localhost and your blog to make requests. The constant * WP_ACCESSIBLE_HOSTS will allow additional hosts to go through for requests. The format of the - * WP_ACCESSIBLE_HOSTS constant is a comma separated list of hostnames to allow. + * WP_ACCESSIBLE_HOSTS constant is a comma separated list of hostnames to allow, wildcard domains + * are supported, eg *.wordpress.org will allow for all subdomains of wordpress.org to be contacted. * * @since 2.8.0 * @link http://core.trac.wordpress.org/ticket/8927 Allow preventing external requests. + * @link http://core.trac.wordpress.org/ticket/14636 Allow wildcard domains in WP_ACCESSIBLE_HOSTS * * @param string $uri URI of url. * @return bool True to block, false to allow. @@ -577,10 +580,25 @@ class WP_Http { return true; static $accessible_hosts; - if ( null == $accessible_hosts ) + static $wildcard_regex = false; + if ( null == $accessible_hosts ) { $accessible_hosts = preg_split('|,\s*|', WP_ACCESSIBLE_HOSTS); - return !in_array( $check['host'], $accessible_hosts ); //Inverse logic, If its in the array, then we can't access it. + if ( false !== strpos(WP_ACCESSIBLE_HOSTS, '*') ) { + $wildcard_regex = array(); + foreach ( $accessible_hosts as $host ) + $wildcard_regex[] = str_replace('\*', '[\w.]+?', preg_quote($host, '/')); + $wildcard_regex = '/^(' . implode('|', $wildcard_regex) . ')$/i'; + } + } + + if ( !empty($wildcard_regex) ) + return !preg_match($wildcard_regex, $check['host']); + else + return !in_array( $check['host'], $accessible_hosts ); //Inverse logic, If its in the array, then we can't access it. + + + } } @@ -621,7 +639,7 @@ class WP_Http_Fsockopen { if ( isset($r['headers']['User-Agent']) ) { $r['user-agent'] = $r['headers']['User-Agent']; unset($r['headers']['User-Agent']); - } else if( isset($r['headers']['user-agent']) ) { + } else if ( isset($r['headers']['user-agent']) ) { $r['user-agent'] = $r['headers']['user-agent']; unset($r['headers']['user-agent']); } @@ -973,7 +991,7 @@ class WP_Http_Streams { if ( isset($r['headers']['User-Agent']) ) { $r['user-agent'] = $r['headers']['User-Agent']; unset($r['headers']['User-Agent']); - } else if( isset($r['headers']['user-agent']) ) { + } else if ( isset($r['headers']['user-agent']) ) { $r['user-agent'] = $r['headers']['user-agent']; unset($r['headers']['user-agent']); } @@ -1120,7 +1138,7 @@ class WP_Http_Streams { * @subpackage HTTP * @since 2.7.0 */ -class WP_Http_ExtHTTP { +class WP_Http_ExtHttp { /** * Send a HTTP request to a URI using HTTP extension. * @@ -1146,7 +1164,7 @@ class WP_Http_ExtHTTP { if ( isset($r['headers']['User-Agent']) ) { $r['user-agent'] = $r['headers']['User-Agent']; unset($r['headers']['User-Agent']); - } else if( isset($r['headers']['user-agent']) ) { + } else if ( isset($r['headers']['user-agent']) ) { $r['user-agent'] = $r['headers']['user-agent']; unset($r['headers']['user-agent']); } @@ -1296,7 +1314,7 @@ class WP_Http_Curl { if ( isset($r['headers']['User-Agent']) ) { $r['user-agent'] = $r['headers']['User-Agent']; unset($r['headers']['User-Agent']); - } else if( isset($r['headers']['user-agent']) ) { + } else if ( isset($r['headers']['user-agent']) ) { $r['user-agent'] = $r['headers']['user-agent']; unset($r['headers']['user-agent']); } @@ -1408,7 +1426,7 @@ class WP_Http_Curl { $theBody = substr( $theResponse, $headerLength ); else $theBody = ''; - if ( false !== strrpos($theHeaders, "\r\n\r\n") ) { + if ( false !== strpos($theHeaders, "\r\n\r\n") ) { $headerParts = explode("\r\n\r\n", $theHeaders); $theHeaders = $headerParts[ count($headerParts) -1 ]; } @@ -1478,17 +1496,18 @@ class WP_Http_Curl { *
      • WP_PROXY_PASSWORD - Proxy password, if it requires authentication.
      • *
      • WP_PROXY_BYPASS_HOSTS - Will prevent the hosts in this list from going through the proxy. * You do not need to have localhost and the blog host in this list, because they will not be passed - * through the proxy. The list should be presented in a comma separated list
      • + * through the proxy. The list should be presented in a comma separated list, wildcards using * are supported, eg. *.wordpress.org * * * An example can be as seen below. * * define('WP_PROXY_HOST', '192.168.84.101'); * define('WP_PROXY_PORT', '8080'); - * define('WP_PROXY_BYPASS_HOSTS', 'localhost, www.example.com'); + * define('WP_PROXY_BYPASS_HOSTS', 'localhost, www.example.com, *.wordpress.org'); * * * @link http://core.trac.wordpress.org/ticket/4011 Proxy support ticket in WordPress. + * @link http://core.trac.wordpress.org/ticket/14636 Allow wildcard domains in WP_PROXY_BYPASS_HOSTS * @since 2.8 */ class WP_HTTP_Proxy { @@ -1605,7 +1624,7 @@ class WP_HTTP_Proxy { * hosts that won't be sent through the proxy. * * @uses WP_PROXY_BYPASS_HOSTS - * @since unknown + * @since 2.8.0 * * @param string $uri URI to check. * @return bool True, to send through the proxy and false if, the proxy should not be used. @@ -1628,10 +1647,22 @@ class WP_HTTP_Proxy { return true; static $bypass_hosts; - if ( null == $bypass_hosts ) + static $wildcard_regex = false; + if ( null == $bypass_hosts ) { $bypass_hosts = preg_split('|,\s*|', WP_PROXY_BYPASS_HOSTS); - return !in_array( $check['host'], $bypass_hosts ); + if ( false !== strpos(WP_PROXY_BYPASS_HOSTS, '*') ) { + $wildcard_regex = array(); + foreach ( $bypass_hosts as $host ) + $wildcard_regex[] = str_replace('\*', '[\w.]+?', preg_quote($host, '/')); + $wildcard_regex = '/^(' . implode('|', $wildcard_regex) . ')$/i'; + } + } + + if ( !empty($wildcard_regex) ) + return !preg_match($wildcard_regex, $check['host']); + else + return !in_array( $check['host'], $bypass_hosts ); } } /** diff --git a/wp-includes/class-json.php b/wp-includes/class-json.php index 7582609a..75010df2 100644 --- a/wp-includes/class-json.php +++ b/wp-includes/class-json.php @@ -153,7 +153,7 @@ class Services_JSON return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16'); } - $bytes = (ord($utf16{0}) << 8) | ord($utf16{1}); + $bytes = (ord($utf16[0]) << 8) | ord($utf16[1]); switch(true) { case ((0x7F & $bytes) == $bytes): @@ -206,17 +206,17 @@ class Services_JSON case 2: // return a UTF-16 character from a 2-byte UTF-8 char // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - return chr(0x07 & (ord($utf8{0}) >> 2)) - . chr((0xC0 & (ord($utf8{0}) << 6)) - | (0x3F & ord($utf8{1}))); + return chr(0x07 & (ord($utf8[0]) >> 2)) + . chr((0xC0 & (ord($utf8[0]) << 6)) + | (0x3F & ord($utf8[1]))); case 3: // return a UTF-16 character from a 3-byte UTF-8 char // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - return chr((0xF0 & (ord($utf8{0}) << 4)) - | (0x0F & (ord($utf8{1}) >> 2))) - . chr((0xC0 & (ord($utf8{1}) << 6)) - | (0x7F & ord($utf8{2}))); + return chr((0xF0 & (ord($utf8[0]) << 4)) + | (0x0F & (ord($utf8[1]) >> 2))) + . chr((0xC0 & (ord($utf8[1]) << 6)) + | (0x7F & ord($utf8[2]))); } // ignoring UTF-32 for now, sorry @@ -293,7 +293,7 @@ class Services_JSON */ for ($c = 0; $c < $strlen_var; ++$c) { - $ord_var_c = ord($var{$c}); + $ord_var_c = ord($var[$c]); switch (true) { case $ord_var_c == 0x08: @@ -316,12 +316,12 @@ class Services_JSON case $ord_var_c == 0x2F: case $ord_var_c == 0x5C: // double quote, slash, slosh - $ascii .= '\\'.$var{$c}; + $ascii .= '\\'.$var[$c]; break; case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)): // characters U-00000000 - U-0000007F (same as ASCII) - $ascii .= $var{$c}; + $ascii .= $var[$c]; break; case (($ord_var_c & 0xE0) == 0xC0): @@ -333,7 +333,7 @@ class Services_JSON break; } - $char = pack('C*', $ord_var_c, ord($var{$c + 1})); + $char = pack('C*', $ord_var_c, ord($var[$c + 1])); $c += 1; $utf16 = $this->utf82utf16($char); $ascii .= sprintf('\u%04s', bin2hex($utf16)); @@ -348,8 +348,8 @@ class Services_JSON // characters U-00000800 - U-0000FFFF, mask 1110XXXX // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 $char = pack('C*', $ord_var_c, - @ord($var{$c + 1}), - @ord($var{$c + 2})); + @ord($var[$c + 1]), + @ord($var[$c + 2])); $c += 2; $utf16 = $this->utf82utf16($char); $ascii .= sprintf('\u%04s', bin2hex($utf16)); @@ -364,9 +364,9 @@ class Services_JSON // characters U-00010000 - U-001FFFFF, mask 11110XXX // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 $char = pack('C*', $ord_var_c, - ord($var{$c + 1}), - ord($var{$c + 2}), - ord($var{$c + 3})); + ord($var[$c + 1]), + ord($var[$c + 2]), + ord($var[$c + 3])); $c += 3; $utf16 = $this->utf82utf16($char); $ascii .= sprintf('\u%04s', bin2hex($utf16)); @@ -381,10 +381,10 @@ class Services_JSON break; } $char = pack('C*', $ord_var_c, - ord($var{$c + 1}), - ord($var{$c + 2}), - ord($var{$c + 3}), - ord($var{$c + 4})); + ord($var[$c + 1]), + ord($var[$c + 2]), + ord($var[$c + 3]), + ord($var[$c + 4])); $c += 4; $utf16 = $this->utf82utf16($char); $ascii .= sprintf('\u%04s', bin2hex($utf16)); @@ -399,11 +399,11 @@ class Services_JSON // characters U-04000000 - U-7FFFFFFF, mask 1111110X // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 $char = pack('C*', $ord_var_c, - ord($var{$c + 1}), - ord($var{$c + 2}), - ord($var{$c + 3}), - ord($var{$c + 4}), - ord($var{$c + 5})); + ord($var[$c + 1]), + ord($var[$c + 2]), + ord($var[$c + 3]), + ord($var[$c + 4]), + ord($var[$c + 5])); $c += 5; $utf16 = $this->utf82utf16($char); $ascii .= sprintf('\u%04s', bin2hex($utf16)); @@ -577,7 +577,7 @@ class Services_JSON for ($c = 0; $c < $strlen_chrs; ++$c) { $substr_chrs_c_2 = substr($chrs, $c, 2); - $ord_chrs_c = ord($chrs{$c}); + $ord_chrs_c = ord($chrs[$c]); switch (true) { case $substr_chrs_c_2 == '\b': @@ -607,7 +607,7 @@ class Services_JSON case $substr_chrs_c_2 == '\\/': if (($delim == '"' && $substr_chrs_c_2 != '\\\'') || ($delim == "'" && $substr_chrs_c_2 != '\\"')) { - $utf8 .= $chrs{++$c}; + $utf8 .= $chrs[++$c]; } break; @@ -620,7 +620,7 @@ class Services_JSON break; case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F): - $utf8 .= $chrs{$c}; + $utf8 .= $chrs[$c]; break; case ($ord_chrs_c & 0xE0) == 0xC0: @@ -667,7 +667,7 @@ class Services_JSON } elseif (preg_match('/^\[.*\]$/s', $str) || preg_match('/^\{.*\}$/s', $str)) { // array, or object notation - if ($str{0} == '[') { + if ($str[0] == '[') { $stk = array(SERVICES_JSON_IN_ARR); $arr = array(); } else { @@ -706,7 +706,7 @@ class Services_JSON $top = end($stk); $substr_chrs_c_2 = substr($chrs, $c, 2); - if (($c == $strlen_chrs) || (($chrs{$c} == ',') && ($top['what'] == SERVICES_JSON_SLICE))) { + if (($c == $strlen_chrs) || (($chrs[$c] == ',') && ($top['what'] == SERVICES_JSON_SLICE))) { // found a comma that is not inside a string, array, etc., // OR we've reached the end of the character list $slice = substr($chrs, $top['where'], ($c - $top['where'])); @@ -748,12 +748,12 @@ class Services_JSON } - } elseif ((($chrs{$c} == '"') || ($chrs{$c} == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) { + } elseif ((($chrs[$c] == '"') || ($chrs[$c] == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) { // found a quote, and we are not inside a string - array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs{$c})); + array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs[$c])); //print("Found start of string at {$c}\n"); - } elseif (($chrs{$c} == $top['delim']) && + } elseif (($chrs[$c] == $top['delim']) && ($top['what'] == SERVICES_JSON_IN_STR) && ((strlen(substr($chrs, 0, $c)) - strlen(rtrim(substr($chrs, 0, $c), '\\'))) % 2 != 1)) { // found a quote, we're in a string, and it's not escaped @@ -762,24 +762,24 @@ class Services_JSON array_pop($stk); //print("Found end of string at {$c}: ".substr($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n"); - } elseif (($chrs{$c} == '[') && + } elseif (($chrs[$c] == '[') && in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) { // found a left-bracket, and we are in an array, object, or slice array_push($stk, array('what' => SERVICES_JSON_IN_ARR, 'where' => $c, 'delim' => false)); //print("Found start of array at {$c}\n"); - } elseif (($chrs{$c} == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) { + } elseif (($chrs[$c] == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) { // found a right-bracket, and we're in an array array_pop($stk); //print("Found end of array at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n"); - } elseif (($chrs{$c} == '{') && + } elseif (($chrs[$c] == '{') && in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) { // found a left-brace, and we are in an array, object, or slice array_push($stk, array('what' => SERVICES_JSON_IN_OBJ, 'where' => $c, 'delim' => false)); //print("Found start of object at {$c}\n"); - } elseif (($chrs{$c} == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) { + } elseif (($chrs[$c] == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) { // found a right-brace, and we're in an object array_pop($stk); //print("Found end of object at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n"); diff --git a/wp-includes/class-oembed.php b/wp-includes/class-oembed.php index a09b3167..87e59a69 100644 --- a/wp-includes/class-oembed.php +++ b/wp-includes/class-oembed.php @@ -242,7 +242,7 @@ class WP_oEmbed { return false; $title = ( !empty($data->title) ) ? $data->title : ''; - $return = '' . esc_attr($title) . ''; + $return = '' . esc_attr($title) . ''; break; case 'video': diff --git a/wp-includes/class-pop3.php b/wp-includes/class-pop3.php index c11676c4..2bf442f8 100644 --- a/wp-includes/class-pop3.php +++ b/wp-includes/class-pop3.php @@ -11,10 +11,11 @@ * An RFC 1939 compliant wrapper class for the POP3 protocol. * * Licensed under the GNU GPL. For full terms see the file COPYING. + * @license http://opensource.org/licenses/gpl-license.php GNU General Public License * * pop3 class * - * $Id: class-pop3.php 9503 2008-11-03 23:25:11Z ryan $ + * $Id: class-pop3.php 17435 2011-02-09 17:35:36Z ryan $ */ class POP3 { @@ -367,7 +368,7 @@ class POP3 { $line = fgets($fp,$buffer); while ( !ereg("^\.\r\n",$line)) { - if ( $line{0} == '.' ) { $line = substr($line,1); } + if ( $line[0] == '.' ) { $line = substr($line,1); } $MsgArray[$count] = $line; $count++; $line = fgets($fp,$buffer); diff --git a/wp-includes/class-simplepie.php b/wp-includes/class-simplepie.php index 98843f03..275033a8 100644 --- a/wp-includes/class-simplepie.php +++ b/wp-includes/class-simplepie.php @@ -1831,7 +1831,7 @@ class SimplePie } /** - * Return the error message for the occured error + * Return the error message for the occurred error * * @access public * @return string Error message diff --git a/wp-includes/class-snoopy.php b/wp-includes/class-snoopy.php index da3d824e..66ff71fc 100644 --- a/wp-includes/class-snoopy.php +++ b/wp-includes/class-snoopy.php @@ -719,13 +719,13 @@ class Snoopy chr(176), chr(39), chr(128), - "ä", - "ö", - "ü", - "Ä", - "Ö", - "Ãœ", - "ß", + chr(0xE4), // ANSI ä + chr(0xF6), // ANSI ö + chr(0xFC), // ANSI ü + chr(0xC4), // ANSI Ä + chr(0xD6), // ANSI Ö + chr(0xDC), // ANSI Ü + chr(0xDF), // ANSI ß ); $text = preg_replace($search,$replace,$document); diff --git a/wp-includes/class-wp-admin-bar.php b/wp-includes/class-wp-admin-bar.php new file mode 100644 index 00000000..549d5ecf --- /dev/null +++ b/wp-includes/class-wp-admin-bar.php @@ -0,0 +1,236 @@ +proto = 'https://'; + + $this->user = new stdClass; + $this->menu = new stdClass; + + /* Populate settings we need for the menu based on the current user. */ + $this->user->blogs = get_blogs_of_user( get_current_user_id() ); + if ( is_multisite() ) { + $this->user->active_blog = get_active_blog_for_user( get_current_user_id() ); + $this->user->domain = empty( $this->user->active_blog ) ? user_admin_url() : trailingslashit( get_home_url( $this->user->active_blog->blog_id ) ); + $this->user->account_domain = $this->user->domain; + } else { + $this->user->active_blog = $this->user->blogs[get_current_blog_id()]; + $this->user->domain = trailingslashit( home_url() ); + $this->user->account_domain = $this->user->domain; + } + $this->user->locale = get_locale(); + + add_action( 'wp_head', 'wp_admin_bar_header' ); + + add_action( 'admin_head', 'wp_admin_bar_header' ); + + if ( current_theme_supports( 'admin-bar' ) ) { + $admin_bar_args = get_theme_support( 'admin-bar' ); // add_theme_support( 'admin-bar', array( 'callback' => '__return_false') ); + $header_callback = $admin_bar_args[0]['callback']; + } + + if ( empty($header_callback) ) + $header_callback = '_admin_bar_bump_cb'; + + add_action('wp_head', $header_callback); + + wp_enqueue_script( 'admin-bar' ); + wp_enqueue_style( 'admin-bar' ); + + do_action( 'admin_bar_init' ); + } + + function add_menu( $args = array() ) { + $defaults = array( + 'title' => false, + 'href' => false, + 'parent' => false, // false for a root menu, pass the ID value for a submenu of that menu. + 'id' => false, // defaults to a sanitized title value. + 'meta' => false // array of any of the following options: array( 'html' => '', 'class' => '', 'onclick' => '', target => '', title => '' ); + ); + + $r = wp_parse_args( $args, $defaults ); + extract( $r, EXTR_SKIP ); + + if ( empty( $title ) ) + return false; + + /* Make sure we have a valid ID */ + if ( empty( $id ) ) + $id = esc_attr( sanitize_title( trim( $title ) ) ); + + if ( ! empty( $parent ) ) { + /* Add the menu to the parent item */ + $child = array( 'id' => $id, 'title' => $title, 'href' => $href ); + + if ( ! empty( $meta ) ) + $child['meta'] = $meta; + + $this->add_node( $parent, $this->menu, $child ); + } else { + /* Add the menu item */ + $this->menu->{$id} = array( 'title' => $title, 'href' => $href ); + + if ( ! empty( $meta ) ) + $this->menu->{$id}['meta'] = $meta; + } + } + + function remove_menu( $id ) { + return $this->remove_node( $id, $this->menu ); + } + + function render() { + ?> +
        + + +
        +
        + + +
        +
        +
        + + menu = null; + } + + /* Helpers */ + function recursive_render( $id, &$menu_item ) { ?> + + +
      • " class=""> + onclick="" target="" title=""> + + +
          + $child_menu_item ) : ?> + recursive_render( $child_id, $child_menu_item ); ?> + +
        + + + + + +
      • $menu_item ) { + if ( $parent_id == $id ) { + $menu->{$parent_id}['children']->{$child['id']} = $child; + $child = null; + return true; + } + + if ( ! empty( $menu->{$id}['children'] ) ) + $this->add_node( $parent_id, $menu->{$id}['children'], $child ); + } + + $child = null; + + return false; + } + + function add_menus() { + add_action( 'admin_bar_menu', 'wp_admin_bar_my_account_menu', 10 ); + add_action( 'admin_bar_menu', 'wp_admin_bar_my_sites_menu', 20 ); + add_action( 'admin_bar_menu', 'wp_admin_bar_edit_menu', 30 ); + add_action( 'admin_bar_menu', 'wp_admin_bar_shortlink_menu', 80 ); + add_action( 'admin_bar_menu', 'wp_admin_bar_updates_menu', 70 ); + + if ( !is_network_admin() && !is_user_admin() ) { + add_action( 'admin_bar_menu', 'wp_admin_bar_new_content_menu', 40 ); + add_action( 'admin_bar_menu', 'wp_admin_bar_comments_menu', 50 ); + add_action( 'admin_bar_menu', 'wp_admin_bar_appearance_menu', 60 ); + } + + do_action( 'add_admin_bar_menus' ); + } + + function remove_node( $id, &$menu ) { + if ( isset( $menu->$id ) ) { + unset( $menu->$id ); + return true; + } + + foreach( $menu as $menu_item_id => $menu_item ) { + if ( ! empty( $menu->{$menu_item_id}['children'] ) ) + $this->remove_node( $id, $menu->{$menu_item_id}['children'] ); + } + + return false; + } + + // TODO: Convert to a core feature for multisite or remove + function load_user_locale_translations() { + $this->need_to_change_locale = ( get_locale() != $this->user->locale ); + if ( ! $this->need_to_change_locale ) + return; + /* + $this->previous_translations = get_translations_for_domain( 'default' ); + $this->adminbar_locale_filter = lambda( '$_', '$GLOBALS["wp_admin_bar"]->user->locale;' ); + unload_textdomain( 'default' ); + add_filter( 'locale', $this->adminbar_locale_filter ); + load_default_textdomain(); + $this->changed_locale = true; + */ + } + + function unload_user_locale_translations() { + global $l10n; + if ( ! $this->changed_locale ) + return; + /* + remove_filter( 'locale', $this->adminbar_locale_filter ); + $l10n['default'] = &$this->previous_translations; + */ + } +} +?> diff --git a/wp-includes/class-wp-ajax-response.php b/wp-includes/class-wp-ajax-response.php new file mode 100644 index 00000000..cf64bfbc --- /dev/null +++ b/wp-includes/class-wp-ajax-response.php @@ -0,0 +1,138 @@ +add($args); + } + + /** + * Append to XML response based on given arguments. + * + * The arguments that can be passed in the $args parameter are below. It is + * also possible to pass a WP_Error object in either the 'id' or 'data' + * argument. The parameter isn't actually optional, content should be given + * in order to send the correct response. + * + * 'what' argument is a string that is the XMLRPC response type. + * 'action' argument is a boolean or string that acts like a nonce. + * 'id' argument can be WP_Error or an integer. + * 'old_id' argument is false by default or an integer of the previous ID. + * 'position' argument is an integer or a string with -1 = top, 1 = bottom, + * html ID = after, -html ID = before. + * 'data' argument is a string with the content or message. + * 'supplemental' argument is an array of strings that will be children of + * the supplemental element. + * + * @since 2.1.0 + * + * @param string|array $args Override defaults. + * @return string XML response. + */ + function add( $args = '' ) { + $defaults = array( + 'what' => 'object', 'action' => false, + 'id' => '0', 'old_id' => false, + 'position' => 1, + 'data' => '', 'supplemental' => array() + ); + + $r = wp_parse_args( $args, $defaults ); + extract( $r, EXTR_SKIP ); + $position = preg_replace( '/[^a-z0-9:_-]/i', '', $position ); + + if ( is_wp_error($id) ) { + $data = $id; + $id = 0; + } + + $response = ''; + if ( is_wp_error($data) ) { + foreach ( (array) $data->get_error_codes() as $code ) { + $response .= "get_error_message($code) . "]]>"; + if ( !$error_data = $data->get_error_data($code) ) + continue; + $class = ''; + if ( is_object($error_data) ) { + $class = ' class="' . get_class($error_data) . '"'; + $error_data = get_object_vars($error_data); + } + + $response .= ""; + + if ( is_scalar($error_data) ) { + $response .= ""; + } elseif ( is_array($error_data) ) { + foreach ( $error_data as $k => $v ) + $response .= "<$k>"; + } + + $response .= ""; + } + } else { + $response = ""; + } + + $s = ''; + if ( is_array($supplemental) ) { + foreach ( $supplemental as $k => $v ) + $s .= "<$k>"; + $s = "$s"; + } + + if ( false === $action ) + $action = $_POST['action']; + + $x = ''; + $x .= ""; // The action attribute in the xml output is formatted like a nonce action + $x .= "<$what id='$id' " . ( false === $old_id ? '' : "old_id='$old_id' " ) . "position='$position'>"; + $x .= $response; + $x .= $s; + $x .= ""; + $x .= ""; + + $this->responses[] = $x; + return $x; + } + + /** + * Display XML formatted responses. + * + * Sets the content type header to text/xml. + * + * @since 2.1.0 + */ + function send() { + header('Content-Type: text/xml'); + echo ""; + foreach ( (array) $this->responses as $response ) + echo $response; + echo ''; + die(); + } +} + +?> diff --git a/wp-includes/class-wp-error.php b/wp-includes/class-wp-error.php new file mode 100644 index 00000000..16241958 --- /dev/null +++ b/wp-includes/class-wp-error.php @@ -0,0 +1,212 @@ +errors[$code][] = $message; + + if ( ! empty($data) ) + $this->error_data[$code] = $data; + } + + /** + * Retrieve all error codes. + * + * @since 2.1.0 + * @access public + * + * @return array List of error codes, if avaiable. + */ + function get_error_codes() { + if ( empty($this->errors) ) + return array(); + + return array_keys($this->errors); + } + + /** + * Retrieve first error code available. + * + * @since 2.1.0 + * @access public + * + * @return string|int Empty string, if no error codes. + */ + function get_error_code() { + $codes = $this->get_error_codes(); + + if ( empty($codes) ) + return ''; + + return $codes[0]; + } + + /** + * Retrieve all error messages or error messages matching code. + * + * @since 2.1.0 + * + * @param string|int $code Optional. Retrieve messages matching code, if exists. + * @return array Error strings on success, or empty array on failure (if using codee parameter). + */ + function get_error_messages($code = '') { + // Return all messages if no code specified. + if ( empty($code) ) { + $all_messages = array(); + foreach ( (array) $this->errors as $code => $messages ) + $all_messages = array_merge($all_messages, $messages); + + return $all_messages; + } + + if ( isset($this->errors[$code]) ) + return $this->errors[$code]; + else + return array(); + } + + /** + * Get single error message. + * + * This will get the first message available for the code. If no code is + * given then the first code available will be used. + * + * @since 2.1.0 + * + * @param string|int $code Optional. Error code to retrieve message. + * @return string + */ + function get_error_message($code = '') { + if ( empty($code) ) + $code = $this->get_error_code(); + $messages = $this->get_error_messages($code); + if ( empty($messages) ) + return ''; + return $messages[0]; + } + + /** + * Retrieve error data for error code. + * + * @since 2.1.0 + * + * @param string|int $code Optional. Error code. + * @return mixed Null, if no errors. + */ + function get_error_data($code = '') { + if ( empty($code) ) + $code = $this->get_error_code(); + + if ( isset($this->error_data[$code]) ) + return $this->error_data[$code]; + return null; + } + + /** + * Append more error messages to list of error messages. + * + * @since 2.1.0 + * @access public + * + * @param string|int $code Error code. + * @param string $message Error message. + * @param mixed $data Optional. Error data. + */ + function add($code, $message, $data = '') { + $this->errors[$code][] = $message; + if ( ! empty($data) ) + $this->error_data[$code] = $data; + } + + /** + * Add data for error code. + * + * The error code can only contain one error data. + * + * @since 2.1.0 + * + * @param mixed $data Error data. + * @param string|int $code Error code. + */ + function add_data($data, $code = '') { + if ( empty($code) ) + $code = $this->get_error_code(); + + $this->error_data[$code] = $data; + } +} + +/** + * Check whether variable is a WordPress Error. + * + * Looks at the object and if a WP_Error class. Does not check to see if the + * parent is also WP_Error, so can't inherit WP_Error and still use this + * function. + * + * @since 2.1.0 + * + * @param mixed $thing Check if unknown variable is WordPress Error object. + * @return bool True, if WP_Error. False, if not WP_Error. + */ +function is_wp_error($thing) { + if ( is_object($thing) && is_a($thing, 'WP_Error') ) + return true; + return false; +} + +?> \ No newline at end of file diff --git a/wp-includes/class-wp-http-ixr-client.php b/wp-includes/class-wp-http-ixr-client.php new file mode 100644 index 00000000..4c36334e --- /dev/null +++ b/wp-includes/class-wp-http-ixr-client.php @@ -0,0 +1,91 @@ +scheme = $bits['scheme']; + $this->server = $bits['host']; + $this->port = isset($bits['port']) ? $bits['port'] : 80; + $this->path = !empty($bits['path']) ? $bits['path'] : '/'; + + // Make absolutely sure we have a path + if ( ! $this->path ) + $this->path = '/'; + } else { + $this->scheme = 'http'; + $this->server = $server; + $this->path = $path; + $this->port = $port; + } + $this->useragent = 'The Incutio XML-RPC PHP Library'; + $this->timeout = $timeout; + } + + function query() { + $args = func_get_args(); + $method = array_shift($args); + $request = new IXR_Request($method, $args); + $xml = $request->getXml(); + + $url = $this->scheme . '://' . $this->server . ':' . $this->port . $this->path; + $args = array( + 'headers' => array('Content-Type' => 'text/xml'), + 'user-agent' => $this->useragent, + 'body' => $xml, + ); + + // Merge Custom headers ala #8145 + foreach ( $this->headers as $header => $value ) + $args['headers'][$header] = $value; + + if ( $this->timeout !== false ) + $args['timeout'] = $this->timeout; + + // Now send the request + if ( $this->debug ) + echo '
        ' . htmlspecialchars($xml) . "\n
        \n\n"; + + $response = wp_remote_post($url, $args); + + if ( is_wp_error($response) ) { + $errno = $response->get_error_code(); + $errorstr = $response->get_error_message(); + $this->error = new IXR_Error(-32300, "transport error: $errno $errorstr"); + return false; + } + + if ( $response['response']['code'] != 200 ) { + $this->error = new IXR_Error(-32301, "transport error - HTTP status code was not 200 ({$response['response']['code']})"); + return false; + } + + if ( $this->debug ) + echo '
        ' . htmlspecialchars($response['body']) . "\n
        \n\n"; + + // Now parse what we've got back + $this->message = new IXR_Message( $response['body'] ); + if ( ! $this->message->parse() ) { + // XML error + $this->error = new IXR_Error(-32700, 'parse error. not well formed'); + return false; + } + + // Is the message a fault? + if ( $this->message->messageType == 'fault' ) { + $this->error = new IXR_Error($this->message->faultCode, $this->message->faultString); + return false; + } + + // Message must be OK + return true; + } +} +?> \ No newline at end of file diff --git a/wp-includes/class-wp-walker.php b/wp-includes/class-wp-walker.php new file mode 100644 index 00000000..25e04059 --- /dev/null +++ b/wp-includes/class-wp-walker.php @@ -0,0 +1,399 @@ +db_fields['id']; + + //display this element + if ( is_array( $args[0] ) ) + $args[0]['has_children'] = ! empty( $children_elements[$element->$id_field] ); + $cb_args = array_merge( array(&$output, $element, $depth), $args); + call_user_func_array(array(&$this, 'start_el'), $cb_args); + + $id = $element->$id_field; + + // descend only when the depth is right and there are childrens for this element + if ( ($max_depth == 0 || $max_depth > $depth+1 ) && isset( $children_elements[$id]) ) { + + foreach( $children_elements[ $id ] as $child ){ + + if ( !isset($newlevel) ) { + $newlevel = true; + //start the child delimiter + $cb_args = array_merge( array(&$output, $depth), $args); + call_user_func_array(array(&$this, 'start_lvl'), $cb_args); + } + $this->display_element( $child, $children_elements, $max_depth, $depth + 1, $args, $output ); + } + unset( $children_elements[ $id ] ); + } + + if ( isset($newlevel) && $newlevel ){ + //end the child delimiter + $cb_args = array_merge( array(&$output, $depth), $args); + call_user_func_array(array(&$this, 'end_lvl'), $cb_args); + } + + //end this element + $cb_args = array_merge( array(&$output, $element, $depth), $args); + call_user_func_array(array(&$this, 'end_el'), $cb_args); + } + + /** + * Display array of elements hierarchically. + * + * It is a generic function which does not assume any existing order of + * elements. max_depth = -1 means flatly display every element. max_depth = + * 0 means display all levels. max_depth > 0 specifies the number of + * display levels. + * + * @since 2.1.0 + * + * @param array $elements + * @param int $max_depth + * @return string + */ + function walk( $elements, $max_depth) { + + $args = array_slice(func_get_args(), 2); + $output = ''; + + if ($max_depth < -1) //invalid parameter + return $output; + + if (empty($elements)) //nothing to walk + return $output; + + $id_field = $this->db_fields['id']; + $parent_field = $this->db_fields['parent']; + + // flat display + if ( -1 == $max_depth ) { + $empty_array = array(); + foreach ( $elements as $e ) + $this->display_element( $e, $empty_array, 1, 0, $args, $output ); + return $output; + } + + /* + * need to display in hierarchical order + * separate elements into two buckets: top level and children elements + * children_elements is two dimensional array, eg. + * children_elements[10][] contains all sub-elements whose parent is 10. + */ + $top_level_elements = array(); + $children_elements = array(); + foreach ( $elements as $e) { + if ( 0 == $e->$parent_field ) + $top_level_elements[] = $e; + else + $children_elements[ $e->$parent_field ][] = $e; + } + + /* + * when none of the elements is top level + * assume the first one must be root of the sub elements + */ + if ( empty($top_level_elements) ) { + + $first = array_slice( $elements, 0, 1 ); + $root = $first[0]; + + $top_level_elements = array(); + $children_elements = array(); + foreach ( $elements as $e) { + if ( $root->$parent_field == $e->$parent_field ) + $top_level_elements[] = $e; + else + $children_elements[ $e->$parent_field ][] = $e; + } + } + + foreach ( $top_level_elements as $e ) + $this->display_element( $e, $children_elements, $max_depth, 0, $args, $output ); + + /* + * if we are displaying all levels, and remaining children_elements is not empty, + * then we got orphans, which should be displayed regardless + */ + if ( ( $max_depth == 0 ) && count( $children_elements ) > 0 ) { + $empty_array = array(); + foreach ( $children_elements as $orphans ) + foreach( $orphans as $op ) + $this->display_element( $op, $empty_array, 1, 0, $args, $output ); + } + + return $output; + } + + /** + * paged_walk() - produce a page of nested elements + * + * Given an array of hierarchical elements, the maximum depth, a specific page number, + * and number of elements per page, this function first determines all top level root elements + * belonging to that page, then lists them and all of their children in hierarchical order. + * + * @package WordPress + * @since 2.7 + * @param int $max_depth = 0 means display all levels; $max_depth > 0 specifies the number of display levels. + * @param int $page_num the specific page number, beginning with 1. + * @return XHTML of the specified page of elements + */ + function paged_walk( $elements, $max_depth, $page_num, $per_page ) { + + /* sanity check */ + if ( empty($elements) || $max_depth < -1 ) + return ''; + + $args = array_slice( func_get_args(), 4 ); + $output = ''; + + $id_field = $this->db_fields['id']; + $parent_field = $this->db_fields['parent']; + + $count = -1; + if ( -1 == $max_depth ) + $total_top = count( $elements ); + if ( $page_num < 1 || $per_page < 0 ) { + // No paging + $paging = false; + $start = 0; + if ( -1 == $max_depth ) + $end = $total_top; + $this->max_pages = 1; + } else { + $paging = true; + $start = ( (int)$page_num - 1 ) * (int)$per_page; + $end = $start + $per_page; + if ( -1 == $max_depth ) + $this->max_pages = ceil($total_top / $per_page); + } + + // flat display + if ( -1 == $max_depth ) { + if ( !empty($args[0]['reverse_top_level']) ) { + $elements = array_reverse( $elements ); + $oldstart = $start; + $start = $total_top - $end; + $end = $total_top - $oldstart; + } + + $empty_array = array(); + foreach ( $elements as $e ) { + $count++; + if ( $count < $start ) + continue; + if ( $count >= $end ) + break; + $this->display_element( $e, $empty_array, 1, 0, $args, $output ); + } + return $output; + } + + /* + * separate elements into two buckets: top level and children elements + * children_elements is two dimensional array, eg. + * children_elements[10][] contains all sub-elements whose parent is 10. + */ + $top_level_elements = array(); + $children_elements = array(); + foreach ( $elements as $e) { + if ( 0 == $e->$parent_field ) + $top_level_elements[] = $e; + else + $children_elements[ $e->$parent_field ][] = $e; + } + + $total_top = count( $top_level_elements ); + if ( $paging ) + $this->max_pages = ceil($total_top / $per_page); + else + $end = $total_top; + + if ( !empty($args[0]['reverse_top_level']) ) { + $top_level_elements = array_reverse( $top_level_elements ); + $oldstart = $start; + $start = $total_top - $end; + $end = $total_top - $oldstart; + } + if ( !empty($args[0]['reverse_children']) ) { + foreach ( $children_elements as $parent => $children ) + $children_elements[$parent] = array_reverse( $children ); + } + + foreach ( $top_level_elements as $e ) { + $count++; + + //for the last page, need to unset earlier children in order to keep track of orphans + if ( $end >= $total_top && $count < $start ) + $this->unset_children( $e, $children_elements ); + + if ( $count < $start ) + continue; + + if ( $count >= $end ) + break; + + $this->display_element( $e, $children_elements, $max_depth, 0, $args, $output ); + } + + if ( $end >= $total_top && count( $children_elements ) > 0 ) { + $empty_array = array(); + foreach ( $children_elements as $orphans ) + foreach( $orphans as $op ) + $this->display_element( $op, $empty_array, 1, 0, $args, $output ); + } + + return $output; + } + + function get_number_of_root_elements( $elements ){ + + $num = 0; + $parent_field = $this->db_fields['parent']; + + foreach ( $elements as $e) { + if ( 0 == $e->$parent_field ) + $num++; + } + return $num; + } + + // unset all the children for a given top level element + function unset_children( $e, &$children_elements ){ + + if ( !$e || !$children_elements ) + return; + + $id_field = $this->db_fields['id']; + $id = $e->$id_field; + + if ( !empty($children_elements[$id]) && is_array($children_elements[$id]) ) + foreach ( (array) $children_elements[$id] as $child ) + $this->unset_children( $child, $children_elements ); + + if ( isset($children_elements[$id]) ) + unset( $children_elements[$id] ); + + } +} + +?> \ No newline at end of file diff --git a/wp-includes/class-wp-xmlrpc-server.php b/wp-includes/class-wp-xmlrpc-server.php new file mode 100644 index 00000000..5e9bbd49 --- /dev/null +++ b/wp-includes/class-wp-xmlrpc-server.php @@ -0,0 +1,3527 @@ +methods = array( + // WordPress API + 'wp.getUsersBlogs' => 'this:wp_getUsersBlogs', + 'wp.getPage' => 'this:wp_getPage', + 'wp.getPages' => 'this:wp_getPages', + 'wp.newPage' => 'this:wp_newPage', + 'wp.deletePage' => 'this:wp_deletePage', + 'wp.editPage' => 'this:wp_editPage', + 'wp.getPageList' => 'this:wp_getPageList', + 'wp.getAuthors' => 'this:wp_getAuthors', + 'wp.getCategories' => 'this:mw_getCategories', // Alias + 'wp.getTags' => 'this:wp_getTags', + 'wp.newCategory' => 'this:wp_newCategory', + 'wp.deleteCategory' => 'this:wp_deleteCategory', + 'wp.suggestCategories' => 'this:wp_suggestCategories', + 'wp.uploadFile' => 'this:mw_newMediaObject', // Alias + 'wp.getCommentCount' => 'this:wp_getCommentCount', + 'wp.getPostStatusList' => 'this:wp_getPostStatusList', + 'wp.getPageStatusList' => 'this:wp_getPageStatusList', + 'wp.getPageTemplates' => 'this:wp_getPageTemplates', + 'wp.getOptions' => 'this:wp_getOptions', + 'wp.setOptions' => 'this:wp_setOptions', + 'wp.getComment' => 'this:wp_getComment', + 'wp.getComments' => 'this:wp_getComments', + 'wp.deleteComment' => 'this:wp_deleteComment', + 'wp.editComment' => 'this:wp_editComment', + 'wp.newComment' => 'this:wp_newComment', + 'wp.getCommentStatusList' => 'this:wp_getCommentStatusList', + 'wp.getMediaItem' => 'this:wp_getMediaItem', + 'wp.getMediaLibrary' => 'this:wp_getMediaLibrary', + 'wp.getPostFormats' => 'this:wp_getPostFormats', + + // Blogger API + 'blogger.getUsersBlogs' => 'this:blogger_getUsersBlogs', + 'blogger.getUserInfo' => 'this:blogger_getUserInfo', + 'blogger.getPost' => 'this:blogger_getPost', + 'blogger.getRecentPosts' => 'this:blogger_getRecentPosts', + 'blogger.getTemplate' => 'this:blogger_getTemplate', + 'blogger.setTemplate' => 'this:blogger_setTemplate', + 'blogger.newPost' => 'this:blogger_newPost', + 'blogger.editPost' => 'this:blogger_editPost', + 'blogger.deletePost' => 'this:blogger_deletePost', + + // MetaWeblog API (with MT extensions to structs) + 'metaWeblog.newPost' => 'this:mw_newPost', + 'metaWeblog.editPost' => 'this:mw_editPost', + 'metaWeblog.getPost' => 'this:mw_getPost', + 'metaWeblog.getRecentPosts' => 'this:mw_getRecentPosts', + 'metaWeblog.getCategories' => 'this:mw_getCategories', + 'metaWeblog.newMediaObject' => 'this:mw_newMediaObject', + + // MetaWeblog API aliases for Blogger API + // see http://www.xmlrpc.com/stories/storyReader$2460 + 'metaWeblog.deletePost' => 'this:blogger_deletePost', + 'metaWeblog.getTemplate' => 'this:blogger_getTemplate', + 'metaWeblog.setTemplate' => 'this:blogger_setTemplate', + 'metaWeblog.getUsersBlogs' => 'this:blogger_getUsersBlogs', + + // MovableType API + 'mt.getCategoryList' => 'this:mt_getCategoryList', + 'mt.getRecentPostTitles' => 'this:mt_getRecentPostTitles', + 'mt.getPostCategories' => 'this:mt_getPostCategories', + 'mt.setPostCategories' => 'this:mt_setPostCategories', + 'mt.supportedMethods' => 'this:mt_supportedMethods', + 'mt.supportedTextFilters' => 'this:mt_supportedTextFilters', + 'mt.getTrackbackPings' => 'this:mt_getTrackbackPings', + 'mt.publishPost' => 'this:mt_publishPost', + + // PingBack + 'pingback.ping' => 'this:pingback_ping', + 'pingback.extensions.getPingbacks' => 'this:pingback_extensions_getPingbacks', + + 'demo.sayHello' => 'this:sayHello', + 'demo.addTwoNumbers' => 'this:addTwoNumbers' + ); + + $this->initialise_blog_option_info( ); + $this->methods = apply_filters('xmlrpc_methods', $this->methods); + } + + function serve_request() { + $this->IXR_Server($this->methods); + } + + /** + * Test XMLRPC API by saying, "Hello!" to client. + * + * @since 1.5.0 + * + * @param array $args Method Parameters. + * @return string + */ + function sayHello($args) { + return 'Hello!'; + } + + /** + * Test XMLRPC API by adding two numbers for client. + * + * @since 1.5.0 + * + * @param array $args Method Parameters. + * @return int + */ + function addTwoNumbers($args) { + $number1 = $args[0]; + $number2 = $args[1]; + return $number1 + $number2; + } + + /** + * Check user's credentials. + * + * @since 1.5.0 + * + * @param string $user_login User's username. + * @param string $user_pass User's password. + * @return bool Whether authentication passed. + * @deprecated use wp_xmlrpc_server::login + * @see wp_xmlrpc_server::login + */ + function login_pass_ok($user_login, $user_pass) { + if ( !get_option( 'enable_xmlrpc' ) ) { + $this->error = new IXR_Error( 405, sprintf( __( 'XML-RPC services are disabled on this site. An admin user can enable them at %s'), admin_url('options-writing.php') ) ); + return false; + } + + if (!user_pass_ok($user_login, $user_pass)) { + $this->error = new IXR_Error(403, __('Bad login/pass combination.')); + return false; + } + return true; + } + + /** + * Log user in. + * + * @since 2.8 + * + * @param string $username User's username. + * @param string $password User's password. + * @return mixed WP_User object if authentication passed, false otherwise + */ + function login($username, $password) { + if ( !get_option( 'enable_xmlrpc' ) ) { + $this->error = new IXR_Error( 405, sprintf( __( 'XML-RPC services are disabled on this site. An admin user can enable them at %s'), admin_url('options-writing.php') ) ); + return false; + } + + $user = wp_authenticate($username, $password); + + if (is_wp_error($user)) { + $this->error = new IXR_Error(403, __('Bad login/pass combination.')); + return false; + } + + wp_set_current_user( $user->ID ); + return $user; + } + + /** + * Sanitize string or array of strings for database. + * + * @since 1.5.2 + * + * @param string|array $array Sanitize single string or array of strings. + * @return string|array Type matches $array and sanitized for the database. + */ + function escape(&$array) { + global $wpdb; + + if (!is_array($array)) { + return($wpdb->escape($array)); + } else { + foreach ( (array) $array as $k => $v ) { + if ( is_array($v) ) { + $this->escape($array[$k]); + } else if ( is_object($v) ) { + //skip + } else { + $array[$k] = $wpdb->escape($v); + } + } + } + } + + /** + * Retrieve custom fields for post. + * + * @since 2.5.0 + * + * @param int $post_id Post ID. + * @return array Custom fields, if exist. + */ + function get_custom_fields($post_id) { + $post_id = (int) $post_id; + + $custom_fields = array(); + + foreach ( (array) has_meta($post_id) as $meta ) { + // Don't expose protected fields. + if ( strpos($meta['meta_key'], '_wp_') === 0 ) { + continue; + } + + $custom_fields[] = array( + "id" => $meta['meta_id'], + "key" => $meta['meta_key'], + "value" => $meta['meta_value'] + ); + } + + return $custom_fields; + } + + /** + * Set custom fields for post. + * + * @since 2.5.0 + * + * @param int $post_id Post ID. + * @param array $fields Custom fields. + */ + function set_custom_fields($post_id, $fields) { + $post_id = (int) $post_id; + + foreach ( (array) $fields as $meta ) { + if ( isset($meta['id']) ) { + $meta['id'] = (int) $meta['id']; + + if ( isset($meta['key']) ) { + update_meta($meta['id'], $meta['key'], $meta['value']); + } + else { + delete_meta($meta['id']); + } + } + else { + $_POST['metakeyinput'] = $meta['key']; + $_POST['metavalue'] = $meta['value']; + add_meta($post_id); + } + } + } + + /** + * Set up blog options property. + * + * Passes property through 'xmlrpc_blog_options' filter. + * + * @since 2.6.0 + */ + function initialise_blog_option_info( ) { + global $wp_version; + + $this->blog_options = array( + // Read only options + 'software_name' => array( + 'desc' => __( 'Software Name' ), + 'readonly' => true, + 'value' => 'WordPress' + ), + 'software_version' => array( + 'desc' => __( 'Software Version' ), + 'readonly' => true, + 'value' => $wp_version + ), + 'blog_url' => array( + 'desc' => __( 'Site URL' ), + 'readonly' => true, + 'option' => 'siteurl' + ), + + // Updatable options + 'time_zone' => array( + 'desc' => __( 'Time Zone' ), + 'readonly' => false, + 'option' => 'gmt_offset' + ), + 'blog_title' => array( + 'desc' => __( 'Site Title' ), + 'readonly' => false, + 'option' => 'blogname' + ), + 'blog_tagline' => array( + 'desc' => __( 'Site Tagline' ), + 'readonly' => false, + 'option' => 'blogdescription' + ), + 'date_format' => array( + 'desc' => __( 'Date Format' ), + 'readonly' => false, + 'option' => 'date_format' + ), + 'time_format' => array( + 'desc' => __( 'Time Format' ), + 'readonly' => false, + 'option' => 'time_format' + ), + 'users_can_register' => array( + 'desc' => __( 'Allow new users to sign up' ), + 'readonly' => false, + 'option' => 'users_can_register' + ), + 'thumbnail_size_w' => array( + 'desc' => __( 'Thumbnail Width' ), + 'readonly' => false, + 'option' => 'thumbnail_size_w' + ), + 'thumbnail_size_h' => array( + 'desc' => __( 'Thumbnail Height' ), + 'readonly' => false, + 'option' => 'thumbnail_size_h' + ), + 'thumbnail_crop' => array( + 'desc' => __( 'Crop thumbnail to exact dimensions' ), + 'readonly' => false, + 'option' => 'thumbnail_crop' + ), + 'medium_size_w' => array( + 'desc' => __( 'Medium size image width' ), + 'readonly' => false, + 'option' => 'medium_size_w' + ), + 'medium_size_h' => array( + 'desc' => __( 'Medium size image height' ), + 'readonly' => false, + 'option' => 'medium_size_h' + ), + 'large_size_w' => array( + 'desc' => __( 'Large size image width' ), + 'readonly' => false, + 'option' => 'large_size_w' + ), + 'large_size_h' => array( + 'desc' => __( 'Large size image height' ), + 'readonly' => false, + 'option' => 'large_size_h' + ) + ); + + $this->blog_options = apply_filters( 'xmlrpc_blog_options', $this->blog_options ); + } + + /** + * Retrieve the blogs of the user. + * + * @since 2.6.0 + * + * @param array $args Method parameters. + * @return array + */ + function wp_getUsersBlogs( $args ) { + global $current_site; + // If this isn't on WPMU then just use blogger_getUsersBlogs + if ( !is_multisite() ) { + array_unshift( $args, 1 ); + return $this->blogger_getUsersBlogs( $args ); + } + + $this->escape( $args ); + + $username = $args[0]; + $password = $args[1]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + + do_action( 'xmlrpc_call', 'wp.getUsersBlogs' ); + + $blogs = (array) get_blogs_of_user( $user->ID ); + $struct = array( ); + + foreach ( $blogs as $blog ) { + // Don't include blogs that aren't hosted at this site + if ( $blog->site_id != $current_site->id ) + continue; + + $blog_id = $blog->userblog_id; + switch_to_blog($blog_id); + $is_admin = current_user_can('manage_options'); + + $struct[] = array( + 'isAdmin' => $is_admin, + 'url' => get_option( 'home' ) . '/', + 'blogid' => (string) $blog_id, + 'blogName' => get_option( 'blogname' ), + 'xmlrpc' => site_url( 'xmlrpc.php' ) + ); + + restore_current_blog( ); + } + + return $struct; + } + + /** + * Retrieve page. + * + * @since 2.2.0 + * + * @param array $args Method parameters. + * @return array + */ + function wp_getPage($args) { + $this->escape($args); + + $blog_id = (int) $args[0]; + $page_id = (int) $args[1]; + $username = $args[2]; + $password = $args[3]; + + if ( !$user = $this->login($username, $password) ) { + return $this->error; + } + + if ( !current_user_can( 'edit_page', $page_id ) ) + return new IXR_Error( 401, __( 'Sorry, you cannot edit this page.' ) ); + + do_action('xmlrpc_call', 'wp.getPage'); + + // Lookup page info. + $page = get_page($page_id); + + // If we found the page then format the data. + if ( $page->ID && ($page->post_type == "page") ) { + // Get all of the page content and link. + $full_page = get_extended($page->post_content); + $link = post_permalink($page->ID); + + // Get info the page parent if there is one. + $parent_title = ""; + if ( !empty($page->post_parent) ) { + $parent = get_page($page->post_parent); + $parent_title = $parent->post_title; + } + + // Determine comment and ping settings. + $allow_comments = comments_open($page->ID) ? 1 : 0; + $allow_pings = pings_open($page->ID) ? 1 : 0; + + // Format page date. + $page_date = mysql2date("Ymd\TH:i:s", $page->post_date, false); + $page_date_gmt = mysql2date("Ymd\TH:i:s", $page->post_date_gmt, false); + + // For drafts use the GMT version of the date + if ( $page->post_status == 'draft' ) + $page_date_gmt = get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $page->post_date ), 'Ymd\TH:i:s' ); + + // Pull the categories info together. + $categories = array(); + foreach ( wp_get_post_categories($page->ID) as $cat_id ) { + $categories[] = get_cat_name($cat_id); + } + + // Get the author info. + $author = get_userdata($page->post_author); + + $page_template = get_post_meta( $page->ID, '_wp_page_template', true ); + if ( empty( $page_template ) ) + $page_template = 'default'; + + $page_struct = array( + "dateCreated" => new IXR_Date($page_date), + "userid" => $page->post_author, + "page_id" => $page->ID, + "page_status" => $page->post_status, + "description" => $full_page["main"], + "title" => $page->post_title, + "link" => $link, + "permaLink" => $link, + "categories" => $categories, + "excerpt" => $page->post_excerpt, + "text_more" => $full_page["extended"], + "mt_allow_comments" => $allow_comments, + "mt_allow_pings" => $allow_pings, + "wp_slug" => $page->post_name, + "wp_password" => $page->post_password, + "wp_author" => $author->display_name, + "wp_page_parent_id" => $page->post_parent, + "wp_page_parent_title" => $parent_title, + "wp_page_order" => $page->menu_order, + "wp_author_id" => $author->ID, + "wp_author_display_name" => $author->display_name, + "date_created_gmt" => new IXR_Date($page_date_gmt), + "custom_fields" => $this->get_custom_fields($page_id), + "wp_page_template" => $page_template + ); + + return($page_struct); + } + // If the page doesn't exist indicate that. + else { + return(new IXR_Error(404, __("Sorry, no such page."))); + } + } + + /** + * Retrieve Pages. + * + * @since 2.2.0 + * + * @param array $args Method parameters. + * @return array + */ + function wp_getPages($args) { + $this->escape($args); + + $blog_id = (int) $args[0]; + $username = $args[1]; + $password = $args[2]; + $num_pages = isset($args[3]) ? (int) $args[3] : 10; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + if ( !current_user_can( 'edit_pages' ) ) + return new IXR_Error( 401, __( 'Sorry, you cannot edit pages.' ) ); + + do_action('xmlrpc_call', 'wp.getPages'); + + $pages = get_posts( array('post_type' => 'page', 'post_status' => 'any', 'numberposts' => $num_pages) ); + $num_pages = count($pages); + + // If we have pages, put together their info. + if ( $num_pages >= 1 ) { + $pages_struct = array(); + + for ( $i = 0; $i < $num_pages; $i++ ) { + $page = wp_xmlrpc_server::wp_getPage(array( + $blog_id, $pages[$i]->ID, $username, $password + )); + $pages_struct[] = $page; + } + + return($pages_struct); + } + // If no pages were found return an error. + else { + return(array()); + } + } + + /** + * Create new page. + * + * @since 2.2.0 + * + * @param array $args Method parameters. + * @return unknown + */ + function wp_newPage($args) { + // Items not escaped here will be escaped in newPost. + $username = $this->escape($args[1]); + $password = $this->escape($args[2]); + $page = $args[3]; + $publish = $args[4]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + do_action('xmlrpc_call', 'wp.newPage'); + + // Make sure the user is allowed to add new pages. + if ( !current_user_can("publish_pages") ) + return(new IXR_Error(401, __("Sorry, you cannot add new pages."))); + + // Mark this as content for a page. + $args[3]["post_type"] = "page"; + + // Let mw_newPost do all of the heavy lifting. + return($this->mw_newPost($args)); + } + + /** + * Delete page. + * + * @since 2.2.0 + * + * @param array $args Method parameters. + * @return bool True, if success. + */ + function wp_deletePage($args) { + $this->escape($args); + + $blog_id = (int) $args[0]; + $username = $args[1]; + $password = $args[2]; + $page_id = (int) $args[3]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + do_action('xmlrpc_call', 'wp.deletePage'); + + // Get the current page based on the page_id and + // make sure it is a page and not a post. + $actual_page = wp_get_single_post($page_id, ARRAY_A); + if ( !$actual_page || ($actual_page["post_type"] != "page") ) + return(new IXR_Error(404, __("Sorry, no such page."))); + + // Make sure the user can delete pages. + if ( !current_user_can("delete_page", $page_id) ) + return(new IXR_Error(401, __("Sorry, you do not have the right to delete this page."))); + + // Attempt to delete the page. + $result = wp_delete_post($page_id); + if ( !$result ) + return(new IXR_Error(500, __("Failed to delete the page."))); + + return(true); + } + + /** + * Edit page. + * + * @since 2.2.0 + * + * @param array $args Method parameters. + * @return unknown + */ + function wp_editPage($args) { + // Items not escaped here will be escaped in editPost. + $blog_id = (int) $args[0]; + $page_id = (int) $this->escape($args[1]); + $username = $this->escape($args[2]); + $password = $this->escape($args[3]); + $content = $args[4]; + $publish = $args[5]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + do_action('xmlrpc_call', 'wp.editPage'); + + // Get the page data and make sure it is a page. + $actual_page = wp_get_single_post($page_id, ARRAY_A); + if ( !$actual_page || ($actual_page["post_type"] != "page") ) + return(new IXR_Error(404, __("Sorry, no such page."))); + + // Make sure the user is allowed to edit pages. + if ( !current_user_can("edit_page", $page_id) ) + return(new IXR_Error(401, __("Sorry, you do not have the right to edit this page."))); + + // Mark this as content for a page. + $content["post_type"] = "page"; + + // Arrange args in the way mw_editPost understands. + $args = array( + $page_id, + $username, + $password, + $content, + $publish + ); + + // Let mw_editPost do all of the heavy lifting. + return($this->mw_editPost($args)); + } + + /** + * Retrieve page list. + * + * @since 2.2.0 + * + * @param array $args Method parameters. + * @return unknown + */ + function wp_getPageList($args) { + global $wpdb; + + $this->escape($args); + + $blog_id = (int) $args[0]; + $username = $args[1]; + $password = $args[2]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + if ( !current_user_can( 'edit_pages' ) ) + return new IXR_Error( 401, __( 'Sorry, you cannot edit pages.' ) ); + + do_action('xmlrpc_call', 'wp.getPageList'); + + // Get list of pages ids and titles + $page_list = $wpdb->get_results(" + SELECT ID page_id, + post_title page_title, + post_parent page_parent_id, + post_date_gmt, + post_date, + post_status + FROM {$wpdb->posts} + WHERE post_type = 'page' + ORDER BY ID + "); + + // The date needs to be formated properly. + $num_pages = count($page_list); + for ( $i = 0; $i < $num_pages; $i++ ) { + $post_date = mysql2date("Ymd\TH:i:s", $page_list[$i]->post_date, false); + $post_date_gmt = mysql2date("Ymd\TH:i:s", $page_list[$i]->post_date_gmt, false); + + $page_list[$i]->dateCreated = new IXR_Date($post_date); + $page_list[$i]->date_created_gmt = new IXR_Date($post_date_gmt); + + // For drafts use the GMT version of the date + if ( $page_list[$i]->post_status == 'draft' ) { + $page_list[$i]->date_created_gmt = get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $page_list[$i]->post_date ), 'Ymd\TH:i:s' ); + $page_list[$i]->date_created_gmt = new IXR_Date( $page_list[$i]->date_created_gmt ); + } + + unset($page_list[$i]->post_date_gmt); + unset($page_list[$i]->post_date); + unset($page_list[$i]->post_status); + } + + return($page_list); + } + + /** + * Retrieve authors list. + * + * @since 2.2.0 + * + * @param array $args Method parameters. + * @return array + */ + function wp_getAuthors($args) { + + $this->escape($args); + + $blog_id = (int) $args[0]; + $username = $args[1]; + $password = $args[2]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + if ( !current_user_can("edit_posts") ) + return(new IXR_Error(401, __("Sorry, you cannot edit posts on this site."))); + + do_action('xmlrpc_call', 'wp.getAuthors'); + + $authors = array(); + foreach ( get_users( array( 'fields' => array('ID','user_login','display_name') ) ) as $user ) { + $authors[] = array( + "user_id" => $user->ID, + "user_login" => $user->user_login, + "display_name" => $user->display_name + ); + } + + return $authors; + } + + /** + * Get list of all tags + * + * @since 2.7 + * + * @param array $args Method parameters. + * @return array + */ + function wp_getTags( $args ) { + $this->escape( $args ); + + $blog_id = (int) $args[0]; + $username = $args[1]; + $password = $args[2]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + if ( !current_user_can( 'edit_posts' ) ) + return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view tags.' ) ); + + do_action( 'xmlrpc_call', 'wp.getKeywords' ); + + $tags = array( ); + + if ( $all_tags = get_tags() ) { + foreach( (array) $all_tags as $tag ) { + $struct['tag_id'] = $tag->term_id; + $struct['name'] = $tag->name; + $struct['count'] = $tag->count; + $struct['slug'] = $tag->slug; + $struct['html_url'] = esc_html( get_tag_link( $tag->term_id ) ); + $struct['rss_url'] = esc_html( get_tag_feed_link( $tag->term_id ) ); + + $tags[] = $struct; + } + } + + return $tags; + } + + /** + * Create new category. + * + * @since 2.2.0 + * + * @param array $args Method parameters. + * @return int Category ID. + */ + function wp_newCategory($args) { + $this->escape($args); + + $blog_id = (int) $args[0]; + $username = $args[1]; + $password = $args[2]; + $category = $args[3]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + do_action('xmlrpc_call', 'wp.newCategory'); + + // Make sure the user is allowed to add a category. + if ( !current_user_can("manage_categories") ) + return(new IXR_Error(401, __("Sorry, you do not have the right to add a category."))); + + // If no slug was provided make it empty so that + // WordPress will generate one. + if ( empty($category["slug"]) ) + $category["slug"] = ""; + + // If no parent_id was provided make it empty + // so that it will be a top level page (no parent). + if ( !isset($category["parent_id"]) ) + $category["parent_id"] = ""; + + // If no description was provided make it empty. + if ( empty($category["description"]) ) + $category["description"] = ""; + + $new_category = array( + "cat_name" => $category["name"], + "category_nicename" => $category["slug"], + "category_parent" => $category["parent_id"], + "category_description" => $category["description"] + ); + + $cat_id = wp_insert_category($new_category, true); + if ( is_wp_error( $cat_id ) ) { + if ( 'term_exists' == $cat_id->get_error_code() ) + return (int) $cat_id->get_error_data(); + else + return(new IXR_Error(500, __("Sorry, the new category failed."))); + } elseif ( ! $cat_id ) { + return(new IXR_Error(500, __("Sorry, the new category failed."))); + } + + return($cat_id); + } + + /** + * Remove category. + * + * @since 2.5.0 + * + * @param array $args Method parameters. + * @return mixed See {@link wp_delete_term()} for return info. + */ + function wp_deleteCategory($args) { + $this->escape($args); + + $blog_id = (int) $args[0]; + $username = $args[1]; + $password = $args[2]; + $category_id = (int) $args[3]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + do_action('xmlrpc_call', 'wp.deleteCategory'); + + if ( !current_user_can("manage_categories") ) + return new IXR_Error( 401, __( "Sorry, you do not have the right to delete a category." ) ); + + return wp_delete_term( $category_id, 'category' ); + } + + /** + * Retrieve category list. + * + * @since 2.2.0 + * + * @param array $args Method parameters. + * @return array + */ + function wp_suggestCategories($args) { + $this->escape($args); + + $blog_id = (int) $args[0]; + $username = $args[1]; + $password = $args[2]; + $category = $args[3]; + $max_results = (int) $args[4]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + if ( !current_user_can( 'edit_posts' ) ) + return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts to this site in order to view categories.' ) ); + + do_action('xmlrpc_call', 'wp.suggestCategories'); + + $category_suggestions = array(); + $args = array('get' => 'all', 'number' => $max_results, 'name__like' => $category); + foreach ( (array) get_categories($args) as $cat ) { + $category_suggestions[] = array( + "category_id" => $cat->term_id, + "category_name" => $cat->name + ); + } + + return($category_suggestions); + } + + /** + * Retrieve comment. + * + * @since 2.7.0 + * + * @param array $args Method parameters. + * @return array + */ + function wp_getComment($args) { + $this->escape($args); + + $blog_id = (int) $args[0]; + $username = $args[1]; + $password = $args[2]; + $comment_id = (int) $args[3]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + if ( !current_user_can( 'moderate_comments' ) ) + return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); + + do_action('xmlrpc_call', 'wp.getComment'); + + if ( ! $comment = get_comment($comment_id) ) + return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); + + // Format page date. + $comment_date = mysql2date("Ymd\TH:i:s", $comment->comment_date, false); + $comment_date_gmt = mysql2date("Ymd\TH:i:s", $comment->comment_date_gmt, false); + + if ( '0' == $comment->comment_approved ) + $comment_status = 'hold'; + else if ( 'spam' == $comment->comment_approved ) + $comment_status = 'spam'; + else if ( '1' == $comment->comment_approved ) + $comment_status = 'approve'; + else + $comment_status = $comment->comment_approved; + + $link = get_comment_link($comment); + + $comment_struct = array( + "date_created_gmt" => new IXR_Date($comment_date_gmt), + "user_id" => $comment->user_id, + "comment_id" => $comment->comment_ID, + "parent" => $comment->comment_parent, + "status" => $comment_status, + "content" => $comment->comment_content, + "link" => $link, + "post_id" => $comment->comment_post_ID, + "post_title" => get_the_title($comment->comment_post_ID), + "author" => $comment->comment_author, + "author_url" => $comment->comment_author_url, + "author_email" => $comment->comment_author_email, + "author_ip" => $comment->comment_author_IP, + "type" => $comment->comment_type, + ); + + return $comment_struct; + } + + /** + * Retrieve comments. + * + * @since 2.7.0 + * + * @param array $args Method parameters. + * @return array + */ + function wp_getComments($args) { + $raw_args = $args; + $this->escape($args); + + $blog_id = (int) $args[0]; + $username = $args[1]; + $password = $args[2]; + $struct = $args[3]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + if ( !current_user_can( 'moderate_comments' ) ) + return new IXR_Error( 401, __( 'Sorry, you cannot edit comments.' ) ); + + do_action('xmlrpc_call', 'wp.getComments'); + + if ( isset($struct['status']) ) + $status = $struct['status']; + else + $status = ''; + + $post_id = ''; + if ( isset($struct['post_id']) ) + $post_id = absint($struct['post_id']); + + $offset = 0; + if ( isset($struct['offset']) ) + $offset = absint($struct['offset']); + + $number = 10; + if ( isset($struct['number']) ) + $number = absint($struct['number']); + + $comments = get_comments( array('status' => $status, 'post_id' => $post_id, 'offset' => $offset, 'number' => $number ) ); + $num_comments = count($comments); + + if ( ! $num_comments ) + return array(); + + $comments_struct = array(); + + for ( $i = 0; $i < $num_comments; $i++ ) { + $comment = wp_xmlrpc_server::wp_getComment(array( + $raw_args[0], $raw_args[1], $raw_args[2], $comments[$i]->comment_ID, + )); + $comments_struct[] = $comment; + } + + return $comments_struct; + } + + /** + * Remove comment. + * + * @since 2.7.0 + * + * @param array $args Method parameters. + * @return mixed {@link wp_delete_comment()} + */ + function wp_deleteComment($args) { + $this->escape($args); + + $blog_id = (int) $args[0]; + $username = $args[1]; + $password = $args[2]; + $comment_ID = (int) $args[3]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + if ( !current_user_can( 'moderate_comments' ) ) + return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); + + if ( !current_user_can( 'edit_comment', $comment_ID ) ) + return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); + + do_action('xmlrpc_call', 'wp.deleteComment'); + + if ( ! get_comment($comment_ID) ) + return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); + + return wp_delete_comment($comment_ID); + } + + /** + * Edit comment. + * + * @since 2.7.0 + * + * @param array $args Method parameters. + * @return bool True, on success. + */ + function wp_editComment($args) { + $this->escape($args); + + $blog_id = (int) $args[0]; + $username = $args[1]; + $password = $args[2]; + $comment_ID = (int) $args[3]; + $content_struct = $args[4]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + if ( !current_user_can( 'moderate_comments' ) ) + return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); + + if ( !current_user_can( 'edit_comment', $comment_ID ) ) + return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); + + do_action('xmlrpc_call', 'wp.editComment'); + + if ( ! get_comment($comment_ID) ) + return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); + + if ( isset($content_struct['status']) ) { + $statuses = get_comment_statuses(); + $statuses = array_keys($statuses); + + if ( ! in_array($content_struct['status'], $statuses) ) + return new IXR_Error( 401, __( 'Invalid comment status.' ) ); + $comment_approved = $content_struct['status']; + } + + // Do some timestamp voodoo + if ( !empty( $content_struct['date_created_gmt'] ) ) { + $dateCreated = str_replace( 'Z', '', $content_struct['date_created_gmt']->getIso() ) . 'Z'; // We know this is supposed to be GMT, so we're going to slap that Z on there by force + $comment_date = get_date_from_gmt(iso8601_to_datetime($dateCreated)); + $comment_date_gmt = iso8601_to_datetime($dateCreated, 'GMT'); + } + + if ( isset($content_struct['content']) ) + $comment_content = $content_struct['content']; + + if ( isset($content_struct['author']) ) + $comment_author = $content_struct['author']; + + if ( isset($content_struct['author_url']) ) + $comment_author_url = $content_struct['author_url']; + + if ( isset($content_struct['author_email']) ) + $comment_author_email = $content_struct['author_email']; + + // We've got all the data -- post it: + $comment = compact('comment_ID', 'comment_content', 'comment_approved', 'comment_date', 'comment_date_gmt', 'comment_author', 'comment_author_email', 'comment_author_url'); + + $result = wp_update_comment($comment); + if ( is_wp_error( $result ) ) + return new IXR_Error(500, $result->get_error_message()); + + if ( !$result ) + return new IXR_Error(500, __('Sorry, the comment could not be edited. Something wrong happened.')); + + return true; + } + + /** + * Create new comment. + * + * @since 2.7.0 + * + * @param array $args Method parameters. + * @return mixed {@link wp_new_comment()} + */ + function wp_newComment($args) { + global $wpdb; + + $this->escape($args); + + $blog_id = (int) $args[0]; + $username = $args[1]; + $password = $args[2]; + $post = $args[3]; + $content_struct = $args[4]; + + $allow_anon = apply_filters('xmlrpc_allow_anonymous_comments', false); + + $user = $this->login($username, $password); + + if ( !$user ) { + $logged_in = false; + if ( $allow_anon && get_option('comment_registration') ) + return new IXR_Error( 403, __( 'You must be registered to comment' ) ); + else if ( !$allow_anon ) + return $this->error; + } else { + $logged_in = true; + } + + if ( is_numeric($post) ) + $post_id = absint($post); + else + $post_id = url_to_postid($post); + + if ( ! $post_id ) + return new IXR_Error( 404, __( 'Invalid post ID.' ) ); + + if ( ! get_post($post_id) ) + return new IXR_Error( 404, __( 'Invalid post ID.' ) ); + + $comment['comment_post_ID'] = $post_id; + + if ( $logged_in ) { + $comment['comment_author'] = $wpdb->escape( $user->display_name ); + $comment['comment_author_email'] = $wpdb->escape( $user->user_email ); + $comment['comment_author_url'] = $wpdb->escape( $user->user_url ); + $comment['user_ID'] = $user->ID; + } else { + $comment['comment_author'] = ''; + if ( isset($content_struct['author']) ) + $comment['comment_author'] = $content_struct['author']; + + $comment['comment_author_email'] = ''; + if ( isset($content_struct['author_email']) ) + $comment['comment_author_email'] = $content_struct['author_email']; + + $comment['comment_author_url'] = ''; + if ( isset($content_struct['author_url']) ) + $comment['comment_author_url'] = $content_struct['author_url']; + + $comment['user_ID'] = 0; + + if ( get_option('require_name_email') ) { + if ( 6 > strlen($comment['comment_author_email']) || '' == $comment['comment_author'] ) + return new IXR_Error( 403, __( 'Comment author name and email are required' ) ); + elseif ( !is_email($comment['comment_author_email']) ) + return new IXR_Error( 403, __( 'A valid email address is required' ) ); + } + } + + $comment['comment_parent'] = isset($content_struct['comment_parent']) ? absint($content_struct['comment_parent']) : 0; + + $comment['comment_content'] = isset($content_struct['content']) ? $content_struct['content'] : null; + + do_action('xmlrpc_call', 'wp.newComment'); + + return wp_new_comment($comment); + } + + /** + * Retrieve all of the comment status. + * + * @since 2.7.0 + * + * @param array $args Method parameters. + * @return array + */ + function wp_getCommentStatusList($args) { + $this->escape( $args ); + + $blog_id = (int) $args[0]; + $username = $args[1]; + $password = $args[2]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + if ( !current_user_can( 'moderate_comments' ) ) + return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); + + do_action('xmlrpc_call', 'wp.getCommentStatusList'); + + return get_comment_statuses( ); + } + + /** + * Retrieve comment count. + * + * @since 2.5.0 + * + * @param array $args Method parameters. + * @return array + */ + function wp_getCommentCount( $args ) { + $this->escape($args); + + $blog_id = (int) $args[0]; + $username = $args[1]; + $password = $args[2]; + $post_id = (int) $args[3]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + if ( !current_user_can( 'edit_posts' ) ) + return new IXR_Error( 403, __( 'You are not allowed access to details about comments.' ) ); + + do_action('xmlrpc_call', 'wp.getCommentCount'); + + $count = wp_count_comments( $post_id ); + return array( + "approved" => $count->approved, + "awaiting_moderation" => $count->moderated, + "spam" => $count->spam, + "total_comments" => $count->total_comments + ); + } + + /** + * Retrieve post statuses. + * + * @since 2.5.0 + * + * @param array $args Method parameters. + * @return array + */ + function wp_getPostStatusList( $args ) { + $this->escape( $args ); + + $blog_id = (int) $args[0]; + $username = $args[1]; + $password = $args[2]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + if ( !current_user_can( 'edit_posts' ) ) + return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); + + do_action('xmlrpc_call', 'wp.getPostStatusList'); + + return get_post_statuses( ); + } + + /** + * Retrieve page statuses. + * + * @since 2.5.0 + * + * @param array $args Method parameters. + * @return array + */ + function wp_getPageStatusList( $args ) { + $this->escape( $args ); + + $blog_id = (int) $args[0]; + $username = $args[1]; + $password = $args[2]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + if ( !current_user_can( 'edit_pages' ) ) + return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); + + do_action('xmlrpc_call', 'wp.getPageStatusList'); + + return get_page_statuses( ); + } + + /** + * Retrieve page templates. + * + * @since 2.6.0 + * + * @param array $args Method parameters. + * @return array + */ + function wp_getPageTemplates( $args ) { + $this->escape( $args ); + + $blog_id = (int) $args[0]; + $username = $args[1]; + $password = $args[2]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + if ( !current_user_can( 'edit_pages' ) ) + return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); + + $templates = get_page_templates( ); + $templates['Default'] = 'default'; + + return $templates; + } + + /** + * Retrieve blog options. + * + * @since 2.6.0 + * + * @param array $args Method parameters. + * @return array + */ + function wp_getOptions( $args ) { + $this->escape( $args ); + + $blog_id = (int) $args[0]; + $username = $args[1]; + $password = $args[2]; + $options = isset( $args[3] ) ? (array) $args[3] : array(); + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + // If no specific options where asked for, return all of them + if ( count( $options ) == 0 ) + $options = array_keys($this->blog_options); + + return $this->_getOptions($options); + } + + /** + * Retrieve blog options value from list. + * + * @since 2.6.0 + * + * @param array $options Options to retrieve. + * @return array + */ + function _getOptions($options) { + $data = array( ); + foreach ( $options as $option ) { + if ( array_key_exists( $option, $this->blog_options ) ) { + $data[$option] = $this->blog_options[$option]; + //Is the value static or dynamic? + if ( isset( $data[$option]['option'] ) ) { + $data[$option]['value'] = get_option( $data[$option]['option'] ); + unset($data[$option]['option']); + } + } + } + + return $data; + } + + /** + * Update blog options. + * + * @since 2.6.0 + * + * @param array $args Method parameters. + * @return unknown + */ + function wp_setOptions( $args ) { + $this->escape( $args ); + + $blog_id = (int) $args[0]; + $username = $args[1]; + $password = $args[2]; + $options = (array) $args[3]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + if ( !current_user_can( 'manage_options' ) ) + return new IXR_Error( 403, __( 'You are not allowed to update options.' ) ); + + foreach ( $options as $o_name => $o_value ) { + $option_names[] = $o_name; + if ( !array_key_exists( $o_name, $this->blog_options ) ) + continue; + + if ( $this->blog_options[$o_name]['readonly'] == true ) + continue; + + update_option( $this->blog_options[$o_name]['option'], $o_value ); + } + + //Now return the updated values + return $this->_getOptions($option_names); + } + + /** + * Retrieve a media item by ID + * + * @since 3.1.0 + * + * @param array $args Method parameters. Contains: + * - blog_id + * - username + * - password + * - attachment_id + * @return array. Assocciative array containing: + * - 'date_created_gmt' + * - 'parent' + * - 'link' + * - 'thumbnail' + * - 'title' + * - 'caption' + * - 'description' + * - 'metadata' + */ + function wp_getMediaItem($args) { + $this->escape($args); + + $blog_id = (int) $args[0]; + $username = $args[1]; + $password = $args[2]; + $attachment_id = (int) $args[3]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + if ( !current_user_can( 'upload_files' ) ) + return new IXR_Error( 403, __( 'You are not allowed to upload files on this site.' ) ); + + do_action('xmlrpc_call', 'wp.getMediaItem'); + + if ( ! $attachment = get_post($attachment_id) ) + return new IXR_Error( 404, __( 'Invalid attachment ID.' ) ); + + // Format page date. + $attachment_date = mysql2date("Ymd\TH:i:s", $attachment->post_date, false); + $attachment_date_gmt = mysql2date("Ymd\TH:i:s", $attachment->post_date_gmt, false); + + $link = wp_get_attachment_url($attachment->ID); + $thumbnail_link = wp_get_attachment_thumb_url($attachment->ID); + + $attachment_struct = array( + "date_created_gmt" => new IXR_Date($attachment_date_gmt), + "parent" => $attachment->post_parent, + "link" => $link, + "thumbnail" => $thumbnail_link, + "title" => $attachment->post_title, + "caption" => $attachment->post_excerpt, + "description" => $attachment->post_content, + "metadata" => wp_get_attachment_metadata($attachment->ID), + ); + + return $attachment_struct; + } + + /** + * Retrieves a collection of media library items (or attachments) + * + * Besides the common blog_id, username, and password arguments, it takes a filter + * array as last argument. + * + * Accepted 'filter' keys are 'parent_id', 'mime_type', 'offset', and 'number'. + * + * The defaults are as follows: + * - 'number' - Default is 5. Total number of media items to retrieve. + * - 'offset' - Default is 0. See {@link WP_Query::query()} for more. + * - 'parent_id' - Default is ''. The post where the media item is attached. Empty string shows all media items. 0 shows unattached media items. + * - 'mime_type' - Default is ''. Filter by mime type (e.g., 'image/jpeg', 'application/pdf') + * + * @since 3.1.0 + * + * @param array $args Method parameters. Contains: + * - blog_id + * - username + * - password + * - filter + * @return array. Contains a collection of media items. See {@link wp_xmlrpc_server::wp_getMediaItem()} for a description of each item contents + */ + function wp_getMediaLibrary($args) { + $raw_args = $args; + $this->escape($args); + + $blog_id = (int) $args[0]; + $username = $args[1]; + $password = $args[2]; + $struct = isset( $args[3] ) ? $args[3] : array() ; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + if ( !current_user_can( 'upload_files' ) ) + return new IXR_Error( 401, __( 'Sorry, you cannot upload files.' ) ); + + do_action('xmlrpc_call', 'wp.getMediaLibrary'); + + $parent_id = ( isset($struct['parent_id']) ) ? absint($struct['parent_id']) : '' ; + $mime_type = ( isset($struct['mime_type']) ) ? $struct['mime_type'] : '' ; + $offset = ( isset($struct['offset']) ) ? absint($struct['offset']) : 0 ; + $number = ( isset($struct['number']) ) ? absint($struct['number']) : -1 ; + + $attachments = get_posts( array('post_type' => 'attachment', 'post_parent' => $parent_id, 'offset' => $offset, 'numberposts' => $number, 'post_mime_type' => $mime_type ) ); + $num_attachments = count($attachments); + + if ( ! $num_attachments ) + return array(); + + $attachments_struct = array(); + + foreach ($attachments as $attachment ) + $attachments_struct[] = $this->wp_getMediaItem( array( $raw_args[0], $raw_args[1], $raw_args[2], $attachment->ID ) ); + + return $attachments_struct; + } + + /** + * Retrives a list of post formats used by the site + * + * @since 3.1 + * + * @param array $args Method parameters. Contains: + * - blog_id + * - username + * - password + * @return array + */ + function wp_getPostFormats( $args ) { + $this->escape( $args ); + + $blog_id = (int) $args[0]; + $username = $args[1]; + $password = $args[2]; + + if ( !$user = $this->login( $username, $password ) ) + return $this->error; + + do_action( 'xmlrpc_call', 'wp.getPostFormats' ); + return get_post_format_strings(); + } + + /* Blogger API functions. + * specs on http://plant.blogger.com/api and http://groups.yahoo.com/group/bloggerDev/ + */ + + /** + * Retrieve blogs that user owns. + * + * Will make more sense once we support multiple blogs. + * + * @since 1.5.0 + * + * @param array $args Method parameters. + * @return array + */ + function blogger_getUsersBlogs($args) { + if ( is_multisite() ) + return $this->_multisite_getUsersBlogs($args); + + $this->escape($args); + + $username = $args[1]; + $password = $args[2]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + do_action('xmlrpc_call', 'blogger.getUsersBlogs'); + + $is_admin = current_user_can('manage_options'); + + $struct = array( + 'isAdmin' => $is_admin, + 'url' => get_option('home') . '/', + 'blogid' => '1', + 'blogName' => get_option('blogname'), + 'xmlrpc' => site_url( 'xmlrpc.php' ) + ); + + return array($struct); + } + + /** + * Private function for retrieving a users blogs for multisite setups + * + * @access protected + */ + function _multisite_getUsersBlogs($args) { + global $current_blog; + $domain = $current_blog->domain; + $path = $current_blog->path . 'xmlrpc.php'; + $protocol = is_ssl() ? 'https' : 'http'; + + $rpc = new IXR_Client("$protocol://{$domain}{$path}"); + $rpc->query('wp.getUsersBlogs', $args[1], $args[2]); + $blogs = $rpc->getResponse(); + + if ( isset($blogs['faultCode']) ) + return new IXR_Error($blogs['faultCode'], $blogs['faultString']); + + if ( $_SERVER['HTTP_HOST'] == $domain && $_SERVER['REQUEST_URI'] == $path ) { + return $blogs; + } else { + foreach ( (array) $blogs as $blog ) { + if ( strpos($blog['url'], $_SERVER['HTTP_HOST']) ) + return array($blog); + } + return array(); + } + } + + /** + * Retrieve user's data. + * + * Gives your client some info about you, so you don't have to. + * + * @since 1.5.0 + * + * @param array $args Method parameters. + * @return array + */ + function blogger_getUserInfo($args) { + + $this->escape($args); + + $username = $args[1]; + $password = $args[2]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + if ( !current_user_can( 'edit_posts' ) ) + return new IXR_Error( 401, __( 'Sorry, you do not have access to user data on this site.' ) ); + + do_action('xmlrpc_call', 'blogger.getUserInfo'); + + $struct = array( + 'nickname' => $user->nickname, + 'userid' => $user->ID, + 'url' => $user->user_url, + 'lastname' => $user->last_name, + 'firstname' => $user->first_name + ); + + return $struct; + } + + /** + * Retrieve post. + * + * @since 1.5.0 + * + * @param array $args Method parameters. + * @return array + */ + function blogger_getPost($args) { + + $this->escape($args); + + $post_ID = (int) $args[1]; + $username = $args[2]; + $password = $args[3]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + if ( !current_user_can( 'edit_post', $post_ID ) ) + return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) ); + + do_action('xmlrpc_call', 'blogger.getPost'); + + $post_data = wp_get_single_post($post_ID, ARRAY_A); + + $categories = implode(',', wp_get_post_categories($post_ID)); + + $content = ''.stripslashes($post_data['post_title']).''; + $content .= ''.$categories.''; + $content .= stripslashes($post_data['post_content']); + + $struct = array( + 'userid' => $post_data['post_author'], + 'dateCreated' => new IXR_Date(mysql2date('Ymd\TH:i:s', $post_data['post_date'], false)), + 'content' => $content, + 'postid' => (string) $post_data['ID'] + ); + + return $struct; + } + + /** + * Retrieve list of recent posts. + * + * @since 1.5.0 + * + * @param array $args Method parameters. + * @return array + */ + function blogger_getRecentPosts($args) { + + $this->escape($args); + + // $args[0] = appkey - ignored + $blog_ID = (int) $args[1]; /* though we don't use it yet */ + $username = $args[2]; + $password = $args[3]; + if ( isset( $args[4] ) ) + $query = array( 'numberposts' => absint( $args[4] ) ); + else + $query = array(); + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + do_action('xmlrpc_call', 'blogger.getRecentPosts'); + + $posts_list = wp_get_recent_posts( $query ); + + if ( !$posts_list ) { + $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); + return $this->error; + } + + foreach ($posts_list as $entry) { + if ( !current_user_can( 'edit_post', $entry['ID'] ) ) + continue; + + $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date'], false); + $categories = implode(',', wp_get_post_categories($entry['ID'])); + + $content = ''.stripslashes($entry['post_title']).''; + $content .= ''.$categories.''; + $content .= stripslashes($entry['post_content']); + + $struct[] = array( + 'userid' => $entry['post_author'], + 'dateCreated' => new IXR_Date($post_date), + 'content' => $content, + 'postid' => (string) $entry['ID'], + ); + + } + + $recent_posts = array(); + for ( $j=0; $jescape($args); + + $blog_ID = (int) $args[1]; + $username = $args[2]; + $password = $args[3]; + $template = $args[4]; /* could be 'main' or 'archiveIndex', but we don't use it */ + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + do_action('xmlrpc_call', 'blogger.getTemplate'); + + if ( !current_user_can('edit_themes') ) + return new IXR_Error(401, __('Sorry, this user can not edit the template.')); + + /* warning: here we make the assumption that the blog's URL is on the same server */ + $filename = get_option('home') . '/'; + $filename = preg_replace('#https?://.+?/#', $_SERVER['DOCUMENT_ROOT'].'/', $filename); + + $f = fopen($filename, 'r'); + $content = fread($f, filesize($filename)); + fclose($f); + + /* so it is actually editable with a windows/mac client */ + // FIXME: (or delete me) do we really want to cater to bad clients at the expense of good ones by BEEPing up their line breaks? commented. $content = str_replace("\n", "\r\n", $content); + + return $content; + } + + /** + * Updates the content of blog_filename. + * + * @since 1.5.0 + * + * @param array $args Method parameters. + * @return bool True when done. + */ + function blogger_setTemplate($args) { + + $this->escape($args); + + $blog_ID = (int) $args[1]; + $username = $args[2]; + $password = $args[3]; + $content = $args[4]; + $template = $args[5]; /* could be 'main' or 'archiveIndex', but we don't use it */ + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + do_action('xmlrpc_call', 'blogger.setTemplate'); + + if ( !current_user_can('edit_themes') ) + return new IXR_Error(401, __('Sorry, this user cannot edit the template.')); + + /* warning: here we make the assumption that the blog's URL is on the same server */ + $filename = get_option('home') . '/'; + $filename = preg_replace('#https?://.+?/#', $_SERVER['DOCUMENT_ROOT'].'/', $filename); + + if ($f = fopen($filename, 'w+')) { + fwrite($f, $content); + fclose($f); + } else { + return new IXR_Error(500, __('Either the file is not writable, or something wrong happened. The file has not been updated.')); + } + + return true; + } + + /** + * Create new post. + * + * @since 1.5.0 + * + * @param array $args Method parameters. + * @return int + */ + function blogger_newPost($args) { + + $this->escape($args); + + $blog_ID = (int) $args[1]; /* though we don't use it yet */ + $username = $args[2]; + $password = $args[3]; + $content = $args[4]; + $publish = $args[5]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + do_action('xmlrpc_call', 'blogger.newPost'); + + $cap = ($publish) ? 'publish_posts' : 'edit_posts'; + if ( !current_user_can($cap) ) + return new IXR_Error(401, __('Sorry, you are not allowed to post on this site.')); + + $post_status = ($publish) ? 'publish' : 'draft'; + + $post_author = $user->ID; + + $post_title = xmlrpc_getposttitle($content); + $post_category = xmlrpc_getpostcategory($content); + $post_content = xmlrpc_removepostdata($content); + + $post_date = current_time('mysql'); + $post_date_gmt = current_time('mysql', 1); + + $post_data = compact('blog_ID', 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_category', 'post_status'); + + $post_ID = wp_insert_post($post_data); + if ( is_wp_error( $post_ID ) ) + return new IXR_Error(500, $post_ID->get_error_message()); + + if ( !$post_ID ) + return new IXR_Error(500, __('Sorry, your entry could not be posted. Something wrong happened.')); + + $this->attach_uploads( $post_ID, $post_content ); + + logIO('O', "Posted ! ID: $post_ID"); + + return $post_ID; + } + + /** + * Edit a post. + * + * @since 1.5.0 + * + * @param array $args Method parameters. + * @return bool true when done. + */ + function blogger_editPost($args) { + + $this->escape($args); + + $post_ID = (int) $args[1]; + $username = $args[2]; + $password = $args[3]; + $content = $args[4]; + $publish = $args[5]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + do_action('xmlrpc_call', 'blogger.editPost'); + + $actual_post = wp_get_single_post($post_ID,ARRAY_A); + + if ( !$actual_post || $actual_post['post_type'] != 'post' ) + return new IXR_Error(404, __('Sorry, no such post.')); + + $this->escape($actual_post); + + if ( !current_user_can('edit_post', $post_ID) ) + return new IXR_Error(401, __('Sorry, you do not have the right to edit this post.')); + + extract($actual_post, EXTR_SKIP); + + if ( ('publish' == $post_status) && !current_user_can('publish_posts') ) + return new IXR_Error(401, __('Sorry, you do not have the right to publish this post.')); + + $post_title = xmlrpc_getposttitle($content); + $post_category = xmlrpc_getpostcategory($content); + $post_content = xmlrpc_removepostdata($content); + + $postdata = compact('ID', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt'); + + $result = wp_update_post($postdata); + + if ( !$result ) + return new IXR_Error(500, __('For some strange yet very annoying reason, this post could not be edited.')); + + $this->attach_uploads( $ID, $post_content ); + + return true; + } + + /** + * Remove a post. + * + * @since 1.5.0 + * + * @param array $args Method parameters. + * @return bool True when post is deleted. + */ + function blogger_deletePost($args) { + $this->escape($args); + + $post_ID = (int) $args[1]; + $username = $args[2]; + $password = $args[3]; + $publish = $args[4]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + do_action('xmlrpc_call', 'blogger.deletePost'); + + $actual_post = wp_get_single_post($post_ID,ARRAY_A); + + if ( !$actual_post || $actual_post['post_type'] != 'post' ) + return new IXR_Error(404, __('Sorry, no such post.')); + + if ( !current_user_can('delete_post', $post_ID) ) + return new IXR_Error(401, __('Sorry, you do not have the right to delete this post.')); + + $result = wp_delete_post($post_ID); + + if ( !$result ) + return new IXR_Error(500, __('For some strange yet very annoying reason, this post could not be deleted.')); + + return true; + } + + /* MetaWeblog API functions + * specs on wherever Dave Winer wants them to be + */ + + /** + * Create a new post. + * + * @since 1.5.0 + * + * @param array $args Method parameters. + * @return int + */ + function mw_newPost($args) { + $this->escape($args); + + $blog_ID = (int) $args[0]; // we will support this in the near future + $username = $args[1]; + $password = $args[2]; + $content_struct = $args[3]; + $publish = isset( $args[4] ) ? $args[4] : 0; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + do_action('xmlrpc_call', 'metaWeblog.newPost'); + + $page_template = ''; + if ( !empty( $content_struct['post_type'] ) ) { + if ( $content_struct['post_type'] == 'page' ) { + if ( $publish ) + $cap = 'publish_pages'; + elseif ('publish' == $content_struct['page_status']) + $cap = 'publish_pages'; + else + $cap = 'edit_pages'; + $error_message = __( 'Sorry, you are not allowed to publish pages on this site.' ); + $post_type = 'page'; + if ( !empty( $content_struct['wp_page_template'] ) ) + $page_template = $content_struct['wp_page_template']; + } elseif ( $content_struct['post_type'] == 'post' ) { + if ( $publish ) + $cap = 'publish_posts'; + elseif ('publish' == $content_struct['post_status']) + $cap = 'publish_posts'; + else + $cap = 'edit_posts'; + $error_message = __( 'Sorry, you are not allowed to publish posts on this site.' ); + $post_type = 'post'; + } else { + // No other post_type values are allowed here + return new IXR_Error( 401, __( 'Invalid post type.' ) ); + } + } else { + if ( $publish ) + $cap = 'publish_posts'; + elseif ('publish' == $content_struct['post_status']) + $cap = 'publish_posts'; + else + $cap = 'edit_posts'; + $error_message = __( 'Sorry, you are not allowed to publish posts on this site.' ); + $post_type = 'post'; + } + + if ( !current_user_can( $cap ) ) + return new IXR_Error( 401, $error_message ); + + // Check for a valid post format if one was given + if ( isset( $content_struct['wp_post_format'] ) ) { + $content_struct['wp_post_format'] = sanitize_key( $content_struct['wp_post_format'] ); + if ( !array_key_exists( $content_struct['wp_post_format'], get_post_format_strings() ) ) { + return new IXR_Error( 404, __( 'Invalid post format' ) ); + } + } + + // Let WordPress generate the post_name (slug) unless + // one has been provided. + $post_name = ""; + if ( isset($content_struct["wp_slug"]) ) + $post_name = $content_struct["wp_slug"]; + + // Only use a password if one was given. + if ( isset($content_struct["wp_password"]) ) + $post_password = $content_struct["wp_password"]; + + // Only set a post parent if one was provided. + if ( isset($content_struct["wp_page_parent_id"]) ) + $post_parent = $content_struct["wp_page_parent_id"]; + + // Only set the menu_order if it was provided. + if ( isset($content_struct["wp_page_order"]) ) + $menu_order = $content_struct["wp_page_order"]; + + $post_author = $user->ID; + + // If an author id was provided then use it instead. + if ( isset($content_struct["wp_author_id"]) && ($user->ID != $content_struct["wp_author_id"]) ) { + switch ( $post_type ) { + case "post": + if ( !current_user_can("edit_others_posts") ) + return(new IXR_Error(401, __("You are not allowed to post as this user"))); + break; + case "page": + if ( !current_user_can("edit_others_pages") ) + return(new IXR_Error(401, __("You are not allowed to create pages as this user"))); + break; + default: + return(new IXR_Error(401, __("Invalid post type."))); + break; + } + $post_author = $content_struct["wp_author_id"]; + } + + $post_title = isset( $content_struct['title'] ) ? $content_struct['title'] : null; + $post_content = isset( $content_struct['description'] ) ? $content_struct['description'] : null; + + $post_status = $publish ? 'publish' : 'draft'; + + if ( isset( $content_struct["{$post_type}_status"] ) ) { + switch ( $content_struct["{$post_type}_status"] ) { + case 'draft': + case 'private': + case 'publish': + $post_status = $content_struct["{$post_type}_status"]; + break; + case 'pending': + // Pending is only valid for posts, not pages. + if ( $post_type === 'post' ) + $post_status = $content_struct["{$post_type}_status"]; + break; + default: + $post_status = $publish ? 'publish' : 'draft'; + break; + } + } + + $post_excerpt = isset($content_struct['mt_excerpt']) ? $content_struct['mt_excerpt'] : null; + $post_more = isset($content_struct['mt_text_more']) ? $content_struct['mt_text_more'] : null; + + $tags_input = isset($content_struct['mt_keywords']) ? $content_struct['mt_keywords'] : null; + + if ( isset($content_struct["mt_allow_comments"]) ) { + if ( !is_numeric($content_struct["mt_allow_comments"]) ) { + switch ( $content_struct["mt_allow_comments"] ) { + case "closed": + $comment_status = "closed"; + break; + case "open": + $comment_status = "open"; + break; + default: + $comment_status = get_option("default_comment_status"); + break; + } + } else { + switch ( (int) $content_struct["mt_allow_comments"] ) { + case 0: + case 2: + $comment_status = "closed"; + break; + case 1: + $comment_status = "open"; + break; + default: + $comment_status = get_option("default_comment_status"); + break; + } + } + } else { + $comment_status = get_option("default_comment_status"); + } + + if ( isset($content_struct["mt_allow_pings"]) ) { + if ( !is_numeric($content_struct["mt_allow_pings"]) ) { + switch ( $content_struct['mt_allow_pings'] ) { + case "closed": + $ping_status = "closed"; + break; + case "open": + $ping_status = "open"; + break; + default: + $ping_status = get_option("default_ping_status"); + break; + } + } else { + switch ( (int) $content_struct["mt_allow_pings"] ) { + case 0: + $ping_status = "closed"; + break; + case 1: + $ping_status = "open"; + break; + default: + $ping_status = get_option("default_ping_status"); + break; + } + } + } else { + $ping_status = get_option("default_ping_status"); + } + + if ( $post_more ) + $post_content = $post_content . "" . $post_more; + + $to_ping = null; + if ( isset( $content_struct['mt_tb_ping_urls'] ) ) { + $to_ping = $content_struct['mt_tb_ping_urls']; + if ( is_array($to_ping) ) + $to_ping = implode(' ', $to_ping); + } + + // Do some timestamp voodoo + if ( !empty( $content_struct['date_created_gmt'] ) ) + $dateCreated = str_replace( 'Z', '', $content_struct['date_created_gmt']->getIso() ) . 'Z'; // We know this is supposed to be GMT, so we're going to slap that Z on there by force + elseif ( !empty( $content_struct['dateCreated']) ) + $dateCreated = $content_struct['dateCreated']->getIso(); + + if ( !empty( $dateCreated ) ) { + $post_date = get_date_from_gmt(iso8601_to_datetime($dateCreated)); + $post_date_gmt = iso8601_to_datetime($dateCreated, 'GMT'); + } else { + $post_date = current_time('mysql'); + $post_date_gmt = current_time('mysql', 1); + } + + $post_category = array(); + if ( isset( $content_struct['categories'] ) ) { + $catnames = $content_struct['categories']; + logIO('O', 'Post cats: ' . var_export($catnames,true)); + + if ( is_array($catnames) ) { + foreach ($catnames as $cat) { + $post_category[] = get_cat_ID($cat); + } + } + } + + // We've got all the data -- post it: + $postdata = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'comment_status', 'ping_status', 'to_ping', 'post_type', 'post_name', 'post_password', 'post_parent', 'menu_order', 'tags_input', 'page_template'); + + $post_ID = wp_insert_post($postdata, true); + if ( is_wp_error( $post_ID ) ) + return new IXR_Error(500, $post_ID->get_error_message()); + + if ( !$post_ID ) + return new IXR_Error(500, __('Sorry, your entry could not be posted. Something wrong happened.')); + + // Only posts can be sticky + if ( $post_type == 'post' && isset( $content_struct['sticky'] ) ) { + if ( $content_struct['sticky'] == true ) + stick_post( $post_ID ); + elseif ( $content_struct['sticky'] == false ) + unstick_post( $post_ID ); + } + + if ( isset($content_struct['custom_fields']) ) + $this->set_custom_fields($post_ID, $content_struct['custom_fields']); + + // Handle enclosures + $thisEnclosure = isset($content_struct['enclosure']) ? $content_struct['enclosure'] : null; + $this->add_enclosure_if_new($post_ID, $thisEnclosure); + + $this->attach_uploads( $post_ID, $post_content ); + + // Handle post formats if assigned, value is validated earlier + // in this function + if ( isset( $content_struct['wp_post_format'] ) ) + wp_set_post_terms( $post_ID, array( 'post-format-' . $content_struct['wp_post_format'] ), 'post_format' ); + + logIO('O', "Posted ! ID: $post_ID"); + + return strval($post_ID); + } + + function add_enclosure_if_new($post_ID, $enclosure) { + if ( is_array( $enclosure ) && isset( $enclosure['url'] ) && isset( $enclosure['length'] ) && isset( $enclosure['type'] ) ) { + + $encstring = $enclosure['url'] . "\n" . $enclosure['length'] . "\n" . $enclosure['type']; + $found = false; + foreach ( (array) get_post_custom($post_ID) as $key => $val) { + if ($key == 'enclosure') { + foreach ( (array) $val as $enc ) { + if ($enc == $encstring) { + $found = true; + break 2; + } + } + } + } + if (!$found) + add_post_meta( $post_ID, 'enclosure', $encstring ); + } + } + + /** + * Attach upload to a post. + * + * @since 2.1.0 + * + * @param int $post_ID Post ID. + * @param string $post_content Post Content for attachment. + */ + function attach_uploads( $post_ID, $post_content ) { + global $wpdb; + + // find any unattached files + $attachments = $wpdb->get_results( "SELECT ID, guid FROM {$wpdb->posts} WHERE post_parent = '0' AND post_type = 'attachment'" ); + if ( is_array( $attachments ) ) { + foreach ( $attachments as $file ) { + if ( strpos( $post_content, $file->guid ) !== false ) + $wpdb->update($wpdb->posts, array('post_parent' => $post_ID), array('ID' => $file->ID) ); + } + } + } + + /** + * Edit a post. + * + * @since 1.5.0 + * + * @param array $args Method parameters. + * @return bool True on success. + */ + function mw_editPost($args) { + + $this->escape($args); + + $post_ID = (int) $args[0]; + $username = $args[1]; + $password = $args[2]; + $content_struct = $args[3]; + $publish = $args[4]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + do_action('xmlrpc_call', 'metaWeblog.editPost'); + + $cap = ( $publish ) ? 'publish_posts' : 'edit_posts'; + $error_message = __( 'Sorry, you are not allowed to publish posts on this site.' ); + $post_type = 'post'; + $page_template = ''; + if ( !empty( $content_struct['post_type'] ) ) { + if ( $content_struct['post_type'] == 'page' ) { + if ( $publish || 'publish' == $content_struct['page_status'] ) + $cap = 'publish_pages'; + else + $cap = 'edit_pages'; + $error_message = __( 'Sorry, you are not allowed to publish pages on this site.' ); + $post_type = 'page'; + if ( !empty( $content_struct['wp_page_template'] ) ) + $page_template = $content_struct['wp_page_template']; + } elseif ( $content_struct['post_type'] == 'post' ) { + if ( $publish || 'publish' == $content_struct['post_status'] ) + $cap = 'publish_posts'; + else + $cap = 'edit_posts'; + $error_message = __( 'Sorry, you are not allowed to publish posts on this site.' ); + $post_type = 'post'; + } else { + // No other post_type values are allowed here + return new IXR_Error( 401, __( 'Invalid post type.' ) ); + } + } else { + if ( $publish || 'publish' == $content_struct['post_status'] ) + $cap = 'publish_posts'; + else + $cap = 'edit_posts'; + $error_message = __( 'Sorry, you are not allowed to publish posts on this site.' ); + $post_type = 'post'; + } + + if ( !current_user_can( $cap ) ) + return new IXR_Error( 401, $error_message ); + + // Check for a valid post format if one was given + if ( isset( $content_struct['wp_post_format'] ) ) { + $content_struct['wp_post_format'] = sanitize_key( $content_struct['wp_post_format'] ); + if ( !array_key_exists( $content_struct['wp_post_format'], get_post_format_strings() ) ) { + return new IXR_Error( 404, __( 'Invalid post format' ) ); + } + } + + $postdata = wp_get_single_post($post_ID, ARRAY_A); + + // If there is no post data for the give post id, stop + // now and return an error. Other wise a new post will be + // created (which was the old behavior). + if ( empty($postdata["ID"]) ) + return(new IXR_Error(404, __("Invalid post ID."))); + + $this->escape($postdata); + extract($postdata, EXTR_SKIP); + + // Let WordPress manage slug if none was provided. + $post_name = ""; + if ( isset($content_struct["wp_slug"]) ) + $post_name = $content_struct["wp_slug"]; + + // Only use a password if one was given. + if ( isset($content_struct["wp_password"]) ) + $post_password = $content_struct["wp_password"]; + + // Only set a post parent if one was given. + if ( isset($content_struct["wp_page_parent_id"]) ) + $post_parent = $content_struct["wp_page_parent_id"]; + + // Only set the menu_order if it was given. + if ( isset($content_struct["wp_page_order"]) ) + $menu_order = $content_struct["wp_page_order"]; + + $post_author = $postdata["post_author"]; + + // Only set the post_author if one is set. + if ( isset($content_struct["wp_author_id"]) && ($user->ID != $content_struct["wp_author_id"]) ) { + switch ( $post_type ) { + case "post": + if ( !current_user_can("edit_others_posts") ) + return(new IXR_Error(401, __("You are not allowed to change the post author as this user."))); + break; + case "page": + if ( !current_user_can("edit_others_pages") ) + return(new IXR_Error(401, __("You are not allowed to change the page author as this user."))); + break; + default: + return(new IXR_Error(401, __("Invalid post type."))); + break; + } + $post_author = $content_struct["wp_author_id"]; + } + + if ( isset($content_struct["mt_allow_comments"]) ) { + if ( !is_numeric($content_struct["mt_allow_comments"]) ) { + switch ( $content_struct["mt_allow_comments"] ) { + case "closed": + $comment_status = "closed"; + break; + case "open": + $comment_status = "open"; + break; + default: + $comment_status = get_option("default_comment_status"); + break; + } + } else { + switch ( (int) $content_struct["mt_allow_comments"] ) { + case 0: + case 2: + $comment_status = "closed"; + break; + case 1: + $comment_status = "open"; + break; + default: + $comment_status = get_option("default_comment_status"); + break; + } + } + } + + if ( isset($content_struct["mt_allow_pings"]) ) { + if ( !is_numeric($content_struct["mt_allow_pings"]) ) { + switch ( $content_struct["mt_allow_pings"] ) { + case "closed": + $ping_status = "closed"; + break; + case "open": + $ping_status = "open"; + break; + default: + $ping_status = get_option("default_ping_status"); + break; + } + } else { + switch ( (int) $content_struct["mt_allow_pings"] ) { + case 0: + $ping_status = "closed"; + break; + case 1: + $ping_status = "open"; + break; + default: + $ping_status = get_option("default_ping_status"); + break; + } + } + } + + $post_title = isset( $content_struct['title'] ) ? $content_struct['title'] : null; + $post_content = isset( $content_struct['description'] ) ? $content_struct['description'] : null; + + $post_category = array(); + if ( isset( $content_struct['categories'] ) ) { + $catnames = $content_struct['categories']; + if ( is_array($catnames) ) { + foreach ($catnames as $cat) { + $post_category[] = get_cat_ID($cat); + } + } + } + + $post_excerpt = isset( $content_struct['mt_excerpt'] ) ? $content_struct['mt_excerpt'] : null; + $post_more = isset( $content_struct['mt_text_more'] ) ? $content_struct['mt_text_more'] : null; + + $post_status = $publish ? 'publish' : 'draft'; + if ( isset( $content_struct["{$post_type}_status"] ) ) { + switch( $content_struct["{$post_type}_status"] ) { + case 'draft': + case 'private': + case 'publish': + $post_status = $content_struct["{$post_type}_status"]; + break; + case 'pending': + // Pending is only valid for posts, not pages. + if ( $post_type === 'post' ) + $post_status = $content_struct["{$post_type}_status"]; + break; + default: + $post_status = $publish ? 'publish' : 'draft'; + break; + } + } + + $tags_input = isset( $content_struct['mt_keywords'] ) ? $content_struct['mt_keywords'] : null; + + if ( ('publish' == $post_status) ) { + if ( ( 'page' == $post_type ) && !current_user_can('publish_pages') ) + return new IXR_Error(401, __('Sorry, you do not have the right to publish this page.')); + else if ( !current_user_can('publish_posts') ) + return new IXR_Error(401, __('Sorry, you do not have the right to publish this post.')); + } + + if ( $post_more ) + $post_content = $post_content . "" . $post_more; + + $to_ping = null; + if ( isset( $content_struct['mt_tb_ping_urls'] ) ) { + $to_ping = $content_struct['mt_tb_ping_urls']; + if ( is_array($to_ping) ) + $to_ping = implode(' ', $to_ping); + } + + // Do some timestamp voodoo + if ( !empty( $content_struct['date_created_gmt'] ) ) + $dateCreated = str_replace( 'Z', '', $content_struct['date_created_gmt']->getIso() ) . 'Z'; // We know this is supposed to be GMT, so we're going to slap that Z on there by force + elseif ( !empty( $content_struct['dateCreated']) ) + $dateCreated = $content_struct['dateCreated']->getIso(); + + if ( !empty( $dateCreated ) ) { + $post_date = get_date_from_gmt(iso8601_to_datetime($dateCreated)); + $post_date_gmt = iso8601_to_datetime($dateCreated, 'GMT'); + } else { + $post_date = $postdata['post_date']; + $post_date_gmt = $postdata['post_date_gmt']; + } + + // We've got all the data -- post it: + $newpost = compact('ID', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'comment_status', 'ping_status', 'post_date', 'post_date_gmt', 'to_ping', 'post_name', 'post_password', 'post_parent', 'menu_order', 'post_author', 'tags_input', 'page_template'); + + $result = wp_update_post($newpost, true); + if ( is_wp_error( $result ) ) + return new IXR_Error(500, $result->get_error_message()); + + if ( !$result ) + return new IXR_Error(500, __('Sorry, your entry could not be edited. Something wrong happened.')); + + // Only posts can be sticky + if ( $post_type == 'post' && isset( $content_struct['sticky'] ) ) { + if ( $content_struct['sticky'] == true ) + stick_post( $post_ID ); + elseif ( $content_struct['sticky'] == false ) + unstick_post( $post_ID ); + } + + if ( isset($content_struct['custom_fields']) ) + $this->set_custom_fields($post_ID, $content_struct['custom_fields']); + + // Handle enclosures + $thisEnclosure = isset($content_struct['enclosure']) ? $content_struct['enclosure'] : null; + $this->add_enclosure_if_new($post_ID, $thisEnclosure); + + $this->attach_uploads( $ID, $post_content ); + + // Handle post formats if assigned, validation is handled + // earlier in this function + if ( isset( $content_struct['wp_post_format'] ) ) + wp_set_post_terms( $post_ID, array( 'post-format-' . $content_struct['wp_post_format'] ), 'post_format' ); + + logIO('O',"(MW) Edited ! ID: $post_ID"); + + return true; + } + + /** + * Retrieve post. + * + * @since 1.5.0 + * + * @param array $args Method parameters. + * @return array + */ + function mw_getPost($args) { + + $this->escape($args); + + $post_ID = (int) $args[0]; + $username = $args[1]; + $password = $args[2]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + if ( !current_user_can( 'edit_post', $post_ID ) ) + return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) ); + + do_action('xmlrpc_call', 'metaWeblog.getPost'); + + $postdata = wp_get_single_post($post_ID, ARRAY_A); + + if ($postdata['post_date'] != '') { + $post_date = mysql2date('Ymd\TH:i:s', $postdata['post_date'], false); + $post_date_gmt = mysql2date('Ymd\TH:i:s', $postdata['post_date_gmt'], false); + + // For drafts use the GMT version of the post date + if ( $postdata['post_status'] == 'draft' ) + $post_date_gmt = get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $postdata['post_date'] ), 'Ymd\TH:i:s' ); + + $categories = array(); + $catids = wp_get_post_categories($post_ID); + foreach($catids as $catid) + $categories[] = get_cat_name($catid); + + $tagnames = array(); + $tags = wp_get_post_tags( $post_ID ); + if ( !empty( $tags ) ) { + foreach ( $tags as $tag ) + $tagnames[] = $tag->name; + $tagnames = implode( ', ', $tagnames ); + } else { + $tagnames = ''; + } + + $post = get_extended($postdata['post_content']); + $link = post_permalink($postdata['ID']); + + // Get the author info. + $author = get_userdata($postdata['post_author']); + + $allow_comments = ('open' == $postdata['comment_status']) ? 1 : 0; + $allow_pings = ('open' == $postdata['ping_status']) ? 1 : 0; + + // Consider future posts as published + if ( $postdata['post_status'] === 'future' ) + $postdata['post_status'] = 'publish'; + + // Get post format + $post_format = get_post_format( $post_ID ); + if ( empty( $post_format ) ) + $post_format = 'standard'; + + $sticky = false; + if ( is_sticky( $post_ID ) ) + $sticky = true; + + $enclosure = array(); + foreach ( (array) get_post_custom($post_ID) as $key => $val) { + if ($key == 'enclosure') { + foreach ( (array) $val as $enc ) { + $encdata = split("\n", $enc); + $enclosure['url'] = trim(htmlspecialchars($encdata[0])); + $enclosure['length'] = (int) trim($encdata[1]); + $enclosure['type'] = trim($encdata[2]); + break 2; + } + } + } + + $resp = array( + 'dateCreated' => new IXR_Date($post_date), + 'userid' => $postdata['post_author'], + 'postid' => $postdata['ID'], + 'description' => $post['main'], + 'title' => $postdata['post_title'], + 'link' => $link, + 'permaLink' => $link, + // commented out because no other tool seems to use this + // 'content' => $entry['post_content'], + 'categories' => $categories, + 'mt_excerpt' => $postdata['post_excerpt'], + 'mt_text_more' => $post['extended'], + 'mt_allow_comments' => $allow_comments, + 'mt_allow_pings' => $allow_pings, + 'mt_keywords' => $tagnames, + 'wp_slug' => $postdata['post_name'], + 'wp_password' => $postdata['post_password'], + 'wp_author_id' => $author->ID, + 'wp_author_display_name' => $author->display_name, + 'date_created_gmt' => new IXR_Date($post_date_gmt), + 'post_status' => $postdata['post_status'], + 'custom_fields' => $this->get_custom_fields($post_ID), + 'wp_post_format' => $post_format, + 'sticky' => $sticky + ); + + if ( !empty($enclosure) ) $resp['enclosure'] = $enclosure; + + return $resp; + } else { + return new IXR_Error(404, __('Sorry, no such post.')); + } + } + + /** + * Retrieve list of recent posts. + * + * @since 1.5.0 + * + * @param array $args Method parameters. + * @return array + */ + function mw_getRecentPosts($args) { + + $this->escape($args); + + $blog_ID = (int) $args[0]; + $username = $args[1]; + $password = $args[2]; + if ( isset( $args[3] ) ) + $query = array( 'numberposts' => absint( $args[3] ) ); + else + $query = array(); + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + do_action('xmlrpc_call', 'metaWeblog.getRecentPosts'); + + $posts_list = wp_get_recent_posts( $query ); + + if ( !$posts_list ) + return array( ); + + foreach ($posts_list as $entry) { + if ( !current_user_can( 'edit_post', $entry['ID'] ) ) + continue; + + $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date'], false); + $post_date_gmt = mysql2date('Ymd\TH:i:s', $entry['post_date_gmt'], false); + + // For drafts use the GMT version of the date + if ( $entry['post_status'] == 'draft' ) + $post_date_gmt = get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $entry['post_date'] ), 'Ymd\TH:i:s' ); + + $categories = array(); + $catids = wp_get_post_categories($entry['ID']); + foreach( $catids as $catid ) + $categories[] = get_cat_name($catid); + + $tagnames = array(); + $tags = wp_get_post_tags( $entry['ID'] ); + if ( !empty( $tags ) ) { + foreach ( $tags as $tag ) { + $tagnames[] = $tag->name; + } + $tagnames = implode( ', ', $tagnames ); + } else { + $tagnames = ''; + } + + $post = get_extended($entry['post_content']); + $link = post_permalink($entry['ID']); + + // Get the post author info. + $author = get_userdata($entry['post_author']); + + $allow_comments = ('open' == $entry['comment_status']) ? 1 : 0; + $allow_pings = ('open' == $entry['ping_status']) ? 1 : 0; + + // Consider future posts as published + if ( $entry['post_status'] === 'future' ) + $entry['post_status'] = 'publish'; + + // Get post format + $post_format = get_post_format( $entry['ID'] ); + if ( empty( $post_format ) ) + $post_format = 'standard'; + + $struct[] = array( + 'dateCreated' => new IXR_Date($post_date), + 'userid' => $entry['post_author'], + 'postid' => (string) $entry['ID'], + 'description' => $post['main'], + 'title' => $entry['post_title'], + 'link' => $link, + 'permaLink' => $link, + // commented out because no other tool seems to use this + // 'content' => $entry['post_content'], + 'categories' => $categories, + 'mt_excerpt' => $entry['post_excerpt'], + 'mt_text_more' => $post['extended'], + 'mt_allow_comments' => $allow_comments, + 'mt_allow_pings' => $allow_pings, + 'mt_keywords' => $tagnames, + 'wp_slug' => $entry['post_name'], + 'wp_password' => $entry['post_password'], + 'wp_author_id' => $author->ID, + 'wp_author_display_name' => $author->display_name, + 'date_created_gmt' => new IXR_Date($post_date_gmt), + 'post_status' => $entry['post_status'], + 'custom_fields' => $this->get_custom_fields($entry['ID']), + 'wp_post_format' => $post_format + ); + + } + + $recent_posts = array(); + for ( $j=0; $jescape($args); + + $blog_ID = (int) $args[0]; + $username = $args[1]; + $password = $args[2]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + if ( !current_user_can( 'edit_posts' ) ) + return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); + + do_action('xmlrpc_call', 'metaWeblog.getCategories'); + + $categories_struct = array(); + + if ( $cats = get_categories(array('get' => 'all')) ) { + foreach ( $cats as $cat ) { + $struct['categoryId'] = $cat->term_id; + $struct['parentId'] = $cat->parent; + $struct['description'] = $cat->name; + $struct['categoryDescription'] = $cat->description; + $struct['categoryName'] = $cat->name; + $struct['htmlUrl'] = esc_html(get_category_link($cat->term_id)); + $struct['rssUrl'] = esc_html(get_category_feed_link($cat->term_id, 'rss2')); + + $categories_struct[] = $struct; + } + } + + return $categories_struct; + } + + /** + * Uploads a file, following your settings. + * + * Adapted from a patch by Johann Richard. + * + * @link http://mycvs.org/archives/2004/06/30/file-upload-to-wordpress-in-ecto/ + * + * @since 1.5.0 + * + * @param array $args Method parameters. + * @return array + */ + function mw_newMediaObject($args) { + global $wpdb; + + $blog_ID = (int) $args[0]; + $username = $wpdb->escape($args[1]); + $password = $wpdb->escape($args[2]); + $data = $args[3]; + + $name = sanitize_file_name( $data['name'] ); + $type = $data['type']; + $bits = $data['bits']; + + logIO('O', '(MW) Received '.strlen($bits).' bytes'); + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + do_action('xmlrpc_call', 'metaWeblog.newMediaObject'); + + if ( !current_user_can('upload_files') ) { + logIO('O', '(MW) User does not have upload_files capability'); + $this->error = new IXR_Error(401, __('You are not allowed to upload files to this site.')); + return $this->error; + } + + if ( $upload_err = apply_filters( "pre_upload_error", false ) ) + return new IXR_Error(500, $upload_err); + + if ( !empty($data["overwrite"]) && ($data["overwrite"] == true) ) { + // Get postmeta info on the object. + $old_file = $wpdb->get_row(" + SELECT ID + FROM {$wpdb->posts} + WHERE post_title = '{$name}' + AND post_type = 'attachment' + "); + + // Delete previous file. + wp_delete_attachment($old_file->ID); + + // Make sure the new name is different by pre-pending the + // previous post id. + $filename = preg_replace("/^wpid\d+-/", "", $name); + $name = "wpid{$old_file->ID}-{$filename}"; + } + + $upload = wp_upload_bits($name, NULL, $bits); + if ( ! empty($upload['error']) ) { + $errorString = sprintf(__('Could not write file %1$s (%2$s)'), $name, $upload['error']); + logIO('O', '(MW) ' . $errorString); + return new IXR_Error(500, $errorString); + } + // Construct the attachment array + // attach to post_id 0 + $post_id = 0; + $attachment = array( + 'post_title' => $name, + 'post_content' => '', + 'post_type' => 'attachment', + 'post_parent' => $post_id, + 'post_mime_type' => $type, + 'guid' => $upload[ 'url' ] + ); + + // Save the data + $id = wp_insert_attachment( $attachment, $upload[ 'file' ], $post_id ); + wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $upload['file'] ) ); + + return apply_filters( 'wp_handle_upload', array( 'file' => $name, 'url' => $upload[ 'url' ], 'type' => $type ), 'upload' ); + } + + /* MovableType API functions + * specs on http://www.movabletype.org/docs/mtmanual_programmatic.html + */ + + /** + * Retrieve the post titles of recent posts. + * + * @since 1.5.0 + * + * @param array $args Method parameters. + * @return array + */ + function mt_getRecentPostTitles($args) { + + $this->escape($args); + + $blog_ID = (int) $args[0]; + $username = $args[1]; + $password = $args[2]; + if ( isset( $args[3] ) ) + $query = array( 'numberposts' => absint( $args[3] ) ); + else + $query = array(); + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + do_action('xmlrpc_call', 'mt.getRecentPostTitles'); + + $posts_list = wp_get_recent_posts( $query ); + + if ( !$posts_list ) { + $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); + return $this->error; + } + + foreach ($posts_list as $entry) { + if ( !current_user_can( 'edit_post', $entry['ID'] ) ) + continue; + + $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date'], false); + $post_date_gmt = mysql2date('Ymd\TH:i:s', $entry['post_date_gmt'], false); + + // For drafts use the GMT version of the date + if ( $entry['post_status'] == 'draft' ) + $post_date_gmt = get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $entry['post_date'] ), 'Ymd\TH:i:s' ); + + $struct[] = array( + 'dateCreated' => new IXR_Date($post_date), + 'userid' => $entry['post_author'], + 'postid' => (string) $entry['ID'], + 'title' => $entry['post_title'], + 'date_created_gmt' => new IXR_Date($post_date_gmt) + ); + + } + + $recent_posts = array(); + for ( $j=0; $jescape($args); + + $blog_ID = (int) $args[0]; + $username = $args[1]; + $password = $args[2]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + if ( !current_user_can( 'edit_posts' ) ) + return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); + + do_action('xmlrpc_call', 'mt.getCategoryList'); + + $categories_struct = array(); + + if ( $cats = get_categories(array('hide_empty' => 0, 'hierarchical' => 0)) ) { + foreach ( $cats as $cat ) { + $struct['categoryId'] = $cat->term_id; + $struct['categoryName'] = $cat->name; + + $categories_struct[] = $struct; + } + } + + return $categories_struct; + } + + /** + * Retrieve post categories. + * + * @since 1.5.0 + * + * @param array $args Method parameters. + * @return array + */ + function mt_getPostCategories($args) { + + $this->escape($args); + + $post_ID = (int) $args[0]; + $username = $args[1]; + $password = $args[2]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + if ( !current_user_can( 'edit_post', $post_ID ) ) + return new IXR_Error( 401, __( 'Sorry, you can not edit this post.' ) ); + + do_action('xmlrpc_call', 'mt.getPostCategories'); + + $categories = array(); + $catids = wp_get_post_categories(intval($post_ID)); + // first listed category will be the primary category + $isPrimary = true; + foreach ( $catids as $catid ) { + $categories[] = array( + 'categoryName' => get_cat_name($catid), + 'categoryId' => (string) $catid, + 'isPrimary' => $isPrimary + ); + $isPrimary = false; + } + + return $categories; + } + + /** + * Sets categories for a post. + * + * @since 1.5.0 + * + * @param array $args Method parameters. + * @return bool True on success. + */ + function mt_setPostCategories($args) { + + $this->escape($args); + + $post_ID = (int) $args[0]; + $username = $args[1]; + $password = $args[2]; + $categories = $args[3]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + do_action('xmlrpc_call', 'mt.setPostCategories'); + + if ( !current_user_can('edit_post', $post_ID) ) + return new IXR_Error(401, __('Sorry, you cannot edit this post.')); + + foreach ( $categories as $cat ) { + $catids[] = $cat['categoryId']; + } + + wp_set_post_categories($post_ID, $catids); + + return true; + } + + /** + * Retrieve an array of methods supported by this server. + * + * @since 1.5.0 + * + * @param array $args Method parameters. + * @return array + */ + function mt_supportedMethods($args) { + + do_action('xmlrpc_call', 'mt.supportedMethods'); + + $supported_methods = array(); + foreach ( $this->methods as $key => $value ) { + $supported_methods[] = $key; + } + + return $supported_methods; + } + + /** + * Retrieve an empty array because we don't support per-post text filters. + * + * @since 1.5.0 + * + * @param array $args Method parameters. + */ + function mt_supportedTextFilters($args) { + do_action('xmlrpc_call', 'mt.supportedTextFilters'); + return apply_filters('xmlrpc_text_filters', array()); + } + + /** + * Retrieve trackbacks sent to a given post. + * + * @since 1.5.0 + * + * @param array $args Method parameters. + * @return mixed + */ + function mt_getTrackbackPings($args) { + + global $wpdb; + + $post_ID = intval($args); + + do_action('xmlrpc_call', 'mt.getTrackbackPings'); + + $actual_post = wp_get_single_post($post_ID, ARRAY_A); + + if ( !$actual_post ) + return new IXR_Error(404, __('Sorry, no such post.')); + + $comments = $wpdb->get_results( $wpdb->prepare("SELECT comment_author_url, comment_content, comment_author_IP, comment_type FROM $wpdb->comments WHERE comment_post_ID = %d", $post_ID) ); + + if ( !$comments ) + return array(); + + $trackback_pings = array(); + foreach ( $comments as $comment ) { + if ( 'trackback' == $comment->comment_type ) { + $content = $comment->comment_content; + $title = substr($content, 8, (strpos($content, '') - 8)); + $trackback_pings[] = array( + 'pingTitle' => $title, + 'pingURL' => $comment->comment_author_url, + 'pingIP' => $comment->comment_author_IP + ); + } + } + + return $trackback_pings; + } + + /** + * Sets a post's publish status to 'publish'. + * + * @since 1.5.0 + * + * @param array $args Method parameters. + * @return int + */ + function mt_publishPost($args) { + + $this->escape($args); + + $post_ID = (int) $args[0]; + $username = $args[1]; + $password = $args[2]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + do_action('xmlrpc_call', 'mt.publishPost'); + + if ( !current_user_can('publish_posts') || !current_user_can('edit_post', $post_ID) ) + return new IXR_Error(401, __('Sorry, you cannot publish this post.')); + + $postdata = wp_get_single_post($post_ID,ARRAY_A); + + $postdata['post_status'] = 'publish'; + + // retain old cats + $cats = wp_get_post_categories($post_ID); + $postdata['post_category'] = $cats; + $this->escape($postdata); + + $result = wp_update_post($postdata); + + return $result; + } + + /* PingBack functions + * specs on www.hixie.ch/specs/pingback/pingback + */ + + /** + * Retrieves a pingback and registers it. + * + * @since 1.5.0 + * + * @param array $args Method parameters. + * @return array + */ + function pingback_ping($args) { + global $wpdb; + + do_action('xmlrpc_call', 'pingback.ping'); + + $this->escape($args); + + $pagelinkedfrom = $args[0]; + $pagelinkedto = $args[1]; + + $title = ''; + + $pagelinkedfrom = str_replace('&', '&', $pagelinkedfrom); + $pagelinkedto = str_replace('&', '&', $pagelinkedto); + $pagelinkedto = str_replace('&', '&', $pagelinkedto); + + // Check if the page linked to is in our site + $pos1 = strpos($pagelinkedto, str_replace(array('http://www.','http://','https://www.','https://'), '', get_option('home'))); + if ( !$pos1 ) + return new IXR_Error(0, __('Is there no link to us?')); + + // let's find which post is linked to + // FIXME: does url_to_postid() cover all these cases already? + // if so, then let's use it and drop the old code. + $urltest = parse_url($pagelinkedto); + if ( $post_ID = url_to_postid($pagelinkedto) ) { + $way = 'url_to_postid()'; + } elseif ( preg_match('#p/[0-9]{1,}#', $urltest['path'], $match) ) { + // the path defines the post_ID (archives/p/XXXX) + $blah = explode('/', $match[0]); + $post_ID = (int) $blah[1]; + $way = 'from the path'; + } elseif ( preg_match('#p=[0-9]{1,}#', $urltest['query'], $match) ) { + // the querystring defines the post_ID (?p=XXXX) + $blah = explode('=', $match[0]); + $post_ID = (int) $blah[1]; + $way = 'from the querystring'; + } elseif ( isset($urltest['fragment']) ) { + // an #anchor is there, it's either... + if ( intval($urltest['fragment']) ) { + // ...an integer #XXXX (simpliest case) + $post_ID = (int) $urltest['fragment']; + $way = 'from the fragment (numeric)'; + } elseif ( preg_match('/post-[0-9]+/',$urltest['fragment']) ) { + // ...a post id in the form 'post-###' + $post_ID = preg_replace('/[^0-9]+/', '', $urltest['fragment']); + $way = 'from the fragment (post-###)'; + } elseif ( is_string($urltest['fragment']) ) { + // ...or a string #title, a little more complicated + $title = preg_replace('/[^a-z0-9]/i', '.', $urltest['fragment']); + $sql = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_title RLIKE %s", like_escape( $title ) ); + if (! ($post_ID = $wpdb->get_var($sql)) ) { + // returning unknown error '0' is better than die()ing + return new IXR_Error(0, ''); + } + $way = 'from the fragment (title)'; + } + } else { + // TODO: Attempt to extract a post ID from the given URL + return new IXR_Error(33, __('The specified target URL cannot be used as a target. It either doesn’t exist, or it is not a pingback-enabled resource.')); + } + $post_ID = (int) $post_ID; + + + logIO("O","(PB) URL='$pagelinkedto' ID='$post_ID' Found='$way'"); + + $post = get_post($post_ID); + + if ( !$post ) // Post_ID not found + return new IXR_Error(33, __('The specified target URL cannot be used as a target. It either doesn’t exist, or it is not a pingback-enabled resource.')); + + if ( $post_ID == url_to_postid($pagelinkedfrom) ) + return new IXR_Error(0, __('The source URL and the target URL cannot both point to the same resource.')); + + // Check if pings are on + if ( !pings_open($post) ) + return new IXR_Error(33, __('The specified target URL cannot be used as a target. It either doesn’t exist, or it is not a pingback-enabled resource.')); + + // Let's check that the remote site didn't already pingback this entry + if ( $wpdb->get_results( $wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_author_url = %s", $post_ID, $pagelinkedfrom) ) ) + return new IXR_Error( 48, __( 'The pingback has already been registered.' ) ); + + // very stupid, but gives time to the 'from' server to publish ! + sleep(1); + + // Let's check the remote site + $linea = wp_remote_fopen( $pagelinkedfrom ); + if ( !$linea ) + return new IXR_Error(16, __('The source URL does not exist.')); + + $linea = apply_filters('pre_remote_source', $linea, $pagelinkedto); + + // Work around bug in strip_tags(): + $linea = str_replace(']*>/", "\n\n", $linea ); + + preg_match('|([^<]*?)|is', $linea, $matchtitle); + $title = $matchtitle[1]; + if ( empty( $title ) ) + return new IXR_Error(32, __('We cannot find a title on that page.')); + + $linea = strip_tags( $linea, '' ); // just keep the tag we need + + $p = explode( "\n\n", $linea ); + + $preg_target = preg_quote($pagelinkedto, '|'); + + foreach ( $p as $para ) { + if ( strpos($para, $pagelinkedto) !== false ) { // it exists, but is it a link? + preg_match("|]+?".$preg_target."[^>]*>([^>]+?)|", $para, $context); + + // If the URL isn't in a link context, keep looking + if ( empty($context) ) + continue; + + // We're going to use this fake tag to mark the context in a bit + // the marker is needed in case the link text appears more than once in the paragraph + $excerpt = preg_replace('|\|', '', $para); + + // prevent really long link text + if ( strlen($context[1]) > 100 ) + $context[1] = substr($context[1], 0, 100) . '...'; + + $marker = ''.$context[1].''; // set up our marker + $excerpt= str_replace($context[0], $marker, $excerpt); // swap out the link for our marker + $excerpt = strip_tags($excerpt, ''); // strip all tags but our context marker + $excerpt = trim($excerpt); + $preg_marker = preg_quote($marker, '|'); + $excerpt = preg_replace("|.*?\s(.{0,100}$preg_marker.{0,100})\s.*|s", '$1', $excerpt); + $excerpt = strip_tags($excerpt); // YES, again, to remove the marker wrapper + break; + } + } + + if ( empty($context) ) // Link to target not found + return new IXR_Error(17, __('The source URL does not contain a link to the target URL, and so cannot be used as a source.')); + + $pagelinkedfrom = str_replace('&', '&', $pagelinkedfrom); + + $context = '[...] ' . esc_html( $excerpt ) . ' [...]'; + $pagelinkedfrom = $wpdb->escape( $pagelinkedfrom ); + + $comment_post_ID = (int) $post_ID; + $comment_author = $title; + $comment_author_email = ''; + $this->escape($comment_author); + $comment_author_url = $pagelinkedfrom; + $comment_content = $context; + $this->escape($comment_content); + $comment_type = 'pingback'; + + $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_author_email', 'comment_content', 'comment_type'); + + $comment_ID = wp_new_comment($commentdata); + do_action('pingback_post', $comment_ID); + + return sprintf(__('Pingback from %1$s to %2$s registered. Keep the web talking! :-)'), $pagelinkedfrom, $pagelinkedto); + } + + /** + * Retrieve array of URLs that pingbacked the given URL. + * + * Specs on http://www.aquarionics.com/misc/archives/blogite/0198.html + * + * @since 1.5.0 + * + * @param array $args Method parameters. + * @return array + */ + function pingback_extensions_getPingbacks($args) { + + global $wpdb; + + do_action('xmlrpc_call', 'pingback.extensions.getPingbacks'); + + $this->escape($args); + + $url = $args; + + $post_ID = url_to_postid($url); + if ( !$post_ID ) { + // We aren't sure that the resource is available and/or pingback enabled + return new IXR_Error(33, __('The specified target URL cannot be used as a target. It either doesn’t exist, or it is not a pingback-enabled resource.')); + } + + $actual_post = wp_get_single_post($post_ID, ARRAY_A); + + if ( !$actual_post ) { + // No such post = resource not found + return new IXR_Error(32, __('The specified target URL does not exist.')); + } + + $comments = $wpdb->get_results( $wpdb->prepare("SELECT comment_author_url, comment_content, comment_author_IP, comment_type FROM $wpdb->comments WHERE comment_post_ID = %d", $post_ID) ); + + if ( !$comments ) + return array(); + + $pingbacks = array(); + foreach ( $comments as $comment ) { + if ( 'pingback' == $comment->comment_type ) + $pingbacks[] = $comment->comment_author_url; + } + + return $pingbacks; + } +} +?> \ No newline at end of file diff --git a/wp-includes/class-wp.php b/wp-includes/class-wp.php new file mode 100644 index 00000000..7ca64697 --- /dev/null +++ b/wp-includes/class-wp.php @@ -0,0 +1,611 @@ +public_query_vars) ) + $this->public_query_vars[] = $qv; + } + + /** + * Set the value of a query variable. + * + * @since 2.3.0 + * + * @param string $key Query variable name. + * @param mixed $value Query variable value. + */ + function set_query_var($key, $value) { + $this->query_vars[$key] = $value; + } + + /** + * Parse request to find correct WordPress query. + * + * Sets up the query variables based on the request. There are also many + * filters and actions that can be used to further manipulate the result. + * + * @since 2.0.0 + * + * @param array|string $extra_query_vars Set the extra query variables. + */ + function parse_request($extra_query_vars = '') { + global $wp_rewrite; + + $this->query_vars = array(); + $post_type_query_vars = array(); + + if ( is_array($extra_query_vars) ) + $this->extra_query_vars = & $extra_query_vars; + else if (! empty($extra_query_vars)) + parse_str($extra_query_vars, $this->extra_query_vars); + + // Process PATH_INFO, REQUEST_URI, and 404 for permalinks. + + // Fetch the rewrite rules. + $rewrite = $wp_rewrite->wp_rewrite_rules(); + + if ( ! empty($rewrite) ) { + // If we match a rewrite rule, this will be cleared. + $error = '404'; + $this->did_permalink = true; + + if ( isset($_SERVER['PATH_INFO']) ) + $pathinfo = $_SERVER['PATH_INFO']; + else + $pathinfo = ''; + $pathinfo_array = explode('?', $pathinfo); + $pathinfo = str_replace("%", "%25", $pathinfo_array[0]); + $req_uri = $_SERVER['REQUEST_URI']; + $req_uri_array = explode('?', $req_uri); + $req_uri = $req_uri_array[0]; + $self = $_SERVER['PHP_SELF']; + $home_path = parse_url(home_url()); + if ( isset($home_path['path']) ) + $home_path = $home_path['path']; + else + $home_path = ''; + $home_path = trim($home_path, '/'); + + // Trim path info from the end and the leading home path from the + // front. For path info requests, this leaves us with the requesting + // filename, if any. For 404 requests, this leaves us with the + // requested permalink. + $req_uri = str_replace($pathinfo, '', $req_uri); + $req_uri = trim($req_uri, '/'); + $req_uri = preg_replace("|^$home_path|", '', $req_uri); + $req_uri = trim($req_uri, '/'); + $pathinfo = trim($pathinfo, '/'); + $pathinfo = preg_replace("|^$home_path|", '', $pathinfo); + $pathinfo = trim($pathinfo, '/'); + $self = trim($self, '/'); + $self = preg_replace("|^$home_path|", '', $self); + $self = trim($self, '/'); + + // The requested permalink is in $pathinfo for path info requests and + // $req_uri for other requests. + if ( ! empty($pathinfo) && !preg_match('|^.*' . $wp_rewrite->index . '$|', $pathinfo) ) { + $request = $pathinfo; + } else { + // If the request uri is the index, blank it out so that we don't try to match it against a rule. + if ( $req_uri == $wp_rewrite->index ) + $req_uri = ''; + $request = $req_uri; + } + + $this->request = $request; + + // Look for matches. + $request_match = $request; + foreach ( (array) $rewrite as $match => $query) { + // Don't try to match against AtomPub calls + if ( $req_uri == 'wp-app.php' ) + break; + + // If the requesting file is the anchor of the match, prepend it + // to the path info. + if ( (! empty($req_uri)) && (strpos($match, $req_uri) === 0) && ($req_uri != $request) ) + $request_match = $req_uri . '/' . $request; + + if ( preg_match("#^$match#", $request_match, $matches) || + preg_match("#^$match#", urldecode($request_match), $matches) ) { + // Got a match. + $this->matched_rule = $match; + + // Trim the query of everything up to the '?'. + $query = preg_replace("!^.+\?!", '', $query); + + // Substitute the substring matches into the query. + $query = addslashes(WP_MatchesMapRegex::apply($query, $matches)); + + $this->matched_query = $query; + + // Parse the query. + parse_str($query, $perma_query_vars); + + // If we're processing a 404 request, clear the error var + // since we found something. + if ( isset($_GET['error']) ) + unset($_GET['error']); + + if ( isset($error) ) + unset($error); + + break; + } + } + + // If req_uri is empty or if it is a request for ourself, unset error. + if ( empty($request) || $req_uri == $self || strpos($_SERVER['PHP_SELF'], 'wp-admin/') !== false ) { + if ( isset($_GET['error']) ) + unset($_GET['error']); + + if ( isset($error) ) + unset($error); + + if ( isset($perma_query_vars) && strpos($_SERVER['PHP_SELF'], 'wp-admin/') !== false ) + unset($perma_query_vars); + + $this->did_permalink = false; + } + } + + $this->public_query_vars = apply_filters('query_vars', $this->public_query_vars); + + foreach ( $GLOBALS['wp_post_types'] as $post_type => $t ) + if ( $t->query_var ) + $post_type_query_vars[$t->query_var] = $post_type; + + foreach ( $this->public_query_vars as $wpvar ) { + if ( isset( $this->extra_query_vars[$wpvar] ) ) + $this->query_vars[$wpvar] = $this->extra_query_vars[$wpvar]; + elseif ( isset( $_POST[$wpvar] ) ) + $this->query_vars[$wpvar] = $_POST[$wpvar]; + elseif ( isset( $_GET[$wpvar] ) ) + $this->query_vars[$wpvar] = $_GET[$wpvar]; + elseif ( isset( $perma_query_vars[$wpvar] ) ) + $this->query_vars[$wpvar] = $perma_query_vars[$wpvar]; + + if ( !empty( $this->query_vars[$wpvar] ) ) { + if ( ! is_array( $this->query_vars[$wpvar] ) ) { + $this->query_vars[$wpvar] = (string) $this->query_vars[$wpvar]; + } else { + foreach ( $this->query_vars[$wpvar] as $vkey => $v ) { + if ( !is_object( $v ) ) { + $this->query_vars[$wpvar][$vkey] = (string) $v; + } + } + } + + if ( isset($post_type_query_vars[$wpvar] ) ) { + $this->query_vars['post_type'] = $post_type_query_vars[$wpvar]; + $this->query_vars['name'] = $this->query_vars[$wpvar]; + } + } + } + + // Convert urldecoded spaces back into + + foreach ( $GLOBALS['wp_taxonomies'] as $taxonomy => $t ) + if ( $t->query_var && isset( $this->query_vars[$t->query_var] ) ) + $this->query_vars[$t->query_var] = str_replace( ' ', '+', $this->query_vars[$t->query_var] ); + + // Limit publicly queried post_types to those that are publicly_queryable + if ( isset( $this->query_vars['post_type']) ) { + $queryable_post_types = get_post_types( array('publicly_queryable' => true) ); + if ( ! is_array( $this->query_vars['post_type'] ) ) { + if ( ! in_array( $this->query_vars['post_type'], $queryable_post_types ) ) + unset( $this->query_vars['post_type'] ); + } else { + $this->query_vars['post_type'] = array_intersect( $this->query_vars['post_type'], $queryable_post_types ); + } + } + + foreach ( (array) $this->private_query_vars as $var) { + if ( isset($this->extra_query_vars[$var]) ) + $this->query_vars[$var] = $this->extra_query_vars[$var]; + } + + if ( isset($error) ) + $this->query_vars['error'] = $error; + + $this->query_vars = apply_filters('request', $this->query_vars); + + do_action_ref_array('parse_request', array(&$this)); + } + + /** + * Send additional HTTP headers for caching, content type, etc. + * + * Sets the X-Pingback header, 404 status (if 404), Content-type. If showing + * a feed, it will also send last-modified, etag, and 304 status if needed. + * + * @since 2.0.0 + */ + function send_headers() { + $headers = array('X-Pingback' => get_bloginfo('pingback_url')); + $status = null; + $exit_required = false; + + if ( is_user_logged_in() ) + $headers = array_merge($headers, wp_get_nocache_headers()); + if ( !empty($this->query_vars['error']) && '404' == $this->query_vars['error'] ) { + $status = 404; + if ( !is_user_logged_in() ) + $headers = array_merge($headers, wp_get_nocache_headers()); + $headers['Content-Type'] = get_option('html_type') . '; charset=' . get_option('blog_charset'); + } else if ( empty($this->query_vars['feed']) ) { + $headers['Content-Type'] = get_option('html_type') . '; charset=' . get_option('blog_charset'); + } else { + // We're showing a feed, so WP is indeed the only thing that last changed + if ( !empty($this->query_vars['withcomments']) + || ( empty($this->query_vars['withoutcomments']) + && ( !empty($this->query_vars['p']) + || !empty($this->query_vars['name']) + || !empty($this->query_vars['page_id']) + || !empty($this->query_vars['pagename']) + || !empty($this->query_vars['attachment']) + || !empty($this->query_vars['attachment_id']) + ) + ) + ) + $wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastcommentmodified('GMT'), 0).' GMT'; + else + $wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastpostmodified('GMT'), 0).' GMT'; + $wp_etag = '"' . md5($wp_last_modified) . '"'; + $headers['Last-Modified'] = $wp_last_modified; + $headers['ETag'] = $wp_etag; + + // Support for Conditional GET + if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) + $client_etag = stripslashes(stripslashes($_SERVER['HTTP_IF_NONE_MATCH'])); + else $client_etag = false; + + $client_last_modified = empty($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? '' : trim($_SERVER['HTTP_IF_MODIFIED_SINCE']); + // If string is empty, return 0. If not, attempt to parse into a timestamp + $client_modified_timestamp = $client_last_modified ? strtotime($client_last_modified) : 0; + + // Make a timestamp for our most recent modification... + $wp_modified_timestamp = strtotime($wp_last_modified); + + if ( ($client_last_modified && $client_etag) ? + (($client_modified_timestamp >= $wp_modified_timestamp) && ($client_etag == $wp_etag)) : + (($client_modified_timestamp >= $wp_modified_timestamp) || ($client_etag == $wp_etag)) ) { + $status = 304; + $exit_required = true; + } + } + + $headers = apply_filters('wp_headers', $headers, $this); + + if ( ! empty( $status ) ) + status_header( $status ); + foreach( (array) $headers as $name => $field_value ) + @header("{$name}: {$field_value}"); + + if ( $exit_required ) + exit(); + + do_action_ref_array('send_headers', array(&$this)); + } + + /** + * Sets the query string property based off of the query variable property. + * + * The 'query_string' filter is deprecated, but still works. Plugins should + * use the 'request' filter instead. + * + * @since 2.0.0 + */ + function build_query_string() { + $this->query_string = ''; + foreach ( (array) array_keys($this->query_vars) as $wpvar) { + if ( '' != $this->query_vars[$wpvar] ) { + $this->query_string .= (strlen($this->query_string) < 1) ? '' : '&'; + if ( !is_scalar($this->query_vars[$wpvar]) ) // Discard non-scalars. + continue; + $this->query_string .= $wpvar . '=' . rawurlencode($this->query_vars[$wpvar]); + } + } + + // query_string filter deprecated. Use request filter instead. + if ( has_filter('query_string') ) { // Don't bother filtering and parsing if no plugins are hooked in. + $this->query_string = apply_filters('query_string', $this->query_string); + parse_str($this->query_string, $this->query_vars); + } + } + + /** + * Set up the WordPress Globals. + * + * The query_vars property will be extracted to the GLOBALS. So care should + * be taken when naming global variables that might interfere with the + * WordPress environment. + * + * @global string $query_string Query string for the loop. + * @global int $more Only set, if single page or post. + * @global int $single If single page or post. Only set, if single page or post. + * + * @since 2.0.0 + */ + function register_globals() { + global $wp_query; + // Extract updated query vars back into global namespace. + foreach ( (array) $wp_query->query_vars as $key => $value) { + $GLOBALS[$key] = $value; + } + + $GLOBALS['query_string'] = $this->query_string; + $GLOBALS['posts'] = & $wp_query->posts; + $GLOBALS['post'] = (isset($wp_query->post)) ? $wp_query->post : null; + $GLOBALS['request'] = $wp_query->request; + + if ( is_single() || is_page() ) { + $GLOBALS['more'] = 1; + $GLOBALS['single'] = 1; + } + } + + /** + * Set up the current user. + * + * @since 2.0.0 + */ + function init() { + wp_get_current_user(); + } + + /** + * Set up the Loop based on the query variables. + * + * @uses WP::$query_vars + * @since 2.0.0 + */ + function query_posts() { + global $wp_the_query; + $this->build_query_string(); + $wp_the_query->query($this->query_vars); + } + + /** + * Set the Headers for 404, if nothing is found for requested URL. + * + * Issue a 404 if a request doesn't match any posts and doesn't match + * any object (e.g. an existing-but-empty category, tag, author) and a 404 was not already + * issued, and if the request was not a search or the homepage. + * + * Otherwise, issue a 200. + * + * @since 2.0.0 + */ + function handle_404() { + global $wp_query; + + if ( !is_admin() && ( 0 == count( $wp_query->posts ) ) && !is_404() && !is_robots() && !is_search() && !is_home() ) { + // Don't 404 for these queries if they matched an object. + if ( ( is_tag() || is_category() || is_tax() || is_author() ) && $wp_query->get_queried_object() && !is_paged() ) { + if ( !is_404() ) + status_header( 200 ); + return; + } + $wp_query->set_404(); + status_header( 404 ); + nocache_headers(); + } elseif ( !is_404() ) { + status_header( 200 ); + } + } + + /** + * Sets up all of the variables required by the WordPress environment. + * + * The action 'wp' has one parameter that references the WP object. It + * allows for accessing the properties and methods to further manipulate the + * object. + * + * @since 2.0.0 + * + * @param string|array $query_args Passed to {@link parse_request()} + */ + function main($query_args = '') { + $this->init(); + $this->parse_request($query_args); + $this->send_headers(); + $this->query_posts(); + $this->handle_404(); + $this->register_globals(); + do_action_ref_array('wp', array(&$this)); + } + + /** + * PHP4 Constructor - Does nothing. + * + * Call main() method when ready to run setup. + * + * @since 2.0.0 + * + * @return WP + */ + function WP() { + // Empty. + } +} + +/** + * Helper class to remove the need to use eval to replace $matches[] in query strings. + * + * @since 2.9.0 + */ +class WP_MatchesMapRegex { + /** + * store for matches + * + * @access private + * @var array + */ + var $_matches; + + /** + * store for mapping result + * + * @access public + * @var string + */ + var $output; + + /** + * subject to perform mapping on (query string containing $matches[] references + * + * @access private + * @var string + */ + var $_subject; + + /** + * regexp pattern to match $matches[] references + * + * @var string + */ + var $_pattern = '(\$matches\[[1-9]+[0-9]*\])'; // magic number + + /** + * constructor + * + * @param string $subject subject if regex + * @param array $matches data to use in map + * @return self + */ + function WP_MatchesMapRegex($subject, $matches) { + $this->_subject = $subject; + $this->_matches = $matches; + $this->output = $this->_map(); + } + + /** + * Substitute substring matches in subject. + * + * static helper function to ease use + * + * @access public + * @param string $subject subject + * @param array $matches data used for subsitution + * @return string + */ + function apply($subject, $matches) { + $oSelf =& new WP_MatchesMapRegex($subject, $matches); + return $oSelf->output; + } + + /** + * do the actual mapping + * + * @access private + * @return string + */ + function _map() { + $callback = array(&$this, 'callback'); + return preg_replace_callback($this->_pattern, $callback, $this->_subject); + } + + /** + * preg_replace_callback hook + * + * @access public + * @param array $matches preg_replace regexp matches + * @return string + */ + function callback($matches) { + $index = intval(substr($matches[0], 9, -1)); + return ( isset( $this->_matches[$index] ) ? urlencode($this->_matches[$index]) : '' ); + } + +} + +?> diff --git a/wp-includes/class.wp-dependencies.php b/wp-includes/class.wp-dependencies.php index ea607de2..de3630ad 100644 --- a/wp-includes/class.wp-dependencies.php +++ b/wp-includes/class.wp-dependencies.php @@ -37,11 +37,11 @@ class WP_Dependencies { * * Process the items passed to it or the queue. Processes all dependencies. * - * @param mixed handles (optional) items to be processed. (void) processes queue, (string) process that item, (array of strings) process those items + * @param mixed $handles (optional) items to be processed. (void) processes queue, (string) process that item, (array of strings) process those items * @return array Items that have been processed */ function do_items( $handles = false, $group = false ) { - // Print the queue if nothing is passed. If a string is passed, print that script. If an array is passed, print those scripts. + // Print the queue if nothing is passed. If a string is passed, print that script. If an array is passed, print those scripts. $handles = false === $handles ? $this->queue : (array) $handles; $this->all_deps( $handles ); @@ -72,9 +72,9 @@ class WP_Dependencies { * * Recursively builds array of items to process taking dependencies into account. Does NOT catch infinite loops. * - - * @param mixed handles Accepts (string) dep name or (array of strings) dep names - * @param bool recursion Used internally when function calls itself + * + * @param mixed $handles Accepts (string) dep name or (array of strings) dep names + * @param bool $recursion Used internally when function calls itself */ function all_deps( $handles, $recursion = false, $group = false ) { if ( !$handles = (array) $handles ) @@ -125,10 +125,10 @@ class WP_Dependencies { * * Adds the item only if no item of that name already exists * - * @param string handle Script name - * @param string src Script url - * @param array deps (optional) Array of script names on which this script depends - * @param string ver (optional) Script version (used for cache busting) + * @param string $handle Script name + * @param string $src Script url + * @param array $deps (optional) Array of script names on which this script depends + * @param string $ver (optional) Script version (used for cache busting) * @return array Hierarchical array of dependencies */ function add( $handle, $src, $deps = array(), $ver = false, $args = null ) { @@ -143,9 +143,9 @@ class WP_Dependencies { * * Adds data only if script has already been added * - * @param string handle Script name - * @param string data_name Name of object in which to store extra data - * @param array data Array of extra data + * @param string $handle Script name + * @param string $data_name Name of object in which to store extra data + * @param array $data Array of extra data * @return bool success */ function add_data( $handle, $data_name, $data ) { diff --git a/wp-includes/class.wp-scripts.php b/wp-includes/class.wp-scripts.php index 45d2e54c..681a8246 100644 --- a/wp-includes/class.wp-scripts.php +++ b/wp-includes/class.wp-scripts.php @@ -39,8 +39,8 @@ class WP_Scripts extends WP_Dependencies { * * Prints the scripts passed to it or the print queue. Also prints all necessary dependencies. * - * @param mixed handles (optional) Scripts to be printed. (void) prints queue, (string) prints that script, (array of strings) prints those scripts. - * @param int group (optional) If scripts were queued in groups prints this group number. + * @param mixed $handles (optional) Scripts to be printed. (void) prints queue, (string) prints that script, (array of strings) prints those scripts. + * @param int $group (optional) If scripts were queued in groups prints this group number. * @return array Scripts that have been printed */ function print_scripts( $handles = false, $group = false ) { @@ -135,9 +135,9 @@ class WP_Scripts extends WP_Dependencies { * * Localizes only if script has already been added * - * @param string handle Script name - * @param string object_name Name of JS object to hold l10n info - * @param array l10n Array of JS var name => localized string + * @param string $handle Script name + * @param string $object_name Name of JS object to hold l10n info + * @param array $l10n Array of JS var name => localized string * @return bool Successful localization */ function localize( $handle, $object_name, $l10n ) { @@ -183,6 +183,9 @@ class WP_Scripts extends WP_Dependencies { if ( ! $this->default_dirs ) return true; + if ( 0 === strpos( $src, '/wp-includes/js/l10n' ) ) + return false; + foreach ( (array) $this->default_dirs as $test ) { if ( 0 === strpos($src, $test) ) return true; diff --git a/wp-includes/classes.php b/wp-includes/classes.php deleted file mode 100644 index f24a6ec2..00000000 --- a/wp-includes/classes.php +++ /dev/null @@ -1,1700 +0,0 @@ -public_query_vars) ) - $this->public_query_vars[] = $qv; - } - - /** - * Set the value of a query variable. - * - * @since 2.3.0 - * - * @param string $key Query variable name. - * @param mixed $value Query variable value. - */ - function set_query_var($key, $value) { - $this->query_vars[$key] = $value; - } - - /** - * Parse request to find correct WordPress query. - * - * Sets up the query variables based on the request. There are also many - * filters and actions that can be used to further manipulate the result. - * - * @since 2.0.0 - * - * @param array|string $extra_query_vars Set the extra query variables. - */ - function parse_request($extra_query_vars = '') { - global $wp_rewrite; - - $this->query_vars = array(); - $taxonomy_query_vars = array(); - $post_type_query_vars = array(); - - if ( is_array($extra_query_vars) ) - $this->extra_query_vars = & $extra_query_vars; - else if (! empty($extra_query_vars)) - parse_str($extra_query_vars, $this->extra_query_vars); - - // Process PATH_INFO, REQUEST_URI, and 404 for permalinks. - - // Fetch the rewrite rules. - $rewrite = $wp_rewrite->wp_rewrite_rules(); - - if ( ! empty($rewrite) ) { - // If we match a rewrite rule, this will be cleared. - $error = '404'; - $this->did_permalink = true; - - if ( isset($_SERVER['PATH_INFO']) ) - $pathinfo = $_SERVER['PATH_INFO']; - else - $pathinfo = ''; - $pathinfo_array = explode('?', $pathinfo); - $pathinfo = str_replace("%", "%25", $pathinfo_array[0]); - $req_uri = $_SERVER['REQUEST_URI']; - $req_uri_array = explode('?', $req_uri); - $req_uri = $req_uri_array[0]; - $self = $_SERVER['PHP_SELF']; - $home_path = parse_url(home_url()); - if ( isset($home_path['path']) ) - $home_path = $home_path['path']; - else - $home_path = ''; - $home_path = trim($home_path, '/'); - - // Trim path info from the end and the leading home path from the - // front. For path info requests, this leaves us with the requesting - // filename, if any. For 404 requests, this leaves us with the - // requested permalink. - $req_uri = str_replace($pathinfo, '', rawurldecode($req_uri)); - $req_uri = trim($req_uri, '/'); - $req_uri = preg_replace("|^$home_path|", '', $req_uri); - $req_uri = trim($req_uri, '/'); - $pathinfo = trim($pathinfo, '/'); - $pathinfo = preg_replace("|^$home_path|", '', $pathinfo); - $pathinfo = trim($pathinfo, '/'); - $self = trim($self, '/'); - $self = preg_replace("|^$home_path|", '', $self); - $self = trim($self, '/'); - - // The requested permalink is in $pathinfo for path info requests and - // $req_uri for other requests. - if ( ! empty($pathinfo) && !preg_match('|^.*' . $wp_rewrite->index . '$|', $pathinfo) ) { - $request = $pathinfo; - } else { - // If the request uri is the index, blank it out so that we don't try to match it against a rule. - if ( $req_uri == $wp_rewrite->index ) - $req_uri = ''; - $request = $req_uri; - } - - $this->request = $request; - - // Look for matches. - $request_match = $request; - foreach ( (array) $rewrite as $match => $query) { - // Don't try to match against AtomPub calls - if ( $req_uri == 'wp-app.php' ) - break; - - // If the requesting file is the anchor of the match, prepend it - // to the path info. - if ( (! empty($req_uri)) && (strpos($match, $req_uri) === 0) && ($req_uri != $request) ) - $request_match = $req_uri . '/' . $request; - - if ( preg_match("#^$match#", $request_match, $matches) || - preg_match("#^$match#", urldecode($request_match), $matches) ) { - // Got a match. - $this->matched_rule = $match; - - // Trim the query of everything up to the '?'. - $query = preg_replace("!^.+\?!", '', $query); - - // Substitute the substring matches into the query. - $query = addslashes(WP_MatchesMapRegex::apply($query, $matches)); - - $this->matched_query = $query; - - // Parse the query. - parse_str($query, $perma_query_vars); - - // If we're processing a 404 request, clear the error var - // since we found something. - if ( isset($_GET['error']) ) - unset($_GET['error']); - - if ( isset($error) ) - unset($error); - - break; - } - } - - // If req_uri is empty or if it is a request for ourself, unset error. - if ( empty($request) || $req_uri == $self || strpos($_SERVER['PHP_SELF'], 'wp-admin/') !== false ) { - if ( isset($_GET['error']) ) - unset($_GET['error']); - - if ( isset($error) ) - unset($error); - - if ( isset($perma_query_vars) && strpos($_SERVER['PHP_SELF'], 'wp-admin/') !== false ) - unset($perma_query_vars); - - $this->did_permalink = false; - } - } - - $this->public_query_vars = apply_filters('query_vars', $this->public_query_vars); - - foreach ( $GLOBALS['wp_taxonomies'] as $taxonomy => $t ) - if ( $t->query_var ) - $taxonomy_query_vars[$t->query_var] = $taxonomy; - - foreach ( $GLOBALS['wp_post_types'] as $post_type => $t ) - if ( $t->query_var ) - $post_type_query_vars[$t->query_var] = $post_type; - - for ( $i = 0; $i < count($this->public_query_vars); $i += 1 ) { - $wpvar = $this->public_query_vars[$i]; - if ( isset($this->extra_query_vars[$wpvar]) ) - $this->query_vars[$wpvar] = $this->extra_query_vars[$wpvar]; - elseif ( isset($GLOBALS[$wpvar]) ) - $this->query_vars[$wpvar] = $GLOBALS[$wpvar]; - elseif ( !empty($_POST[$wpvar]) ) - $this->query_vars[$wpvar] = $_POST[$wpvar]; - elseif ( !empty($_GET[$wpvar]) ) - $this->query_vars[$wpvar] = $_GET[$wpvar]; - elseif ( !empty($perma_query_vars[$wpvar]) ) - $this->query_vars[$wpvar] = $perma_query_vars[$wpvar]; - - if ( !empty( $this->query_vars[$wpvar] ) ) { - $this->query_vars[$wpvar] = (string) $this->query_vars[$wpvar]; - if ( isset( $taxonomy_query_vars[$wpvar] ) ) { - $this->query_vars['taxonomy'] = $taxonomy_query_vars[$wpvar]; - $this->query_vars['term'] = $this->query_vars[$wpvar]; - } elseif ( isset($post_type_query_vars[$wpvar] ) ) { - $this->query_vars['post_type'] = $post_type_query_vars[$wpvar]; - $this->query_vars['name'] = $this->query_vars[$wpvar]; - } - } - } - - // Limit publicly queried post_types to those that are publicly_queryable - if ( isset( $this->query_vars['post_type']) ) { - $queryable_post_types = get_post_types( array('publicly_queryable' => true) ); - if ( ! in_array( $this->query_vars['post_type'], $queryable_post_types ) ) - unset( $this->query_vars['post_type'] ); - } - - foreach ( (array) $this->private_query_vars as $var) { - if ( isset($this->extra_query_vars[$var]) ) - $this->query_vars[$var] = $this->extra_query_vars[$var]; - elseif ( isset($GLOBALS[$var]) && '' != $GLOBALS[$var] ) - $this->query_vars[$var] = $GLOBALS[$var]; - } - - if ( isset($error) ) - $this->query_vars['error'] = $error; - - $this->query_vars = apply_filters('request', $this->query_vars); - - do_action_ref_array('parse_request', array(&$this)); - } - - /** - * Send additional HTTP headers for caching, content type, etc. - * - * Sets the X-Pingback header, 404 status (if 404), Content-type. If showing - * a feed, it will also send last-modified, etag, and 304 status if needed. - * - * @since 2.0.0 - */ - function send_headers() { - $headers = array('X-Pingback' => get_bloginfo('pingback_url')); - $status = null; - $exit_required = false; - - if ( is_user_logged_in() ) - $headers = array_merge($headers, wp_get_nocache_headers()); - if ( !empty($this->query_vars['error']) && '404' == $this->query_vars['error'] ) { - $status = 404; - if ( !is_user_logged_in() ) - $headers = array_merge($headers, wp_get_nocache_headers()); - $headers['Content-Type'] = get_option('html_type') . '; charset=' . get_option('blog_charset'); - } else if ( empty($this->query_vars['feed']) ) { - $headers['Content-Type'] = get_option('html_type') . '; charset=' . get_option('blog_charset'); - } else { - // We're showing a feed, so WP is indeed the only thing that last changed - if ( !empty($this->query_vars['withcomments']) - || ( empty($this->query_vars['withoutcomments']) - && ( !empty($this->query_vars['p']) - || !empty($this->query_vars['name']) - || !empty($this->query_vars['page_id']) - || !empty($this->query_vars['pagename']) - || !empty($this->query_vars['attachment']) - || !empty($this->query_vars['attachment_id']) - ) - ) - ) - $wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastcommentmodified('GMT'), 0).' GMT'; - else - $wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastpostmodified('GMT'), 0).' GMT'; - $wp_etag = '"' . md5($wp_last_modified) . '"'; - $headers['Last-Modified'] = $wp_last_modified; - $headers['ETag'] = $wp_etag; - - // Support for Conditional GET - if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) - $client_etag = stripslashes(stripslashes($_SERVER['HTTP_IF_NONE_MATCH'])); - else $client_etag = false; - - $client_last_modified = empty($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? '' : trim($_SERVER['HTTP_IF_MODIFIED_SINCE']); - // If string is empty, return 0. If not, attempt to parse into a timestamp - $client_modified_timestamp = $client_last_modified ? strtotime($client_last_modified) : 0; - - // Make a timestamp for our most recent modification... - $wp_modified_timestamp = strtotime($wp_last_modified); - - if ( ($client_last_modified && $client_etag) ? - (($client_modified_timestamp >= $wp_modified_timestamp) && ($client_etag == $wp_etag)) : - (($client_modified_timestamp >= $wp_modified_timestamp) || ($client_etag == $wp_etag)) ) { - $status = 304; - $exit_required = true; - } - } - - $headers = apply_filters('wp_headers', $headers, $this); - - if ( ! empty( $status ) ) - status_header( $status ); - foreach( (array) $headers as $name => $field_value ) - @header("{$name}: {$field_value}"); - - if ($exit_required) - exit(); - - do_action_ref_array('send_headers', array(&$this)); - } - - /** - * Sets the query string property based off of the query variable property. - * - * The 'query_string' filter is deprecated, but still works. Plugins should - * use the 'request' filter instead. - * - * @since 2.0.0 - */ - function build_query_string() { - $this->query_string = ''; - foreach ( (array) array_keys($this->query_vars) as $wpvar) { - if ( '' != $this->query_vars[$wpvar] ) { - $this->query_string .= (strlen($this->query_string) < 1) ? '' : '&'; - if ( !is_scalar($this->query_vars[$wpvar]) ) // Discard non-scalars. - continue; - $this->query_string .= $wpvar . '=' . rawurlencode($this->query_vars[$wpvar]); - } - } - - // query_string filter deprecated. Use request filter instead. - if ( has_filter('query_string') ) { // Don't bother filtering and parsing if no plugins are hooked in. - $this->query_string = apply_filters('query_string', $this->query_string); - parse_str($this->query_string, $this->query_vars); - } - } - - /** - * Set up the WordPress Globals. - * - * The query_vars property will be extracted to the GLOBALS. So care should - * be taken when naming global variables that might interfere with the - * WordPress environment. - * - * @global string $query_string Query string for the loop. - * @global int $more Only set, if single page or post. - * @global int $single If single page or post. Only set, if single page or post. - * - * @since 2.0.0 - */ - function register_globals() { - global $wp_query; - // Extract updated query vars back into global namespace. - foreach ( (array) $wp_query->query_vars as $key => $value) { - $GLOBALS[$key] = $value; - } - - $GLOBALS['query_string'] = $this->query_string; - $GLOBALS['posts'] = & $wp_query->posts; - $GLOBALS['post'] = $wp_query->post; - $GLOBALS['request'] = $wp_query->request; - - if ( is_single() || is_page() ) { - $GLOBALS['more'] = 1; - $GLOBALS['single'] = 1; - } - } - - /** - * Set up the current user. - * - * @since 2.0.0 - */ - function init() { - wp_get_current_user(); - } - - /** - * Set up the Loop based on the query variables. - * - * @uses WP::$query_vars - * @since 2.0.0 - */ - function query_posts() { - global $wp_the_query; - $this->build_query_string(); - $wp_the_query->query($this->query_vars); - } - - /** - * Set the Headers for 404, if nothing is found for requested URL. - * - * Issue a 404 if a request doesn't match any posts and doesn't match - * any object (e.g. an existing-but-empty category, tag, author) and a 404 was not already - * issued, and if the request was not a search or the homepage. - * - * Otherwise, issue a 200. - * - * @since 2.0.0 - */ - function handle_404() { - global $wp_query; - - if ( !is_admin() && ( 0 == count( $wp_query->posts ) ) && !is_404() && !is_robots() && !is_search() && !is_home() ) { - // Don't 404 for these queries if they matched an object. - if ( ( is_tag() || is_category() || is_tax() || is_author() ) && $wp_query->get_queried_object() && !is_paged() ) { - if ( !is_404() ) - status_header( 200 ); - return; - } - $wp_query->set_404(); - status_header( 404 ); - nocache_headers(); - } elseif ( !is_404() ) { - status_header( 200 ); - } - } - - /** - * Sets up all of the variables required by the WordPress environment. - * - * The action 'wp' has one parameter that references the WP object. It - * allows for accessing the properties and methods to further manipulate the - * object. - * - * @since 2.0.0 - * - * @param string|array $query_args Passed to {@link parse_request()} - */ - function main($query_args = '') { - $this->init(); - $this->parse_request($query_args); - $this->send_headers(); - $this->query_posts(); - $this->handle_404(); - $this->register_globals(); - do_action_ref_array('wp', array(&$this)); - } - - /** - * PHP4 Constructor - Does nothing. - * - * Call main() method when ready to run setup. - * - * @since 2.0.0 - * - * @return WP - */ - function WP() { - // Empty. - } -} - -/** - * WordPress Error class. - * - * Container for checking for WordPress errors and error messages. Return - * WP_Error and use {@link is_wp_error()} to check if this class is returned. - * Many core WordPress functions pass this class in the event of an error and - * if not handled properly will result in code errors. - * - * @package WordPress - * @since 2.1.0 - */ -class WP_Error { - /** - * Stores the list of errors. - * - * @since 2.1.0 - * @var array - * @access private - */ - var $errors = array(); - - /** - * Stores the list of data for error codes. - * - * @since 2.1.0 - * @var array - * @access private - */ - var $error_data = array(); - - /** - * PHP4 Constructor - Sets up error message. - * - * If code parameter is empty then nothing will be done. It is possible to - * add multiple messages to the same code, but with other methods in the - * class. - * - * All parameters are optional, but if the code parameter is set, then the - * data parameter is optional. - * - * @since 2.1.0 - * - * @param string|int $code Error code - * @param string $message Error message - * @param mixed $data Optional. Error data. - * @return WP_Error - */ - function WP_Error($code = '', $message = '', $data = '') { - if ( empty($code) ) - return; - - $this->errors[$code][] = $message; - - if ( ! empty($data) ) - $this->error_data[$code] = $data; - } - - /** - * Retrieve all error codes. - * - * @since 2.1.0 - * @access public - * - * @return array List of error codes, if avaiable. - */ - function get_error_codes() { - if ( empty($this->errors) ) - return array(); - - return array_keys($this->errors); - } - - /** - * Retrieve first error code available. - * - * @since 2.1.0 - * @access public - * - * @return string|int Empty string, if no error codes. - */ - function get_error_code() { - $codes = $this->get_error_codes(); - - if ( empty($codes) ) - return ''; - - return $codes[0]; - } - - /** - * Retrieve all error messages or error messages matching code. - * - * @since 2.1.0 - * - * @param string|int $code Optional. Retrieve messages matching code, if exists. - * @return array Error strings on success, or empty array on failure (if using codee parameter). - */ - function get_error_messages($code = '') { - // Return all messages if no code specified. - if ( empty($code) ) { - $all_messages = array(); - foreach ( (array) $this->errors as $code => $messages ) - $all_messages = array_merge($all_messages, $messages); - - return $all_messages; - } - - if ( isset($this->errors[$code]) ) - return $this->errors[$code]; - else - return array(); - } - - /** - * Get single error message. - * - * This will get the first message available for the code. If no code is - * given then the first code available will be used. - * - * @since 2.1.0 - * - * @param string|int $code Optional. Error code to retrieve message. - * @return string - */ - function get_error_message($code = '') { - if ( empty($code) ) - $code = $this->get_error_code(); - $messages = $this->get_error_messages($code); - if ( empty($messages) ) - return ''; - return $messages[0]; - } - - /** - * Retrieve error data for error code. - * - * @since 2.1.0 - * - * @param string|int $code Optional. Error code. - * @return mixed Null, if no errors. - */ - function get_error_data($code = '') { - if ( empty($code) ) - $code = $this->get_error_code(); - - if ( isset($this->error_data[$code]) ) - return $this->error_data[$code]; - return null; - } - - /** - * Append more error messages to list of error messages. - * - * @since 2.1.0 - * @access public - * - * @param string|int $code Error code. - * @param string $message Error message. - * @param mixed $data Optional. Error data. - */ - function add($code, $message, $data = '') { - $this->errors[$code][] = $message; - if ( ! empty($data) ) - $this->error_data[$code] = $data; - } - - /** - * Add data for error code. - * - * The error code can only contain one error data. - * - * @since 2.1.0 - * - * @param mixed $data Error data. - * @param string|int $code Error code. - */ - function add_data($data, $code = '') { - if ( empty($code) ) - $code = $this->get_error_code(); - - $this->error_data[$code] = $data; - } -} - -/** - * Check whether variable is a WordPress Error. - * - * Looks at the object and if a WP_Error class. Does not check to see if the - * parent is also WP_Error, so can't inherit WP_Error and still use this - * function. - * - * @since 2.1.0 - * - * @param mixed $thing Check if unknown variable is WordPress Error object. - * @return bool True, if WP_Error. False, if not WP_Error. - */ -function is_wp_error($thing) { - if ( is_object($thing) && is_a($thing, 'WP_Error') ) - return true; - return false; -} - -/** - * A class for displaying various tree-like structures. - * - * Extend the Walker class to use it, see examples at the below. Child classes - * do not need to implement all of the abstract methods in the class. The child - * only needs to implement the methods that are needed. Also, the methods are - * not strictly abstract in that the parameter definition needs to be followed. - * The child classes can have additional parameters. - * - * @package WordPress - * @since 2.1.0 - * @abstract - */ -class Walker { - /** - * What the class handles. - * - * @since 2.1.0 - * @var string - * @access public - */ - var $tree_type; - - /** - * DB fields to use. - * - * @since 2.1.0 - * @var array - * @access protected - */ - var $db_fields; - - /** - * Max number of pages walked by the paged walker - * - * @since 2.7.0 - * @var int - * @access protected - */ - var $max_pages = 1; - - /** - * Starts the list before the elements are added. - * - * Additional parameters are used in child classes. The args parameter holds - * additional values that may be used with the child class methods. This - * method is called at the start of the output list. - * - * @since 2.1.0 - * @abstract - * - * @param string $output Passed by reference. Used to append additional content. - */ - function start_lvl(&$output) {} - - /** - * Ends the list of after the elements are added. - * - * Additional parameters are used in child classes. The args parameter holds - * additional values that may be used with the child class methods. This - * method finishes the list at the end of output of the elements. - * - * @since 2.1.0 - * @abstract - * - * @param string $output Passed by reference. Used to append additional content. - */ - function end_lvl(&$output) {} - - /** - * Start the element output. - * - * Additional parameters are used in child classes. The args parameter holds - * additional values that may be used with the child class methods. Includes - * the element output also. - * - * @since 2.1.0 - * @abstract - * - * @param string $output Passed by reference. Used to append additional content. - */ - function start_el(&$output) {} - - /** - * Ends the element output, if needed. - * - * Additional parameters are used in child classes. The args parameter holds - * additional values that may be used with the child class methods. - * - * @since 2.1.0 - * @abstract - * - * @param string $output Passed by reference. Used to append additional content. - */ - function end_el(&$output) {} - - /** - * Traverse elements to create list from elements. - * - * Display one element if the element doesn't have any children otherwise, - * display the element and its children. Will only traverse up to the max - * depth and no ignore elements under that depth. It is possible to set the - * max depth to include all depths, see walk() method. - * - * This method shouldn't be called directly, use the walk() method instead. - * - * @since 2.5.0 - * - * @param object $element Data object - * @param array $children_elements List of elements to continue traversing. - * @param int $max_depth Max depth to traverse. - * @param int $depth Depth of current element. - * @param array $args - * @param string $output Passed by reference. Used to append additional content. - * @return null Null on failure with no changes to parameters. - */ - function display_element( $element, &$children_elements, $max_depth, $depth=0, $args, &$output ) { - - if ( !$element ) - return; - - $id_field = $this->db_fields['id']; - - //display this element - if ( is_array( $args[0] ) ) - $args[0]['has_children'] = ! empty( $children_elements[$element->$id_field] ); - $cb_args = array_merge( array(&$output, $element, $depth), $args); - call_user_func_array(array(&$this, 'start_el'), $cb_args); - - $id = $element->$id_field; - - // descend only when the depth is right and there are childrens for this element - if ( ($max_depth == 0 || $max_depth > $depth+1 ) && isset( $children_elements[$id]) ) { - - foreach( $children_elements[ $id ] as $child ){ - - if ( !isset($newlevel) ) { - $newlevel = true; - //start the child delimiter - $cb_args = array_merge( array(&$output, $depth), $args); - call_user_func_array(array(&$this, 'start_lvl'), $cb_args); - } - $this->display_element( $child, $children_elements, $max_depth, $depth + 1, $args, $output ); - } - unset( $children_elements[ $id ] ); - } - - if ( isset($newlevel) && $newlevel ){ - //end the child delimiter - $cb_args = array_merge( array(&$output, $depth), $args); - call_user_func_array(array(&$this, 'end_lvl'), $cb_args); - } - - //end this element - $cb_args = array_merge( array(&$output, $element, $depth), $args); - call_user_func_array(array(&$this, 'end_el'), $cb_args); - } - - /** - * Display array of elements hierarchically. - * - * It is a generic function which does not assume any existing order of - * elements. max_depth = -1 means flatly display every element. max_depth = - * 0 means display all levels. max_depth > 0 specifies the number of - * display levels. - * - * @since 2.1.0 - * - * @param array $elements - * @param int $max_depth - * @return string - */ - function walk( $elements, $max_depth) { - - $args = array_slice(func_get_args(), 2); - $output = ''; - - if ($max_depth < -1) //invalid parameter - return $output; - - if (empty($elements)) //nothing to walk - return $output; - - $id_field = $this->db_fields['id']; - $parent_field = $this->db_fields['parent']; - - // flat display - if ( -1 == $max_depth ) { - $empty_array = array(); - foreach ( $elements as $e ) - $this->display_element( $e, $empty_array, 1, 0, $args, $output ); - return $output; - } - - /* - * need to display in hierarchical order - * separate elements into two buckets: top level and children elements - * children_elements is two dimensional array, eg. - * children_elements[10][] contains all sub-elements whose parent is 10. - */ - $top_level_elements = array(); - $children_elements = array(); - foreach ( $elements as $e) { - if ( 0 == $e->$parent_field ) - $top_level_elements[] = $e; - else - $children_elements[ $e->$parent_field ][] = $e; - } - - /* - * when none of the elements is top level - * assume the first one must be root of the sub elements - */ - if ( empty($top_level_elements) ) { - - $first = array_slice( $elements, 0, 1 ); - $root = $first[0]; - - $top_level_elements = array(); - $children_elements = array(); - foreach ( $elements as $e) { - if ( $root->$parent_field == $e->$parent_field ) - $top_level_elements[] = $e; - else - $children_elements[ $e->$parent_field ][] = $e; - } - } - - foreach ( $top_level_elements as $e ) - $this->display_element( $e, $children_elements, $max_depth, 0, $args, $output ); - - /* - * if we are displaying all levels, and remaining children_elements is not empty, - * then we got orphans, which should be displayed regardless - */ - if ( ( $max_depth == 0 ) && count( $children_elements ) > 0 ) { - $empty_array = array(); - foreach ( $children_elements as $orphans ) - foreach( $orphans as $op ) - $this->display_element( $op, $empty_array, 1, 0, $args, $output ); - } - - return $output; - } - - /** - * paged_walk() - produce a page of nested elements - * - * Given an array of hierarchical elements, the maximum depth, a specific page number, - * and number of elements per page, this function first determines all top level root elements - * belonging to that page, then lists them and all of their children in hierarchical order. - * - * @package WordPress - * @since 2.7 - * @param $max_depth = 0 means display all levels; $max_depth > 0 specifies the number of display levels. - * @param $page_num the specific page number, beginning with 1. - * @return XHTML of the specified page of elements - */ - function paged_walk( $elements, $max_depth, $page_num, $per_page ) { - - /* sanity check */ - if ( empty($elements) || $max_depth < -1 ) - return ''; - - $args = array_slice( func_get_args(), 4 ); - $output = ''; - - $id_field = $this->db_fields['id']; - $parent_field = $this->db_fields['parent']; - - $count = -1; - if ( -1 == $max_depth ) - $total_top = count( $elements ); - if ( $page_num < 1 || $per_page < 0 ) { - // No paging - $paging = false; - $start = 0; - if ( -1 == $max_depth ) - $end = $total_top; - $this->max_pages = 1; - } else { - $paging = true; - $start = ( (int)$page_num - 1 ) * (int)$per_page; - $end = $start + $per_page; - if ( -1 == $max_depth ) - $this->max_pages = ceil($total_top / $per_page); - } - - // flat display - if ( -1 == $max_depth ) { - if ( !empty($args[0]['reverse_top_level']) ) { - $elements = array_reverse( $elements ); - $oldstart = $start; - $start = $total_top - $end; - $end = $total_top - $oldstart; - } - - $empty_array = array(); - foreach ( $elements as $e ) { - $count++; - if ( $count < $start ) - continue; - if ( $count >= $end ) - break; - $this->display_element( $e, $empty_array, 1, 0, $args, $output ); - } - return $output; - } - - /* - * separate elements into two buckets: top level and children elements - * children_elements is two dimensional array, eg. - * children_elements[10][] contains all sub-elements whose parent is 10. - */ - $top_level_elements = array(); - $children_elements = array(); - foreach ( $elements as $e) { - if ( 0 == $e->$parent_field ) - $top_level_elements[] = $e; - else - $children_elements[ $e->$parent_field ][] = $e; - } - - $total_top = count( $top_level_elements ); - if ( $paging ) - $this->max_pages = ceil($total_top / $per_page); - else - $end = $total_top; - - if ( !empty($args[0]['reverse_top_level']) ) { - $top_level_elements = array_reverse( $top_level_elements ); - $oldstart = $start; - $start = $total_top - $end; - $end = $total_top - $oldstart; - } - if ( !empty($args[0]['reverse_children']) ) { - foreach ( $children_elements as $parent => $children ) - $children_elements[$parent] = array_reverse( $children ); - } - - foreach ( $top_level_elements as $e ) { - $count++; - - //for the last page, need to unset earlier children in order to keep track of orphans - if ( $end >= $total_top && $count < $start ) - $this->unset_children( $e, $children_elements ); - - if ( $count < $start ) - continue; - - if ( $count >= $end ) - break; - - $this->display_element( $e, $children_elements, $max_depth, 0, $args, $output ); - } - - if ( $end >= $total_top && count( $children_elements ) > 0 ) { - $empty_array = array(); - foreach ( $children_elements as $orphans ) - foreach( $orphans as $op ) - $this->display_element( $op, $empty_array, 1, 0, $args, $output ); - } - - return $output; - } - - function get_number_of_root_elements( $elements ){ - - $num = 0; - $parent_field = $this->db_fields['parent']; - - foreach ( $elements as $e) { - if ( 0 == $e->$parent_field ) - $num++; - } - return $num; - } - - // unset all the children for a given top level element - function unset_children( $e, &$children_elements ){ - - if ( !$e || !$children_elements ) - return; - - $id_field = $this->db_fields['id']; - $id = $e->$id_field; - - if ( !empty($children_elements[$id]) && is_array($children_elements[$id]) ) - foreach ( (array) $children_elements[$id] as $child ) - $this->unset_children( $child, $children_elements ); - - if ( isset($children_elements[$id]) ) - unset( $children_elements[$id] ); - - } -} - -/** - * Create HTML list of pages. - * - * @package WordPress - * @since 2.1.0 - * @uses Walker - */ -class Walker_Page extends Walker { - /** - * @see Walker::$tree_type - * @since 2.1.0 - * @var string - */ - var $tree_type = 'page'; - - /** - * @see Walker::$db_fields - * @since 2.1.0 - * @todo Decouple this. - * @var array - */ - var $db_fields = array ('parent' => 'post_parent', 'id' => 'ID'); - - /** - * @see Walker::start_lvl() - * @since 2.1.0 - * - * @param string $output Passed by reference. Used to append additional content. - * @param int $depth Depth of page. Used for padding. - */ - function start_lvl(&$output, $depth) { - $indent = str_repeat("\t", $depth); - $output .= "\n$indent
          \n"; - } - - /** - * @see Walker::end_lvl() - * @since 2.1.0 - * - * @param string $output Passed by reference. Used to append additional content. - * @param int $depth Depth of page. Used for padding. - */ - function end_lvl(&$output, $depth) { - $indent = str_repeat("\t", $depth); - $output .= "$indent
        \n"; - } - - /** - * @see Walker::start_el() - * @since 2.1.0 - * - * @param string $output Passed by reference. Used to append additional content. - * @param object $page Page data object. - * @param int $depth Depth of page. Used for padding. - * @param int $current_page Page ID. - * @param array $args - */ - function start_el(&$output, $page, $depth, $args, $current_page) { - if ( $depth ) - $indent = str_repeat("\t", $depth); - else - $indent = ''; - - extract($args, EXTR_SKIP); - $css_class = array('page_item', 'page-item-'.$page->ID); - if ( !empty($current_page) ) { - $_current_page = get_page( $current_page ); - if ( isset($_current_page->ancestors) && in_array($page->ID, (array) $_current_page->ancestors) ) - $css_class[] = 'current_page_ancestor'; - if ( $page->ID == $current_page ) - $css_class[] = 'current_page_item'; - elseif ( $_current_page && $page->ID == $_current_page->post_parent ) - $css_class[] = 'current_page_parent'; - } elseif ( $page->ID == get_option('page_for_posts') ) { - $css_class[] = 'current_page_parent'; - } - - $css_class = implode(' ', apply_filters('page_css_class', $css_class, $page)); - - $output .= $indent . '
      • ' . $link_before . apply_filters( 'the_title', $page->post_title, $page->ID ) . $link_after . ''; - - if ( !empty($show_date) ) { - if ( 'modified' == $show_date ) - $time = $page->post_modified; - else - $time = $page->post_date; - - $output .= " " . mysql2date($date_format, $time); - } - } - - /** - * @see Walker::end_el() - * @since 2.1.0 - * - * @param string $output Passed by reference. Used to append additional content. - * @param object $page Page data object. Not used. - * @param int $depth Depth of page. Not Used. - */ - function end_el(&$output, $page, $depth) { - $output .= "
      • \n"; - } - -} - -/** - * Create HTML dropdown list of pages. - * - * @package WordPress - * @since 2.1.0 - * @uses Walker - */ -class Walker_PageDropdown extends Walker { - /** - * @see Walker::$tree_type - * @since 2.1.0 - * @var string - */ - var $tree_type = 'page'; - - /** - * @see Walker::$db_fields - * @since 2.1.0 - * @todo Decouple this - * @var array - */ - var $db_fields = array ('parent' => 'post_parent', 'id' => 'ID'); - - /** - * @see Walker::start_el() - * @since 2.1.0 - * - * @param string $output Passed by reference. Used to append additional content. - * @param object $page Page data object. - * @param int $depth Depth of page in reference to parent pages. Used for padding. - * @param array $args Uses 'selected' argument for selected page to set selected HTML attribute for option element. - */ - function start_el(&$output, $page, $depth, $args) { - $pad = str_repeat(' ', $depth * 3); - - $output .= "\t\n"; - } -} - -/** - * Create HTML list of categories. - * - * @package WordPress - * @since 2.1.0 - * @uses Walker - */ -class Walker_Category extends Walker { - /** - * @see Walker::$tree_type - * @since 2.1.0 - * @var string - */ - var $tree_type = 'category'; - - /** - * @see Walker::$db_fields - * @since 2.1.0 - * @todo Decouple this - * @var array - */ - var $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); - - /** - * @see Walker::start_lvl() - * @since 2.1.0 - * - * @param string $output Passed by reference. Used to append additional content. - * @param int $depth Depth of category. Used for tab indentation. - * @param array $args Will only append content if style argument value is 'list'. - */ - function start_lvl(&$output, $depth, $args) { - if ( 'list' != $args['style'] ) - return; - - $indent = str_repeat("\t", $depth); - $output .= "$indent
          \n"; - } - - /** - * @see Walker::end_lvl() - * @since 2.1.0 - * - * @param string $output Passed by reference. Used to append additional content. - * @param int $depth Depth of category. Used for tab indentation. - * @param array $args Will only append content if style argument value is 'list'. - */ - function end_lvl(&$output, $depth, $args) { - if ( 'list' != $args['style'] ) - return; - - $indent = str_repeat("\t", $depth); - $output .= "$indent
        \n"; - } - - /** - * @see Walker::start_el() - * @since 2.1.0 - * - * @param string $output Passed by reference. Used to append additional content. - * @param object $category Category data object. - * @param int $depth Depth of category in reference to parents. - * @param array $args - */ - function start_el(&$output, $category, $depth, $args) { - extract($args); - - $cat_name = esc_attr( $category->name); - $cat_name = apply_filters( 'list_cats', $cat_name, $category ); - $link = 'description) ) - $link .= 'title="' . sprintf(__( 'View all posts filed under %s' ), $cat_name) . '"'; - else - $link .= 'title="' . esc_attr( strip_tags( apply_filters( 'category_description', $category->description, $category ) ) ) . '"'; - $link .= '>'; - $link .= $cat_name . ''; - - if ( (! empty($feed_image)) || (! empty($feed)) ) { - $link .= ' '; - - if ( empty($feed_image) ) - $link .= '('; - - $link .= ''; - $link .= ''; - if ( empty($feed_image) ) - $link .= ')'; - } - - if ( isset($show_count) && $show_count ) - $link .= ' (' . intval($category->count) . ')'; - - if ( isset($show_date) && $show_date ) { - $link .= ' ' . gmdate('Y-m-d', $category->last_update_timestamp); - } - - if ( isset($current_category) && $current_category ) - $_current_category = get_category( $current_category ); - - if ( 'list' == $args['style'] ) { - $output .= "\tterm_id; - if ( isset($current_category) && $current_category && ($category->term_id == $current_category) ) - $class .= ' current-cat'; - elseif ( isset($_current_category) && $_current_category && ($category->term_id == $_current_category->parent) ) - $class .= ' current-cat-parent'; - $output .= ' class="'.$class.'"'; - $output .= ">$link\n"; - } else { - $output .= "\t$link
        \n"; - } - } - - /** - * @see Walker::end_el() - * @since 2.1.0 - * - * @param string $output Passed by reference. Used to append additional content. - * @param object $page Not used. - * @param int $depth Depth of category. Not used. - * @param array $args Only uses 'list' for whether should append to output. - */ - function end_el(&$output, $page, $depth, $args) { - if ( 'list' != $args['style'] ) - return; - - $output .= "\n"; - } - -} - -/** - * Create HTML dropdown list of Categories. - * - * @package WordPress - * @since 2.1.0 - * @uses Walker - */ -class Walker_CategoryDropdown extends Walker { - /** - * @see Walker::$tree_type - * @since 2.1.0 - * @var string - */ - var $tree_type = 'category'; - - /** - * @see Walker::$db_fields - * @since 2.1.0 - * @todo Decouple this - * @var array - */ - var $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); - - /** - * @see Walker::start_el() - * @since 2.1.0 - * - * @param string $output Passed by reference. Used to append additional content. - * @param object $category Category data object. - * @param int $depth Depth of category. Used for padding. - * @param array $args Uses 'selected', 'show_count', and 'show_last_update' keys, if they exist. - */ - function start_el(&$output, $category, $depth, $args) { - $pad = str_repeat(' ', $depth * 3); - - $cat_name = apply_filters('list_cats', $category->name, $category); - $output .= "\t\n"; - } -} - -/** - * Send XML response back to AJAX request. - * - * @package WordPress - * @since 2.1.0 - */ -class WP_Ajax_Response { - /** - * Store XML responses to send. - * - * @since 2.1.0 - * @var array - * @access private - */ - var $responses = array(); - - /** - * PHP4 Constructor - Passes args to {@link WP_Ajax_Response::add()}. - * - * @since 2.1.0 - * @see WP_Ajax_Response::add() - * - * @param string|array $args Optional. Will be passed to add() method. - * @return WP_Ajax_Response - */ - function WP_Ajax_Response( $args = '' ) { - if ( !empty($args) ) - $this->add($args); - } - - /** - * Append to XML response based on given arguments. - * - * The arguments that can be passed in the $args parameter are below. It is - * also possible to pass a WP_Error object in either the 'id' or 'data' - * argument. The parameter isn't actually optional, content should be given - * in order to send the correct response. - * - * 'what' argument is a string that is the XMLRPC response type. - * 'action' argument is a boolean or string that acts like a nonce. - * 'id' argument can be WP_Error or an integer. - * 'old_id' argument is false by default or an integer of the previous ID. - * 'position' argument is an integer or a string with -1 = top, 1 = bottom, - * html ID = after, -html ID = before. - * 'data' argument is a string with the content or message. - * 'supplemental' argument is an array of strings that will be children of - * the supplemental element. - * - * @since 2.1.0 - * - * @param string|array $args Override defaults. - * @return string XML response. - */ - function add( $args = '' ) { - $defaults = array( - 'what' => 'object', 'action' => false, - 'id' => '0', 'old_id' => false, - 'position' => 1, - 'data' => '', 'supplemental' => array() - ); - - $r = wp_parse_args( $args, $defaults ); - extract( $r, EXTR_SKIP ); - $position = preg_replace( '/[^a-z0-9:_-]/i', '', $position ); - - if ( is_wp_error($id) ) { - $data = $id; - $id = 0; - } - - $response = ''; - if ( is_wp_error($data) ) { - foreach ( (array) $data->get_error_codes() as $code ) { - $response .= "get_error_message($code) . "]]>"; - if ( !$error_data = $data->get_error_data($code) ) - continue; - $class = ''; - if ( is_object($error_data) ) { - $class = ' class="' . get_class($error_data) . '"'; - $error_data = get_object_vars($error_data); - } - - $response .= ""; - - if ( is_scalar($error_data) ) { - $response .= ""; - } elseif ( is_array($error_data) ) { - foreach ( $error_data as $k => $v ) - $response .= "<$k>"; - } - - $response .= ""; - } - } else { - $response = ""; - } - - $s = ''; - if ( is_array($supplemental) ) { - foreach ( $supplemental as $k => $v ) - $s .= "<$k>"; - $s = "$s"; - } - - if ( false === $action ) - $action = $_POST['action']; - - $x = ''; - $x .= ""; // The action attribute in the xml output is formatted like a nonce action - $x .= "<$what id='$id' " . ( false === $old_id ? '' : "old_id='$old_id' " ) . "position='$position'>"; - $x .= $response; - $x .= $s; - $x .= ""; - $x .= ""; - - $this->responses[] = $x; - return $x; - } - - /** - * Display XML formatted responses. - * - * Sets the content type header to text/xml. - * - * @since 2.1.0 - */ - function send() { - header('Content-Type: text/xml'); - echo ""; - foreach ( (array) $this->responses as $response ) - echo $response; - echo ''; - die(); - } -} - -/** - * Helper class to remove the need to use eval to replace $matches[] in query strings. - * - * @since 2.9.0 - */ -class WP_MatchesMapRegex { - /** - * store for matches - * - * @access private - * @var array - */ - var $_matches; - - /** - * store for mapping result - * - * @access public - * @var string - */ - var $output; - - /** - * subject to perform mapping on (query string containing $matches[] references - * - * @access private - * @var string - */ - var $_subject; - - /** - * regexp pattern to match $matches[] references - * - * @var string - */ - var $_pattern = '(\$matches\[[1-9]+[0-9]*\])'; // magic number - - /** - * constructor - * - * @param string $subject subject if regex - * @param array $matches data to use in map - * @return self - */ - function WP_MatchesMapRegex($subject, $matches) { - $this->_subject = $subject; - $this->_matches = $matches; - $this->output = $this->_map(); - } - - /** - * Substitute substring matches in subject. - * - * static helper function to ease use - * - * @access public - * @param string $subject subject - * @param array $matches data used for subsitution - * @return string - */ - function apply($subject, $matches) { - $oSelf =& new WP_MatchesMapRegex($subject, $matches); - return $oSelf->output; - } - - /** - * do the actual mapping - * - * @access private - * @return string - */ - function _map() { - $callback = array(&$this, 'callback'); - return preg_replace_callback($this->_pattern, $callback, $this->_subject); - } - - /** - * preg_replace_callback hook - * - * @access public - * @param array $matches preg_replace regexp matches - * @return string - */ - function callback($matches) { - $index = intval(substr($matches[0], 9, -1)); - return ( isset( $this->_matches[$index] ) ? urlencode($this->_matches[$index]) : '' ); - } - -} - -?> diff --git a/wp-includes/comment-template.php b/wp-includes/comment-template.php index d3ee1906..d00c6599 100644 --- a/wp-includes/comment-template.php +++ b/wp-includes/comment-template.php @@ -162,7 +162,7 @@ function get_comment_author_link( $comment_ID = 0 ) { * @since 0.71 * @see get_comment_author_link() Echoes result * - * @param int The ID of the comment for which to print the author's link. Optional. + * @param int $comment_ID The ID of the comment for which to print the author's link. Optional. */ function comment_author_link( $comment_ID = 0 ) { echo get_comment_author_link( $comment_ID ); @@ -545,11 +545,10 @@ function comments_link( $deprecated = '', $deprecated_2 = '' ) { * @return int The number of comments a post has */ function get_comments_number( $post_id = 0 ) { - global $id; - $post_id = (int) $post_id; + $post_id = absint( $post_id ); if ( !$post_id ) - $post_id = (int) $id; + $post_id = get_the_ID(); $post = get_post($post_id); if ( ! isset($post->comment_count) ) @@ -564,7 +563,6 @@ function get_comments_number( $post_id = 0 ) { * Display the language string for the number of comments the current post has. * * @since 0.71 - * @uses $id * @uses apply_filters() Calls the 'comments_number' hook on the output and number of comments respectively. * * @param string $zero Text for no comments @@ -573,12 +571,10 @@ function get_comments_number( $post_id = 0 ) { * @param string $deprecated Not used. */ function comments_number( $zero = false, $one = false, $more = false, $deprecated = '' ) { - global $id; - if ( !empty( $deprecated ) ) _deprecated_argument( __FUNCTION__, '1.3' ); - $number = get_comments_number($id); + $number = get_comments_number(); if ( $number > 1 ) $output = str_replace('%', number_format_i18n($number), ( false === $more ) ? __('% Comments') : $more); @@ -601,7 +597,7 @@ function comments_number( $zero = false, $one = false, $more = false, $deprecate */ function get_comment_text( $comment_ID = 0 ) { $comment = get_comment( $comment_ID ); - return apply_filters('get_comment_text', $comment->comment_content); + return apply_filters( 'get_comment_text', $comment->comment_content, $comment ); } /** @@ -614,7 +610,8 @@ function get_comment_text( $comment_ID = 0 ) { * @param int $comment_ID The ID of the comment for which to print the text. Optional. */ function comment_text( $comment_ID = 0 ) { - echo apply_filters('comment_text', get_comment_text() ); + $comment = get_comment( $comment_ID ); + echo apply_filters( 'comment_text', get_comment_text( $comment_ID ), $comment ); } /** @@ -678,9 +675,9 @@ function get_comment_type( $comment_ID = 0 ) { * @param string $pingbacktxt The string to display for pingback type */ function comment_type($commenttxt = false, $trackbacktxt = false, $pingbacktxt = false) { - if ( false === $commenttxt ) $commenttxt = _x( 'Comment', 'noun' ); - if ( false === $trackbacktxt ) $trackbacktxt = __( 'Trackback' ); - if ( false === $pingbacktxt ) $pingbacktxt = __( 'Pingback' ); + if ( false === $commenttxt ) $commenttxt = _x( 'Comment', 'noun' ); + if ( false === $trackbacktxt ) $trackbacktxt = __( 'Trackback' ); + if ( false === $pingbacktxt ) $pingbacktxt = __( 'Pingback' ); $type = get_comment_type(); switch( $type ) { case 'trackback' : @@ -703,16 +700,14 @@ function comment_type($commenttxt = false, $trackbacktxt = false, $pingbacktxt = * * @since 1.5.0 * @uses apply_filters() Calls 'trackback_url' on the resulting trackback URL - * @uses $id * * @return string The trackback URL after being filtered */ function get_trackback_url() { - global $id; if ( '' != get_option('permalink_structure') ) { $tb_url = trailingslashit(get_permalink()) . user_trailingslashit('trackback', 'single_trackback'); } else { - $tb_url = get_option('siteurl') . '/wp-trackback.php?p=' . $id; + $tb_url = get_option('siteurl') . '/wp-trackback.php?p=' . get_the_ID(); } return apply_filters('trackback_url', $tb_url); } @@ -748,6 +743,9 @@ function trackback_rdf( $deprecated = '' ) { if ( !empty( $deprecated ) ) _deprecated_argument( __FUNCTION__, '2.5' ); + if ( false !== stripos($_SERVER['HTTP_USER_AGENT'], 'W3C_Validator') ) + return; + echo ' @@ -841,7 +839,6 @@ function wp_comment_form_unfiltered_html_nonce() { * @since 1.5.0 * @global array $comment List of comment objects for the current post * @uses $wpdb - * @uses $id * @uses $post * @uses $withcomments Will not try to get the comments if the post has none. * @@ -958,7 +955,6 @@ function comments_popup_script($width=400, $height=400, $file='') { * lists of posts * * @since 0.71 - * @uses $id * @uses $wpcommentspopupfile * @uses $wpcommentsjavascript * @uses $post @@ -971,12 +967,14 @@ function comments_popup_script($width=400, $height=400, $file='') { * @return null Returns null on single posts and pages. */ function comments_popup_link( $zero = false, $one = false, $more = false, $css_class = '', $none = false ) { - global $id, $wpcommentspopupfile, $wpcommentsjavascript; + global $wpcommentspopupfile, $wpcommentsjavascript; + + $id = get_the_ID(); - if ( false === $zero ) $zero = __( 'No Comments' ); - if ( false === $one ) $one = __( '1 Comment' ); - if ( false === $more ) $more = __( '% Comments' ); - if ( false === $none ) $none = __( 'Comments Off' ); + if ( false === $zero ) $zero = __( 'No Comments' ); + if ( false === $one ) $one = __( '1 Comment' ); + if ( false === $more ) $more = __( '% Comments' ); + if ( false === $none ) $none = __( 'Comments Off' ); $number = get_comments_number( $id ); @@ -1061,7 +1059,7 @@ function get_comment_reply_link($args = array(), $comment = null, $post = null) if ( get_option('comment_registration') && !$user_ID ) $link = ''; else - $link = "comment_ID ) ) . "#" . $respond_id . "' onclick='return addComment.moveForm(\"$add_below-$comment->comment_ID\", \"$comment->comment_ID\", \"$respond_id\", \"$post->ID\")'>$reply_text"; + $link = "comment_ID ) ) . "#" . $respond_id . "' onclick='return addComment.moveForm(\"$add_below-$comment->comment_ID\", \"$comment->comment_ID\", \"$respond_id\", \"$post->ID\")'>$reply_text"; return apply_filters('comment_reply_link', $before . $link . $after, $args, $comment, $post); } @@ -1165,7 +1163,7 @@ function cancel_comment_reply_link($text = '') { * @return string Hidden input HTML for replying to comments */ function get_comment_id_fields() { - global $id; + $id = get_the_ID(); $replytoid = isset($_GET['replytocom']) ? (int) $_GET['replytocom'] : 0; $result = "\n"; @@ -1214,26 +1212,26 @@ function comment_form_title( $noreplytext = false, $replytext = false, $linktopa * * @package WordPress * @uses Walker - * @since unknown + * @since 2.7.0 */ class Walker_Comment extends Walker { /** * @see Walker::$tree_type - * @since unknown + * @since 2.7.0 * @var string */ var $tree_type = 'comment'; /** * @see Walker::$db_fields - * @since unknown + * @since 2.7.0 * @var array */ var $db_fields = array ('parent' => 'comment_parent', 'id' => 'comment_ID'); /** * @see Walker::start_lvl() - * @since unknown + * @since 2.7.0 * * @param string $output Passed by reference. Used to append additional content. * @param int $depth Depth of comment. @@ -1257,7 +1255,7 @@ class Walker_Comment extends Walker { /** * @see Walker::end_lvl() - * @since unknown + * @since 2.7.0 * * @param string $output Passed by reference. Used to append additional content. * @param int $depth Depth of comment. @@ -1320,7 +1318,7 @@ class Walker_Comment extends Walker { /** * @see Walker::start_el() - * @since unknown + * @since 2.7.0 * * @param string $output Passed by reference. Used to append additional content. * @param object $comment Comment data object. @@ -1356,7 +1354,7 @@ class Walker_Comment extends Walker { %s says:'), get_comment_author_link()) ?> comment_approved == '0') : ?> - +
        @@ -1380,7 +1378,7 @@ class Walker_Comment extends Walker { /** * @see Walker::end_el() - * @since unknown + * @since 2.7.0 * * @param string $output Passed by reference. Used to append additional content. * @param object $comment diff --git a/wp-includes/comment.php b/wp-includes/comment.php index 517cb9a7..c0c17566 100644 --- a/wp-includes/comment.php +++ b/wp-includes/comment.php @@ -44,9 +44,11 @@ function check_comment($author, $email, $url, $comment, $user_ip, $user_agent, $ if ( 1 == get_option('comment_moderation') ) return false; // If moderation is set to manual + $comment = apply_filters( 'comment_text', $comment ); + // Check # of external links if ( $max_links = get_option( 'comment_max_links' ) ) { - $num_links = preg_match_all( '/]*href/i', apply_filters( 'comment_text', $comment ), $out ); + $num_links = preg_match_all( '/]*href/i', $comment, $out ); $num_links = apply_filters( 'comment_max_links_url', $num_links, $url ); // provide for counting of $url as a link if ( $num_links >= $max_links ) return false; @@ -178,116 +180,182 @@ function &get_comment(&$comment, $output = OBJECT) { * @return array List of comments. */ function get_comments( $args = '' ) { - global $wpdb; + $query = new WP_Comment_Query; + return $query->query( $args ); +} - $defaults = array( - 'author_email' => '', - 'ID' => '', - 'karma' => '', - 'number' => '', - 'offset' => '', - 'orderby' => '', - 'order' => 'DESC', - 'parent' => '', - 'post_ID' => '', - 'post_id' => 0, - 'status' => '', - 'type' => '', - 'user_id' => '', - ); +/** + * WordPress Comment Query class. + * + * @since 3.1.0 + */ +class WP_Comment_Query { + + /** + * Execute the query + * + * @since 3.1.0 + * + * @param string|array $query_vars + * @return int|array + */ + function query( $query_vars ) { + global $wpdb; + + $defaults = array( + 'author_email' => '', + 'ID' => '', + 'karma' => '', + 'number' => '', + 'offset' => '', + 'orderby' => '', + 'order' => 'DESC', + 'parent' => '', + 'post_ID' => '', + 'post_id' => 0, + 'status' => '', + 'type' => '', + 'user_id' => '', + 'search' => '', + 'count' => false + ); - $args = wp_parse_args( $args, $defaults ); - extract( $args, EXTR_SKIP ); - - // $args can be whatever, only use the args defined in defaults to compute the key - $key = md5( serialize( compact(array_keys($defaults)) ) ); - $last_changed = wp_cache_get('last_changed', 'comment'); - if ( !$last_changed ) { - $last_changed = time(); - wp_cache_set('last_changed', $last_changed, 'comment'); - } - $cache_key = "get_comments:$key:$last_changed"; + $this->query_vars = wp_parse_args( $query_vars, $defaults ); + do_action_ref_array( 'pre_get_comments', array( &$this ) ); + extract( $this->query_vars, EXTR_SKIP ); - if ( $cache = wp_cache_get( $cache_key, 'comment' ) ) { - return $cache; - } + // $args can be whatever, only use the args defined in defaults to compute the key + $key = md5( serialize( compact(array_keys($defaults)) ) ); + $last_changed = wp_cache_get('last_changed', 'comment'); + if ( !$last_changed ) { + $last_changed = time(); + wp_cache_set('last_changed', $last_changed, 'comment'); + } + $cache_key = "get_comments:$key:$last_changed"; - $post_id = absint($post_id); + if ( $cache = wp_cache_get( $cache_key, 'comment' ) ) { + return $cache; + } - if ( 'hold' == $status ) - $approved = "comment_approved = '0'"; - elseif ( 'approve' == $status ) - $approved = "comment_approved = '1'"; - elseif ( 'spam' == $status ) - $approved = "comment_approved = 'spam'"; - elseif ( 'trash' == $status ) - $approved = "comment_approved = 'trash'"; - else - $approved = "( comment_approved = '0' OR comment_approved = '1' )"; - - $order = ( 'ASC' == $order ) ? 'ASC' : 'DESC'; - - if ( ! empty( $orderby ) ) { - $ordersby = is_array($orderby) ? $orderby : preg_split('/[,\s]/', $orderby); - $ordersby = array_intersect( - $ordersby, - array( - 'comment_agent', - 'comment_approved', - 'comment_author', - 'comment_author_email', - 'comment_author_IP', - 'comment_author_url', - 'comment_content', - 'comment_date', - 'comment_date_gmt', - 'comment_ID', - 'comment_karma', - 'comment_parent', - 'comment_post_ID', - 'comment_type', - 'user_id', - ) - ); - $orderby = empty( $ordersby ) ? 'comment_date_gmt' : implode(', ', $ordersby); - } else { - $orderby = 'comment_date_gmt'; - } + $post_id = absint($post_id); + + if ( 'hold' == $status ) + $approved = "comment_approved = '0'"; + elseif ( 'approve' == $status ) + $approved = "comment_approved = '1'"; + elseif ( 'spam' == $status ) + $approved = "comment_approved = 'spam'"; + elseif ( 'trash' == $status ) + $approved = "comment_approved = 'trash'"; + else + $approved = "( comment_approved = '0' OR comment_approved = '1' )"; + + $order = ( 'ASC' == strtoupper($order) ) ? 'ASC' : 'DESC'; + + if ( ! empty( $orderby ) ) { + $ordersby = is_array($orderby) ? $orderby : preg_split('/[,\s]/', $orderby); + $ordersby = array_intersect( + $ordersby, + array( + 'comment_agent', + 'comment_approved', + 'comment_author', + 'comment_author_email', + 'comment_author_IP', + 'comment_author_url', + 'comment_content', + 'comment_date', + 'comment_date_gmt', + 'comment_ID', + 'comment_karma', + 'comment_parent', + 'comment_post_ID', + 'comment_type', + 'user_id', + ) + ); + $orderby = empty( $ordersby ) ? 'comment_date_gmt' : implode(', ', $ordersby); + } else { + $orderby = 'comment_date_gmt'; + } - $number = absint($number); - $offset = absint($offset); + $number = absint($number); + $offset = absint($offset); - if ( !empty($number) ) { - if ( $offset ) - $number = 'LIMIT ' . $offset . ',' . $number; + if ( !empty($number) ) { + if ( $offset ) + $limits = 'LIMIT ' . $offset . ',' . $number; + else + $limits = 'LIMIT ' . $number; + } else { + $limits = ''; + } + + if ( $count ) + $fields = 'COUNT(*)'; else - $number = 'LIMIT ' . $number; + $fields = '*'; + + $join = ''; + $where = $approved; + + if ( ! empty($post_id) ) + $where .= $wpdb->prepare( ' AND comment_post_ID = %d', $post_id ); + if ( '' !== $author_email ) + $where .= $wpdb->prepare( ' AND comment_author_email = %s', $author_email ); + if ( '' !== $karma ) + $where .= $wpdb->prepare( ' AND comment_karma = %d', $karma ); + if ( 'comment' == $type ) { + $where .= " AND comment_type = ''"; + } elseif( 'pings' == $type ) { + $where .= ' AND comment_type IN ("pingback", "trackback")'; + } elseif ( ! empty( $type ) ) { + $where .= $wpdb->prepare( ' AND comment_type = %s', $type ); + } + if ( '' !== $parent ) + $where .= $wpdb->prepare( ' AND comment_parent = %d', $parent ); + if ( '' !== $user_id ) + $where .= $wpdb->prepare( ' AND user_id = %d', $user_id ); + if ( '' !== $search ) + $where .= $this->get_search_sql( $search, array( 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_author_IP', 'comment_content' ) ); - } else { - $number = ''; + $pieces = array( 'fields', 'join', 'where', 'orderby', 'order', 'limits' ); + $clauses = apply_filters_ref_array( 'comments_clauses', array( compact( $pieces ), &$this ) ); + foreach ( $pieces as $piece ) + $$piece = isset( $clauses[ $piece ] ) ? $clauses[ $piece ] : ''; + + $query = "SELECT $fields FROM $wpdb->comments $join WHERE $where ORDER BY $orderby $order $limits"; + + if ( $count ) + return $wpdb->get_var( $query ); + + $comments = $wpdb->get_results( $query ); + $comments = apply_filters_ref_array( 'the_comments', array( $comments, &$this ) ); + + wp_cache_add( $cache_key, $comments, 'comment' ); + + return $comments; } - $post_where = ''; - - if ( ! empty($post_id) ) - $post_where .= $wpdb->prepare( 'comment_post_ID = %d AND ', $post_id ); - if ( '' !== $author_email ) - $post_where .= $wpdb->prepare( 'comment_author_email = %s AND ', $author_email ); - if ( '' !== $karma ) - $post_where .= $wpdb->prepare( 'comment_karma = %d AND ', $karma ); - if ( 'comment' == $type ) - $post_where .= "comment_type = '' AND "; - elseif ( ! empty( $type ) ) - $post_where .= $wpdb->prepare( 'comment_type = %s AND ', $type ); - if ( '' !== $parent ) - $post_where .= $wpdb->prepare( 'comment_parent = %d AND ', $parent ); - if ( '' !== $user_id ) - $post_where .= $wpdb->prepare( 'user_id = %d AND ', $user_id ); - - $comments = $wpdb->get_results( "SELECT * FROM $wpdb->comments WHERE $post_where $approved ORDER BY $orderby $order $number" ); - wp_cache_add( $cache_key, $comments, 'comment' ); - - return $comments; + /* + * Used internally to generate an SQL string for searching across multiple columns + * + * @access protected + * @since 3.1.0 + * + * @param string $string + * @param array $cols + * @return string + */ + function get_search_sql( $string, $cols ) { + $string = esc_sql( like_escape( $string ) ); + + $searches = array(); + foreach ( $cols as $col ) + $searches[] = "$col LIKE '%$string%'"; + + return ' AND (' . implode(' OR ', $searches) . ')'; + } } /** @@ -422,8 +490,8 @@ function get_comment_count( $post_id = 0 ) { * @link http://codex.wordpress.org/Function_Reference/add_comment_meta * * @param int $comment_id Comment ID. - * @param string $key Metadata name. - * @param mixed $value Metadata value. + * @param string $meta_key Metadata name. + * @param mixed $meta_value Metadata value. * @param bool $unique Optional, default is false. Whether the same key should not be added. * @return bool False for failure. True for success. */ @@ -481,8 +549,8 @@ function get_comment_meta($comment_id, $key, $single = false) { * @link http://codex.wordpress.org/Function_Reference/update_comment_meta * * @param int $comment_id Comment ID. - * @param string $key Metadata key. - * @param mixed $value Metadata value. + * @param string $meta_key Metadata key. + * @param mixed $meta_value Metadata value. * @param mixed $prev_value Optional. Previous value to check before removing. * @return bool False on failure, true if success. */ @@ -571,7 +639,7 @@ function wp_allow_comment($commentdata) { $approved = 'spam'; } - $approved = apply_filters('pre_comment_approved', $approved); + $approved = apply_filters( 'pre_comment_approved', $approved, $commentdata ); return $approved; } @@ -1086,9 +1154,9 @@ function wp_transition_comment_status($new_status, $old_status, $comment) { // Call the hooks if ( $new_status != $old_status ) { do_action('transition_comment_status', $new_status, $old_status, $comment); - do_action("comment_${old_status}_to_$new_status", $comment); + do_action("comment_{$old_status}_to_{$new_status}", $comment); } - do_action("comment_${new_status}_$comment->comment_type", $comment->comment_ID, $comment); + do_action("comment_{$new_status}_{$comment->comment_type}", $comment->comment_ID, $comment); } /** @@ -1118,7 +1186,7 @@ function wp_get_current_commenter() { if ( isset($_COOKIE['comment_author_url_'.COOKIEHASH]) ) $comment_author_url = $_COOKIE['comment_author_url_'.COOKIEHASH]; - return compact('comment_author', 'comment_author_email', 'comment_author_url'); + return apply_filters('wp_get_current_commenter', compact('comment_author', 'comment_author_email', 'comment_author_url')); } /** @@ -1228,6 +1296,10 @@ function wp_throttle_comment_flood($block, $time_lastcomment, $time_newcomment) * and whether comment is approved by WordPress. Also has 'preprocess_comment' * filter for processing the comment data before the function handles it. * + * We use REMOTE_ADDR here directly. If you are behind a proxy, you should ensure + * that it is properly set, such as in wp-config.php, for your environment. + * See {@link http://core.trac.wordpress.org/ticket/9235} + * * @since 1.5.0 * @uses apply_filters() Calls 'preprocess_comment' hook on $commentdata parameter array before processing * @uses do_action() Calls 'comment_post' hook on $comment_ID returned from adding the comment and if the comment was approved. @@ -1272,7 +1344,7 @@ function wp_new_comment( $commentdata ) { $post = &get_post($commentdata['comment_post_ID']); // Don't notify if it's your own comment if ( get_option('comments_notify') && $commentdata['comment_approved'] && ( ! isset( $commentdata['user_id'] ) || $post->post_author != $commentdata['user_id'] ) ) - wp_notify_postauthor($comment_ID, empty( $commentdata['comment_type'] ) ? $commentdata['comment_type'] : '' ); + wp_notify_postauthor($comment_ID, isset( $commentdata['comment_type'] ) ? $commentdata['comment_type'] : '' ); } return $comment_ID; @@ -1684,6 +1756,7 @@ function generic_ping($post_id = 0) { function pingback($content, $post_ID) { global $wp_version; include_once(ABSPATH . WPINC . '/class-IXR.php'); + include_once(ABSPATH . WPINC . '/class-wp-http-ixr-client.php'); // original code by Mort (http://mort.mine.nu:8080) $post_links = array(); @@ -1717,7 +1790,7 @@ function pingback($content, $post_ID) { if ( $test = @parse_url($link_test) ) { if ( isset($test['query']) ) $post_links[] = $link_test; - elseif ( ($test['path'] != '/') && ($test['path'] != '') ) + elseif ( isset( $test['path'] ) && ( $test['path'] != '/' ) && ( $test['path'] != '' ) ) $post_links[] = $link_test; } endif; @@ -1726,7 +1799,7 @@ function pingback($content, $post_ID) { do_action_ref_array('pre_ping', array(&$post_links, &$pung)); foreach ( (array) $post_links as $pagelinkedto ) { - $pingback_server_url = discover_pingback_server_uri($pagelinkedto, 2048); + $pingback_server_url = discover_pingback_server_uri( $pagelinkedto ); if ( $pingback_server_url ) { @ set_time_limit( 60 ); @@ -1734,7 +1807,7 @@ function pingback($content, $post_ID) { $pagelinkedfrom = get_permalink($post_ID); // using a timeout of 3 seconds should be enough to cover slow servers - $client = new IXR_Client($pingback_server_url); + $client = new WP_HTTP_IXR_Client($pingback_server_url); $client->timeout = 3; $client->useragent = apply_filters( 'pingback_useragent', $client->useragent . ' -- WordPress/' . $wp_version, $client->useragent, $pingback_server_url, $pagelinkedto, $pagelinkedfrom); // when set to true, this outputs debug messages by itself @@ -1795,9 +1868,8 @@ function trackback($trackback_url, $title, $excerpt, $ID) { if ( is_wp_error( $response ) ) return; - $tb_url = addslashes( $trackback_url ); - $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET pinged = CONCAT(pinged, '\n', '$tb_url') WHERE ID = %d", $ID) ); - return $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET to_ping = TRIM(REPLACE(to_ping, '$tb_url', '')) WHERE ID = %d", $ID) ); + $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET pinged = CONCAT(pinged, '\n', %s) WHERE ID = %d", $trackback_url, $ID) ); + return $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET to_ping = TRIM(REPLACE(to_ping, %s, '')) WHERE ID = %d", $trackback_url, $ID) ); } /** @@ -1813,9 +1885,10 @@ function trackback($trackback_url, $title, $excerpt, $ID) { function weblog_ping($server = '', $path = '') { global $wp_version; include_once(ABSPATH . WPINC . '/class-IXR.php'); + include_once(ABSPATH . WPINC . '/class-wp-http-ixr-client.php'); // using a timeout of 3 seconds should be enough to cover slow servers - $client = new IXR_Client($server, ((!strlen(trim($path)) || ('/' == $path)) ? false : $path)); + $client = new WP_HTTP_IXR_Client($server, ((!strlen(trim($path)) || ('/' == $path)) ? false : $path)); $client->timeout = 3; $client->useragent .= ' -- WordPress/'.$wp_version; @@ -1837,11 +1910,13 @@ function weblog_ping($server = '', $path = '') { * @package WordPress * @subpackage Cache * - * @param int|array $id Comment ID or array of comment IDs to remove from cache + * @param int|array $ids Comment ID or array of comment IDs to remove from cache */ function clean_comment_cache($ids) { foreach ( (array) $ids as $id ) wp_cache_delete($id, 'comment'); + + wp_cache_set('last_changed', time(), 'comment'); } /** diff --git a/wp-includes/cron.php b/wp-includes/cron.php index 921f8c86..b7d04f2a 100644 --- a/wp-includes/cron.php +++ b/wp-includes/cron.php @@ -26,8 +26,16 @@ function wp_schedule_single_event( $timestamp, $hook, $args = array()) { return; $crons = _get_cron_array(); - $key = md5(serialize($args)); - $crons[$timestamp][$hook][$key] = array( 'schedule' => false, 'args' => $args ); + $event = (object) array( 'hook' => $hook, 'timestamp' => $timestamp, 'schedule' => false, 'args' => $args ); + $event = apply_filters('schedule_event', $event); + + // A plugin disallowed this event + if ( ! $event ) + return false; + + $key = md5(serialize($event->args)); + + $crons[$event->timestamp][$event->hook][$key] = array( 'schedule' => $event->schedule, 'args' => $event->args ); uksort( $crons, "strnatcasecmp" ); _set_cron_array( $crons ); } @@ -42,6 +50,8 @@ function wp_schedule_single_event( $timestamp, $hook, $args = array()) { * Valid values for the recurrence are hourly, daily and twicedaily. These can * be extended using the cron_schedules filter in wp_get_schedules(). * + * Use wp_next_scheduled() to prevent duplicates + * * @since 2.1.0 * * @param int $timestamp Timestamp for when to run the event. @@ -53,10 +63,20 @@ function wp_schedule_single_event( $timestamp, $hook, $args = array()) { function wp_schedule_event( $timestamp, $recurrence, $hook, $args = array()) { $crons = _get_cron_array(); $schedules = wp_get_schedules(); - $key = md5(serialize($args)); + if ( !isset( $schedules[$recurrence] ) ) return false; - $crons[$timestamp][$hook][$key] = array( 'schedule' => $recurrence, 'args' => $args, 'interval' => $schedules[$recurrence]['interval'] ); + + $event = (object) array( 'hook' => $hook, 'timestamp' => $timestamp, 'schedule' => $recurrence, 'args' => $args, 'interval' => $schedules[$recurrence]['interval'] ); + $event = apply_filters('schedule_event', $event); + + // A plugin disallowed this event + if ( ! $event ) + return false; + + $key = md5(serialize($event->args)); + + $crons[$event->timestamp][$event->hook][$key] = array( 'schedule' => $event->schedule, 'args' => $event->args, 'interval' => $event->interval ); uksort( $crons, "strnatcasecmp" ); _set_cron_array( $crons ); } @@ -90,10 +110,10 @@ function wp_reschedule_event( $timestamp, $recurrence, $hook, $args = array()) { $now = time(); - if ( $timestamp >= $now ) - $timestamp = $now + $interval; - else - $timestamp = $now + ($interval - (($now - $timestamp) % $interval)); + if ( $timestamp >= $now ) + $timestamp = $now + $interval; + else + $timestamp = $now + ($interval - (($now - $timestamp) % $interval)); wp_schedule_event( $timestamp, $recurrence, $hook, $args ); } @@ -136,7 +156,7 @@ function wp_clear_scheduled_hook( $hook, $args = array() ) { // Backward compatibility // Previously this function took the arguments as discrete vars rather than an array like the rest of the API if ( !is_array($args) ) { - _deprecated_argument( __FUNCTION__, '3.0.0', __('This argument has changed to an array to match the behavior of the other cron functions.') ); + _deprecated_argument( __FUNCTION__, '3.0', __('This argument has changed to an array to match the behavior of the other cron functions.') ); $args = array_slice( func_get_args(), 1 ); } @@ -180,14 +200,6 @@ function spawn_cron( $local_time = 0 ) { if ( defined('DOING_CRON') || isset($_GET['doing_wp_cron']) ) return; - /* - * do not even start the cron if local server timer has drifted - * such as due to power failure, or misconfiguration - */ - $timer_accurate = check_server_timer( $local_time ); - if ( !$timer_accurate ) - return; - /* * multiple processes on multiple web servers can run this code concurrently * try to make this as atomic as possible by setting doing_cron switch @@ -393,8 +405,3 @@ function _upgrade_cron_array($cron) { update_option( 'cron', $new_cron ); return $new_cron; } - -// stub for checking server timer accuracy, using outside standard time sources -function check_server_timer( $local_time ) { - return true; -} diff --git a/wp-includes/css/admin-bar-rtl.css b/wp-includes/css/admin-bar-rtl.css new file mode 100644 index 00000000..5684c095 --- /dev/null +++ b/wp-includes/css/admin-bar-rtl.css @@ -0,0 +1 @@ +#wpadminbar{direction:rtl;font-family:Tahoma,Arial,sans-serif;right:0;left:auto;}#wpadminbar .quicklinks ul{text-align:right;}#wpadminbar .quicklinks ul li{float:right;}#wpadminbar .quicklinks>ul>li>a{border-left:1px solid #686868;border-right:1px solid #808080;}#wpadminbar .quicklinks>ul>li:last-child>a{border-left:none;border-right:1px solid #808080;}#wpadminbar .quicklinks>ul>li:hover>a{border-right-color:#707070;border-left-color:#686868;}#wpadminbar .quicklinks li#wp-admin-bar-my-account-with-avatar a img{margin:-2px -5px 0 23px;}#wpadminbar .quicklinks li#wp-admin-bar-my-account-with-avatar ul{left:auto;right:30px;}#wpadminbar .quicklinks .menupop li:hover>ul,#wpadminbar .quicklinks .menupop li.hover>ul{margin-right:100%;margin-left:0;}#wpadminbar .quicklinks .menupop a>span{background:url(../images/admin-bar-sprite-rtl.png?d=11122010) left -58px no-repeat;padding-right:0;padding-left:.8em;}#wpadminbar .quicklinks .menupop ul li a>span{background:url(../images/admin-bar-sprite-rtl.png?d=11122010) left -29px no-repeat;padding-right:0;padding-left:1.5em;}#wpadminbar .quicklinks a{font-family:Tahoma,Arial,Helvetica,sans-serif;}#wpadminbar .quicklinks .menupop li a img.blavatar{margin-right:0;margin-left:8px;}#wpadminbar .quicklinks li#wp-admin-bar-my-account-with-avatar>a{background:url(../images/admin-bar-sprite-rtl.png?d=11122010) top right no-repeat;}#wpadminbar .quicklinks li#wp-admin-bar-my-account>a,#wpadminbar .quicklinks li#wp-admin-bar-my-account-with-avatar>a{border-right:none;border-left:1px solid #686868;}#wpadminbar #adminbarsearch{float:left;}#wpadminbar #adminbarsearch .adminbar-input{float:right;font-family:Tahoma,Arial,Helvetica,sans-serif;margin-right:0;margin-left:3px;-moz-box-shadow:inset 2px -2px 1px #cdcdcd;-webkit-box-shadow:inset -2px 2px 1px #cdcdcd;box-shadow:inset 2px -2px 1px #cdcdcd;}#wpadminbar #adminbarsearch .adminbar-button{float:right;font-family:Tahoma,Arial,Helvetica,sans-serif;} \ No newline at end of file diff --git a/wp-includes/css/admin-bar-rtl.dev.css b/wp-includes/css/admin-bar-rtl.dev.css new file mode 100644 index 00000000..acfe0452 --- /dev/null +++ b/wp-includes/css/admin-bar-rtl.dev.css @@ -0,0 +1,94 @@ +#wpadminbar { + direction: rtl; + font-family: Tahoma, Arial ,sans-serif; + right: 0; + left: auto; +} + +#wpadminbar .quicklinks ul { + text-align: right; +} + +#wpadminbar .quicklinks ul li { + float: right; +} + +#wpadminbar .quicklinks > ul > li > a { + border-left: 1px solid #686868; + border-right: 1px solid #808080; +} + +#wpadminbar .quicklinks > ul > li:last-child > a { + border-left: none; + border-right: 1px solid #808080; +} + +#wpadminbar .quicklinks > ul > li:hover > a { + border-right-color: #707070; + border-left-color: #686868; +} + +#wpadminbar .quicklinks li#wp-admin-bar-my-account-with-avatar a img { + margin: -2px -5px 0 23px; +} + +#wpadminbar .quicklinks li#wp-admin-bar-my-account-with-avatar ul { + left: auto; + right: 30px; +} + +#wpadminbar .quicklinks .menupop li:hover > ul, +#wpadminbar .quicklinks .menupop li.hover > ul { + margin-right: 100%; + margin-left: 0; +} + +#wpadminbar .quicklinks .menupop a > span { + background: url(../images/admin-bar-sprite-rtl.png?d=11122010) left -58px no-repeat; + padding-right: 0; + padding-left: .8em; +} + +#wpadminbar .quicklinks .menupop ul li a > span { + background: url(../images/admin-bar-sprite-rtl.png?d=11122010) left -29px no-repeat; + padding-right: 0; + padding-left: 1.5em; +} + +#wpadminbar .quicklinks a { + font-family: Tahoma, Arial, Helvetica, sans-serif; +} + +#wpadminbar .quicklinks .menupop li a img.blavatar { + margin-right: 0; + margin-left: 8px; +} + +#wpadminbar .quicklinks li#wp-admin-bar-my-account-with-avatar > a { + background: url(../images/admin-bar-sprite-rtl.png?d=11122010) top right no-repeat; +} + +#wpadminbar .quicklinks li#wp-admin-bar-my-account > a, +#wpadminbar .quicklinks li#wp-admin-bar-my-account-with-avatar > a { + border-right: none; + border-left: 1px solid #686868; +} + +#wpadminbar #adminbarsearch { + float: left; +} + +#wpadminbar #adminbarsearch .adminbar-input { + float: right; + font-family: Tahoma, Arial, Helvetica, sans-serif; + margin-right: 0; + margin-left: 3px; + -moz-box-shadow: inset 2px -2px 1px #cdcdcd; + -webkit-box-shadow: inset -2px 2px 1px #cdcdcd; + box-shadow: inset 2px -2px 1px #cdcdcd; +} + +#wpadminbar #adminbarsearch .adminbar-button { + float: right; + font-family: Tahoma, Arial, Helvetica, sans-serif; +} diff --git a/wp-includes/css/admin-bar.css b/wp-includes/css/admin-bar.css new file mode 100644 index 00000000..2de4f4d9 --- /dev/null +++ b/wp-includes/css/admin-bar.css @@ -0,0 +1 @@ +#wpadminbar *{height:auto;width:auto;margin:0;padding:0;position:static;text-transform:none;letter-spacing:normal;line-height:1;}#wpadminbar :before,#wpadminbar :after{content:normal;}#wpadminbar a,#wpadminbar a:hover,#wpadminbar a img,#wpadminbar a img:hover{outline:none;border:none;text-decoration:none;background:none;}#wpadminbar{direction:ltr;background-color:#777;background-image:-moz-linear-gradient(bottom,#666,#7f7f7f);background-image:-webkit-gradient(linear,left bottom,left top,from(#666),to(#7f7f7f));color:#ddd;font:normal 12px/28px Arial,Helvetica,sans-serif;height:28px;position:fixed;top:0;left:0;width:100%;z-index:99999;min-width:960px;}#wpadminbar ul,#wpadminbar ul li{background:none;list-style:none;margin:0;padding:0;position:relative;z-index:99999;}#wpadminbar .quicklinks ul{text-align:left;}#wpadminbar .quicklinks ul li{float:left;}#wpadminbar .quicklinks>ul>li>a{border-right:1px solid #686868;border-left:1px solid #808080;}#wpadminbar .quicklinks>ul>li:last-child>a{border-right:none;}#wpadminbar .quicklinks>ul>li:hover>a{border-left-color:#707070;}#wpadminbar .quicklinks a,#wpadminbar .shortlink-input{color:#ddd;height:28px;text-shadow:#555 0 -1px 0;display:block;font:normal 13px/28px Arial,Helvetica,sans-serif;padding:0 .85em;margin:0;}#wpadminbar .quicklinks a>span{line-height:28px;}#wpadminbar .quicklinks .menupop ul,#wpadminbar .shortlink-input{-moz-box-shadow:0 4px 8px rgba(0,0,0,0.1);-webkit-box-shadow:0 4px 8px rgba(0,0,0,0.1);box-shadow:0 4px 8px rgba(0,0,0,0.1);background:#fff;background:rgba(255,255,255,0.97);display:none;position:absolute;border:1px solid #dfdfdf;border-top:none;float:none;}#wpadminbar .selected .shortlink-input{display:block;}#wpadminbar .quicklinks .menupop ul li{float:none;}#wpadminbar .quicklinks .menupop ul li a,#wpadminbar .shortlink-input{color:#555;text-shadow:none;white-space:nowrap;min-width:140px;}#wpadminbar .shortlink-input{width:200px;}#wpadminbar .quicklinks .menupop ul li:hover>a{color:#fff;text-shadow:#666 0 -1px 0;}#wpadminbar .quicklinks li:hover>ul,#wpadminbar .quicklinks li.hover>ul{display:block;}#wpadminbar .quicklinks .menupop li:hover>ul,#wpadminbar .quicklinks .menupop li.hover>ul{margin-left:100%;margin-top:-28px;}#wpadminbar .quicklinks li:hover,#wpadminbar .quicklinks .selected{background:#555;background:-moz-linear-gradient(bottom,#555,#3e3e3e);background:-webkit-gradient(linear,left bottom,left top,from(#555),to(#3e3e3e));}#wpadminbar .quicklinks .menupop li:hover{background:#888;background:-moz-linear-gradient(bottom,#888,#9d9d9d);background:-webkit-gradient(linear,left bottom,left top,from(#888),to(#9d9d9d));}#wpadminbar .quicklinks .menupop a>span{display:inline;background:url(../images/admin-bar-sprite.png?d=11122010) right -58px no-repeat;padding-right:.8em;}#wpadminbar .quicklinks .menupop ul li a>span{display:block;background:url(../images/admin-bar-sprite.png?d=11122010) right -29px no-repeat;padding-right:1.5em;}#wpadminbar .quicklinks a span#ab-awaiting-mod,#wpadminbar .quicklinks a span#ab-updates{background:#eee;color:#333;text-shadow:none;display:inline;padding:2px 5px;font-size:10px;font-weight:bold;-moz-border-radius:10px;-khtml-border-radius:10px;-webkit-border-radius:10px;border-radius:10px;}#wpadminbar .quicklinks a:hover span#ab-awaiting-mod,#wpadminbar .quicklinks a:hover span#ab-updates{background:#fff;color:#000;}#wpadminbar .quicklinks li#wp-admin-bar-my-account>a{border-left:none;}#wpadminbar .quicklinks li#wp-admin-bar-my-account-with-avatar>a{border-left:none;background:url(../images/admin-bar-sprite.png?d=11122010) top left no-repeat;}#wpadminbar .quicklinks li#wp-admin-bar-my-account-with-avatar>a img{display:inline;border:1px solid #999;vertical-align:middle;margin:-2px 23px 0 -5px;padding:0;background:#eee;float:none;}#wpadminbar .quicklinks li#wp-admin-bar-my-account-with-avatar ul{left:30px;}#wpadminbar .quicklinks .menupop li a img.blavatar{vertical-align:middle;margin:0 8px 0 0;padding:0;}#wpadminbar #adminbarsearch{float:right;height:18px;padding:3px;margin:0;}#wpadminbar #adminbarsearch .adminbar-input{width:140px;height:auto;float:left;font:12px Arial,Helvetica,sans-serif;color:#555;text-shadow:0 1px 0 #fff;border:1px solid #626262;padding:2px 3px;margin:0 3px 0 0;background:#ddd;-moz-box-shadow:inset 2px 2px 1px #cdcdcd;-webkit-box-shadow:inset 2px 2px 1px #cdcdcd;box-shadow:inset 2px 2px 1px #cdcdcd;-webkit-border-radius:0;-khtml-border-radius:0;-moz-border-radius:0;border-radius:0;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;-ms-box-sizing:border-box;box-sizing:border-box;outline:none;}#wpadminbar #adminbarsearch .adminbar-button{font:bold 12px Arial,Helvetica,sans-serif;color:#444;text-shadow:0 1px 0 #eee;cursor:pointer;float:left;background:#aaa;background:-moz-linear-gradient(bottom,#aaa,#cecece);background:-webkit-gradient(linear,left bottom,left top,from(#aaa),to(#cecece));-webkit-border-radius:10px;-khtml-border-radius:10px;-moz-border-radius:10px;border-radius:10px;border:1px solid #626262;padding:2px 13px;margin:0;width:auto;height:auto;}#wpadminbar #adminbarsearch .adminbar-button:active{background:#a0a0a0;background:-moz-linear-gradient(bottom,#a0a0a0,#c1c1c1);background:-webkit-gradient(linear,left bottom,left top,from(#a0a0a0),to(#c1c1c1));-moz-box-shadow:inset 1px 1px 1px #9b9b9b;-webkit-box-shadow:inset 1px 1px 1px #9b9b9b;box-shadow:inset 1px 1px 1px #9b9b9b;}#wpadminbar #adminbarsearch .adminbar-button:hover{color:#000;}#wpadminbar #adminbarsearch .adminbar-button::-moz-focus-inner{border:none;}* html #wpadminbar{overflow:hidden;position:absolute;}* html #wpadminbar .quicklinks ul li a{float:left;}* html #wpadminbar .menupop a span{background-image:none;} \ No newline at end of file diff --git a/wp-includes/css/admin-bar.dev.css b/wp-includes/css/admin-bar.dev.css new file mode 100644 index 00000000..865f4d66 --- /dev/null +++ b/wp-includes/css/admin-bar.dev.css @@ -0,0 +1,298 @@ +#wpadminbar * { + height: auto; + width: auto; + margin: 0; + padding: 0; + position: static; + text-transform: none; + letter-spacing: normal; + line-height: 1; +} + +#wpadminbar :before, +#wpadminbar :after { + content: normal; +} + +#wpadminbar a, +#wpadminbar a:hover, +#wpadminbar a img, +#wpadminbar a img:hover { + outline: none; + border: none; + text-decoration: none; + background: none; +} + +#wpadminbar { + direction: ltr; + background-color: #777; + background-image: -moz-linear-gradient(bottom, #666, #7f7f7f); + background-image: -webkit-gradient(linear, left bottom, left top, from(#666), to(#7f7f7f)); + color: #ddd; + font: normal 12px/28px Arial, Helvetica, sans-serif; + height: 28px; + position: fixed; + top: 0; + left: 0; + width: 100%; + z-index: 99999; + min-width: 960px; +} + +#wpadminbar ul, +#wpadminbar ul li { + background: none; + list-style: none; + margin: 0; + padding: 0; + position: relative; + z-index: 99999; +} + +#wpadminbar .quicklinks ul { + text-align: left; +} + +#wpadminbar .quicklinks ul li { + float: left; +} + +#wpadminbar .quicklinks > ul > li > a { + border-right: 1px solid #686868; + border-left: 1px solid #808080; +} + +#wpadminbar .quicklinks > ul > li:last-child > a { + border-right: none; +} + +#wpadminbar .quicklinks > ul > li:hover > a { + border-left-color: #707070; +} + +#wpadminbar .quicklinks a, +#wpadminbar .shortlink-input { + color: #ddd; + height: 28px; + text-shadow: #555 0px -1px 0px; + display: block; + font: normal 13px/28px Arial, Helvetica, sans-serif; + padding: 0 0.85em; + margin: 0; +} + +#wpadminbar .quicklinks a > span { + line-height: 28px; +} + +#wpadminbar .quicklinks .menupop ul, +#wpadminbar .shortlink-input { + -moz-box-shadow: 0 4px 8px rgba(0,0,0,0.1); + -webkit-box-shadow: 0 4px 8px rgba(0,0,0,0.1); + box-shadow: 0 4px 8px rgba(0,0,0,0.1); + background: #fff; + background: rgba(255,255,255,0.97); + display: none; + position: absolute; + border: 1px solid #dfdfdf; + border-top: none; + float: none; +} + +#wpadminbar .selected .shortlink-input { + display: block; +} + +#wpadminbar .quicklinks .menupop ul li { + float: none; +} + +#wpadminbar .quicklinks .menupop ul li a, +#wpadminbar .shortlink-input { + color: #555; + text-shadow: none; + white-space: nowrap; + min-width: 140px; +} + +#wpadminbar .shortlink-input { + width: 200px; +} + +#wpadminbar .quicklinks .menupop ul li:hover > a { + color: #fff; + text-shadow: #666 0px -1px 0px; +} + +#wpadminbar .quicklinks li:hover > ul, +#wpadminbar .quicklinks li.hover > ul { + display: block; +} + +#wpadminbar .quicklinks .menupop li:hover > ul, +#wpadminbar .quicklinks .menupop li.hover > ul { + margin-left: 100%; + margin-top: -28px; +} + +#wpadminbar .quicklinks li:hover, +#wpadminbar .quicklinks .selected { + background: #555; + background: -moz-linear-gradient(bottom, #555, #3e3e3e); + background: -webkit-gradient(linear, left bottom, left top, from(#555), to(#3e3e3e)); +} + +#wpadminbar .quicklinks .menupop li:hover { + background: #888; + background: -moz-linear-gradient(bottom, #888, #9d9d9d); + background: -webkit-gradient(linear, left bottom, left top, from(#888), to(#9d9d9d)); +} + +#wpadminbar .quicklinks .menupop a > span { + display: inline; + background: url(../images/admin-bar-sprite.png?d=11122010) right -58px no-repeat; + padding-right: .8em; +} + +#wpadminbar .quicklinks .menupop ul li a > span { + display: block; + background: url(../images/admin-bar-sprite.png?d=11122010) right -29px no-repeat; + padding-right: 1.5em; +} + +#wpadminbar .quicklinks a span#ab-awaiting-mod, +#wpadminbar .quicklinks a span#ab-updates { + background: #eee; + color: #333; + text-shadow: none; + display: inline; + padding: 2px 5px; + font-size: 10px; + font-weight: bold; + -moz-border-radius: 10px; + -khtml-border-radius: 10px; + -webkit-border-radius: 10px; + border-radius: 10px; +} + +#wpadminbar .quicklinks a:hover span#ab-awaiting-mod, +#wpadminbar .quicklinks a:hover span#ab-updates { + background: #fff; + color: #000; +} + +#wpadminbar .quicklinks li#wp-admin-bar-my-account > a { + border-left: none; +} + +#wpadminbar .quicklinks li#wp-admin-bar-my-account-with-avatar > a { + border-left: none; + background: url(../images/admin-bar-sprite.png?d=11122010) top left no-repeat; +} + +#wpadminbar .quicklinks li#wp-admin-bar-my-account-with-avatar > a img { + display: inline; + border: 1px solid #999; + vertical-align: middle; + margin: -2px 23px 0 -5px; + padding: 0; + background: #eee; + float: none; +} + +#wpadminbar .quicklinks li#wp-admin-bar-my-account-with-avatar ul { + left: 30px; +} + +#wpadminbar .quicklinks .menupop li a img.blavatar { + vertical-align: middle; + margin: 0 8px 0 0; + padding: 0; +} + +#wpadminbar #adminbarsearch { + float: right; + height: 18px; + padding: 3px; + margin: 0; +} + +#wpadminbar #adminbarsearch .adminbar-input { + width: 140px; + height: auto; + float: left; + font: 12px Arial, Helvetica, sans-serif; + color: #555; + text-shadow: 0 1px 0 #fff; + border: 1px solid #626262; + padding: 2px 3px; + margin: 0 3px 0 0; + background: #ddd; + -moz-box-shadow: inset 2px 2px 1px #cdcdcd; + -webkit-box-shadow: inset 2px 2px 1px #cdcdcd; + box-shadow: inset 2px 2px 1px #cdcdcd; + -webkit-border-radius: 0; + -khtml-border-radius: 0; + -moz-border-radius: 0; + border-radius: 0; + -moz-box-sizing: border-box; + -webkit-box-sizing: border-box; + -ms-box-sizing: border-box; + box-sizing: border-box; + outline: none; +} + +#wpadminbar #adminbarsearch .adminbar-button { + font: bold 12px Arial, Helvetica, sans-serif; + color: #444; + text-shadow: 0px 1px 0px #eee; + cursor: pointer; + float: left; + background: #aaa; + background: -moz-linear-gradient(bottom, #aaa, #cecece); + background: -webkit-gradient(linear, left bottom, left top, from(#aaa), to(#cecece)); + -webkit-border-radius: 10px; + -khtml-border-radius: 10px; + -moz-border-radius: 10px; + border-radius: 10px; + border: 1px solid #626262; + padding: 2px 13px; + margin: 0; + width: auto; + height: auto; +} + +#wpadminbar #adminbarsearch .adminbar-button:active { + background: #a0a0a0; + background:-moz-linear-gradient(bottom, #a0a0a0, #c1c1c1); + background:-webkit-gradient(linear, left bottom, left top, from(#a0a0a0), to(#c1c1c1)); + -moz-box-shadow: inset 1px 1px 1px #9b9b9b; + -webkit-box-shadow: inset 1px 1px 1px #9b9b9b; + box-shadow: inset 1px 1px 1px #9b9b9b; +} + +#wpadminbar #adminbarsearch .adminbar-button:hover { + color: #000; +} + +#wpadminbar #adminbarsearch .adminbar-button::-moz-focus-inner { + border: none; +} + + +/** + * IE 6-targeted rules + */ +* html #wpadminbar { + overflow: hidden; + position: absolute; +} + +* html #wpadminbar .quicklinks ul li a { + float: left; +} + +* html #wpadminbar .menupop a span { + background-image: none; +} diff --git a/wp-includes/css/jquery-ui-dialog.css b/wp-includes/css/jquery-ui-dialog.css new file mode 100644 index 00000000..fa51cfbd --- /dev/null +++ b/wp-includes/css/jquery-ui-dialog.css @@ -0,0 +1 @@ +.ui-helper-hidden{display:none;}.ui-helper-hidden-accessible{position:absolute;left:-99999999px;}.ui-helper-reset{margin:0;padding:0;border:0;outline:0;line-height:1.3;text-decoration:none;font-size:100%;list-style:none;}.ui-helper-clearfix:after{content:".";display:block;height:0;clear:both;visibility:hidden;}.ui-helper-clearfix{display:inline-block;}/* required comment for clearfix to work in Opera \*/ * html .ui-helper-clearfix{height:1%;}.ui-helper-clearfix{display:block;}/* end clearfix */ .ui-helper-zfix{width:100%;height:100%;top:0;left:0;position:absolute;opacity:0;filter:Alpha(Opacity=0);}.ui-state-disabled{cursor:default!important;}.ui-icon{display:block;text-indent:-99999px;overflow:hidden;background-repeat:no-repeat;}.ui-widget-overlay{position:absolute;top:0;left:0;width:100%;height:100%;}.ui-resizable{position:relative;}.ui-resizable-handle{position:absolute;font-size:.1px;z-index:99999;display:block;}.ui-resizable-disabled .ui-resizable-handle,.ui-resizable-autohide .ui-resizable-handle{display:none;}.ui-resizable-n{cursor:n-resize;height:7px;width:100%;top:-5px;left:0;}.ui-resizable-s{cursor:s-resize;height:7px;width:100%;bottom:-5px;left:0;}.ui-resizable-e{cursor:e-resize;width:7px;right:-5px;top:0;height:100%;}.ui-resizable-w{cursor:w-resize;width:7px;left:-5px;top:0;height:100%;}.ui-resizable-se{cursor:se-resize;width:12px;height:12px;right:1px;bottom:1px;}.ui-resizable-sw{cursor:sw-resize;width:9px;height:9px;left:-5px;bottom:-5px;}.ui-resizable-nw{cursor:nw-resize;width:9px;height:9px;left:-5px;top:-5px;}.ui-resizable-ne{cursor:ne-resize;width:9px;height:9px;right:-5px;top:-5px;}.wp-dialog{position:absolute;width:300px;overflow:hidden;}.wp-dialog .ui-dialog-titlebar{position:relative;}.wp-dialog .ui-dialog-titlebar-close span{display:block;margin:1px;}.wp-dialog .ui-dialog-content{position:relative;border:0;padding:0;background:none;overflow:auto;zoom:1;}.wp-dialog .ui-dialog-buttonpane{text-align:left;border-width:1px 0 0 0;background-image:none;margin:.5em 0 0 0;padding:.3em 1em .5em .4em;}.wp-dialog .ui-dialog-buttonpane .ui-dialog-buttonset{float:right;}.wp-dialog .ui-dialog-buttonpane button{margin:.5em .4em .5em 0;cursor:pointer;}.wp-dialog .ui-resizable-se{width:14px;height:14px;right:3px;bottom:3px;}.ui-draggable .ui-dialog-titlebar{cursor:move;}.wp-dialog{border:1px solid #999;-moz-box-shadow:0 0 16px rgba(0,0,0,0.3);-webkit-box-shadow:0 0 16px rgba(0,0,0,0.3);box-shadow:0 0 16px rgba(0,0,0,0.3);}.wp-dialog .ui-dialog-title{display:block;text-align:center;padding:1px 0 2px;}.wp-dialog .ui-dialog-titlebar{padding:0 1em;background-color:#444;font-weight:bold;font-size:11px;line-height:18px;color:#e5e5e5;}.wp-dialog{-moz-border-radius-topleft:4px;-webkit-border-top-left-radius:4px;-khtml-border-top-left-radius:4px;border-top-left-radius:4px;-moz-border-radius-topright:4px;-webkit-border-top-right-radius:4px;-khtml-border-top-right-radius:4px;border-top-right-radius:4px;}.wp-dialog .ui-dialog-titlebar{-moz-border-radius-topleft:3px;-webkit-border-top-left-radius:3px;-khtml-border-top-left-radius:3px;border-top-left-radius:3px;-moz-border-radius-topright:3px;-webkit-border-top-right-radius:3px;-khtml-border-top-right-radius:3px;border-top-right-radius:3px;}.wp-dialog .ui-dialog-titlebar-close{position:absolute;width:29px;height:16px;top:2px;right:6px;background:url('../js/tinymce/plugins/inlinepopups/skins/clearlooks2/img/buttons.gif') no-repeat -87px -16px;padding:0;}.wp-dialog .ui-dialog-titlebar-close:hover,.wp-dialog .ui-dialog-titlebar-close:focus{background-position:-87px -32px;}.ui-widget-overlay{background-color:#000;opacity:.6;filter:alpha(opacity=60);} \ No newline at end of file diff --git a/wp-includes/css/jquery-ui-dialog.dev.css b/wp-includes/css/jquery-ui-dialog.dev.css new file mode 100644 index 00000000..b5a0675b --- /dev/null +++ b/wp-includes/css/jquery-ui-dialog.dev.css @@ -0,0 +1,143 @@ +/* + * jQuery UI CSS Framework @VERSION + * + * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * http://docs.jquery.com/UI/Theming/API + */ + +/* Layout helpers +----------------------------------*/ +.ui-helper-hidden { display: none; } +.ui-helper-hidden-accessible { position: absolute; left: -99999999px; } +.ui-helper-reset { margin: 0; padding: 0; border: 0; outline: 0; line-height: 1.3; text-decoration: none; font-size: 100%; list-style: none; } +.ui-helper-clearfix:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; } +.ui-helper-clearfix { display: inline-block; } +/* required comment for clearfix to work in Opera \*/ +* html .ui-helper-clearfix { height:1%; } +.ui-helper-clearfix { display:block; } +/* end clearfix */ +.ui-helper-zfix { width: 100%; height: 100%; top: 0; left: 0; position: absolute; opacity: 0; filter:Alpha(Opacity=0); } + + +/* Interaction Cues +----------------------------------*/ +.ui-state-disabled { cursor: default !important; } + + +/* Icons +----------------------------------*/ + +/* states and images */ +.ui-icon { display: block; text-indent: -99999px; overflow: hidden; background-repeat: no-repeat; } + + +/* Misc visuals +----------------------------------*/ + +/* Overlays */ +.ui-widget-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; } + +/* + * jQuery UI Resizable + * + * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * http://docs.jquery.com/UI/Resizable#theming + */ +.ui-resizable { position: relative;} +.ui-resizable-handle { position: absolute;font-size: 0.1px;z-index: 99999; display: block;} +.ui-resizable-disabled .ui-resizable-handle, .ui-resizable-autohide .ui-resizable-handle { display: none; } +.ui-resizable-n { cursor: n-resize; height: 7px; width: 100%; top: -5px; left: 0; } +.ui-resizable-s { cursor: s-resize; height: 7px; width: 100%; bottom: -5px; left: 0; } +.ui-resizable-e { cursor: e-resize; width: 7px; right: -5px; top: 0; height: 100%; } +.ui-resizable-w { cursor: w-resize; width: 7px; left: -5px; top: 0; height: 100%; } +.ui-resizable-se { cursor: se-resize; width: 12px; height: 12px; right: 1px; bottom: 1px; } +.ui-resizable-sw { cursor: sw-resize; width: 9px; height: 9px; left: -5px; bottom: -5px; } +.ui-resizable-nw { cursor: nw-resize; width: 9px; height: 9px; left: -5px; top: -5px; } +.ui-resizable-ne { cursor: ne-resize; width: 9px; height: 9px; right: -5px; top: -5px;} + +/* + * jQuery UI Dialog + * + * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * http://docs.jquery.com/UI/Dialog#theming + */ +.wp-dialog { position: absolute; width: 300px; overflow: hidden; } +.wp-dialog .ui-dialog-titlebar { position: relative; } +.wp-dialog .ui-dialog-titlebar-close span { display: block; margin: 1px; } +.wp-dialog .ui-dialog-content { position: relative; border: 0; padding: 0; background: none; overflow: auto; zoom: 1; } +.wp-dialog .ui-dialog-buttonpane { text-align: left; border-width: 1px 0 0 0; background-image: none; margin: .5em 0 0 0; padding: .3em 1em .5em .4em; } +.wp-dialog .ui-dialog-buttonpane .ui-dialog-buttonset { float: right; } +.wp-dialog .ui-dialog-buttonpane button { margin: .5em .4em .5em 0; cursor: pointer; } +.wp-dialog .ui-resizable-se { width: 14px; height: 14px; right: 3px; bottom: 3px; } +.ui-draggable .ui-dialog-titlebar { cursor: move; } + + + +/* WP jQuery Dialog Theme */ +.wp-dialog { + border: 1px solid #999; + -moz-box-shadow: 0px 0px 16px rgba( 0,0,0,0.3 ); + -webkit-box-shadow: 0px 0px 16px rgba( 0,0,0,0.3 ); + box-shadow: 0px 0px 16px rgba( 0,0,0,0.3 ); +} +.wp-dialog .ui-dialog-title { + display: block; + text-align: center; + padding: 1px 0 2px; +} +.wp-dialog .ui-dialog-titlebar { + padding: 0 1em; + background-color: #444; + font-weight: bold; + font-size: 11px; + line-height: 18px; + color: #e5e5e5; +} +.wp-dialog { + -moz-border-radius-topleft: 4px; + -webkit-border-top-left-radius: 4px; + -khtml-border-top-left-radius: 4px; + border-top-left-radius: 4px; + -moz-border-radius-topright: 4px; + -webkit-border-top-right-radius: 4px; + -khtml-border-top-right-radius: 4px; + border-top-right-radius: 4px; +} +.wp-dialog .ui-dialog-titlebar { + -moz-border-radius-topleft: 3px; + -webkit-border-top-left-radius: 3px; + -khtml-border-top-left-radius: 3px; + border-top-left-radius: 3px; + -moz-border-radius-topright: 3px; + -webkit-border-top-right-radius: 3px; + -khtml-border-top-right-radius: 3px; + border-top-right-radius: 3px; +} + +.wp-dialog .ui-dialog-titlebar-close { + position: absolute; + width: 29px; + height: 16px; + top: 2px; + right: 6px; + background: url('../js/tinymce/plugins/inlinepopups/skins/clearlooks2/img/buttons.gif') no-repeat -87px -16px; + padding: 0; +} +.wp-dialog .ui-dialog-titlebar-close:hover, +.wp-dialog .ui-dialog-titlebar-close:focus { + background-position: -87px -32px; +} +.ui-widget-overlay { + background-color: #000; + opacity: 0.6; + filter: alpha(opacity=60); +} \ No newline at end of file diff --git a/wp-includes/default-embeds.php b/wp-includes/default-embeds.php index 1283c1e2..ca599445 100644 --- a/wp-includes/default-embeds.php +++ b/wp-includes/default-embeds.php @@ -28,7 +28,7 @@ function wp_embed_handler_googlevideo( $matches, $attr, $url, $rawattr ) { list( $width, $height ) = wp_expand_dimensions( 425, 344, $attr['width'], $attr['height'] ); } - return apply_filters( 'embed_googlevideo', '', $matches, $attr, $url, $rawattr ); + return apply_filters( 'embed_googlevideo', '', $matches, $attr, $url, $rawattr ); } wp_embed_register_handler( 'googlevideo', '#http://video\.google\.([A-Za-z.]{2,5})/videoplay\?docid=([\d-]+)(.*?)#i', 'wp_embed_handler_googlevideo' ); diff --git a/wp-includes/default-filters.php b/wp-includes/default-filters.php index 8898864e..4822e2ea 100644 --- a/wp-includes/default-filters.php +++ b/wp-includes/default-filters.php @@ -21,8 +21,11 @@ foreach ( array( 'pre_term_name', 'pre_comment_author_name', 'pre_link_name', 'p // Strip, kses, special chars for string display foreach ( array( 'term_name', 'comment_author_name', 'link_name', 'link_target', 'link_rel', 'user_display_name', 'user_first_name', 'user_last_name', 'user_nickname' ) as $filter ) { - add_filter( $filter, 'sanitize_text_field' ); - add_filter( $filter, 'wp_kses_data' ); + if ( is_admin() ) { + // These are expensive. Run only on admin pages for defense in depth. + add_filter( $filter, 'sanitize_text_field' ); + add_filter( $filter, 'wp_kses_data' ); + } add_filter( $filter, '_wp_specialchars', 30 ); } @@ -32,11 +35,12 @@ foreach ( array( 'pre_term_description', 'pre_link_description', 'pre_link_notes } // Kses only for textarea admin displays -foreach ( array( 'term_description', 'link_description', 'link_notes', 'user_description' ) as $filter ) { - add_filter( $filter, 'wp_kses_data' ); -} -if ( is_admin() ) +if ( is_admin() ) { + foreach ( array( 'term_description', 'link_description', 'link_notes', 'user_description' ) as $filter ) { + add_filter( $filter, 'wp_kses_data' ); + } add_filter( 'comment_text', 'wp_kses_post' ); +} // Email saves foreach ( array( 'pre_comment_author_email', 'pre_user_email' ) as $filter ) { @@ -45,10 +49,11 @@ foreach ( array( 'pre_comment_author_email', 'pre_user_email' ) as $filter ) { add_filter( $filter, 'wp_filter_kses' ); } -// Email display +// Email admin display foreach ( array( 'comment_author_email', 'user_email' ) as $filter ) { add_filter( $filter, 'sanitize_email' ); - add_filter( $filter, 'wp_kses_data' ); + if ( is_admin() ) + add_filter( $filter, 'wp_kses_data' ); } // Save URL @@ -61,9 +66,11 @@ foreach ( array( 'pre_comment_author_url', 'pre_user_url', 'pre_link_url', 'pre_ // Display URL foreach ( array( 'user_url', 'link_url', 'link_image', 'link_rss', 'comment_url' ) as $filter ) { - add_filter( $filter, 'wp_strip_all_tags' ); + if ( is_admin() ) + add_filter( $filter, 'wp_strip_all_tags' ); add_filter( $filter, 'esc_url' ); - add_filter( $filter, 'wp_kses_data' ); + if ( is_admin() ) + add_filter( $filter, 'wp_kses_data' ); } // Slugs @@ -92,8 +99,9 @@ foreach ( array( 'comment_author', 'term_name', 'link_name', 'link_description', } // Format WordPress -foreach ( array( 'the_content', 'the_title', 'comment_text' ) as $filter ) +foreach ( array( 'the_content', 'the_title' ) as $filter ) add_filter( $filter, 'capital_P_dangit', 11 ); +add_filter( 'comment_text', 'capital_P_dangit', 31 ); // Format titles foreach ( array( 'single_post_title', 'single_cat_title', 'single_tag_title', 'single_month_title', 'nav_menu_attr_title', 'nav_menu_description' ) as $filter ) { @@ -114,6 +122,10 @@ foreach ( array( 'term_name_rss' ) as $filter ) { add_filter( $filter, 'convert_chars' ); } +// Pre save hierarchy +add_filter( 'wp_insert_post_parent', 'wp_check_post_hierarchy_for_loops', 10, 2 ); +add_filter( 'wp_update_term_parent', 'wp_check_term_hierarchy_for_loops', 10, 3 ); + // Display filters add_filter( 'the_title', 'wptexturize' ); add_filter( 'the_title', 'convert_chars' ); @@ -143,7 +155,6 @@ add_filter( 'comment_text', 'wpautop', 30 ); add_filter( 'comment_excerpt', 'convert_chars' ); add_filter( 'list_cats', 'wptexturize' ); -add_filter( 'single_post_title', 'wptexturize' ); add_filter( 'wp_sprintf', 'wp_sprintf_l', 10, 2 ); @@ -204,6 +215,10 @@ add_action( 'wp_footer', 'wp_print_footer_scripts' ); add_action( 'wp_head', 'wp_shortlink_wp_head', 10, 0 ); add_action( 'template_redirect', 'wp_shortlink_header', 11, 0 ); +// Login actions +add_action( 'login_head', 'wp_print_head_scripts', 9 ); +add_action( 'login_footer', 'wp_print_footer_scripts' ); + // Feed Generator Tags foreach ( array( 'rss2_head', 'commentsrss2_head', 'rss_head', 'rdf_header', 'atom_head', 'comments_atom_head', 'opml_head', 'app_head' ) as $action ) { add_action( $action, 'the_generator' ); @@ -258,4 +273,6 @@ add_filter( 'pre_option_gmt_offset','wp_timezone_override_offset' ); add_action( 'admin_init', 'register_admin_color_schemes', 1); add_action( 'admin_color_scheme_picker', 'admin_color_scheme_picker' ); +unset($filter, $action); + ?> diff --git a/wp-includes/default-widgets.php b/wp-includes/default-widgets.php index 2c9ec067..a3699051 100644 --- a/wp-includes/default-widgets.php +++ b/wp-includes/default-widgets.php @@ -1,5 +1,4 @@

        + id="get_field_id('dropdown'); ?>" name="get_field_name('dropdown'); ?>" /> +
        id="get_field_id('count'); ?>" name="get_field_name('count'); ?>" /> -
        - id="get_field_id('dropdown'); ?>" name="get_field_name('dropdown'); ?>" />

        '', 'text' => '' ) ); $title = strip_tags($instance['title']); - $text = format_to_edit($instance['text']); + $text = esc_textarea($instance['text']); ?>

        @@ -491,7 +490,7 @@ class WP_Widget_Categories extends WP_Widget {

        /> -
        +
        />
        @@ -535,14 +534,10 @@ class WP_Widget_Recent_Posts extends WP_Widget { extract($args); $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Posts') : $instance['title'], $instance, $this->id_base); - if ( !$number = (int) $instance['number'] ) - $number = 10; - else if ( $number < 1 ) - $number = 1; - else if ( $number > 15 ) - $number = 15; - - $r = new WP_Query(array('showposts' => $number, 'nopaging' => 0, 'post_status' => 'publish', 'caller_get_posts' => 1)); + if ( ! $number = absint( $instance['number'] ) ) + $number = 10; + + $r = new WP_Query(array('posts_per_page' => $number, 'nopaging' => 0, 'post_status' => 'publish', 'ignore_sticky_posts' => true)); if ($r->have_posts()) : ?> @@ -582,8 +577,7 @@ class WP_Widget_Recent_Posts extends WP_Widget { function form( $instance ) { $title = isset($instance['title']) ? esc_attr($instance['title']) : ''; - if ( !isset($instance['number']) || !$number = (int) $instance['number'] ) - $number = 5; + $number = isset($instance['number']) ? absint($instance['number']) : 5; ?>

        @@ -613,7 +607,11 @@ class WP_Widget_Recent_Comments extends WP_Widget { add_action( 'transition_comment_status', array(&$this, 'flush_widget_cache') ); } - function recent_comments_style() { ?> + function recent_comments_style() { + if ( ! current_theme_supports( 'widgets' ) // Temp hack #14876 + || ! apply_filters( 'show_recent_comments_widget_style', true, $this->id_base ) ) + return; + ?> $number, 'status' => 'approve' ) ); $output .= $before_widget; @@ -666,7 +662,7 @@ class WP_Widget_Recent_Comments extends WP_Widget { function update( $new_instance, $old_instance ) { $instance = $old_instance; $instance['title'] = strip_tags($new_instance['title']); - $instance['number'] = (int) $new_instance['number']; + $instance['number'] = absint( $new_instance['number'] ); $this->flush_widget_cache(); $alloptions = wp_cache_get( 'alloptions', 'options' ); @@ -716,6 +712,10 @@ class WP_Widget_RSS extends WP_Widget { if ( empty($url) ) return; + // self-url destruction sequence + if ( $url == site_url() || $url == home_url() ) + return; + $rss = fetch_feed($url); $title = $instance['title']; $desc = ''; @@ -836,13 +836,10 @@ function wp_widget_rss_output( $rss, $args = array() ) { $date = ''; if ( $show_date ) { - $date = $item->get_date(); + $date = $item->get_date( 'U' ); if ( $date ) { - if ( $date_stamp = strtotime( $date ) ) - $date = ' ' . date_i18n( get_option( 'date_format' ), $date_stamp ) . ''; - else - $date = ''; + $date = ' ' . date_i18n( get_option( 'date_format' ), $date ) . ''; } } @@ -1011,7 +1008,7 @@ class WP_Widget_Tag_Cloud extends WP_Widget { echo $before_widget; if ( $title ) echo $before_title . $title . $after_title; - echo '
        '; + echo '
        '; wp_tag_cloud( apply_filters('widget_tag_cloud_args', array('taxonomy' => $current_taxonomy) ) ); echo "
        \n"; echo $after_widget; diff --git a/wp-includes/deprecated.php b/wp-includes/deprecated.php index c32a288c..2300572e 100644 --- a/wp-includes/deprecated.php +++ b/wp-includes/deprecated.php @@ -164,10 +164,10 @@ function previous_post($format='%', $previous='previous post: ', $title='yes', $ * @see next_post_link() * * @param string $format - * @param string $previous + * @param string $next * @param string $title * @param string $in_same_cat - * @param int $limitprev + * @param int $limitnext * @param string $excluded_categories */ function next_post($format='%', $next='next post: ', $title='yes', $in_same_cat='no', $limitnext=1, $excluded_categories='') { @@ -430,7 +430,7 @@ function get_linksbyname($cat_name = "noname", $before = '', $after = '
        ', * @return bool|null */ function wp_get_linksbyname($category, $args = '') { - _deprecated_function(__FUNCTION__, '0.0', 'wp_list_bookmarks()'); + _deprecated_function(__FUNCTION__, '2.1', 'wp_list_bookmarks()'); $defaults = array( 'after' => '
        ', @@ -872,10 +872,10 @@ function permalink_link() { * @deprecated Use the_permalink_rss() * @see the_permalink_rss() * - * @param string $file + * @param string $deprecated */ function permalink_single_rss($deprecated = '') { - _deprecated_function( __FUNCTION__, '0.0', 'the_permalink_rss()' ); + _deprecated_function( __FUNCTION__, '2.3', 'the_permalink_rss()' ); the_permalink_rss(); } @@ -892,7 +892,7 @@ function permalink_single_rss($deprecated = '') { * @return null|string */ function wp_get_links($args = '') { - _deprecated_function( __FUNCTION__, '0.0', 'wp_list_bookmarks()' ); + _deprecated_function( __FUNCTION__, '2.1', 'wp_list_bookmarks()' ); if ( strpos( $args, '=' ) === false ) { $cat_id = $args; @@ -2035,7 +2035,7 @@ function get_attachment_innerHTML($id = 0, $fullsize = false, $max_dims = false) return apply_filters('attachment_innerHTML', $innerHTML, $post->ID); } -/* +/** * Retrieve bookmark data based on ID. * * @since 2.0.0 @@ -2296,7 +2296,8 @@ function delete_usermeta( $user_id, $meta_key, $meta_value = '' ) { else $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) ); - wp_cache_delete($user_id, 'users'); + clean_user_cache( $user_id ); + wp_cache_delete( $user_id, 'user_meta' ); if ( $cur && $cur->umeta_id ) do_action( 'deleted_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value ); @@ -2403,7 +2404,8 @@ function update_usermeta( $user_id, $meta_key, $meta_value ) { else return false; - wp_cache_delete($user_id, 'users'); + clean_user_cache( $user_id ); + wp_cache_delete( $user_id, 'user_meta' ); if ( !$cur ) do_action( 'added_usermeta', $wpdb->insert_id, $user_id, $meta_key, $meta_value ); @@ -2413,6 +2415,31 @@ function update_usermeta( $user_id, $meta_key, $meta_value ) { return true; } +/** + * Get users for the blog. + * + * For setups that use the multi-blog feature. Can be used outside of the + * multi-blog feature. + * + * @since 2.2.0 + * @deprecated 3.1.0 + * @uses $wpdb WordPress database object for queries + * @uses $blog_id The Blog id of the blog for those that use more than one blog + * + * @param int $id Blog ID. + * @return array List of users that are part of that Blog ID + */ +function get_users_of_blog( $id = '' ) { + _deprecated_function( __FUNCTION__, '3.1', 'get_users()' ); + + global $wpdb, $blog_id; + if ( empty($id) ) + $id = (int) $blog_id; + $blog_prefix = $wpdb->get_blog_prefix($id); + $users = $wpdb->get_results( "SELECT user_id, user_id AS ID, user_login, display_name, user_email, meta_value FROM $wpdb->users, $wpdb->usermeta WHERE {$wpdb->users}.ID = {$wpdb->usermeta}.user_id AND meta_key = '{$blog_prefix}capabilities' ORDER BY {$wpdb->usermeta}.user_id" ); + return $users; +} + /** * Enable/disable automatic general feed link outputting. * @@ -2534,3 +2561,44 @@ function is_term( $term, $taxonomy = '', $parent = 0 ) { _deprecated_function( __FUNCTION__, '3.0', 'term_exists()' ); return term_exists( $term, $taxonomy, $parent ); } + +/** + * Is the current admin page generated by a plugin? + * + * @since 1.5.0 + * @deprecated 3.1 + * @deprecated Use global $plugin_page and/or get_plugin_page_hookname() hooks. + * + * @global $plugin_page + * + * @return bool + */ +function is_plugin_page() { + _deprecated_function( __FUNCTION__, '3.1' ); + + global $plugin_page; + + if ( isset($plugin_page) ) + return true; + + return false; +} + +/** + * Update the categories cache. + * + * This function does not appear to be used anymore or does not appear to be + * needed. It might be a legacy function left over from when there was a need + * for updating the category cache. + * + * @since 1.5.0 + * @deprecated 3.1 + * + * @return bool Always return True + */ +function update_category_cache() { + _deprecated_function( __FUNCTION__, '3.1' ); + + return true; +} + diff --git a/wp-includes/feed-rss2.php b/wp-includes/feed-rss2.php index 538f96b7..5bf67f2f 100644 --- a/wp-includes/feed-rss2.php +++ b/wp-includes/feed-rss2.php @@ -37,7 +37,7 @@ echo ''; ?> - + diff --git a/wp-includes/feed.php b/wp-includes/feed.php index 1be12a45..b94e3476 100644 --- a/wp-includes/feed.php +++ b/wp-includes/feed.php @@ -161,7 +161,7 @@ function get_the_content_feed($feed_type = null) { * @param string $feed_type The type of feed. rss2 | atom | rss | rdf */ function the_content_feed($feed_type = null) { - echo get_the_content_feed(); + echo get_the_content_feed($feed_type); } /** @@ -204,7 +204,7 @@ function comments_link_feed() { * * @package WordPress * @subpackage Feed - * @since unknown + * @since 2.5.0 * * @param int|object $comment_id Optional comment object or id. Defaults to global comment object. */ @@ -217,7 +217,7 @@ function comment_guid($comment_id = null) { * * @package WordPress * @subpackage Feed - * @since unknown + * @since 2.5.0 * * @param int|object $comment_id Optional comment object or id. Defaults to global comment object. * @return bool|string false on failure or guid for comment on success. diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php index 3d203e6f..be2669c1 100644 --- a/wp-includes/formatting.php +++ b/wp-includes/formatting.php @@ -56,7 +56,7 @@ function wptexturize($text) { $static_characters = array_merge(array('---', ' -- ', '--', ' - ', 'xn–', '...', '``', '\'\'', ' (tm)'), $cockney); $static_replacements = array_merge(array('—', ' — ', '–', ' – ', 'xn--', '…', $opening_quote, $closing_quote, ' ™'), $cockneyreplace); - $dynamic_characters = array('/\'(\d\d(?:’|\')?s)/', '/\'(\d+)/', '/(\s|\A|[([{<]|")\'/', '/(\d+)"/', '/(\d+)\'/', '/(\S)\'([^\'\s])/', '/(\s|\A|[([{<])"(?!\s)/', '/"(\s|\S|\Z)/', '/\'([\s.]|\Z)/', '/\b(\d+)x(\d+)\b/'); + $dynamic_characters = array('/\'(\d\d(?:’|\')?s)/', '/\'(\d)/', '/(\s|\A|[([{<]|")\'/', '/(\d)"/', '/(\d)\'/', '/(\S)\'([^\'\s])/', '/(\s|\A|[([{<])"(?!\s)/', '/"(\s|\S|\Z)/', '/\'([\s.]|\Z)/', '/\b(\d+)x(\d+)\b/'); $dynamic_replacements = array('’$1','’$1', '$1‘', '$1″', '$1′', '$1’$2', '$1' . $opening_quote . '$2', $closing_quote . '$1', '’$1', '$1×$2'); $static_setup = true; @@ -73,7 +73,7 @@ function wptexturize($text) { for ( $i = 0; $i < $stop; $i++ ) { $curl = $textarr[$i]; - if ( !empty($curl) && '<' != $curl{0} && '[' != $curl{0} + if ( !empty($curl) && '<' != $curl[0] && '[' != $curl[0] && empty($no_texturize_shortcodes_stack) && empty($no_texturize_tags_stack)) { // This is not a tag, nor is the texturization disabled // static strings @@ -85,9 +85,9 @@ function wptexturize($text) { * Only call _wptexturize_pushpop_element if first char is correct * tag opening */ - if ('<' == $curl{0}) + if ('<' == $curl[0]) _wptexturize_pushpop_element($curl, $no_texturize_tags_stack, $no_texturize_tags, '<', '>'); - elseif ('[' == $curl{0}) + elseif ('[' == $curl[0]) _wptexturize_pushpop_element($curl, $no_texturize_shortcodes_stack, $no_texturize_shortcodes, '[', ']'); } @@ -208,7 +208,7 @@ function wpautop($pee, $br = 1) { $pee = preg_replace('!

        \s*(]*>)!', "$1", $pee); $pee = preg_replace('!(]*>)\s*

        !', "$1", $pee); if ($br) { - $pee = preg_replace_callback('/<(script|style).*?<\/\\1>/s', create_function('$matches', 'return str_replace("\n", "", $matches[0]);'), $pee); + $pee = preg_replace_callback('/<(script|style).*?<\/\\1>/s', '_autop_newline_preservation_helper', $pee); $pee = preg_replace('|(?)\s*\n|', "
        \n", $pee); // optionally make line breaks $pee = str_replace('', "\n", $pee); } @@ -221,6 +221,18 @@ function wpautop($pee, $br = 1) { return $pee; } +/** + * Newline preservation help function for wpautop + * + * @since 3.1.0 + * @access private + * @param array $matches preg_replace_callback matches array + * @returns string + */ +function _autop_newline_preservation_helper( $matches ) { + return str_replace("\n", "", $matches[0]); +} + /** * Don't auto-p wrap shortcodes that stand alone * @@ -538,30 +550,33 @@ function remove_accents($string) { chr(195).chr(128) => 'A', chr(195).chr(129) => 'A', chr(195).chr(130) => 'A', chr(195).chr(131) => 'A', chr(195).chr(132) => 'A', chr(195).chr(133) => 'A', - chr(195).chr(135) => 'C', chr(195).chr(136) => 'E', - chr(195).chr(137) => 'E', chr(195).chr(138) => 'E', - chr(195).chr(139) => 'E', chr(195).chr(140) => 'I', - chr(195).chr(141) => 'I', chr(195).chr(142) => 'I', - chr(195).chr(143) => 'I', chr(195).chr(145) => 'N', + chr(195).chr(134) => 'AE',chr(195).chr(135) => 'C', + chr(195).chr(136) => 'E', chr(195).chr(137) => 'E', + chr(195).chr(138) => 'E', chr(195).chr(139) => 'E', + chr(195).chr(140) => 'I', chr(195).chr(141) => 'I', + chr(195).chr(142) => 'I', chr(195).chr(143) => 'I', + chr(195).chr(144) => 'D', chr(195).chr(145) => 'N', chr(195).chr(146) => 'O', chr(195).chr(147) => 'O', chr(195).chr(148) => 'O', chr(195).chr(149) => 'O', chr(195).chr(150) => 'O', chr(195).chr(153) => 'U', chr(195).chr(154) => 'U', chr(195).chr(155) => 'U', chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y', - chr(195).chr(159) => 's', chr(195).chr(160) => 'a', - chr(195).chr(161) => 'a', chr(195).chr(162) => 'a', - chr(195).chr(163) => 'a', chr(195).chr(164) => 'a', - chr(195).chr(165) => 'a', chr(195).chr(167) => 'c', + chr(195).chr(158) => 'TH',chr(195).chr(159) => 's', + chr(195).chr(160) => 'a', chr(195).chr(161) => 'a', + chr(195).chr(162) => 'a', chr(195).chr(163) => 'a', + chr(195).chr(164) => 'a', chr(195).chr(165) => 'a', + chr(195).chr(166) => 'ae',chr(195).chr(167) => 'c', chr(195).chr(168) => 'e', chr(195).chr(169) => 'e', chr(195).chr(170) => 'e', chr(195).chr(171) => 'e', chr(195).chr(172) => 'i', chr(195).chr(173) => 'i', chr(195).chr(174) => 'i', chr(195).chr(175) => 'i', - chr(195).chr(177) => 'n', chr(195).chr(178) => 'o', - chr(195).chr(179) => 'o', chr(195).chr(180) => 'o', - chr(195).chr(181) => 'o', chr(195).chr(182) => 'o', - chr(195).chr(182) => 'o', chr(195).chr(185) => 'u', - chr(195).chr(186) => 'u', chr(195).chr(187) => 'u', - chr(195).chr(188) => 'u', chr(195).chr(189) => 'y', + chr(195).chr(176) => 'd', chr(195).chr(177) => 'n', + chr(195).chr(178) => 'o', chr(195).chr(179) => 'o', + chr(195).chr(180) => 'o', chr(195).chr(181) => 'o', + chr(195).chr(182) => 'o', chr(195).chr(182) => 'o', + chr(195).chr(185) => 'u', chr(195).chr(186) => 'u', + chr(195).chr(187) => 'u', chr(195).chr(188) => 'u', + chr(195).chr(189) => 'y', chr(195).chr(190) => 'th', chr(195).chr(191) => 'y', // Decompositions for Latin Extended-A chr(196).chr(128) => 'A', chr(196).chr(129) => 'a', @@ -628,6 +643,9 @@ function remove_accents($string) { chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z', chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z', chr(197).chr(190) => 'z', chr(197).chr(191) => 's', + // Decompositions for Latin Extended-B + chr(200).chr(152) => 'S', chr(200).chr(153) => 's', + chr(200).chr(154) => 'T', chr(200).chr(155) => 't', // Euro Sign chr(226).chr(130).chr(172) => 'E', // GBP (Pound) Sign @@ -718,12 +736,10 @@ function sanitize_file_name( $filename ) { /** * Sanitize username stripping out unsafe characters. * - * If $strict is true, only alphanumeric characters (as well as _, space, ., -, - * @) are returned. - * Removes tags, octets, entities, and if strict is enabled, will remove all - * non-ASCII characters. After sanitizing, it passes the username, raw username - * (the username in the parameter), and the strict parameter as parameters for - * the filter. + * Removes tags, octets, entities, and if strict is enabled, will only keep + * alphanumeric, _, space, ., -, @. After sanitizing, it passes the username, + * raw username (the username in the parameter), and the value of $strict as + * parameters for the 'sanitize_user' filter. * * @since 2.0.0 * @uses apply_filters() Calls 'sanitize_user' hook on username, raw username, @@ -745,6 +761,7 @@ function sanitize_user( $username, $strict = false ) { if ( $strict ) $username = preg_replace( '|[^a-z0-9 _.\-@]|i', '', $username ); + $username = trim( $username ); // Consolidate contiguous whitespace $username = preg_replace( '|\s+|', ' ', $username ); @@ -754,7 +771,7 @@ function sanitize_user( $username, $strict = false ) { /** * Sanitize a string key. * - * Keys are used as internal identifiers. They should be lowercase ASCII. Dashes and underscores are allowed. + * Keys are used as internal identifiers. Lowercase alphanumeric characters, dashes and underscores are allowed. * * @since 3.0.0 * @@ -763,17 +780,9 @@ function sanitize_user( $username, $strict = false ) { */ function sanitize_key( $key ) { $raw_key = $key; - $key = wp_strip_all_tags($key); - // Kill octets - $key = preg_replace('|%([a-fA-F0-9][a-fA-F0-9])|', '', $key); - $key = preg_replace('/&.+?;/', '', $key); // Kill entities - - $key = preg_replace('|[^a-z0-9 _.\-@]|i', '', $key); - - // Consolidate contiguous whitespace - $key = preg_replace('|\s+|', ' ', $key); - - return apply_filters('sanitize_key', $key, $raw_key); + $key = strtolower( $key ); + $key = preg_replace( '/[^a-z0-9_\-]/', '', $key ); + return apply_filters( 'sanitize_key', $key, $raw_key ); } /** @@ -787,12 +796,16 @@ function sanitize_key( $key ) { * * @param string $title The string to be sanitized. * @param string $fallback_title Optional. A title to use if $title is empty. + * @param string $context Optional. The operation for which the string is sanitized * @return string The sanitized string. */ -function sanitize_title($title, $fallback_title = '') { +function sanitize_title($title, $fallback_title = '', $context = 'save') { $raw_title = $title; - $title = strip_tags($title); - $title = apply_filters('sanitize_title', $title, $raw_title); + + if ( 'save' == $context ) + $title = remove_accents($title); + + $title = apply_filters('sanitize_title', $title, $raw_title, $context); if ( '' === $title || false === $title ) $title = $fallback_title; @@ -800,6 +813,10 @@ function sanitize_title($title, $fallback_title = '') { return $title; } +function sanitize_title_for_query($title) { + return sanitize_title($title, '', 'query'); +} + /** * Sanitizes title, replacing whitespace with dashes. * @@ -820,7 +837,6 @@ function sanitize_title_with_dashes($title) { // Restore octets. $title = preg_replace('|---([a-fA-F0-9][a-fA-F0-9])---|', '%$1', $title); - $title = remove_accents($title); if (seems_utf8($title)) { if (function_exists('mb_strtolower')) { $title = mb_strtolower($title, 'UTF-8'); @@ -980,7 +996,7 @@ function balanceTags( $text, $force = false ) { * @since 2.0.4 * * @author Leonard Lin - * @license GPL v2.0 + * @license GPL * @copyright November 4, 2001 * @version 1.1 * @todo Make better - change loop condition to $text in 1.2 @@ -1098,8 +1114,8 @@ function force_balance_tags( $text ) { * Acts on text which is about to be edited. * * Unless $richedit is set, it is simply a holder for the 'format_to_edit' - * filter. If $richedit is set true htmlspecialchars() will be run on the - * content, converting special characters to HTMl entities. + * filter. If $richedit is set true htmlspecialchars(), through esc_textarea(), + * will be run on the content, converting special characters to HTML entities. * * @since 0.71 * @@ -1107,10 +1123,10 @@ function force_balance_tags( $text ) { * @param bool $richedit Whether the $content should pass through htmlspecialchars(). Default false. * @return string The text after the filter (and possibly htmlspecialchars()) has been run. */ -function format_to_edit($content, $richedit = false) { - $content = apply_filters('format_to_edit', $content); - if (! $richedit ) - $content = htmlspecialchars($content); +function format_to_edit( $content, $richedit = false ) { + $content = apply_filters( 'format_to_edit', $content ); + if ( ! $richedit ) + $content = esc_textarea( $content ); return $content; } @@ -1296,12 +1312,19 @@ function antispambot($emailaddy, $mailto=0) { */ function _make_url_clickable_cb($matches) { $url = $matches[2]; + $suffix = ''; + + /** Include parentheses in the URL only if paired **/ + while ( substr_count( $url, '(' ) < substr_count( $url, ')' ) ) { + $suffix = strrchr( $url, ')' ) . $suffix; + $url = substr( $url, 0, strrpos( $url, ')' ) ); + } $url = esc_url($url); if ( empty($url) ) return $matches[0]; - return $matches[1] . "
        $url"; + return $matches[1] . "$url" . $suffix; } /** @@ -1363,7 +1386,7 @@ function _make_email_clickable_cb($matches) { function make_clickable($ret) { $ret = ' ' . $ret; // in testing, using arrays here was found to be faster - $ret = preg_replace_callback('#(?<=[\s>])(\()?([\w]+?://(?:[\w\\x80-\\xff\#$%&~/=?@\[\](+-]|[.,;:](?![\s<]|(\))?([\s]|$))|(?(1)\)(?![\s<.,;:]|$)|\)))+)#is', '_make_url_clickable_cb', $ret); + $ret = preg_replace_callback('#(?])(\()?([\w]+?://(?:[\w\\x80-\\xff\#%~/?@\[\]-]|[\'*(+.,;:!=&$](?![\b\)]|(\))?([\s]|$))|(?(1)\)(?![\s<.,;:]|$)|\)))+)#is', '_make_url_clickable_cb', $ret); $ret = preg_replace_callback('#([\s>])((www|ftp)\.[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]+)#is', '_make_web_ftp_clickable_cb', $ret); $ret = preg_replace_callback('#([\s>])([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})#i', '_make_email_clickable_cb', $ret); // this one is not in an array because we need it to run last, for cleanup of accidental links within links @@ -1424,13 +1447,11 @@ function translate_smiley($smiley) { return ''; } - $siteurl = get_option( 'siteurl' ); - $smiley = trim(reset($smiley)); $img = $wpsmiliestrans[$smiley]; $smiley_masked = esc_attr($smiley); - $srcurl = apply_filters('smilies_src', "$siteurl/wp-includes/images/smilies/$img", $img, $siteurl); + $srcurl = apply_filters('smilies_src', includes_url("images/smilies/$img"), $img, site_url()); return " $smiley_masked "; } @@ -1456,7 +1477,7 @@ function convert_smilies($text) { $stop = count($textarr);// loop stuff for ($i = 0; $i < $stop; $i++) { $content = $textarr[$i]; - if ((strlen($content) > 0) && ('<' != $content{0})) { // If it's not a tag + if ((strlen($content) > 0) && ('<' != $content[0])) { // If it's not a tag $content = preg_replace_callback($wp_smiliessearch, 'translate_smiley', $content); } $output .= $content; @@ -1476,7 +1497,7 @@ function convert_smilies($text) { * @since 0.71 * * @param string $email Email address to verify. - * @param boolean $deprecated. Deprecated. + * @param boolean $deprecated Deprecated. * @return string|bool Either false or the valid email address. */ function is_email( $email, $deprecated = false ) { @@ -1553,11 +1574,22 @@ function wp_iso_descrambler($string) { return $string; } else { $subject = str_replace('_', ' ', $matches[2]); - $subject = preg_replace_callback('#\=([0-9a-f]{2})#i', create_function('$match', 'return chr(hexdec(strtolower($match[1])));'), $subject); + $subject = preg_replace_callback('#\=([0-9a-f]{2})#i', '_wp_iso_convert', $subject); return $subject; } } +/** + * Helper function to convert hex encoded chars to ascii + * + * @since 3.1.0 + * @access private + * @param array $match the preg_replace_callback matches array + */ +function _wp_iso_convert( $match ) { + return chr( hexdec( strtolower( $match[1] ) ) ); +} + /** * Returns a date in the GMT equivalent. * @@ -1743,7 +1775,7 @@ function sanitize_email( $email ) { $sub = trim( $sub, " \t\n\r\0\x0B-" ); // Test for invalid characters - $sub = preg_replace( '/^[^a-z0-9-]+$/i', '', $sub ); + $sub = preg_replace( '/[^a-z0-9-]+/i', '', $sub ); // If there's anything left, add it to the valid subs if ( '' !== $sub ) { @@ -2328,6 +2360,19 @@ function esc_attr( $text ) { return apply_filters( 'attribute_escape', $safe_text, $text ); } +/** + * Escaping for textarea values. + * + * @since 3.1 + * + * @param string $text + * @return string + */ +function esc_textarea( $text ) { + $safe_text = htmlspecialchars( $text, ENT_QUOTES ); + return apply_filters( 'esc_textarea', $safe_text, $text ); +} + /** * Escape a HTML tag name. * @@ -2580,7 +2625,7 @@ function wp_sprintf( $pattern ) { $fragment = substr($pattern, $start, $end - $start); // Fragment has a specifier - if ( $pattern{$start} == '%' ) { + if ( $pattern[$start] == '%' ) { // Find numbered arguments or take the next one in order if ( preg_match('/^%(\d+)\$/', $fragment, $matches) ) { $arg = isset($args[$matches[1]]) ? $args[$matches[1]] : ''; @@ -2689,10 +2734,10 @@ function wp_html_excerpt( $str, $count ) { * @return string The processed content. */ function links_add_base_url( $content, $base, $attrs = array('src', 'href') ) { + global $_links_add_base; + $_links_add_base = $base; $attrs = implode('|', (array)$attrs); - return preg_replace_callback("!($attrs)=(['\"])(.+?)\\2!i", - create_function('$m', 'return _links_add_base($m, "' . $base . '");'), - $content); + return preg_replace_callback( "!($attrs)=(['\"])(.+?)\\2!i", '_links_add_base', $content ); } /** @@ -2702,14 +2747,14 @@ function links_add_base_url( $content, $base, $attrs = array('src', 'href') ) { * @access private * * @param string $m The matched link. - * @param string $base The base URL to prefix to links. * @return string The processed link. */ -function _links_add_base($m, $base) { +function _links_add_base($m) { + global $_links_add_base; //1 = attribute name 2 = quotation mark 3 = URL return $m[1] . '=' . $m[2] . (strpos($m[3], 'http://') === false ? - path_join($base, $m[3]) : + path_join($_links_add_base, $m[3]) : $m[3]) . $m[2]; } @@ -2730,10 +2775,10 @@ function _links_add_base($m, $base) { * @return string The processed content. */ function links_add_target( $content, $target = '_blank', $tags = array('a') ) { + global $_links_add_target; + $_links_add_target = $target; $tags = implode('|', (array)$tags); - return preg_replace_callback("!<($tags)(.+?)>!i", - create_function('$m', 'return _links_add_target($m, "' . $target . '");'), - $content); + return preg_replace_callback( "!<($tags)(.+?)>!i", '_links_add_target', $content ); } /** @@ -2743,13 +2788,13 @@ function links_add_target( $content, $target = '_blank', $tags = array('a') ) { * @access private * * @param string $m The matched link. - * @param string $target The Target to add to the links. * @return string The processed link. */ -function _links_add_target( $m, $target ) { +function _links_add_target( $m ) { + global $_links_add_target; $tag = $m[1]; $link = preg_replace('|(target=[\'"](.*?)[\'"])|i', '', $m[2]); - return '<' . $tag . $link . ' target="' . $target . '">'; + return '<' . $tag . $link . ' target="' . esc_attr( $_links_add_target ) . '">'; } // normalize EOL characters and strip duplicate whitespace @@ -2819,6 +2864,19 @@ function sanitize_text_field($str) { return apply_filters('sanitize_text_field', $filtered, $str); } +/** + * i18n friendly version of basename() + * + * @since 3.1.0 + * + * @param string $path A path. + * @param string $suffix If the filename ends in suffix this will also be cut off. + * @return string + */ +function wp_basename( $path, $suffix = '' ) { + return urldecode( basename( str_replace( '%2F', '/', urlencode( $path ) ), $suffix ) ); +} + /** * Forever eliminate "Wordpress" from the planet (or at least the little bit we can influence). * @@ -2826,7 +2884,6 @@ function sanitize_text_field($str) { * * @since 3.0.0 */ - function capital_P_dangit( $text ) { // Simple replacement for titles if ( 'the_title' === current_filter() ) diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 8cd9ba79..65ee33ea 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -27,19 +27,18 @@ function mysql2date( $dateformatstring, $mysqlstring, $translate = true ) { if ( empty( $m ) ) return false; - if ( 'G' == $dateformatstring ) { + if ( 'G' == $dateformatstring ) return strtotime( $m . ' +0000' ); - } $i = strtotime( $m ); if ( 'U' == $dateformatstring ) return $i; - if ( $translate) - return date_i18n( $dateformatstring, $i ); + if ( $translate ) + return date_i18n( $dateformatstring, $i ); else - return date( $dateformatstring, $i ); + return date( $dateformatstring, $i ); } /** @@ -119,6 +118,23 @@ function date_i18n( $dateformatstring, $unixtimestamp = false, $gmt = false ) { $dateformatstring = substr( $dateformatstring, 1, strlen( $dateformatstring ) -1 ); } + $timezone_formats = array( 'P', 'I', 'O', 'T', 'Z', 'e' ); + $timezone_formats_re = implode( '|', $timezone_formats ); + if ( preg_match( "/$timezone_formats_re/", $dateformatstring ) && wp_timezone_supported() ) { + $timezone_string = get_option( 'timezone_string' ); + if ( $timezone_string ) { + $timezone_object = timezone_open( $timezone_string ); + $date_object = date_create( null, $timezone_object ); + foreach( $timezone_formats as $timezone_format ) { + if ( false !== strpos( $dateformatstring, $timezone_format ) ) { + $formatted = date_format( $date_object, $timezone_format ); + $dateformatstring = ' '.$dateformatstring; + $dateformatstring = preg_replace( "/([^\\\])$timezone_format/", "\\1" . backslashit( $formatted ), $dateformatstring ); + $dateformatstring = substr( $dateformatstring, 1, strlen( $dateformatstring ) -1 ); + } + } + } + } $j = @$datefunc( $dateformatstring, $i ); // allow plugins to redo this entirely for languages with untypical grammars $j = apply_filters('date_i18n', $j, $req_format, $i, $gmt); @@ -230,26 +246,31 @@ function maybe_unserialize( $original ) { */ function is_serialized( $data ) { // if it isn't a string, it isn't serialized - if ( !is_string( $data ) ) + if ( ! is_string( $data ) ) return false; $data = trim( $data ); - if ( 'N;' == $data ) + if ( 'N;' == $data ) return true; - if ( !preg_match( '/^([adObis]):/', $data, $badions ) ) + $length = strlen( $data ); + if ( $length < 4 ) + return false; + if ( ':' !== $data[1] ) + return false; + $lastc = $data[$length-1]; + if ( ';' !== $lastc && '}' !== $lastc ) return false; - switch ( $badions[1] ) { + $token = $data[0]; + switch ( $token ) { + case 's' : + if ( '"' !== $data[$length-2] ) + return false; case 'a' : case 'O' : - case 's' : - if ( preg_match( "/^{$badions[1]}:[0-9]+:.*[;}]\$/s", $data ) ) - return true; - break; + return (bool) preg_match( "/^{$token}:[0-9]+:/s", $data ); case 'b' : case 'i' : case 'd' : - if ( preg_match( "/^{$badions[1]}:[0-9.E-]+;\$/", $data ) ) - return true; - break; + return (bool) preg_match( "/^{$token}:[0-9.E-]+;\$/", $data ); } return false; } @@ -412,10 +433,11 @@ function wp_load_alloptions() { $alloptions_db = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options" ); $wpdb->suppress_errors($suppress); $alloptions = array(); - foreach ( (array) $alloptions_db as $o ) + foreach ( (array) $alloptions_db as $o ) { $alloptions[$o->option_name] = $o->option_value; - if ( !defined( 'WP_INSTALLING' ) || !is_multisite() ) - wp_cache_add( 'alloptions', $alloptions, 'options' ); + } + if ( !defined( 'WP_INSTALLING' ) || !is_multisite() ) + wp_cache_add( 'alloptions', $alloptions, 'options' ); } return $alloptions; @@ -439,7 +461,7 @@ function wp_load_core_site_options( $site_id = null ) { if ( empty($site_id) ) $site_id = $wpdb->siteid; - $core_options = array('site_name', 'siteurl', 'active_sitewide_plugins', '_site_transient_timeout_theme_roots', '_site_transient_theme_roots', 'site_admins', 'dashboard_blog', 'can_compress_scripts', 'global_terms_enabled' ); + $core_options = array('site_name', 'siteurl', 'active_sitewide_plugins', '_site_transient_timeout_theme_roots', '_site_transient_theme_roots', 'site_admins', 'can_compress_scripts', 'global_terms_enabled' ); $core_options_in = "'" . implode("', '", $core_options) . "'"; $options = $wpdb->get_results( $wpdb->prepare("SELECT meta_key, meta_value FROM $wpdb->sitemeta WHERE meta_key IN ($core_options_in) AND site_id = %d", $site_id) ); @@ -546,7 +568,6 @@ function update_option( $option, $newvalue ) { * @package WordPress * @subpackage Option * @since 1.0.0 - * @link http://alex.vort-x.net/blog/ Thanks Alex Stapleton * * @uses do_action() Calls 'add_option' hook before adding the option. * @uses do_action() Calls 'add_option_$option' and 'added_option' hooks on success. @@ -670,7 +691,7 @@ function delete_option( $option ) { function delete_transient( $transient ) { global $_wp_using_ext_object_cache; - do_action( 'delete_transient_' . $transient, $transient ); + do_action( 'delete_transient_' . $transient, $transient ); if ( $_wp_using_ext_object_cache ) { $result = wp_cache_delete( $transient, 'transient' ); @@ -758,7 +779,7 @@ function get_transient( $transient ) { function set_transient( $transient, $value, $expiration = 0 ) { global $_wp_using_ext_object_cache; - $value = apply_filters( 'pre_set_transient_' . $transient, $value ); + $value = apply_filters( 'pre_set_transient_' . $transient, $value ); if ( $_wp_using_ext_object_cache ) { $result = wp_cache_set( $transient, $value, 'transient', $expiration ); @@ -1163,6 +1184,8 @@ function debug_fclose( $fp ) { */ function do_enclose( $content, $post_ID ) { global $wpdb; + + //TODO: Tidy this ghetto code up and make the debug code optional include_once( ABSPATH . WPINC . '/class-IXR.php' ); $log = debug_fopen( ABSPATH . 'enclosures.log', 'a' ); @@ -1183,7 +1206,7 @@ function do_enclose( $content, $post_ID ) { foreach ( $pung as $link_test ) { if ( !in_array( $link_test, $post_links_temp[0] ) ) { // link no longer in post - $mid = $wpdb->get_col( $wpdb->prepare("SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE (%s)", $post_ID, $link_test . '%') ); + $mid = $wpdb->get_col( $wpdb->prepare("SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE (%s)", $post_ID, like_escape( $link_test ) . '%') ); do_action( 'delete_postmeta', $mid ); $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->postmeta WHERE meta_id IN(%s)", implode( ',', $mid ) ) ); do_action( 'deleted_postmeta', $mid ); @@ -1197,13 +1220,13 @@ function do_enclose( $content, $post_ID ) { continue; if ( isset( $test['query'] ) ) $post_links[] = $link_test; - elseif ( $test['path'] != '/' && $test['path'] != '' ) + elseif ( isset($test['path']) && ( $test['path'] != '/' ) && ($test['path'] != '' ) ) $post_links[] = $link_test; } } foreach ( (array) $post_links as $url ) { - if ( $url != '' && !$wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE (%s)", $post_ID, $url . '%' ) ) ) { + if ( $url != '' && !$wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE (%s)", $post_ID, like_escape( $url ) . '%' ) ) ) { if ( $headers = wp_get_http_headers( $url) ) { $len = (int) $headers['content-length']; @@ -1321,8 +1344,8 @@ function wp_get_http_headers( $url, $deprecated = false ) { * @return int 1 when new day, 0 if not a new day. */ function is_new_day() { - global $day, $previousday; - if ( $day != $previousday ) + global $currentday, $previousday; + if ( $currentday != $previousday ) return 1; else return 0; @@ -1619,7 +1642,7 @@ function status_header( $header ) { * The several different headers cover the different ways cache prevention is handled * by different browsers * - * @since 2.8 + * @since 2.8.0 * * @uses apply_filters() * @return array The associative array of header names and field values. @@ -1633,7 +1656,7 @@ function wp_get_nocache_headers() { ); if ( function_exists('apply_filters') ) { - $headers = apply_filters('nocache_headers', $headers); + $headers = (array) apply_filters('nocache_headers', $headers); } return $headers; } @@ -1649,7 +1672,7 @@ function wp_get_nocache_headers() { */ function nocache_headers() { $headers = wp_get_nocache_headers(); - foreach( (array) $headers as $name => $field_value ) + foreach( $headers as $name => $field_value ) @header("{$name}: {$field_value}"); } @@ -2058,7 +2081,7 @@ function path_is_absolute( $path ) { if ( realpath($path) == $path ) return true; - if ( strlen($path) == 0 || $path{0} == '.' ) + if ( strlen($path) == 0 || $path[0] == '.' ) return false; // windows allows absolute paths like this @@ -2190,14 +2213,14 @@ function wp_upload_dir( $time = null ) { * before the extension, and will continue adding numbers until the filename is * unique. * - * The callback must accept two parameters, the first one is the directory and - * the second is the filename. The callback must be a function. + * The callback is passed three parameters, the first one is the directory, the + * second is the filename, and the third is the extension. * - * @since 2.5 + * @since 2.5.0 * * @param string $dir * @param string $filename - * @param string $unique_filename_callback Function name, must be a function. + * @param mixed $unique_filename_callback Callback. * @return string New filename, if given wasn't unique. */ function wp_unique_filename( $dir, $filename, $unique_filename_callback = null ) { @@ -2213,9 +2236,9 @@ function wp_unique_filename( $dir, $filename, $unique_filename_callback = null ) if ( $name === $ext ) $name = ''; - // Increment the file number until we have a unique file to save in $dir. Use $override['unique_filename_callback'] if supplied. + // Increment the file number until we have a unique file to save in $dir. Use callback if supplied. if ( $unique_filename_callback && is_callable( $unique_filename_callback ) ) { - $filename = $unique_filename_callback( $dir, $name ); + $filename = call_user_func( $unique_filename_callback, $dir, $name, $ext ); } else { $number = ''; @@ -2573,7 +2596,7 @@ function wp_explain_nonce( $action ) { $trans['edit']['plugin'] = array( __( 'Your attempt to edit this plugin file: “%s” has failed.' ), 'use_id' ); $trans['activate']['plugin'] = array( __( 'Your attempt to activate this plugin: “%s” has failed.' ), 'use_id' ); $trans['deactivate']['plugin'] = array( __( 'Your attempt to deactivate this plugin: “%s” has failed.' ), 'use_id' ); - $trans['upgrade']['plugin'] = array( __( 'Your attempt to upgrade this plugin: “%s” has failed.' ), 'use_id' ); + $trans['upgrade']['plugin'] = array( __( 'Your attempt to update this plugin: “%s” has failed.' ), 'use_id' ); $trans['add']['post'] = array( __( 'Your attempt to add this post has failed.' ), false ); $trans['delete']['post'] = array( __( 'Your attempt to delete this post: “%s” has failed.' ), 'get_the_title' ); @@ -2657,9 +2680,12 @@ function wp_nonce_ays( $action ) { * @param string|array $args Optional arguements to control behaviour. */ function wp_die( $message, $title = '', $args = array() ) { + if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) + die('-1'); + if ( function_exists( 'apply_filters' ) ) { $function = apply_filters( 'wp_die_handler', '_default_wp_die_handler'); - }else { + } else { $function = '_default_wp_die_handler'; } @@ -2739,7 +2765,7 @@ function _default_wp_die_handler( $message, $title = '', $args = array() ) { ?> -> +> <?php echo $title ?> @@ -2977,6 +3003,24 @@ function wp_parse_id_list( $list ) { return array_unique(array_map('absint', $list)); } +/** + * Extract a slice of an array, given a list of keys + * + * @since 3.1.0 + * + * @param array $array The original array + * @param array $keys The list of keys + * @return array The array slice + */ +function wp_array_slice_assoc( $array, $keys ) { + $slice = array(); + foreach ( $keys as $key ) + if ( isset( $array[ $key ] ) ) + $slice[ $key ] = $array[ $key ]; + + return $slice; +} + /** * Filters a list of objects, based on a set of key => value arguments * @@ -2990,32 +3034,72 @@ function wp_parse_id_list( $list ) { * @return array A list of objects or object fields */ function wp_filter_object_list( $list, $args = array(), $operator = 'and', $field = false ) { - if ( !is_array($list) ) + if ( ! is_array( $list ) ) return array(); - if ( empty($args) ) - $args = array(); + $list = wp_list_filter( $list, $args, $operator ); - if ( empty($args) && !$field ) - return $list; // nothing to do + if ( $field ) + $list = wp_list_pluck( $list, $field ); - $count = count($args); + return $list; +} +/** + * Filters a list of objects, based on a set of key => value arguments + * + * @since 3.1.0 + * + * @param array $list An array of objects to filter + * @param array $args An array of key => value arguments to match against each object + * @param string $operator The logical operation to perform: + * 'AND' means all elements from the array must match; + * 'OR' means only one element needs to match; + * 'NOT' means no elements may match. + * The default is 'AND'. + * @return array + */ +function wp_list_filter( $list, $args = array(), $operator = 'AND' ) { + if ( ! is_array( $list ) ) + return array(); + + if ( empty( $args ) ) + return $list; + + $operator = strtoupper( $operator ); + $count = count( $args ); $filtered = array(); foreach ( $list as $key => $obj ) { - $matched = count(array_intersect_assoc(get_object_vars($obj), $args)); - if ( ('and' == $operator && $matched == $count) || ('or' == $operator && $matched <= $count) ) { - if ( $field ) - $filtered[] = $obj->$field; - else - $filtered[$key] = $obj; + $matched = count( array_intersect_assoc( (array) $obj, $args ) ); + if ( ( 'AND' == $operator && $matched == $count ) + || ( 'OR' == $operator && $matched <= $count ) + || ( 'NOT' == $operator && 0 == $matched ) ) { + $filtered[$key] = $obj; } } return $filtered; } +/** + * Pluck a certain field out of each object in a list + * + * @since 3.1.0 + * + * @param array $list A list of objects or arrays + * @param int|string $field A field from the object to place instead of the entire object + * @return array + */ +function wp_list_pluck( $list, $field ) { + foreach ( $list as $key => $value ) { + $value = (array) $value; + $list[ $key ] = $value[ $field ]; + } + + return $list; +} + /** * Determines if default embed handlers should be loaded. * @@ -3071,24 +3155,6 @@ function wp_ob_end_flush_all() { ob_end_flush(); } -/** - * Load the correct database class file. - * - * This function is used to load the database class file either at runtime or by - * wp-admin/setup-config.php We must globalise $wpdb to ensure that it is - * defined globally by the inline code in wp-db.php. - * - * @since 2.5.0 - * @global $wpdb WordPress Database Object - */ -function require_wp_db() { - global $wpdb; - if ( file_exists( WP_CONTENT_DIR . '/db.php' ) ) - require_once( WP_CONTENT_DIR . '/db.php' ); - else - require_once( ABSPATH . WPINC . '/wp-db.php' ); -} - /** * Load custom DB error or display WordPress DB error. * @@ -3209,9 +3275,9 @@ function atom_service_url_filter($url) * to get the backtrace up to what file and function called the deprecated * function. * - * The current behavior is to trigger an user error if WP_DEBUG is true. + * The current behavior is to trigger a user error if WP_DEBUG is true. * - * This function is to be used in every function in depreceated.php + * This function is to be used in every function that is deprecated. * * @package WordPress * @subpackage Debug @@ -3247,9 +3313,9 @@ function _deprecated_function( $function, $version, $replacement=null ) { * to get the backtrace up to what file and function included the deprecated * file. * - * The current behavior is to trigger an user error if WP_DEBUG is true. + * The current behavior is to trigger a user error if WP_DEBUG is true. * - * This function is to be used in every file that is depreceated + * This function is to be used in every file that is deprecated. * * @package WordPress * @subpackage Debug @@ -3295,7 +3361,7 @@ function _deprecated_file( $file, $version, $replacement = null, $message = '' ) * to get the backtrace up to what file and function used the deprecated * argument. * - * The current behavior is to trigger an user error if WP_DEBUG is true. + * The current behavior is to trigger a user error if WP_DEBUG is true. * * @package WordPress * @subpackage Debug @@ -3324,6 +3390,39 @@ function _deprecated_argument( $function, $version, $message = null ) { } } +/** + * Marks something as being incorrectly called. + * + * There is a hook doing_it_wrong_run that will be called that can be used + * to get the backtrace up to what file and function called the deprecated + * function. + * + * The current behavior is to trigger a user error if WP_DEBUG is true. + * + * @package WordPress + * @subpackage Debug + * @since 3.1.0 + * @access private + * + * @uses do_action() Calls 'doing_it_wrong_run' and passes the function arguments. + * @uses apply_filters() Calls 'doing_it_wrong_trigger_error' and expects boolean value of true to do + * trigger or false to not trigger error. + * + * @param string $function The function that was called. + * @param string $message A message explaining what has been done incorrectly. + * @param string $version The version of WordPress where the message was added. + */ +function _doing_it_wrong( $function, $message, $version ) { + + do_action( 'doing_it_wrong_run', $function, $message, $version ); + + // Allow plugin to filter the output error trigger + if ( WP_DEBUG && apply_filters( 'doing_it_wrong_trigger_error', true ) ) { + $version = is_null( $version ) ? '' : sprintf( __( '(This message was added in version %s.)' ), $version ); + trigger_error( sprintf( __( '%1$s was called incorrectly. %2$s %3$s' ), $function, $message, $version ) ); + } +} + /** * Is the server running earlier than 1.5.0 version of lighttpd * @@ -3366,6 +3465,34 @@ function apache_mod_loaded($mod, $default = false) { return $default; } +/** + * Check if IIS 7 supports pretty permalinks + * + * @since 2.8.0 + * + * @return bool + */ +function iis7_supports_permalinks() { + global $is_iis7; + + $supports_permalinks = false; + if ( $is_iis7 ) { + /* First we check if the DOMDocument class exists. If it does not exist, + * which is the case for PHP 4.X, then we cannot easily update the xml configuration file, + * hence we just bail out and tell user that pretty permalinks cannot be used. + * This is not a big issue because PHP 4.X is going to be depricated and for IIS it + * is recommended to use PHP 5.X NTS. + * Next we check if the URL Rewrite Module 1.1 is loaded and enabled for the web site. When + * URL Rewrite 1.1 is loaded it always sets a server variable called 'IIS_UrlRewriteModule'. + * Lastly we make sure that PHP is running via FastCGI. This is important because if it runs + * via ISAPI then pretty permalinks will not work. + */ + $supports_permalinks = class_exists('DOMDocument') && isset($_SERVER['IIS_UrlRewriteModule']) && ( php_sapi_name() == 'cgi-fcgi' ); + } + + return apply_filters('iis7_supports_permalinks', $supports_permalinks); +} + /** * File validates against allowed set of defined rules. * @@ -3472,7 +3599,7 @@ function wp_guess_url() { $schema = is_ssl() ? 'https://' : 'http://'; $url = preg_replace('|/wp-admin/.*|i', '', $schema . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); } - return $url; + return rtrim($url, '/'); } /** @@ -3785,7 +3912,7 @@ function get_site_transient( $transient ) { function set_site_transient( $transient, $value, $expiration = 0 ) { global $_wp_using_ext_object_cache; - $value = apply_filters( 'pre_set_site_transient_' . $transient, $value ); + $value = apply_filters( 'pre_set_site_transient_' . $transient, $value ); if ( $_wp_using_ext_object_cache ) { $result = wp_cache_set( $transient, $value, 'site-transient', $expiration ); @@ -4136,29 +4263,21 @@ function wp_scheduled_delete() { } /** - * Parse the file contents to retrieve its metadata. - * - * Searches for metadata for a file, such as a plugin or theme. Each piece of - * metadata must be on its own line. For a field spanning multple lines, it - * must not have any newlines or only parts of it will be displayed. + * Retrieve metadata from a file. * - * Some users have issues with opening large files and manipulating the contents - * for want is usually the first 1kiB or 2kiB. This function stops pulling in - * the file contents when it has all of the required data. + * Searches for metadata in the first 8kiB of a file, such as a plugin or theme. + * Each piece of metadata must be on its own line. Fields can not span multple + * lines, the value will get cut at the end of the first line. * - * The first 8kiB of the file will be pulled in and if the file data is not - * within that first 8kiB, then the author should correct their plugin file - * and move the data headers to the top. + * If the file data is not within that first 8kiB, then the author should correct + * their plugin file and move the data headers to the top. * - * The file is assumed to have permissions to allow for scripts to read - * the file. This is not checked however and the file is only opened for - * reading. + * @see http://codex.wordpress.org/File_Header * * @since 2.9.0 - * * @param string $file Path to the file - * @param bool $markup If the returned data should have HTML markup applied - * @param string $context If specified adds filter hook "extra_<$context>_headers" + * @param array $default_headers List of headers, in the format array('HeaderKey' => 'Header Name') + * @param string $context If specified adds filter hook "extra_{$context}_headers" */ function get_file_data( $file, $default_headers, $context = '' ) { // We don't need to write to the file, so just open for reading. @@ -4171,20 +4290,19 @@ function get_file_data( $file, $default_headers, $context = '' ) { fclose( $fp ); if ( $context != '' ) { - $extra_headers = apply_filters( "extra_$context".'_headers', array() ); + $extra_headers = apply_filters( "extra_{$context}_headers", array() ); $extra_headers = array_flip( $extra_headers ); foreach( $extra_headers as $key=>$value ) { $extra_headers[$key] = $key; } - $all_headers = array_merge($extra_headers, $default_headers); + $all_headers = array_merge( $extra_headers, (array) $default_headers ); } else { $all_headers = $default_headers; } - foreach ( $all_headers as $field => $regex ) { - preg_match( '/' . preg_quote( $regex, '/' ) . ':(.*)$/mi', $file_data, ${$field}); + preg_match( '/^[ \t\/*#]*' . preg_quote( $regex, '/' ) . ':(.*)$/mi', $file_data, ${$field}); if ( !empty( ${$field} ) ) ${$field} = _cleanup_header_comment( ${$field}[1] ); else @@ -4195,7 +4313,8 @@ function get_file_data( $file, $default_headers, $context = '' ) { return $file_data; } -/* + +/** * Used internally to tidy up the search terms * * @access private @@ -4297,4 +4416,70 @@ function _wp_mysql_week( $column ) { } } +/** + * Finds hierarchy loops using a callback function that maps object IDs to parent IDs. + * + * @since 3.1.0 + * @access private + * + * @param callback $callback function that accepts ( ID, $callback_args ) and outputs parent_ID + * @param int $start The ID to start the loop check at + * @param int $start_parent the parent_ID of $start to use instead of calling $callback( $start ). Use null to always use $callback + * @param array $callback_args optional additional arguments to send to $callback + * @return array IDs of all members of loop + */ +function wp_find_hierarchy_loop( $callback, $start, $start_parent, $callback_args = array() ) { + $override = is_null( $start_parent ) ? array() : array( $start => $start_parent ); + + if ( !$arbitrary_loop_member = wp_find_hierarchy_loop_tortoise_hare( $callback, $start, $override, $callback_args ) ) + return array(); + + return wp_find_hierarchy_loop_tortoise_hare( $callback, $arbitrary_loop_member, $override, $callback_args, true ); +} + +/** + * Uses the "The Tortoise and the Hare" algorithm to detect loops. + * + * For every step of the algorithm, the hare takes two steps and the tortoise one. + * If the hare ever laps the tortoise, there must be a loop. + * + * @since 3.1.0 + * @access private + * + * @param callback $callback function that accupts ( ID, callback_arg, ... ) and outputs parent_ID + * @param int $start The ID to start the loop check at + * @param array $override an array of ( ID => parent_ID, ... ) to use instead of $callback + * @param array $callback_args optional additional arguments to send to $callback + * @param bool $_return_loop Return loop members or just detect presence of loop? + * Only set to true if you already know the given $start is part of a loop + * (otherwise the returned array might include branches) + * @return mixed scalar ID of some arbitrary member of the loop, or array of IDs of all members of loop if $_return_loop + */ +function wp_find_hierarchy_loop_tortoise_hare( $callback, $start, $override = array(), $callback_args = array(), $_return_loop = false ) { + $tortoise = $hare = $evanescent_hare = $start; + $return = array(); + + // Set evanescent_hare to one past hare + // Increment hare two steps + while ( + $tortoise + && + ( $evanescent_hare = isset( $override[$hare] ) ? $override[$hare] : call_user_func_array( $callback, array_merge( array( $hare ), $callback_args ) ) ) + && + ( $hare = isset( $override[$evanescent_hare] ) ? $override[$evanescent_hare] : call_user_func_array( $callback, array_merge( array( $evanescent_hare ), $callback_args ) ) ) + ) { + if ( $_return_loop ) + $return[$tortoise] = $return[$evanescent_hare] = $return[$hare] = true; + + // tortoise got lapped - must be a loop + if ( $tortoise == $evanescent_hare || $tortoise == $hare ) + return $_return_loop ? $return : $tortoise; + + // Increment tortoise by one step + $tortoise = isset( $override[$tortoise] ) ? $override[$tortoise] : call_user_func_array( $callback, array_merge( array( $tortoise ), $callback_args ) ); + } + + return false; +} + ?> diff --git a/wp-includes/functions.wp-scripts.php b/wp-includes/functions.wp-scripts.php index f284435e..af2055d3 100644 --- a/wp-includes/functions.wp-scripts.php +++ b/wp-includes/functions.wp-scripts.php @@ -42,7 +42,7 @@ function wp_print_scripts( $handles = false ) { * @param string $src Script url * @param array $deps (optional) Array of script names on which this script depends * @param string|bool $ver (optional) Script version (used for cache busting), set to NULL to disable - * @param bool (optional) Wether to enqueue the script before or before + * @param bool $in_footer (optional) Whether to enqueue the script before or before * @return null */ function wp_register_script( $handle, $src, $deps = array(), $ver = false, $in_footer = false ) { @@ -107,6 +107,20 @@ function wp_enqueue_script( $handle, $src = false, $deps = array(), $ver = false $wp_scripts->enqueue( $handle ); } +/** + * Remove an enqueued script. + * + * @since WP 3.1 + * @see WP_Scripts::dequeue() For parameter information. + */ +function wp_dequeue_script( $handle ) { + global $wp_scripts; + if ( !is_a($wp_scripts, 'WP_Scripts') ) + $wp_scripts = new WP_Scripts(); + + $wp_scripts->dequeue( $handle ); +} + /** * Check whether script has been added to WordPress Scripts. * diff --git a/wp-includes/functions.wp-styles.php b/wp-includes/functions.wp-styles.php index df4bd5ac..630a112d 100644 --- a/wp-includes/functions.wp-styles.php +++ b/wp-includes/functions.wp-styles.php @@ -105,6 +105,20 @@ function wp_enqueue_style( $handle, $src = false, $deps = array(), $ver = false, $wp_styles->enqueue( $handle ); } +/** + * Remove an enqueued style. + * + * @since WP 3.1 + * @see WP_Styles::dequeue() For parameter information. + */ +function wp_dequeue_style( $handle ) { + global $wp_styles; + if ( !is_a($wp_styles, 'WP_Styles') ) + $wp_styles = new WP_Styles(); + + $wp_styles->dequeue( $handle ); +} + /** * Check whether style has been added to WordPress Styles. * diff --git a/wp-includes/general-template.php b/wp-includes/general-template.php index 333d2642..19194f2f 100644 --- a/wp-includes/general-template.php +++ b/wp-includes/general-template.php @@ -151,7 +151,7 @@ function get_template_part( $slug, $name = null ) { function get_search_form($echo = true) { do_action( 'get_search_form' ); - $search_form_template = locate_template(array('searchform.php')); + $search_form_template = locate_template('searchform.php'); if ( '' != $search_form_template ) { require($search_form_template); return; @@ -199,7 +199,7 @@ function wp_loginout($redirect = '', $echo = true) { * * Returns the URL that allows the user to log out of the site * - * @since 2.7 + * @since 2.7.0 * @uses wp_nonce_url() To protect against CSRF * @uses site_url() To generate the log in URL * @uses apply_filters() calls 'logout_url' hook on final logout url @@ -223,7 +223,7 @@ function wp_logout_url($redirect = '') { * * Returns the URL that allows the user to log in to the site * - * @since 2.7 + * @since 2.7.0 * @uses site_url() To generate the log in URL * @uses apply_filters() calls 'login_url' hook on final login url * @@ -271,7 +271,7 @@ function wp_login_form( $args = array() ) { $form = '
        - ' . apply_filters( 'login_form_top', '' ) . ' + ' . apply_filters( 'login_form_top', '', $args ) . ' - ' . apply_filters( 'login_form_middle', '' ) . ' + ' . apply_filters( 'login_form_middle', '', $args ) . ' ' . ( $args['remember'] ? '' : '' ) . ' - ' . apply_filters( 'login_form_bottom', '' ) . ' + ' . apply_filters( 'login_form_bottom', '', $args ) . '
        '; if ( $args['echo'] ) @@ -381,7 +381,7 @@ function bloginfo( $show='' ) { * * The possible values for the 'show' parameter are listed below. *
          - *
        1. url - Blog URI to homepage.
        2. + *
        3. url - Blog URI to homepage.
        4. *
        5. wpurl - Blog URI path to WordPress.
        6. *
        7. description - Secondary title
        8. *
        @@ -491,6 +491,18 @@ function get_bloginfo( $show = '', $filter = 'raw' ) { return $output; } +/** + * Retrieve the current blog id + * + * @since 3.1.0 + * + * @return int Blog id + */ +function get_current_blog_id() { + global $blog_id; + return absint($blog_id); +} + /** * Display or retrieve page title for all areas of blog. * @@ -514,13 +526,8 @@ function get_bloginfo( $show = '', $filter = 'raw' ) { * @return string|null String on retrieve, null when displaying. */ function wp_title($sep = '»', $display = true, $seplocation = '') { - global $wpdb, $wp_locale, $wp_query; + global $wpdb, $wp_locale; - $cat = get_query_var('cat'); - $tag = get_query_var('tag_id'); - $category_name = get_query_var('category_name'); - $author = get_query_var('author'); - $author_name = get_query_var('author_name'); $m = get_query_var('m'); $year = get_query_var('year'); $monthnum = get_query_var('monthnum'); @@ -530,51 +537,43 @@ function wp_title($sep = '»', $display = true, $seplocation = '') { $t_sep = '%WP_TITILE_SEP%'; // Temporary separator, for accurate flipping, if necessary - // If there's a category - if ( !empty($cat) ) { - // category exclusion - if ( !stristr($cat,'-') ) - $title = apply_filters('single_cat_title', get_the_category_by_ID($cat)); - } elseif ( !empty($category_name) ) { - if ( stristr($category_name,'/') ) { - $category_name = explode('/',$category_name); - if ( $category_name[count($category_name)-1] ) - $category_name = $category_name[count($category_name)-1]; // no trailing slash - else - $category_name = $category_name[count($category_name)-2]; // there was a trailling slash - } - $cat = get_term_by('slug', $category_name, 'category', OBJECT, 'display'); - if ( $cat ) - $title = apply_filters('single_cat_title', $cat->name); + // If there is a post + if ( is_single() || ( is_home() && !is_front_page() ) || ( is_page() && !is_front_page() ) ) { + $title = single_post_title( '', false ); } - if ( !empty($tag) ) { - $tag = get_term($tag, 'post_tag', OBJECT, 'display'); - if ( is_wp_error( $tag ) ) - return $tag; - if ( ! empty($tag->name) ) - $title = apply_filters('single_tag_title', $tag->name); + // If there's a category or tag + if ( is_category() || is_tag() ) { + $title = single_term_title( '', false ); } - // If there's an author - if ( !empty($author) ) { - $title = get_userdata($author); - $title = $title->display_name; + // If there's a taxonomy + if ( is_tax() ) { + $term = get_queried_object(); + $tax = get_taxonomy( $term->taxonomy ); + $title = single_term_title( $tax->labels->name . $t_sep, false ); } - if ( !empty($author_name) ) { - // We do a direct query here because we don't cache by nicename. - $title = $wpdb->get_var($wpdb->prepare("SELECT display_name FROM $wpdb->users WHERE user_nicename = %s", $author_name)); + + // If there's an author + if ( is_author() ) { + $author = get_queried_object(); + $title = $author->display_name; } + // If there's a post type archive + if ( is_post_type_archive() ) + $title = post_type_archive_title( '', false ); + // If there's a month - if ( !empty($m) ) { + if ( is_archive() && !empty($m) ) { $my_year = substr($m, 0, 4); $my_month = $wp_locale->get_month(substr($m, 4, 2)); $my_day = intval(substr($m, 6, 2)); $title = $my_year . ($my_month ? $t_sep . $my_month : "") . ($my_day ? $t_sep . $my_day : ""); } - if ( !empty($year) ) { + // If there's a year + if ( is_archive() && !empty($year) ) { $title = $year; if ( !empty($monthnum) ) $title .= $t_sep . $wp_locale->get_month($monthnum); @@ -582,27 +581,13 @@ function wp_title($sep = '»', $display = true, $seplocation = '') { $title .= $t_sep . zeroise($day, 2); } - // If there is a post - if ( is_single() || ( is_home() && !is_front_page() ) || ( is_page() && !is_front_page() ) ) { - $post = $wp_query->get_queried_object(); - $title = apply_filters( 'single_post_title', $post->post_title ); - } - - // If there's a taxonomy - if ( is_tax() ) { - $taxonomy = get_query_var( 'taxonomy' ); - $tax = get_taxonomy( $taxonomy ); - $term = $wp_query->get_queried_object(); - $term = $term->name; - $title = $tax->labels->name . $t_sep . $term; - } - - //If it's a search + // If it's a search if ( is_search() ) { /* translators: 1: separator, 2: search phrase */ $title = sprintf(__('Search Results %1$s %2$s'), $t_sep, strip_tags($search)); } + // If it's a 404 page if ( is_404() ) { $title = __('Page not found'); } @@ -635,7 +620,6 @@ function wp_title($sep = '»', $display = true, $seplocation = '') { * Display or retrieve page title for post. * * This is optimized for single.php template file for displaying the post title. - * Only useful for posts, does not support pages for example. * * It does not support placing the separator after the title, but by leaving the * prefix parameter empty, you can set the title separator manually. The prefix @@ -643,19 +627,13 @@ function wp_title($sep = '»', $display = true, $seplocation = '') { * be a space, the parameter value will need to have it at the end. * * @since 0.71 - * @uses $wpdb * * @param string $prefix Optional. What to display before the title. * @param bool $display Optional, default is true. Whether to display or retrieve title. * @return string|null Title when retrieving, null when displaying or failure. */ function single_post_title($prefix = '', $display = true) { - global $wp_query, $post; - - if ( ! $post ) - $_post = $wp_query->get_queried_object(); - else - $_post = $post; + $_post = get_queried_object(); if ( !isset($_post->post_title) ) return; @@ -667,6 +645,31 @@ function single_post_title($prefix = '', $display = true) { return $title; } +/** + * Display or retrieve title for a post type archive. + * + * This is optimized for archive.php and archive-{$post_type}.php template files + * for displaying the title of the post type. + * + * @since 3.1.0 + * + * @param string $prefix Optional. What to display before the title. + * @param bool $display Optional, default is true. Whether to display or retrieve title. + * @return string|null Title when retrieving, null when displaying or failure. + */ +function post_type_archive_title( $prefix = '', $display = true ) { + if ( ! is_post_type_archive() ) + return; + + $post_type_obj = get_queried_object(); + $title = apply_filters('post_type_archive_title', $post_type_obj->labels->name ); + + if ( $display ) + echo $prefix . $title; + else + return $title; +} + /** * Display or retrieve page title for category archive. * @@ -684,23 +687,8 @@ function single_post_title($prefix = '', $display = true) { * @param bool $display Optional, default is true. Whether to display or retrieve title. * @return string|null Title when retrieving, null when displaying or failure. */ -function single_cat_title($prefix = '', $display = true ) { - global $wp_query; - - if ( is_tag() ) - return single_tag_title($prefix, $display); - - if ( !is_category() ) - return; - - $cat = $wp_query->get_queried_object(); - $my_cat_name = apply_filters('single_cat_title', $cat->name); - if ( !empty($my_cat_name) ) { - if ( $display ) - echo $prefix . $my_cat_name; - else - return $my_cat_name; - } +function single_cat_title( $prefix = '', $display = true ) { + return single_term_title( $prefix, $display ); } /** @@ -720,23 +708,49 @@ function single_cat_title($prefix = '', $display = true ) { * @param bool $display Optional, default is true. Whether to display or retrieve title. * @return string|null Title when retrieving, null when displaying or failure. */ -function single_tag_title($prefix = '', $display = true ) { - global $wp_query; - if ( !is_tag() ) +function single_tag_title( $prefix = '', $display = true ) { + return single_term_title( $prefix, $display ); +} + +/** + * Display or retrieve page title for taxonomy term archive. + * + * Useful for taxonomy term template files for displaying the taxonomy term page title. + * It has less overhead than {@link wp_title()}, because of its limited implementation. + * + * It does not support placing the separator after the title, but by leaving the + * prefix parameter empty, you can set the title separator manually. The prefix + * does not automatically place a space between the prefix, so if there should + * be a space, the parameter value will need to have it at the end. + * + * @since 3.1.0 + * + * @param string $prefix Optional. What to display before the title. + * @param bool $display Optional, default is true. Whether to display or retrieve title. + * @return string|null Title when retrieving, null when displaying or failure. + */ +function single_term_title( $prefix = '', $display = true ) { + $term = get_queried_object(); + + if ( !$term ) return; - $tag = $wp_query->get_queried_object(); + if ( is_category() ) + $term_name = apply_filters( 'single_cat_title', $term->name ); + elseif ( is_tag() ) + $term_name = apply_filters( 'single_tag_title', $term->name ); + elseif ( is_tax() ) + $term_name = apply_filters( 'single_term_title', $term->name ); + else + return; - if ( ! $tag ) + if ( empty( $term_name ) ) return; - $my_tag_name = apply_filters('single_tag_title', $tag->name); - if ( !empty($my_tag_name) ) { - if ( $display ) - echo $prefix . $my_tag_name; - else - return $my_tag_name; - } + if ( $display ) + echo $prefix . $term_name; + else + return $term_name; } /** @@ -1101,7 +1115,7 @@ function get_calendar($initial = true, $echo = true) { // We need to get the month from MySQL $thisyear = ''.intval(substr($m, 0, 4)); $d = (($w - 1) * 7) + 6; //it seems MySQL's weeks disagree with PHP's - $thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('${thisyear}0101', INTERVAL $d DAY) ), '%m')"); + $thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('{$thisyear}0101', INTERVAL $d DAY) ), '%m')"); } elseif ( !empty($m) ) { $thisyear = ''.intval(substr($m, 0, 4)); if ( strlen($m) < 6 ) @@ -1114,20 +1128,20 @@ function get_calendar($initial = true, $echo = true) { } $unixmonth = mktime(0, 0 , 0, $thismonth, 1, $thisyear); + $last_day = date('t', $unixmonth); // Get the next and previous month and year with at least one post - $previous = $wpdb->get_row("SELECT DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year + $previous = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year FROM $wpdb->posts WHERE post_date < '$thisyear-$thismonth-01' AND post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC LIMIT 1"); - $next = $wpdb->get_row("SELECT DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year + $next = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year FROM $wpdb->posts - WHERE post_date > '$thisyear-$thismonth-01' - AND MONTH( post_date ) != MONTH( '$thisyear-$thismonth-01' ) + WHERE post_date > '$thisyear-$thismonth-{$last_day} 23:59:59' AND post_type = 'post' AND post_status = 'publish' - ORDER BY post_date ASC + ORDER BY post_date ASC LIMIT 1"); /* translators: Calendar caption: 1: month name, 2: 4-digit year */ @@ -1157,7 +1171,7 @@ function get_calendar($initial = true, $echo = true) { '; if ( $previous ) { - $calendar_output .= "\n\t\t".'« ' . $wp_locale->get_month_abbrev($wp_locale->get_month($previous->month)) . ''; + $calendar_output .= "\n\t\t".'« ' . $wp_locale->get_month_abbrev($wp_locale->get_month($previous->month)) . ''; } else { $calendar_output .= "\n\t\t".' '; } @@ -1179,10 +1193,9 @@ function get_calendar($initial = true, $echo = true) { // Get days with posts $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date) - FROM $wpdb->posts WHERE MONTH(post_date) = '$thismonth' - AND YEAR(post_date) = '$thisyear' + FROM $wpdb->posts WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00' AND post_type = 'post' AND post_status = 'publish' - AND post_date < '" . current_time('mysql') . '\'', ARRAY_N); + AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59'", ARRAY_N); if ( $dayswithposts ) { foreach ( (array) $dayswithposts as $daywith ) { $daywithpost[] = $daywith[0]; @@ -1199,9 +1212,8 @@ function get_calendar($initial = true, $echo = true) { $ak_titles_for_day = array(); $ak_post_titles = $wpdb->get_results("SELECT ID, post_title, DAYOFMONTH(post_date) as dom " ."FROM $wpdb->posts " - ."WHERE YEAR(post_date) = '$thisyear' " - ."AND MONTH(post_date) = '$thismonth' " - ."AND post_date < '".current_time('mysql')."' " + ."WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00' " + ."AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59' " ."AND post_type = 'post' AND post_status = 'publish'" ); if ( $ak_post_titles ) { @@ -1318,7 +1330,7 @@ function the_date_xml() { * * Will only output the date if the current post's date is different from the * previous one output. - + * * i.e. Only one date listing will show per day worth of posts shown in the loop, even if the * function is called several times for each post. * @@ -1334,13 +1346,13 @@ function the_date_xml() { * @return string|null Null if displaying, string if retrieving. */ function the_date( $d = '', $before = '', $after = '', $echo = true ) { - global $day, $previousday; + global $currentday, $previousday; $the_date = ''; - if ( $day != $previousday ) { + if ( $currentday != $previousday ) { $the_date .= $before; $the_date .= get_the_date( $d ); $the_date .= $after; - $previousday = $day; + $previousday = $currentday; $the_date = apply_filters('the_date', $the_date, $d, $before, $after); @@ -1542,15 +1554,15 @@ function the_weekday() { * * @param string $before Optional Output before the date. * @param string $after Optional Output after the date. - */ + */ function the_weekday_date($before='',$after='') { global $wp_locale, $post, $day, $previousweekday; $the_weekday_date = ''; - if ( $day != $previousweekday ) { + if ( $currentday != $previousweekday ) { $the_weekday_date .= $before; $the_weekday_date .= $wp_locale->get_weekday(mysql2date('w', $post->post_date, false)); $the_weekday_date .= $after; - $previousweekday = $day; + $previousweekday = $currentday; } $the_weekday_date = apply_filters('the_weekday_date', $the_weekday_date, $before, $after); echo $the_weekday_date; @@ -1635,16 +1647,15 @@ function feed_links_extra( $args = array() ) { $href = get_post_comments_feed_link( $post->ID ); } } elseif ( is_category() ) { - $cat_id = intval( get_query_var('cat') ); + $term = get_queried_object(); - $title = esc_attr(sprintf( $args['cattitle'], get_bloginfo('name'), $args['separator'], get_cat_name( $cat_id ) )); - $href = get_category_feed_link( $cat_id ); + $title = esc_attr(sprintf( $args['cattitle'], get_bloginfo('name'), $args['separator'], $term->name )); + $href = get_category_feed_link( $term->term_id ); } elseif ( is_tag() ) { - $tag_id = intval( get_query_var('tag_id') ); - $tag = get_tag( $tag_id ); + $term = get_queried_object(); - $title = esc_attr(sprintf( $args['tagtitle'], get_bloginfo('name'), $args['separator'], $tag->name )); - $href = get_tag_feed_link( $tag_id ); + $title = esc_attr(sprintf( $args['tagtitle'], get_bloginfo('name'), $args['separator'], $term->name )); + $href = get_tag_feed_link( $term->term_id ); } elseif ( is_author() ) { $author_id = intval( get_query_var('author') ); @@ -2039,7 +2050,7 @@ function paginate_links( $args = '' ) { * @param string $key The unique key for this theme. * @param string $name The name of the theme. * @param string $url The url of the css file containing the colour scheme. - * @param array @colors Optional An array of CSS color definitions which are used to give the user a feel for the theme. + * @param array $colors Optional An array of CSS color definitions which are used to give the user a feel for the theme. */ function wp_admin_css_color($key, $name, $url, $colors = array()) { global $_wp_admin_css_colors; @@ -2056,8 +2067,11 @@ function wp_admin_css_color($key, $name, $url, $colors = array()) { * @since 3.0.0 */ function register_admin_color_schemes() { - wp_admin_css_color('classic', __('Blue'), admin_url("css/colors-classic.css"), array('#073447', '#21759B', '#EAF3FA', '#BBD8E7')); - wp_admin_css_color('fresh', __('Gray'), admin_url("css/colors-fresh.css"), array('#464646', '#6D6D6D', '#F1F1F1', '#DFDFDF'));} + wp_admin_css_color( 'classic', __( 'Blue' ), admin_url( 'css/colors-classic.css' ), + array( '#5589aa', '#cfdfe9', '#d1e5ee', '#eff8ff' ) ); + wp_admin_css_color( 'fresh', __( 'Gray' ), admin_url( 'css/colors-fresh.css' ), + array( '#7c7976', '#c6c6c6', '#e0e0e0', '#f1f1f1' ) ); +} /** * Display the URL of a WordPress admin CSS file. @@ -2097,7 +2111,8 @@ function wp_admin_css_uri( $file = 'wp-admin' ) { * @since 2.3.0 * @uses $wp_styles WordPress Styles Object * - * @param string $file Style handle name or file name (without ".css" extension) relative to wp-admin/ + * @param string $file Optional. Style handle name or file name (without ".css" extension) relative + * to wp-admin/. Defaults to 'wp-admin'. * @param bool $force_echo Optional. Force the stylesheet link to be printed rather than enqueued. */ function wp_admin_css( $file = 'wp-admin', $force_echo = false ) { @@ -2133,6 +2148,9 @@ function wp_admin_css( $file = 'wp-admin', $force_echo = false ) { function add_thickbox() { wp_enqueue_script( 'thickbox' ); wp_enqueue_style( 'thickbox' ); + + if ( is_network_admin() ) + add_action( 'admin_head', '_thickbox_path_admin_subfolder' ); } /** @@ -2219,7 +2237,7 @@ function get_the_generator( $type = '' ) { $gen = ''; break; case 'export': - $gen = ''; + $gen = ''; break; } return apply_filters( "get_the_generator_{$type}", $gen, $type ); @@ -2230,7 +2248,7 @@ function get_the_generator( $type = '' ) { * * Compares the first two arguments and if identical marks as checked * - * @since 1.0 + * @since 1.0.0 * * @param mixed $checked One of the values to compare * @param mixed $current (true) The other value to compare if not just true @@ -2246,9 +2264,9 @@ function checked( $checked, $current = true, $echo = true ) { * * Compares the first two arguments and if identical marks as selected * - * @since 1.0 + * @since 1.0.0 * - * @param mixed selected One of the values to compare + * @param mixed $selected One of the values to compare * @param mixed $current (true) The other value to compare if not just true * @param bool $echo Whether to echo or just return the string * @return string html attribute or empty string @@ -2278,7 +2296,7 @@ function disabled( $disabled, $current = true, $echo = true ) { * * Compares the first two arguments and if identical marks as $type * - * @since 2.8 + * @since 2.8.0 * @access private * * @param any $helper One of the values to compare diff --git a/wp-includes/images/admin-bar-sprite-rtl.png b/wp-includes/images/admin-bar-sprite-rtl.png new file mode 100644 index 0000000000000000000000000000000000000000..f49aae7a01741631161df6df5e3175afeea69406 GIT binary patch literal 732 zcmV<20wev2P)mLPTr32Bbtv|ALaF?MwUqcl-G z(ywy;cDX*LQBxHFz&B2d#R5?C`TRDzMC)C1dkq~?K?uNVHk$zoi)m~(HaVJ?)^qD< ztq3)lOu%S5oq|0#9`(68pFY$Rp~mAej7Fn7**?Z}9#_xxq!OW|1fxiHTCGB@Rs$SOY|Hqx&Yp8V?MZ#tp3&p0R4P%@9wpDt*?AgE zbDuqKUvzE*2_O!P`yd>oq))E|TvRTX@5K3LGds5H>|9(Ay7unnSt^xoNsNtbkIPGv zYAK-caAbdG3WWmLDi({8sBdzvSXw9b##sD8=9>9#^ynIz6QT0?JfN_M#&qOrsklCp z9)fZKNT6{*T)h)2m&_%%ZYDK+1=bsi`&4w}xVg*cJP|6J z&BC+7#;>dwp^}tBDU?DfltL-ge+RW(E+ehiYgBr(+58TI;QKp3rB>@DB1HA-d^mZFrGZ|pqKO+J#B6=2zEUZr;~ns z0bZ}nZ3fTk=p_zyz4z^}x0=*jKwZHyc-=B{eI+QALMfC&DU?F}J^cYm?HP(~ver%j O0000hl^Y&TDOJs!F8-D0Jv3*+wp(+f=SK%osmD z+T14I$ObF{xj=c{*Na{*mjT7^%EalsH1b;N+j>axn@>WiREj6eNQE&fTU-*&mFj5h z?&Dc37NJlm#6p|;lFU4>lWblm&53_A(t^G)kL0SsnDq}ipU;C$SS;DDJnHk2+ul&N z1#Do_!mgX}g39G`;3I58M^}z-zeG?z0KPZj($l|G(#6dqa^-kKNex^J`}z`~6)Ky} z!tV+jKT~govQ4C^02QDDRDcRl0V+WK&Bc{^+ithZ&1UnerB$dbKQO*@ZEgH%pcb<}T*4%`BNe6J0dK zFh~cw0i`ieDg8CpgV1)grBK>)_I^h$%ue#0obUaf=Q;2DeecWJ&-CGcPcz{o!d}9b zwb%qL}N`Q_PZT$+iPaJ`)(=mR5nQb zw+VT{xa%!u@Rg(5@XD2s4_nV)9X1a>3}YdagRB4?$0LfYI^|7O6aZfZ+Quu9^QpoGy`NsSrGUV=cTzuuo!*W=N7Fb&f(1G~Gf+CCDRM|2^B z7PAq$GA%ek1J6txilSiOCJP+~k60?J8Vm>K(6phlfj(>1BB>@$)U3n6^b=?V9($V1 zfFi?IrBwxO^(K@H3f5O>5t&aTG?#?Hb8Jgs2GK`SB4{<~;fW;a^AYD;R&AqV)85)n>v(AcEhA z{sH^f8(SQ3+AJ6to5G$}E0~7DcbP%&ZC}XUUSIjhT2&5DIH9Kf$?I+SJ2Z!2VhPD? z4x6nT@GP5$QLn>+t*w5hA=)Ko;G?_$`TgFTnKS#EGV#S_S$7w^56InmdjCC!ga%dgEu&y19sJNEU}*vV~{KtTqkrA6qC>rrE=gOrn5OQOSW z3LO9TW`uD`bCwC!SzyETQ}=c>oc&H6rh`tK_ucju-A>2LHb(LUo`ioHonE}{3%l7c z1uuMf@%ZHj&xeWi4xya&3&B|7-0iAxbsiB7CRZVyu&5(jQTe!#dN!G!9J-eF4Np>t gwPcEr`A>iW0C727`Ns`5r2qf`07*qoM6N<$f0)){autosave()}if(tinyMCE.activeEditor&&!tinyMCE.activeEditor.isHidden()&&a){c.preventDefault();a=false;tinyMCE.activeEditor.focus();return false}}})}if("1"==b("#auto_draft").val()){b("#title").blur(function(){if(!this.value||b("#auto_draft").val()!="1"){return}delayed_autosave()})}});function autosave_parse_response(c){var e=wpAjax.parseAjaxResponse(c,"autosave"),f="",a,b,d;if(e&&e.responses&&e.responses.length){f=e.responses[0].data;if(e.responses[0].supplemental){b=e.responses[0].supplemental;if("disable"==b.disable_autosave){autosave=function(){};e={errors:true}}if(b.session_expired&&(d=b.session_expired)){if(!interimLogin||interimLogin.closed){interimLogin=window.open(d,"login","width=600,height=450,resizable=yes,scrollbars=yes,status=yes");interimLogin.focus()}delete b.session_expired}jQuery.each(b,function(g,h){if(g.match(/^replace-/)){jQuery("#"+g.replace("replace-","")).val(h)}})}if(!e.errors){a=parseInt(e.responses[0].id,10);if(!isNaN(a)&&a>0){autosave_update_slug(a)}}}if(f){jQuery("#autosave").html(f)}else{if(autosaveOldMessage&&e){jQuery("#autosave").html(autosaveOldMessage)}}return e}function autosave_saved(a){blockSave=false;autosave_parse_response(a);autosave_enable_buttons()}function autosave_saved_new(b){blockSave=false;var d=autosave_parse_response(b),c,a;if(d&&d.responses.length&&!d.errors){a=parseInt(d.responses[0].id,10);if(!isNaN(a)&&a>0){notSaved=false;jQuery("#auto_draft").val("0")}autosave_enable_buttons();if(autosaveDelayPreview){autosaveDelayPreview=false;doPreview()}}else{autosave_enable_buttons()}}function autosave_update_slug(a){if("undefined"!=makeSlugeditClickable&&jQuery.isFunction(makeSlugeditClickable)&&!jQuery("#edit-slug-box > *").size()){jQuery.post(ajaxurl,{action:"sample-permalink",post_id:a,new_title:jQuery("#title").val(),samplepermalinknonce:jQuery("#samplepermalinknonce").val()},function(b){jQuery("#edit-slug-box").html(b);makeSlugeditClickable()})}}function autosave_loading(){jQuery("#autosave").html(autosaveL10n.savingText)}function autosave_enable_buttons(){setTimeout(function(){jQuery(":button, :submit","#submitpost").removeAttr("disabled");jQuery("#ajax-loading").css("visibility","hidden")},500)}function autosave_disable_buttons(){jQuery(":button, :submit","#submitpost").attr("disabled","disabled");setTimeout(autosave_enable_buttons,5000)}function delayed_autosave(){setTimeout(function(){if(blockSave){return}autosave()},200)}autosave=function(){blockSave=true;var c=(typeof tinyMCE!="undefined")&&tinyMCE.activeEditor&&!tinyMCE.activeEditor.isHidden(),d,f,b,e,a;autosave_disable_buttons();d={action:"autosave",post_ID:jQuery("#post_ID").val()||0,post_title:jQuery("#title").val()||"",autosavenonce:jQuery("#autosavenonce").val(),post_type:jQuery("#post_type").val()||"",autosave:1};jQuery(".tags-input").each(function(){d[this.name]=this.value});f=true;if(jQuery("#TB_window").css("display")=="block"){f=false}if(c&&f){b=tinyMCE.activeEditor;if(b.plugins.spellchecker&&b.plugins.spellchecker.active){f=false}else{if("mce_fullscreen"==b.id){tinyMCE.get("content").setContent(b.getContent({format:"raw"}),{format:"raw"})}tinyMCE.get("content").save()}}d.content=jQuery("#content").val();if(jQuery("#post_name").val()){d.post_name=jQuery("#post_name").val()}if((d.post_title.length==0&&d.content.length==0)||d.post_title+d.content==autosaveLast){f=false}e=jQuery("#original_post_status").val();goodcats=([]);jQuery("[name='post_category[]']:checked").each(function(g){goodcats.push(this.value)});d.catslist=goodcats.join(",");if(jQuery("#comment_status").attr("checked")){d.comment_status="open"}if(jQuery("#ping_status").attr("checked")){d.ping_status="open"}if(jQuery("#excerpt").size()){d.excerpt=jQuery("#excerpt").val()}if(jQuery("#post_author").size()){d.post_author=jQuery("#post_author").val()}if(jQuery("#parent_id").val()){d.parent_id=jQuery("#parent_id").val()}d.user_ID=jQuery("#user-id").val();if(jQuery("#auto_draft").val()=="1"){d.auto_draft="1"}if(f){autosaveLast=jQuery("#title").val()+jQuery("#content").val()}else{d.autosave=0}if(d.auto_draft=="1"){a=autosave_saved_new}else{a=autosave_saved}autosaveOldMessage=jQuery("#autosave").html();jQuery.ajax({data:d,beforeSend:f?autosave_loading:null,type:"POST",url:autosaveL10n.requestFile,success:a})}; \ No newline at end of file +var autosave,autosaveLast="",autosavePeriodical,autosaveOldMessage="",autosaveDelayPreview=false,notSaved=true,blockSave=false,interimLogin=false;jQuery(document).ready(function(b){var a=true;autosaveLast=b("#post #title").val()+b("#post #content").val();autosavePeriodical=b.schedule({time:autosaveL10n.autosaveInterval*1000,func:function(){autosave()},repeat:true,protect:true});b("#post").submit(function(){b.cancel(autosavePeriodical)});b('input[type="submit"], a.submitdelete',"#submitpost").click(function(){blockSave=true;window.onbeforeunload=null;b(":button, :submit","#submitpost").each(function(){var c=b(this);if(c.hasClass("button-primary")){c.addClass("button-primary-disabled")}else{c.addClass("button-disabled")}});if(b(this).attr("id")=="publish"){b("#ajax-loading").css("visibility","visible")}else{b("#draft-ajax-loading").css("visibility","visible")}});window.onbeforeunload=function(){var c=typeof(tinyMCE)!="undefined"?tinyMCE.activeEditor:false,e,d;if(c&&!c.isHidden()){if(c.isDirty()){return autosaveL10n.saveAlert}}else{e=b("#post #title").val(),d=b("#post #content").val();if((e||d)&&e+d!=autosaveLast){return autosaveL10n.saveAlert}}};b("#post-preview").click(function(){if(b("#auto_draft").val()=="1"&¬Saved){autosaveDelayPreview=true;autosave();return false}doPreview();return false});doPreview=function(){b("input#wp-preview").val("dopreview");b("form#post").attr("target","wp-preview").submit().attr("target","");b("input#wp-preview").val("")};if(typeof tinyMCE!="undefined"){b("#title")[b.browser.opera?"keypress":"keydown"](function(c){if(c.which==9&&!c.shiftKey&&!c.controlKey&&!c.altKey){if((b("#auto_draft").val()=="1")&&(b("#title").val().length>0)){autosave()}if(tinyMCE.activeEditor&&!tinyMCE.activeEditor.isHidden()&&a){c.preventDefault();a=false;tinyMCE.activeEditor.focus();return false}}})}if("1"==b("#auto_draft").val()){b("#title").blur(function(){if(!this.value||b("#auto_draft").val()!="1"){return}delayed_autosave()})}});function autosave_parse_response(c){var e=wpAjax.parseAjaxResponse(c,"autosave"),f="",a,b,d;if(e&&e.responses&&e.responses.length){f=e.responses[0].data;if(e.responses[0].supplemental){b=e.responses[0].supplemental;if("disable"==b.disable_autosave){autosave=function(){};e={errors:true}}if(b.session_expired&&(d=b.session_expired)){if(!interimLogin||interimLogin.closed){interimLogin=window.open(d,"login","width=600,height=450,resizable=yes,scrollbars=yes,status=yes");interimLogin.focus()}delete b.session_expired}jQuery.each(b,function(g,h){if(g.match(/^replace-/)){jQuery("#"+g.replace("replace-","")).val(h)}})}if(!e.errors){a=parseInt(e.responses[0].id,10);if(!isNaN(a)&&a>0){autosave_update_slug(a)}}}if(f){jQuery("#autosave").html(f)}else{if(autosaveOldMessage&&e){jQuery("#autosave").html(autosaveOldMessage)}}return e}function autosave_saved(a){blockSave=false;autosave_parse_response(a);autosave_enable_buttons()}function autosave_saved_new(b){blockSave=false;var d=autosave_parse_response(b),c,a;if(d&&d.responses.length&&!d.errors){a=parseInt(d.responses[0].id,10);if(!isNaN(a)&&a>0){notSaved=false;jQuery("#auto_draft").val("0")}autosave_enable_buttons();if(autosaveDelayPreview){autosaveDelayPreview=false;doPreview()}}else{autosave_enable_buttons()}}function autosave_update_slug(a){if("undefined"!=makeSlugeditClickable&&jQuery.isFunction(makeSlugeditClickable)&&!jQuery("#edit-slug-box > *").size()){jQuery.post(ajaxurl,{action:"sample-permalink",post_id:a,new_title:jQuery("#title").val(),samplepermalinknonce:jQuery("#samplepermalinknonce").val()},function(b){jQuery("#edit-slug-box").html(b);makeSlugeditClickable()})}}function autosave_loading(){jQuery("#autosave").html(autosaveL10n.savingText)}function autosave_enable_buttons(){setTimeout(function(){jQuery(":button, :submit","#submitpost").removeAttr("disabled");jQuery(".ajax-loading").css("visibility","hidden")},500)}function autosave_disable_buttons(){jQuery(":button, :submit","#submitpost").attr("disabled","disabled");setTimeout(autosave_enable_buttons,5000)}function delayed_autosave(){setTimeout(function(){if(blockSave){return}autosave()},200)}autosave=function(){blockSave=true;var c=(typeof tinyMCE!="undefined")&&tinyMCE.activeEditor&&!tinyMCE.activeEditor.isHidden(),d,f,b,e,a;autosave_disable_buttons();d={action:"autosave",post_ID:jQuery("#post_ID").val()||0,post_title:jQuery("#title").val()||"",autosavenonce:jQuery("#autosavenonce").val(),post_type:jQuery("#post_type").val()||"",autosave:1};jQuery(".tags-input").each(function(){d[this.name]=this.value});f=true;if(jQuery("#TB_window").css("display")=="block"){f=false}if(c&&f){b=tinyMCE.activeEditor;if(b.plugins.spellchecker&&b.plugins.spellchecker.active){f=false}else{if("mce_fullscreen"==b.id){tinyMCE.get("content").setContent(b.getContent({format:"raw"}),{format:"raw"})}tinyMCE.get("content").save()}}d.content=jQuery("#content").val();if(jQuery("#post_name").val()){d.post_name=jQuery("#post_name").val()}if((d.post_title.length==0&&d.content.length==0)||d.post_title+d.content==autosaveLast){f=false}e=jQuery("#original_post_status").val();goodcats=([]);jQuery("[name='post_category[]']:checked").each(function(g){goodcats.push(this.value)});d.catslist=goodcats.join(",");if(jQuery("#comment_status").attr("checked")){d.comment_status="open"}if(jQuery("#ping_status").attr("checked")){d.ping_status="open"}if(jQuery("#excerpt").size()){d.excerpt=jQuery("#excerpt").val()}if(jQuery("#post_author").size()){d.post_author=jQuery("#post_author").val()}if(jQuery("#parent_id").val()){d.parent_id=jQuery("#parent_id").val()}d.user_ID=jQuery("#user-id").val();if(jQuery("#auto_draft").val()=="1"){d.auto_draft="1"}if(f){autosaveLast=jQuery("#title").val()+jQuery("#content").val()}else{d.autosave=0}if(d.auto_draft=="1"){a=autosave_saved_new}else{a=autosave_saved}autosaveOldMessage=jQuery("#autosave").html();jQuery.ajax({data:d,beforeSend:f?autosave_loading:null,type:"POST",url:autosaveL10n.requestFile,success:a})}; \ No newline at end of file diff --git a/wp-includes/js/imgareaselect/jquery.imgareaselect.js b/wp-includes/js/imgareaselect/jquery.imgareaselect.js index aabbcca1..9f2aee24 100644 --- a/wp-includes/js/imgareaselect/jquery.imgareaselect.js +++ b/wp-includes/js/imgareaselect/jquery.imgareaselect.js @@ -1 +1 @@ -(function($){var abs=Math.abs,max=Math.max,min=Math.min,round=Math.round;function div(){return $('
        ')}$.imgAreaSelect=function(img,options){var $img=$(img),imgLoaded,$box=div(),$area=div(),$border=div().add(div()).add(div()).add(div()),$outer=div().add(div()).add(div()).add(div()),$handles=$([]),$areaOpera,left,top,imgOfs,imgWidth,imgHeight,$parent,parOfs,zIndex=0,position='absolute',startX,startY,scaleX,scaleY,resizeMargin=10,resize,aspectRatio,shown,x1,y1,x2,y2,selection={x1:0,y1:0,x2:0,y2:0,width:0,height:0},$p,d,i,o,w,h,adjusted;function viewX(x){return x+imgOfs.left-parOfs.left}function viewY(y){return y+imgOfs.top-parOfs.top}function selX(x){return x-imgOfs.left+parOfs.left}function selY(y){return y-imgOfs.top+parOfs.top}function evX(event){return event.pageX-parOfs.left}function evY(event){return event.pageY-parOfs.top}function getSelection(noScale){var sx=noScale||scaleX,sy=noScale||scaleY;return{x1:round(selection.x1*sx),y1:round(selection.y1*sy),x2:round(selection.x2*sx),y2:round(selection.y2*sy),width:round(selection.x2*sx)-round(selection.x1*sx),height:round(selection.y2*sy)-round(selection.y1*sy)}}function setSelection(x1,y1,x2,y2,noScale){var sx=noScale||scaleX,sy=noScale||scaleY;selection={x1:round(x1/sx),y1:round(y1/sy),x2:round(x2/sx),y2:round(y2/sy)};selection.width=(x2=viewX(selection.x2))-(x1=viewX(selection.x1));selection.height=(y2=viewX(selection.y2))-(y1=viewX(selection.y1))}function adjust(){if(!$img.width())return;imgOfs={left:round($img.offset().left),top:round($img.offset().top)};imgWidth=$img.width();imgHeight=$img.height();if($().jquery=='1.3.2'&&$.browser.safari&&position=='fixed'){imgOfs.top+=max(document.documentElement.scrollTop,$('body').scrollTop());imgOfs.left+=max(document.documentElement.scrollLeft,$('body').scrollLeft())}parOfs=$.inArray($parent.css('position'),['absolute','relative'])+1?{left:round($parent.offset().left)-$parent.scrollLeft(),top:round($parent.offset().top)-$parent.scrollTop()}:position=='fixed'?{left:$(document).scrollLeft(),top:$(document).scrollTop()}:{left:0,top:0};left=viewX(0);top=viewY(0)}function update(resetKeyPress){if(!shown)return;$box.css({left:viewX(selection.x1),top:viewY(selection.y1)}).add($area).width(w=selection.width).height(h=selection.height);$area.add($border).add($handles).css({left:0,top:0});$border.width(max(w-$border.outerWidth()+$border.innerWidth(),0)).height(max(h-$border.outerHeight()+$border.innerHeight(),0));$($outer[0]).css({left:left,top:top,width:selection.x1,height:imgHeight});$($outer[1]).css({left:left+selection.x1,top:top,width:w,height:selection.y1});$($outer[2]).css({left:left+selection.x2,top:top,width:imgWidth-selection.x2,height:imgHeight});$($outer[3]).css({left:left+selection.x1,top:top+selection.y2,width:w,height:imgHeight-selection.y2});w-=$handles.outerWidth();h-=$handles.outerHeight();switch($handles.length){case 8:$($handles[4]).css({left:w/2});$($handles[5]).css({left:w,top:h/2});$($handles[6]).css({left:w/2,top:h});$($handles[7]).css({top:h/2});case 4:$handles.slice(1,3).css({left:w});$handles.slice(2,4).css({top:h})}if(resetKeyPress!==false){if($.imgAreaSelect.keyPress!=docKeyPress)$(document).unbind($.imgAreaSelect.keyPress,$.imgAreaSelect.onKeyPress);if(options.keys)$(document)[$.imgAreaSelect.keyPress]($.imgAreaSelect.onKeyPress=docKeyPress)}if($.browser.msie&&$border.outerWidth()-$border.innerWidth()==2){$border.css('margin',0);setTimeout(function(){$border.css('margin','auto')},0)}}function doUpdate(resetKeyPress){adjust();update(resetKeyPress);x1=viewX(selection.x1);y1=viewY(selection.y1);x2=viewX(selection.x2);y2=viewY(selection.y2)}function hide($elem,fn){options.fadeSpeed?$elem.fadeOut(options.fadeSpeed,fn):$elem.hide()}function areaMouseMove(event){var x=selX(evX(event))-selection.x1,y=selY(evY(event))-selection.y1;if(!adjusted){adjust();adjusted=true;$box.one('mouseout',function(){adjusted=false})}resize='';if(options.resizable){if(y<=resizeMargin)resize='n';else if(y>=selection.height-resizeMargin)resize='s';if(x<=resizeMargin)resize+='w';else if(x>=selection.width-resizeMargin)resize+='e'}$box.css('cursor',resize?resize+'-resize':options.movable?'move':'');if($areaOpera)$areaOpera.toggle()}function docMouseUp(event){$('body').css('cursor','');if(options.autoHide||selection.width*selection.height==0)hide($box.add($outer),function(){$(this).hide()});options.onSelectEnd(img,getSelection());$(document).unbind('mousemove',selectingMouseMove);$box.mousemove(areaMouseMove)}function areaMouseDown(event){if(event.which!=1)return false;adjust();if(resize){$('body').css('cursor',resize+'-resize');x1=viewX(selection[/w/.test(resize)?'x2':'x1']);y1=viewY(selection[/n/.test(resize)?'y2':'y1']);$(document).mousemove(selectingMouseMove).one('mouseup',docMouseUp);$box.unbind('mousemove',areaMouseMove)}else if(options.movable){startX=left+selection.x1-evX(event);startY=top+selection.y1-evY(event);$box.unbind('mousemove',areaMouseMove);$(document).mousemove(movingMouseMove).one('mouseup',function(){options.onSelectEnd(img,getSelection());$(document).unbind('mousemove',movingMouseMove);$box.mousemove(areaMouseMove)})}else $img.mousedown(event);return false}function aspectRatioXY(){x2=max(left,min(left+imgWidth,x1+abs(y2-y1)*aspectRatio*(x2>x1||-1)));y2=round(max(top,min(top+imgHeight,y1+abs(x2-x1)/aspectRatio*(y2>y1||-1))));x2=round(x2)}function aspectRatioYX(){y2=max(top,min(top+imgHeight,y1+abs(x2-x1)/aspectRatio*(y2>y1||-1)));x2=round(max(left,min(left+imgWidth,x1+abs(y2-y1)*aspectRatio*(x2>x1||-1))));y2=round(y2)}function doResize(){if(abs(x2-x1)left+imgWidth)x1=left+imgWidth-options.minWidth}if(abs(y2-y1)top+imgHeight)y1=top+imgHeight-options.minHeight}x2=max(left,min(x2,left+imgWidth));y2=max(top,min(y2,top+imgHeight));if(aspectRatio)if(abs(x2-x1)/aspectRatio>abs(y2-y1))aspectRatioYX();else aspectRatioXY();if(abs(x2-x1)>options.maxWidth){x2=x1-options.maxWidth*(x2options.maxHeight){y2=y1-options.maxHeight*(y2zIndex)zIndex=$p.css('z-index');if($p.css('position')=='fixed')position='fixed';$p=$p.parent()}if(!isNaN(options.zIndex))zIndex=options.zIndex;if($.browser.msie)$img.attr('unselectable','on');$.imgAreaSelect.keyPress=$.browser.msie||$.browser.safari?'keydown':'keypress';if($.browser.opera)$areaOpera=div().css({width:'100%',height:'100%',position:'absolute',zIndex:zIndex+2||2});$box.add($outer).css({visibility:'hidden',position:position,overflow:'hidden',zIndex:zIndex||'0'});$box.css({zIndex:zIndex+2||2});$area.add($border).css({position:'absolute'});img.complete||img.readyState=='complete'||!$img.is('img')?imgLoad():$img.one('load',imgLoad)};$.fn.imgAreaSelect=function(options){options=options||{};this.each(function(){if($(this).data('imgAreaSelect'))$(this).data('imgAreaSelect').setOptions(options);else{if(options.enable===undefined&&options.disable===undefined)options.enable=true;$(this).data('imgAreaSelect',new $.imgAreaSelect(this,options))}});if(options.instance)return $(this).data('imgAreaSelect');return this}})(jQuery); \ No newline at end of file +(function(e){var b=Math.abs,a=Math.max,d=Math.min,c=Math.round;function f(){return e("
        ")}e.imgAreaSelect=function(q,S){var aw=e(q),U,ar=f(),af=f(),H=f().add(f()).add(f()).add(f()),Y=f().add(f()).add(f()).add(f()),L=e([]),R,n,p,az,N,j,A,M,B=0,ad="absolute",Q,P,aa,Z,V=10,I,T,K,y,aA,x,ay,v={x1:0,y1:0,x2:0,y2:0,width:0,height:0},l,aq,am,ag,ac,an,u;function G(h){return h+az.left-M.left}function F(h){return h+az.top-M.top}function E(h){return h-az.left+M.left}function z(h){return h-az.top+M.top}function ak(h){return h.pageX-M.left}function ai(h){return h.pageY-M.top}function D(h){var o=h||aa,i=h||Z;return{x1:c(v.x1*o),y1:c(v.y1*i),x2:c(v.x2*o),y2:c(v.y2*i),width:c(v.x2*o)-c(v.x1*o),height:c(v.y2*i)-c(v.y1*i)}}function ae(i,w,h,o,aB){var aD=aB||aa,aC=aB||Z;v={x1:c(i/aD),y1:c(w/aC),x2:c(h/aD),y2:c(o/aC)};v.width=(h=G(v.x2))-(i=G(v.x1));v.height=(o=G(v.y2))-(w=G(v.y1))}function ao(){if(!aw.width()){return}az={left:c(aw.offset().left),top:c(aw.offset().top)};N=aw.width();j=aw.height();if(e().jquery=="1.3.2"&&e.browser.safari&&ad=="fixed"){az.top+=a(document.documentElement.scrollTop,e("body").scrollTop());az.left+=a(document.documentElement.scrollLeft,e("body").scrollLeft())}M=e.inArray(A.css("position"),["absolute","relative"])+1?{left:c(A.offset().left)-A.scrollLeft(),top:c(A.offset().top)-A.scrollTop()}:ad=="fixed"?{left:e(document).scrollLeft(),top:e(document).scrollTop()}:{left:0,top:0};n=G(0);p=F(0)}function X(h){if(!K){return}ar.css({left:G(v.x1),top:F(v.y1)}).add(af).width(ac=v.width).height(an=v.height);af.add(H).add(L).css({left:0,top:0});H.width(a(ac-H.outerWidth()+H.innerWidth(),0)).height(a(an-H.outerHeight()+H.innerHeight(),0));e(Y[0]).css({left:n,top:p,width:v.x1,height:j});e(Y[1]).css({left:n+v.x1,top:p,width:ac,height:v.y1});e(Y[2]).css({left:n+v.x2,top:p,width:N-v.x2,height:j});e(Y[3]).css({left:n+v.x1,top:p+v.y2,width:ac,height:j-v.y2});ac-=L.outerWidth();an-=L.outerHeight();switch(L.length){case 8:e(L[4]).css({left:ac/2});e(L[5]).css({left:ac,top:an/2});e(L[6]).css({left:ac/2,top:an});e(L[7]).css({top:an/2});case 4:L.slice(1,3).css({left:ac});L.slice(2,4).css({top:an})}if(h!==false){if(e.imgAreaSelect.keyPress!=at){e(document).unbind(e.imgAreaSelect.keyPress,e.imgAreaSelect.onKeyPress)}if(S.keys){e(document)[e.imgAreaSelect.keyPress](e.imgAreaSelect.onKeyPress=at)}}if(e.browser.msie&&H.outerWidth()-H.innerWidth()==2){H.css("margin",0);setTimeout(function(){H.css("margin","auto")},0)}}function t(h){ao();X(h);y=G(v.x1);aA=F(v.y1);x=G(v.x2);ay=F(v.y2)}function ah(h,i){S.fadeSpeed?h.fadeOut(S.fadeSpeed,i):h.hide()}function C(i){var h=E(ak(i))-v.x1,o=z(ai(i))-v.y1;if(!u){ao();u=true;ar.one("mouseout",function(){u=false})}I="";if(S.resizable){if(o<=V){I="n"}else{if(o>=v.height-V){I="s"}}if(h<=V){I+="w"}else{if(h>=v.width-V){I+="e"}}}ar.css("cursor",I?I+"-resize":S.movable?"move":"");if(R){R.toggle()}}function aj(h){e("body").css("cursor","");if(S.autoHide||v.width*v.height==0){ah(ar.add(Y),function(){e(this).hide()})}S.onSelectEnd(q,D());e(document).unbind("mousemove",ab);ar.mousemove(C)}function s(h){if(h.which!=1){return false}ao();if(I){e("body").css("cursor",I+"-resize");y=G(v[/w/.test(I)?"x2":"x1"]);aA=F(v[/n/.test(I)?"y2":"y1"]);e(document).mousemove(ab).one("mouseup",aj);ar.unbind("mousemove",C)}else{if(S.movable){Q=n+v.x1-ak(h);P=p+v.y1-ai(h);ar.unbind("mousemove",C);e(document).mousemove(g).one("mouseup",function(){S.onSelectEnd(q,D());e(document).unbind("mousemove",g);ar.mousemove(C)})}else{aw.mousedown(h)}}return false}function r(){x=a(n,d(n+N,y+b(ay-aA)*T*(x>y||-1)));ay=c(a(p,d(p+j,aA+b(x-y)/T*(ay>aA||-1))));x=c(x)}function al(){ay=a(p,d(p+j,aA+b(x-y)/T*(ay>aA||-1)));x=c(a(n,d(n+N,y+b(ay-aA)*T*(x>y||-1))));ay=c(ay)}function av(){if(b(x-y)n+N){y=n+N-S.minWidth}}}if(b(ay-aA)p+j){aA=p+j-S.minHeight}}}x=a(n,d(x,n+N));ay=a(p,d(ay,p+j));if(T){if(b(x-y)/T>b(ay-aA)){al()}else{r()}}if(b(x-y)>S.maxWidth){x=y-S.maxWidth*(xS.maxHeight){ay=aA-S.maxHeight*(ayB){B=l.css("z-index")}if(l.css("position")=="fixed"){ad="fixed"}l=l.parent()}if(!isNaN(S.zIndex)){B=S.zIndex}if(e.browser.msie){aw.attr("unselectable","on")}e.imgAreaSelect.keyPress=e.browser.msie||e.browser.safari?"keydown":"keypress";if(e.browser.opera){R=f().css({width:"100%",height:"100%",position:"absolute",zIndex:B+2||2})}ar.add(Y).css({visibility:"hidden",position:ad,overflow:"hidden",zIndex:B||"0"});ar.css({zIndex:B+2||2});af.add(H).css({position:"absolute"});q.complete||q.readyState=="complete"||!aw.is("img")?au():aw.one("load",au)};e.fn.imgAreaSelect=function(g){g=g||{};this.each(function(){if(e(this).data("imgAreaSelect")){e(this).data("imgAreaSelect").setOptions(g)}else{if(g.enable===undefined&&g.disable===undefined){g.enable=true}e(this).data("imgAreaSelect",new e.imgAreaSelect(this,g))}});if(g.instance){return e(this).data("imgAreaSelect")}return this}})(jQuery); \ No newline at end of file diff --git a/wp-includes/js/jcrop/jquery.Jcrop.js b/wp-includes/js/jcrop/jquery.Jcrop.js index 9002b978..70b55053 100644 --- a/wp-includes/js/jcrop/jquery.Jcrop.js +++ b/wp-includes/js/jcrop/jquery.Jcrop.js @@ -1,163 +1 @@ -/** - * Jcrop v.0.9.8 (minimized) - * (c) 2008 Kelly Hallman and DeepLiquid.com - * More information: http://deepliquid.com/content/Jcrop.html - * Released under MIT License - this header must remain with code - */ - - -(function($){$.Jcrop=function(obj,opt) -{var obj=obj,opt=opt;if(typeof(obj)!=='object')obj=$(obj)[0];if(typeof(opt)!=='object')opt={};if(!('trackDocument'in opt)) -{opt.trackDocument=$.browser.msie?false:true;if($.browser.msie&&$.browser.version.split('.')[0]=='8') -opt.trackDocument=true;} -if(!('keySupport'in opt)) -opt.keySupport=$.browser.msie?false:true;var defaults={trackDocument:false,baseClass:'jcrop',addClass:null,bgColor:'black',bgOpacity:.6,borderOpacity:.4,handleOpacity:.5,handlePad:5,handleSize:9,handleOffset:5,edgeMargin:14,aspectRatio:0,keySupport:true,cornerHandles:true,sideHandles:true,drawBorders:true,dragEdges:true,boxWidth:0,boxHeight:0,boundary:8,animationDelay:20,swingSpeed:3,allowSelect:true,allowMove:true,allowResize:true,minSelect:[0,0],maxSize:[0,0],minSize:[0,0],onChange:function(){},onSelect:function(){}};var options=defaults;setOptions(opt);var $origimg=$(obj);var $img=$origimg.clone().removeAttr('id').css({position:'absolute'});$img.width($origimg.width());$img.height($origimg.height());$origimg.after($img).hide();presize($img,options.boxWidth,options.boxHeight);var boundx=$img.width(),boundy=$img.height(),$div=$('
        ').width(boundx).height(boundy).addClass(cssClass('holder')).css({position:'relative',backgroundColor:options.bgColor}).insertAfter($origimg).append($img);;if(options.addClass)$div.addClass(options.addClass);var $img2=$('').attr('src',$img.attr('src')).css('position','absolute').width(boundx).height(boundy);var $img_holder=$('
        ').width(pct(100)).height(pct(100)).css({zIndex:310,position:'absolute',overflow:'hidden'}).append($img2);var $hdl_holder=$('
        ').width(pct(100)).height(pct(100)).css('zIndex',320);var $sel=$('
        ').css({position:'absolute',zIndex:300}).insertBefore($img).append($img_holder,$hdl_holder);var bound=options.boundary;var $trk=newTracker().width(boundx+(bound*2)).height(boundy+(bound*2)).css({position:'absolute',top:px(-bound),left:px(-bound),zIndex:290}).mousedown(newSelection);var xlimit,ylimit,xmin,ymin;var xscale,yscale,enabled=true;var docOffset=getPos($img),btndown,lastcurs,dimmed,animating,shift_down;var Coords=function() -{var x1=0,y1=0,x2=0,y2=0,ox,oy;function setPressed(pos) -{var pos=rebound(pos);x2=x1=pos[0];y2=y1=pos[1];};function setCurrent(pos) -{var pos=rebound(pos);ox=pos[0]-x2;oy=pos[1]-y2;x2=pos[0];y2=pos[1];};function getOffset() -{return[ox,oy];};function moveOffset(offset) -{var ox=offset[0],oy=offset[1];if(0>x1+ox)ox-=ox+x1;if(0>y1+oy)oy-=oy+y1;if(boundyboundx) -{xx=boundx;h=Math.abs((xx-x1)/aspect);yy=rh<0?y1-h:h+y1;}} -else -{xx=x2;h=rwa/aspect;yy=rh<0?y1-h:y1+h;if(yy<0) -{yy=0;w=Math.abs((yy-y1)*aspect);xx=rw<0?x1-w:w+x1;} -else if(yy>boundy) -{yy=boundy;w=Math.abs(yy-y1)*aspect;xx=rw<0?x1-w:w+x1;}} -if(xx>x1){if(xx-x1max_x){xx=x1+max_x;} -if(yy>y1){yy=y1+(xx-x1)/aspect;}else{yy=y1-(xx-x1)/aspect;}}else if(xxmax_x){xx=x1-max_x;} -if(yy>y1){yy=y1+(x1-xx)/aspect;}else{yy=y1-(x1-xx)/aspect;}} -if(xx<0){x1-=xx;xx=0;}else if(xx>boundx){x1-=xx-boundx;xx=boundx;} -if(yy<0){y1-=yy;yy=0;}else if(yy>boundy){y1-=yy-boundy;yy=boundy;} -return last=makeObj(flipCoords(x1,y1,xx,yy));};function rebound(p) -{if(p[0]<0)p[0]=0;if(p[1]<0)p[1]=0;if(p[0]>boundx)p[0]=boundx;if(p[1]>boundy)p[1]=boundy;return[p[0],p[1]];};function flipCoords(x1,y1,x2,y2) -{var xa=x1,xb=x2,ya=y1,yb=y2;if(x2xlimit)) -x2=(xsize>0)?(x1+xlimit):(x1-xlimit);if(ylimit&&(Math.abs(ysize)>ylimit)) -y2=(ysize>0)?(y1+ylimit):(y1-ylimit);if(ymin&&(Math.abs(ysize)0)?(y1+ymin):(y1-ymin);if(xmin&&(Math.abs(xsize)0)?(x1+xmin):(x1-xmin);if(x1<0){x2-=x1;x1-=x1;} -if(y1<0){y2-=y1;y1-=y1;} -if(x2<0){x1-=x2;x2-=x2;} -if(y2<0){y1-=y2;y2-=y2;} -if(x2>boundx){var delta=x2-boundx;x1-=delta;x2-=delta;} -if(y2>boundy){var delta=y2-boundy;y1-=delta;y2-=delta;} -if(x1>boundx){var delta=x1-boundy;y2-=delta;y1-=delta;} -if(y1>boundy){var delta=y1-boundy;y2-=delta;y1-=delta;} -return makeObj(flipCoords(x1,y1,x2,y2));};function makeObj(a) -{return{x:a[0],y:a[1],x2:a[2],y2:a[3],w:a[2]-a[0],h:a[3]-a[1]};};return{flipCoords:flipCoords,setPressed:setPressed,setCurrent:setCurrent,getOffset:getOffset,moveOffset:moveOffset,getCorner:getCorner,getFixed:getFixed};}();var Selection=function() -{var start,end,dragmode,awake,hdep=370;var borders={};var handle={};var seehandles=false;var hhs=options.handleOffset;if(options.drawBorders){borders={top:insertBorder('hline').css('top',$.browser.msie?px(-1):px(0)),bottom:insertBorder('hline'),left:insertBorder('vline'),right:insertBorder('vline')};} -if(options.dragEdges){handle.t=insertDragbar('n');handle.b=insertDragbar('s');handle.r=insertDragbar('e');handle.l=insertDragbar('w');} -options.sideHandles&&createHandles(['n','s','e','w']);options.cornerHandles&&createHandles(['sw','nw','ne','se']);function insertBorder(type) -{var jq=$('
        ').css({position:'absolute',opacity:options.borderOpacity}).addClass(cssClass(type));$img_holder.append(jq);return jq;};function dragDiv(ord,zi) -{var jq=$('
        ').mousedown(createDragger(ord)).css({cursor:ord+'-resize',position:'absolute',zIndex:zi});$hdl_holder.append(jq);return jq;};function insertHandle(ord) -{return dragDiv(ord,hdep++).css({top:px(-hhs+1),left:px(-hhs+1),opacity:options.handleOpacity}).addClass(cssClass('handle'));};function insertDragbar(ord) -{var s=options.handleSize,o=hhs,h=s,w=s,t=o,l=o;switch(ord) -{case'n':case's':w=pct(100);break;case'e':case'w':h=pct(100);break;} -return dragDiv(ord,hdep++).width(w).height(h).css({top:px(-t+1),left:px(-l+1)});};function createHandles(li) -{for(i in li)handle[li[i]]=insertHandle(li[i]);};function moveHandles(c) -{var midvert=Math.round((c.h/2)-hhs),midhoriz=Math.round((c.w/2)-hhs),north=west=-hhs+1,east=c.w-hhs,south=c.h-hhs,x,y;'e'in handle&&handle.e.css({top:px(midvert),left:px(east)})&&handle.w.css({top:px(midvert)})&&handle.s.css({top:px(south),left:px(midhoriz)})&&handle.n.css({left:px(midhoriz)});'ne'in handle&&handle.ne.css({left:px(east)})&&handle.se.css({top:px(south),left:px(east)})&&handle.sw.css({top:px(south)});'b'in handle&&handle.b.css({top:px(south)})&&handle.r.css({left:px(east)});};function moveto(x,y) -{$img2.css({top:px(-y),left:px(-x)});$sel.css({top:px(y),left:px(x)});};function resize(w,h) -{$sel.width(w).height(h);};function refresh() -{var c=Coords.getFixed();Coords.setPressed([c.x,c.y]);Coords.setCurrent([c.x2,c.y2]);updateVisible();};function updateVisible() -{if(awake)return update();};function update() -{var c=Coords.getFixed();resize(c.w,c.h);moveto(c.x,c.y);options.drawBorders&&borders['right'].css({left:px(c.w-1)})&&borders['bottom'].css({top:px(c.h-1)});seehandles&&moveHandles(c);awake||show();options.onChange(unscale(c));};function show() -{$sel.show();$img.css('opacity',options.bgOpacity);awake=true;};function release() -{disableHandles();$sel.hide();$img.css('opacity',1);awake=false;};function showHandles() -{if(seehandles) -{moveHandles(Coords.getFixed());$hdl_holder.show();}};function enableHandles() -{seehandles=true;if(options.allowResize) -{moveHandles(Coords.getFixed());$hdl_holder.show();return true;}};function disableHandles() -{seehandles=false;$hdl_holder.hide();};function animMode(v) -{(animating=v)?disableHandles():enableHandles();};function done() -{animMode(false);refresh();};var $track=newTracker().mousedown(createDragger('move')).css({cursor:'move',position:'absolute',zIndex:360}) -$img_holder.append($track);disableHandles();return{updateVisible:updateVisible,update:update,release:release,refresh:refresh,setCursor:function(cursor){$track.css('cursor',cursor);},enableHandles:enableHandles,enableOnly:function(){seehandles=true;},showHandles:showHandles,disableHandles:disableHandles,animMode:animMode,done:done};}();var Tracker=function() -{var onMove=function(){},onDone=function(){},trackDoc=options.trackDocument;if(!trackDoc) -{$trk.mousemove(trackMove).mouseup(trackUp).mouseout(trackUp);} -function toFront() -{$trk.css({zIndex:450});if(trackDoc) -{$(document).mousemove(trackMove).mouseup(trackUp);}} -function toBack() -{$trk.css({zIndex:290});if(trackDoc) -{$(document).unbind('mousemove',trackMove).unbind('mouseup',trackUp);}} -function trackMove(e) -{onMove(mouseAbs(e));};function trackUp(e) -{e.preventDefault();e.stopPropagation();if(btndown) -{btndown=false;onDone(mouseAbs(e));options.onSelect(unscale(Coords.getFixed()));toBack();onMove=function(){};onDone=function(){};} -return false;};function activateHandlers(move,done) -{btndown=true;onMove=move;onDone=done;toFront();return false;};function setCursor(t){$trk.css('cursor',t);};$img.before($trk);return{activateHandlers:activateHandlers,setCursor:setCursor};}();var KeyManager=function() -{var $keymgr=$('').css({position:'absolute',left:'-30px'}).keypress(parseKey).blur(onBlur),$keywrap=$('
        ').css({position:'absolute',overflow:'hidden'}).append($keymgr);function watchKeys() -{if(options.keySupport) -{$keymgr.show();$keymgr.focus();}};function onBlur(e) -{$keymgr.hide();};function doNudge(e,x,y) -{if(options.allowMove){Coords.moveOffset([x,y]);Selection.updateVisible();};e.preventDefault();e.stopPropagation();};function parseKey(e) -{if(e.ctrlKey)return true;shift_down=e.shiftKey?true:false;var nudge=shift_down?10:1;switch(e.keyCode) -{case 37:doNudge(e,-nudge,0);break;case 39:doNudge(e,nudge,0);break;case 38:doNudge(e,0,-nudge);break;case 40:doNudge(e,0,nudge);break;case 27:Selection.release();break;case 9:return true;} -return nothing(e);};if(options.keySupport)$keywrap.insertBefore($img);return{watchKeys:watchKeys};}();function px(n){return''+parseInt(n)+'px';};function pct(n){return''+parseInt(n)+'%';};function cssClass(cl){return options.baseClass+'-'+cl;};function getPos(obj) -{var pos=$(obj).offset();return[pos.left,pos.top];};function mouseAbs(e) -{return[(e.pageX-docOffset[0]),(e.pageY-docOffset[1])];};function myCursor(type) -{if(type!=lastcurs) -{Tracker.setCursor(type);lastcurs=type;}};function startDragMode(mode,pos) -{docOffset=getPos($img);Tracker.setCursor(mode=='move'?mode:mode+'-resize');if(mode=='move') -return Tracker.activateHandlers(createMover(pos),doneSelect);var fc=Coords.getFixed();var opp=oppLockCorner(mode);var opc=Coords.getCorner(oppLockCorner(opp));Coords.setPressed(Coords.getCorner(opp));Coords.setCurrent(opc);Tracker.activateHandlers(dragmodeHandler(mode,fc),doneSelect);};function dragmodeHandler(mode,f) -{return function(pos){if(!options.aspectRatio)switch(mode) -{case'e':pos[1]=f.y2;break;case'w':pos[1]=f.y2;break;case'n':pos[0]=f.x2;break;case's':pos[0]=f.x2;break;} -else switch(mode) -{case'e':pos[1]=f.y+1;break;case'w':pos[1]=f.y+1;break;case'n':pos[0]=f.x+1;break;case's':pos[0]=f.x+1;break;} -Coords.setCurrent(pos);Selection.update();};};function createMover(pos) -{var lloc=pos;KeyManager.watchKeys();return function(pos) -{Coords.moveOffset([pos[0]-lloc[0],pos[1]-lloc[1]]);lloc=pos;Selection.update();};};function oppLockCorner(ord) -{switch(ord) -{case'n':return'sw';case's':return'nw';case'e':return'nw';case'w':return'ne';case'ne':return'sw';case'nw':return'se';case'se':return'nw';case'sw':return'ne';};};function createDragger(ord) -{return function(e){if(options.disabled)return false;if((ord=='move')&&!options.allowMove)return false;btndown=true;startDragMode(ord,mouseAbs(e));e.stopPropagation();e.preventDefault();return false;};};function presize($obj,w,h) -{var nw=$obj.width(),nh=$obj.height();if((nw>w)&&w>0) -{nw=w;nh=(w/$obj.width())*$obj.height();} -if((nh>h)&&h>0) -{nh=h;nw=(h/$obj.height())*$obj.width();} -xscale=$obj.width()/nw;yscale=$obj.height()/nh;$obj.width(nw).height(nh);};function unscale(c) -{return{x:parseInt(c.x*xscale),y:parseInt(c.y*yscale),x2:parseInt(c.x2*xscale),y2:parseInt(c.y2*yscale),w:parseInt(c.w*xscale),h:parseInt(c.h*yscale)};};function doneSelect(pos) -{var c=Coords.getFixed();if(c.w>options.minSelect[0]&&c.h>options.minSelect[1]) -{Selection.enableHandles();Selection.done();} -else -{Selection.release();} -Tracker.setCursor(options.allowSelect?'crosshair':'default');};function newSelection(e) -{if(options.disabled)return false;if(!options.allowSelect)return false;btndown=true;docOffset=getPos($img);Selection.disableHandles();myCursor('crosshair');var pos=mouseAbs(e);Coords.setPressed(pos);Tracker.activateHandlers(selectDrag,doneSelect);KeyManager.watchKeys();Selection.update();e.stopPropagation();e.preventDefault();return false;};function selectDrag(pos) -{Coords.setCurrent(pos);Selection.update();};function newTracker() -{var trk=$('
        ').addClass(cssClass('tracker'));$.browser.msie&&trk.css({opacity:0,backgroundColor:'white'});return trk;};function animateTo(a) -{var x1=a[0]/xscale,y1=a[1]/yscale,x2=a[2]/xscale,y2=a[3]/yscale;if(animating)return;var animto=Coords.flipCoords(x1,y1,x2,y2);var c=Coords.getFixed();var animat=initcr=[c.x,c.y,c.x2,c.y2];var interv=options.animationDelay;var x=animat[0];var y=animat[1];var x2=animat[2];var y2=animat[3];var ix1=animto[0]-initcr[0];var iy1=animto[1]-initcr[1];var ix2=animto[2]-initcr[2];var iy2=animto[3]-initcr[3];var pcent=0;var velocity=options.swingSpeed;Selection.animMode(true);var animator=function() -{return function() -{pcent+=(100-pcent)/velocity;animat[0]=x+((pcent/100)*ix1);animat[1]=y+((pcent/100)*iy1);animat[2]=x2+((pcent/100)*ix2);animat[3]=y2+((pcent/100)*iy2);if(pcent<100)animateStart();else Selection.done();if(pcent>=99.8)pcent=100;setSelectRaw(animat);};}();function animateStart() -{window.setTimeout(animator,interv);};animateStart();};function setSelect(rect) -{setSelectRaw([rect[0]/xscale,rect[1]/yscale,rect[2]/xscale,rect[3]/yscale]);};function setSelectRaw(l) -{Coords.setPressed([l[0],l[1]]);Coords.setCurrent([l[2],l[3]]);Selection.update();};function setOptions(opt) -{if(typeof(opt)!='object')opt={};options=$.extend(options,opt);if(typeof(options.onChange)!=='function') -options.onChange=function(){};if(typeof(options.onSelect)!=='function') -options.onSelect=function(){};};function tellSelect() -{return unscale(Coords.getFixed());};function tellScaled() -{return Coords.getFixed();};function setOptionsNew(opt) -{setOptions(opt);interfaceUpdate();};function disableCrop() -{options.disabled=true;Selection.disableHandles();Selection.setCursor('default');Tracker.setCursor('default');};function enableCrop() -{options.disabled=false;interfaceUpdate();};function cancelCrop() -{Selection.done();Tracker.activateHandlers(null,null);};function destroy() -{$div.remove();$origimg.show();};function interfaceUpdate(alt) -{options.allowResize?alt?Selection.enableOnly():Selection.enableHandles():Selection.disableHandles();Tracker.setCursor(options.allowSelect?'crosshair':'default');Selection.setCursor(options.allowMove?'move':'default');$div.css('backgroundColor',options.bgColor);if('setSelect'in options){setSelect(opt.setSelect);Selection.done();delete(options.setSelect);} -if('trueSize'in options){xscale=options.trueSize[0]/boundx;yscale=options.trueSize[1]/boundy;} -xlimit=options.maxSize[0]||0;ylimit=options.maxSize[1]||0;xmin=options.minSize[0]||0;ymin=options.minSize[1]||0;if('outerImage'in options) -{$img.attr('src',options.outerImage);delete(options.outerImage);} -Selection.refresh();};$hdl_holder.hide();interfaceUpdate(true);var api={animateTo:animateTo,setSelect:setSelect,setOptions:setOptionsNew,tellSelect:tellSelect,tellScaled:tellScaled,disable:disableCrop,enable:enableCrop,cancel:cancelCrop,focus:KeyManager.watchKeys,getBounds:function(){return[boundx*xscale,boundy*yscale];},getWidgetSize:function(){return[boundx,boundy];},release:Selection.release,destroy:destroy};$origimg.data('Jcrop',api);return api;};$.fn.Jcrop=function(options) -{function attachWhenDone(from) -{var loadsrc=options.useImg||from.src;var img=new Image();img.onload=function(){$.Jcrop(from,options);};img.src=loadsrc;};if(typeof(options)!=='object')options={};this.each(function() -{if($(this).data('Jcrop')) -{if(options=='api')return $(this).data('Jcrop');else $(this).data('Jcrop').setOptions(options);} -else attachWhenDone(this);});return this;};})(jQuery); \ No newline at end of file +(function(a){a.Jcrop=function(d,A){var d=d,A=A;if(typeof(d)!=="object"){d=a(d)[0]}if(typeof(A)!=="object"){A={}}if(!("trackDocument" in A)){A.trackDocument=a.browser.msie?false:true;if(a.browser.msie&&a.browser.version.split(".")[0]=="8"){A.trackDocument=true}}if(!("keySupport" in A)){A.keySupport=a.browser.msie?false:true}var U={trackDocument:false,baseClass:"jcrop",addClass:null,bgColor:"black",bgOpacity:0.6,borderOpacity:0.4,handleOpacity:0.5,handlePad:5,handleSize:9,handleOffset:5,edgeMargin:14,aspectRatio:0,keySupport:true,cornerHandles:true,sideHandles:true,drawBorders:true,dragEdges:true,boxWidth:0,boxHeight:0,boundary:8,animationDelay:20,swingSpeed:3,allowSelect:true,allowMove:true,allowResize:true,minSelect:[0,0],maxSize:[0,0],minSize:[0,0],onChange:function(){},onSelect:function(){}};var H=U;z(A);var W=a(d);var al=W.clone().removeAttr("id").css({position:"absolute"});al.width(W.width());al.height(W.height());W.after(al).hide();T(al,H.boxWidth,H.boxHeight);var Q=al.width(),O=al.height(),Z=a("
        ").width(Q).height(O).addClass(C("holder")).css({position:"relative",backgroundColor:H.bgColor}).insertAfter(W).append(al);if(H.addClass){Z.addClass(H.addClass)}var I=a("").attr("src",al.attr("src")).css("position","absolute").width(Q).height(O);var k=a("
        ").width(K(100)).height(K(100)).css({zIndex:310,position:"absolute",overflow:"hidden"}).append(I);var L=a("
        ").width(K(100)).height(K(100)).css("zIndex",320);var y=a("
        ").css({position:"absolute",zIndex:300}).insertBefore(al).append(k,L);var t=H.boundary;var b=ae().width(Q+(t*2)).height(O+(t*2)).css({position:"absolute",top:l(-t),left:l(-t),zIndex:290}).mousedown(ac);var x,ah,p,S;var M,e,n=true;var ad=D(al),r,an,am,B,ab;var aa=function(){var aq=0,aC=0,ap=0,aB=0,au,ar;function aw(aF){var aF=at(aF);ap=aq=aF[0];aB=aC=aF[1]}function av(aF){var aF=at(aF);au=aF[0]-ap;ar=aF[1]-aB;ap=aF[0];aB=aF[1]}function aE(){return[au,ar]}function ao(aH){var aG=aH[0],aF=aH[1];if(0>aq+aG){aG-=aG+aq}if(0>aC+aF){aF-=aF+aC}if(OQ){aF=Q;h=Math.abs((aF-aq)/aH);aM=aP<0?aC-h:h+aC}}}else{aF=ap;h=aJ/aH;aM=aP<0?aC-h:aC+h;if(aM<0){aM=0;w=Math.abs((aM-aC)*aH);aF=aI<0?aq-w:w+aq}else{if(aM>O){aM=O;w=Math.abs(aM-aC)*aH;aF=aI<0?aq-w:w+aq}}}if(aF>aq){if(aF-aqaG){aF=aq+aG}}if(aM>aC){aM=aC+(aF-aq)/aH}else{aM=aC-(aF-aq)/aH}}else{if(aFaG){aF=aq-aG}}if(aM>aC){aM=aC+(aq-aF)/aH}else{aM=aC-(aq-aF)/aH}}}if(aF<0){aq-=aF;aF=0}else{if(aF>Q){aq-=aF-Q;aF=Q}}if(aM<0){aC-=aM;aM=0}else{if(aM>O){aC-=aM-O;aM=O}}return last=az(ay(aq,aC,aF,aM))}function at(aF){if(aF[0]<0){aF[0]=0}if(aF[1]<0){aF[1]=0}if(aF[0]>Q){aF[0]=Q}if(aF[1]>O){aF[1]=O}return[aF[0],aF[1]]}function ay(aI,aK,aH,aJ){var aM=aI,aL=aH,aG=aK,aF=aJ;if(aHx)){ap=(aG>0)?(aq+x):(aq-x)}if(ah&&(Math.abs(aF)>ah)){aB=(aF>0)?(aC+ah):(aC-ah)}if(S&&(Math.abs(aF)0)?(aC+S):(aC-S)}if(p&&(Math.abs(aG)0)?(aq+p):(aq-p)}if(aq<0){ap-=aq;aq-=aq}if(aC<0){aB-=aC;aC-=aC}if(ap<0){aq-=ap;ap-=ap}if(aB<0){aC-=aB;aB-=aB}if(ap>Q){var aH=ap-Q;aq-=aH;ap-=aH}if(aB>O){var aH=aB-O;aC-=aH;aB-=aH}if(aq>Q){var aH=aq-O;aB-=aH;aC-=aH}if(aC>O){var aH=aC-O;aB-=aH;aC-=aH}return az(ay(aq,aC,ap,aB))}function az(aF){return{x:aF[0],y:aF[1],x2:aF[2],y2:aF[3],w:aF[2]-aF[0],h:aF[3]-aF[1]}}return{flipCoords:ay,setPressed:aw,setCurrent:av,getOffset:aE,moveOffset:ao,getCorner:ax,getFixed:aD}}();var X=function(){var aw,ar,aC,aB,aK=370;var av={};var aO={};var aq=false;var aA=H.handleOffset;if(H.drawBorders){av={top:ax("hline").css("top",a.browser.msie?l(-1):l(0)),bottom:ax("hline"),left:ax("vline"),right:ax("vline")}}if(H.dragEdges){aO.t=aJ("n");aO.b=aJ("s");aO.r=aJ("e");aO.l=aJ("w")}H.sideHandles&&aF(["n","s","e","w"]);H.cornerHandles&&aF(["sw","nw","ne","se"]);function ax(aR){var aS=a("
        ").css({position:"absolute",opacity:H.borderOpacity}).addClass(C(aR));k.append(aS);return aS}function ap(aR,aS){var aT=a("
        ").mousedown(c(aR)).css({cursor:aR+"-resize",position:"absolute",zIndex:aS});L.append(aT);return aT}function aD(aR){return ap(aR,aK++).css({top:l(-aA+1),left:l(-aA+1),opacity:H.handleOpacity}).addClass(C("handle"))}function aJ(aT){var aW=H.handleSize,aX=aA,aV=aW,aS=aW,aU=aX,aR=aX;switch(aT){case"n":case"s":aS=K(100);break;case"e":case"w":aV=K(100);break}return ap(aT,aK++).width(aS).height(aV).css({top:l(-aU+1),left:l(-aR+1)})}function aF(aR){for(i in aR){aO[aR[i]]=aD(aR[i])}}function aH(aY){var aT=Math.round((aY.h/2)-aA),aS=Math.round((aY.w/2)-aA),aW=west=-aA+1,aV=aY.w-aA,aU=aY.h-aA,aR,aX;"e" in aO&&aO.e.css({top:l(aT),left:l(aV)})&&aO.w.css({top:l(aT)})&&aO.s.css({top:l(aU),left:l(aS)})&&aO.n.css({left:l(aS)});"ne" in aO&&aO.ne.css({left:l(aV)})&&aO.se.css({top:l(aU),left:l(aV)})&&aO.sw.css({top:l(aU)});"b" in aO&&aO.b.css({top:l(aU)})&&aO.r.css({left:l(aV)})}function az(aR,aS){I.css({top:l(-aS),left:l(-aR)});y.css({top:l(aS),left:l(aR)})}function aQ(aR,aS){y.width(aR).height(aS)}function at(){var aR=aa.getFixed();aa.setPressed([aR.x,aR.y]);aa.setCurrent([aR.x2,aR.y2]);aN()}function aN(){if(aB){return ay()}}function ay(){var aR=aa.getFixed();aQ(aR.w,aR.h);az(aR.x,aR.y);H.drawBorders&&av.right.css({left:l(aR.w-1)})&&av.bottom.css({top:l(aR.h-1)});aq&&aH(aR);aB||aP();H.onChange(Y(aR))}function aP(){y.show();al.css("opacity",H.bgOpacity);aB=true}function aL(){aM();y.hide();al.css("opacity",1);aB=false}function ao(){if(aq){aH(aa.getFixed());L.show()}}function aG(){aq=true;if(H.allowResize){aH(aa.getFixed());L.show();return true}}function aM(){aq=false;L.hide()}function aI(aR){(B=aR)?aM():aG()}function aE(){aI(false);at()}var au=ae().mousedown(c("move")).css({cursor:"move",position:"absolute",zIndex:360});k.append(au);aM();return{updateVisible:aN,update:ay,release:aL,refresh:at,setCursor:function(aR){au.css("cursor",aR)},enableHandles:aG,enableOnly:function(){aq=true},showHandles:ao,disableHandles:aM,animMode:aI,done:aE}}();var P=function(){var ap=function(){},ar=function(){},aq=H.trackDocument;if(!aq){b.mousemove(ao).mouseup(at).mouseout(at)}function ax(){b.css({zIndex:450});if(aq){a(document).mousemove(ao).mouseup(at)}}function aw(){b.css({zIndex:290});if(aq){a(document).unbind("mousemove",ao).unbind("mouseup",at)}}function ao(ay){ap(F(ay))}function at(ay){ay.preventDefault();ay.stopPropagation();if(r){r=false;ar(F(ay));H.onSelect(Y(aa.getFixed()));aw();ap=function(){};ar=function(){}}return false}function au(az,ay){r=true;ap=az;ar=ay;ax();return false}function av(ay){b.css("cursor",ay)}al.before(b);return{activateHandlers:au,setCursor:av}}();var ak=function(){var ar=a('').css({position:"absolute",left:"-30px"}).keypress(ao).blur(at),au=a("
        ").css({position:"absolute",overflow:"hidden"}).append(ar);function ap(){if(H.keySupport){ar.show();ar.focus()}}function at(av){ar.hide()}function aq(aw,av,ax){if(H.allowMove){aa.moveOffset([av,ax]);X.updateVisible()}aw.preventDefault();aw.stopPropagation()}function ao(aw){if(aw.ctrlKey){return true}ab=aw.shiftKey?true:false;var av=ab?10:1;switch(aw.keyCode){case 37:aq(aw,-av,0);break;case 39:aq(aw,av,0);break;case 38:aq(aw,0,-av);break;case 40:aq(aw,0,av);break;case 27:X.release();break;case 9:return true}return nothing(aw)}if(H.keySupport){au.insertBefore(al)}return{watchKeys:ap}}();function l(ao){return""+parseInt(ao)+"px"}function K(ao){return""+parseInt(ao)+"%"}function C(ao){return H.baseClass+"-"+ao}function D(ao){var ap=a(ao).offset();return[ap.left,ap.top]}function F(ao){return[(ao.pageX-ad[0]),(ao.pageY-ad[1])]}function E(ao){if(ao!=an){P.setCursor(ao);an=ao}}function f(aq,at){ad=D(al);P.setCursor(aq=="move"?aq:aq+"-resize");if(aq=="move"){return P.activateHandlers(R(at),o)}var ao=aa.getFixed();var ap=q(aq);var ar=aa.getCorner(q(ap));aa.setPressed(aa.getCorner(ap));aa.setCurrent(ar);P.activateHandlers(G(aq,ao),o)}function G(ap,ao){return function(aq){if(!H.aspectRatio){switch(ap){case"e":aq[1]=ao.y2;break;case"w":aq[1]=ao.y2;break;case"n":aq[0]=ao.x2;break;case"s":aq[0]=ao.x2;break}}else{switch(ap){case"e":aq[1]=ao.y+1;break;case"w":aq[1]=ao.y+1;break;case"n":aq[0]=ao.x+1;break;case"s":aq[0]=ao.x+1;break}}aa.setCurrent(aq);X.update()}}function R(ap){var ao=ap;ak.watchKeys();return function(aq){aa.moveOffset([aq[0]-ao[0],aq[1]-ao[1]]);ao=aq;X.update()}}function q(ao){switch(ao){case"n":return"sw";case"s":return"nw";case"e":return"nw";case"w":return"ne";case"ne":return"sw";case"nw":return"se";case"se":return"nw";case"sw":return"ne"}}function c(ao){return function(ap){if(H.disabled){return false}if((ao=="move")&&!H.allowMove){return false}r=true;f(ao,F(ap));ap.stopPropagation();ap.preventDefault();return false}}function T(at,ap,ar){var ao=at.width(),aq=at.height();if((ao>ap)&&ap>0){ao=ap;aq=(ap/at.width())*at.height()}if((aq>ar)&&ar>0){aq=ar;ao=(ar/at.height())*at.width()}M=at.width()/ao;e=at.height()/aq;at.width(ao).height(aq)}function Y(ao){return{x:parseInt(ao.x*M),y:parseInt(ao.y*e),x2:parseInt(ao.x2*M),y2:parseInt(ao.y2*e),w:parseInt(ao.w*M),h:parseInt(ao.h*e)}}function o(ap){var ao=aa.getFixed();if(ao.w>H.minSelect[0]&&ao.h>H.minSelect[1]){X.enableHandles();X.done()}else{X.release()}P.setCursor(H.allowSelect?"crosshair":"default")}function ac(ao){if(H.disabled){return false}if(!H.allowSelect){return false}r=true;ad=D(al);X.disableHandles();E("crosshair");var ap=F(ao);aa.setPressed(ap);P.activateHandlers(aj,o);ak.watchKeys();X.update();ao.stopPropagation();ao.preventDefault();return false}function aj(ao){aa.setCurrent(ao);X.update()}function ae(){var ao=a("
        ").addClass(C("tracker"));a.browser.msie&&ao.css({opacity:0,backgroundColor:"white"});return ao}function s(aG){var aB=aG[0]/M,ap=aG[1]/e,aA=aG[2]/M,ao=aG[3]/e;if(B){return}var az=aa.flipCoords(aB,ap,aA,ao);var aE=aa.getFixed();var ar=initcr=[aE.x,aE.y,aE.x2,aE.y2];var aq=H.animationDelay;var ax=ar[0];var aw=ar[1];var aA=ar[2];var ao=ar[3];var aD=az[0]-initcr[0];var au=az[1]-initcr[1];var aC=az[2]-initcr[2];var at=az[3]-initcr[3];var ay=0;var av=H.swingSpeed;X.animMode(true);var aF=function(){return function(){ay+=(100-ay)/av;ar[0]=ax+((ay/100)*aD);ar[1]=aw+((ay/100)*au);ar[2]=aA+((ay/100)*aC);ar[3]=ao+((ay/100)*at);if(ay<100){aH()}else{X.done()}if(ay>=99.8){ay=100}ai(ar)}}();function aH(){window.setTimeout(aF,aq)}aH()}function J(ao){ai([ao[0]/M,ao[1]/e,ao[2]/M,ao[3]/e])}function ai(ao){aa.setPressed([ao[0],ao[1]]);aa.setCurrent([ao[2],ao[3]]);X.update()}function z(ao){if(typeof(ao)!="object"){ao={}}H=a.extend(H,ao);if(typeof(H.onChange)!=="function"){H.onChange=function(){}}if(typeof(H.onSelect)!=="function"){H.onSelect=function(){}}}function j(){return Y(aa.getFixed())}function ag(){return aa.getFixed()}function u(ao){z(ao);N()}function v(){H.disabled=true;X.disableHandles();X.setCursor("default");P.setCursor("default")}function V(){H.disabled=false;N()}function m(){X.done();P.activateHandlers(null,null)}function af(){Z.remove();W.show()}function N(ao){H.allowResize?ao?X.enableOnly():X.enableHandles():X.disableHandles();P.setCursor(H.allowSelect?"crosshair":"default");X.setCursor(H.allowMove?"move":"default");Z.css("backgroundColor",H.bgColor);if("setSelect" in H){J(A.setSelect);X.done();delete (H.setSelect)}if("trueSize" in H){M=H.trueSize[0]/Q;e=H.trueSize[1]/O}x=H.maxSize[0]||0;ah=H.maxSize[1]||0;p=H.minSize[0]||0;S=H.minSize[1]||0;if("outerImage" in H){al.attr("src",H.outerImage);delete (H.outerImage)}X.refresh()}L.hide();N(true);var g={animateTo:s,setSelect:J,setOptions:u,tellSelect:j,tellScaled:ag,disable:v,enable:V,cancel:m,focus:ak.watchKeys,getBounds:function(){return[Q*M,O*e]},getWidgetSize:function(){return[Q,O]},release:X.release,destroy:af};W.data("Jcrop",g);return g};a.fn.Jcrop=function(c){function b(f){var e=c.useImg||f.src;var d=new Image();d.onload=function(){a.Jcrop(f,c)};d.src=e}if(typeof(c)!=="object"){c={}}this.each(function(){if(a(this).data("Jcrop")){if(c=="api"){return a(this).data("Jcrop")}else{a(this).data("Jcrop").setOptions(c)}}else{b(this)}});return this}})(jQuery); \ No newline at end of file diff --git a/wp-includes/js/jquery/jquery.js b/wp-includes/js/jquery/jquery.js index 00999f68..53e8e8be 100644 --- a/wp-includes/js/jquery/jquery.js +++ b/wp-includes/js/jquery/jquery.js @@ -1,5 +1,5 @@ /*! - * jQuery JavaScript Library v1.4.2 + * jQuery JavaScript Library v1.4.4 * http://jquery.com/ * * Copyright 2010, John Resig @@ -11,144 +11,157 @@ * Copyright 2010, The Dojo Foundation * Released under the MIT, BSD, and GPL Licenses. * - * Date: Sat Feb 13 22:33:48 2010 -0500 + * Date: Thu Nov 11 19:04:53 2010 -0500 */ -(function(A,w){function ma(){if(!c.isReady){try{s.documentElement.doScroll("left")}catch(a){setTimeout(ma,1);return}c.ready()}}function Qa(a,b){b.src?c.ajax({url:b.src,async:false,dataType:"script"}):c.globalEval(b.text||b.textContent||b.innerHTML||"");b.parentNode&&b.parentNode.removeChild(b)}function X(a,b,d,f,e,j){var i=a.length;if(typeof b==="object"){for(var o in b)X(a,o,b[o],f,e,d);return a}if(d!==w){f=!j&&f&&c.isFunction(d);for(o=0;o)[^>]*$|^#([\w-]+)$/,Ua=/^.[^:#\[\.,]*$/,Va=/\S/, -Wa=/^(\s|\u00A0)+|(\s|\u00A0)+$/g,Xa=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,P=navigator.userAgent,xa=false,Q=[],L,$=Object.prototype.toString,aa=Object.prototype.hasOwnProperty,ba=Array.prototype.push,R=Array.prototype.slice,ya=Array.prototype.indexOf;c.fn=c.prototype={init:function(a,b){var d,f;if(!a)return this;if(a.nodeType){this.context=this[0]=a;this.length=1;return this}if(a==="body"&&!b){this.context=s;this[0]=s.body;this.selector="body";this.length=1;return this}if(typeof a==="string")if((d=Ta.exec(a))&& -(d[1]||!b))if(d[1]){f=b?b.ownerDocument||b:s;if(a=Xa.exec(a))if(c.isPlainObject(b)){a=[s.createElement(a[1])];c.fn.attr.call(a,b,true)}else a=[f.createElement(a[1])];else{a=sa([d[1]],[f]);a=(a.cacheable?a.fragment.cloneNode(true):a.fragment).childNodes}return c.merge(this,a)}else{if(b=s.getElementById(d[2])){if(b.id!==d[2])return T.find(a);this.length=1;this[0]=b}this.context=s;this.selector=a;return this}else if(!b&&/^\w+$/.test(a)){this.selector=a;this.context=s;a=s.getElementsByTagName(a);return c.merge(this, -a)}else return!b||b.jquery?(b||T).find(a):c(b).find(a);else if(c.isFunction(a))return T.ready(a);if(a.selector!==w){this.selector=a.selector;this.context=a.context}return c.makeArray(a,this)},selector:"",jquery:"1.4.2",length:0,size:function(){return this.length},toArray:function(){return R.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this.slice(a)[0]:this[a]},pushStack:function(a,b,d){var f=c();c.isArray(a)?ba.apply(f,a):c.merge(f,a);f.prevObject=this;f.context=this.context;if(b=== -"find")f.selector=this.selector+(this.selector?" ":"")+d;else if(b)f.selector=this.selector+"."+b+"("+d+")";return f},each:function(a,b){return c.each(this,a,b)},ready:function(a){c.bindReady();if(c.isReady)a.call(s,c);else Q&&Q.push(a);return this},eq:function(a){return a===-1?this.slice(a):this.slice(a,+a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(R.apply(this,arguments),"slice",R.call(arguments).join(","))},map:function(a){return this.pushStack(c.map(this, -function(b,d){return a.call(b,d,b)}))},end:function(){return this.prevObject||c(null)},push:ba,sort:[].sort,splice:[].splice};c.fn.init.prototype=c.fn;c.extend=c.fn.extend=function(){var a=arguments[0]||{},b=1,d=arguments.length,f=false,e,j,i,o;if(typeof a==="boolean"){f=a;a=arguments[1]||{};b=2}if(typeof a!=="object"&&!c.isFunction(a))a={};if(d===b){a=this;--b}for(;b
        a"; -var e=d.getElementsByTagName("*"),j=d.getElementsByTagName("a")[0];if(!(!e||!e.length||!j)){c.support={leadingWhitespace:d.firstChild.nodeType===3,tbody:!d.getElementsByTagName("tbody").length,htmlSerialize:!!d.getElementsByTagName("link").length,style:/red/.test(j.getAttribute("style")),hrefNormalized:j.getAttribute("href")==="/a",opacity:/^0.55$/.test(j.style.opacity),cssFloat:!!j.style.cssFloat,checkOn:d.getElementsByTagName("input")[0].value==="on",optSelected:s.createElement("select").appendChild(s.createElement("option")).selected, -parentNode:d.removeChild(d.appendChild(s.createElement("div"))).parentNode===null,deleteExpando:true,checkClone:false,scriptEval:false,noCloneEvent:true,boxModel:null};b.type="text/javascript";try{b.appendChild(s.createTextNode("window."+f+"=1;"))}catch(i){}a.insertBefore(b,a.firstChild);if(A[f]){c.support.scriptEval=true;delete A[f]}try{delete b.test}catch(o){c.support.deleteExpando=false}a.removeChild(b);if(d.attachEvent&&d.fireEvent){d.attachEvent("onclick",function k(){c.support.noCloneEvent= -false;d.detachEvent("onclick",k)});d.cloneNode(true).fireEvent("onclick")}d=s.createElement("div");d.innerHTML="";a=s.createDocumentFragment();a.appendChild(d.firstChild);c.support.checkClone=a.cloneNode(true).cloneNode(true).lastChild.checked;c(function(){var k=s.createElement("div");k.style.width=k.style.paddingLeft="1px";s.body.appendChild(k);c.boxModel=c.support.boxModel=k.offsetWidth===2;s.body.removeChild(k).style.display="none"});a=function(k){var n= -s.createElement("div");k="on"+k;var r=k in n;if(!r){n.setAttribute(k,"return;");r=typeof n[k]==="function"}return r};c.support.submitBubbles=a("submit");c.support.changeBubbles=a("change");a=b=d=e=j=null}})();c.props={"for":"htmlFor","class":"className",readonly:"readOnly",maxlength:"maxLength",cellspacing:"cellSpacing",rowspan:"rowSpan",colspan:"colSpan",tabindex:"tabIndex",usemap:"useMap",frameborder:"frameBorder"};var G="jQuery"+J(),Ya=0,za={};c.extend({cache:{},expando:G,noData:{embed:true,object:true, -applet:true},data:function(a,b,d){if(!(a.nodeName&&c.noData[a.nodeName.toLowerCase()])){a=a==A?za:a;var f=a[G],e=c.cache;if(!f&&typeof b==="string"&&d===w)return null;f||(f=++Ya);if(typeof b==="object"){a[G]=f;e[f]=c.extend(true,{},b)}else if(!e[f]){a[G]=f;e[f]={}}a=e[f];if(d!==w)a[b]=d;return typeof b==="string"?a[b]:a}},removeData:function(a,b){if(!(a.nodeName&&c.noData[a.nodeName.toLowerCase()])){a=a==A?za:a;var d=a[G],f=c.cache,e=f[d];if(b){if(e){delete e[b];c.isEmptyObject(e)&&c.removeData(a)}}else{if(c.support.deleteExpando)delete a[c.expando]; -else a.removeAttribute&&a.removeAttribute(c.expando);delete f[d]}}}});c.fn.extend({data:function(a,b){if(typeof a==="undefined"&&this.length)return c.data(this[0]);else if(typeof a==="object")return this.each(function(){c.data(this,a)});var d=a.split(".");d[1]=d[1]?"."+d[1]:"";if(b===w){var f=this.triggerHandler("getData"+d[1]+"!",[d[0]]);if(f===w&&this.length)f=c.data(this[0],a);return f===w&&d[1]?this.data(d[0]):f}else return this.trigger("setData"+d[1]+"!",[d[0],b]).each(function(){c.data(this, -a,b)})},removeData:function(a){return this.each(function(){c.removeData(this,a)})}});c.extend({queue:function(a,b,d){if(a){b=(b||"fx")+"queue";var f=c.data(a,b);if(!d)return f||[];if(!f||c.isArray(d))f=c.data(a,b,c.makeArray(d));else f.push(d);return f}},dequeue:function(a,b){b=b||"fx";var d=c.queue(a,b),f=d.shift();if(f==="inprogress")f=d.shift();if(f){b==="fx"&&d.unshift("inprogress");f.call(a,function(){c.dequeue(a,b)})}}});c.fn.extend({queue:function(a,b){if(typeof a!=="string"){b=a;a="fx"}if(b=== -w)return c.queue(this[0],a);return this.each(function(){var d=c.queue(this,a,b);a==="fx"&&d[0]!=="inprogress"&&c.dequeue(this,a)})},dequeue:function(a){return this.each(function(){c.dequeue(this,a)})},delay:function(a,b){a=c.fx?c.fx.speeds[a]||a:a;b=b||"fx";return this.queue(b,function(){var d=this;setTimeout(function(){c.dequeue(d,b)},a)})},clearQueue:function(a){return this.queue(a||"fx",[])}});var Aa=/[\n\t]/g,ca=/\s+/,Za=/\r/g,$a=/href|src|style/,ab=/(button|input)/i,bb=/(button|input|object|select|textarea)/i, -cb=/^(a|area)$/i,Ba=/radio|checkbox/;c.fn.extend({attr:function(a,b){return X(this,a,b,true,c.attr)},removeAttr:function(a){return this.each(function(){c.attr(this,a,"");this.nodeType===1&&this.removeAttribute(a)})},addClass:function(a){if(c.isFunction(a))return this.each(function(n){var r=c(this);r.addClass(a.call(this,n,r.attr("class")))});if(a&&typeof a==="string")for(var b=(a||"").split(ca),d=0,f=this.length;d-1)return true;return false},val:function(a){if(a===w){var b=this[0];if(b){if(c.nodeName(b,"option"))return(b.attributes.value||{}).specified?b.value:b.text;if(c.nodeName(b,"select")){var d=b.selectedIndex,f=[],e=b.options;b=b.type==="select-one";if(d<0)return null;var j=b?d:0;for(d=b?d+1:e.length;j=0;else if(c.nodeName(this,"select")){var u=c.makeArray(r);c("option",this).each(function(){this.selected= -c.inArray(c(this).val(),u)>=0});if(!u.length)this.selectedIndex=-1}else this.value=r}})}});c.extend({attrFn:{val:true,css:true,html:true,text:true,data:true,width:true,height:true,offset:true},attr:function(a,b,d,f){if(!a||a.nodeType===3||a.nodeType===8)return w;if(f&&b in c.attrFn)return c(a)[b](d);f=a.nodeType!==1||!c.isXMLDoc(a);var e=d!==w;b=f&&c.props[b]||b;if(a.nodeType===1){var j=$a.test(b);if(b in a&&f&&!j){if(e){b==="type"&&ab.test(a.nodeName)&&a.parentNode&&c.error("type property can't be changed"); -a[b]=d}if(c.nodeName(a,"form")&&a.getAttributeNode(b))return a.getAttributeNode(b).nodeValue;if(b==="tabIndex")return(b=a.getAttributeNode("tabIndex"))&&b.specified?b.value:bb.test(a.nodeName)||cb.test(a.nodeName)&&a.href?0:w;return a[b]}if(!c.support.style&&f&&b==="style"){if(e)a.style.cssText=""+d;return a.style.cssText}e&&a.setAttribute(b,""+d);a=!c.support.hrefNormalized&&f&&j?a.getAttribute(b,2):a.getAttribute(b);return a===null?w:a}return c.style(a,b,d)}});var O=/\.(.*)$/,db=function(a){return a.replace(/[^\w\s\.\|`]/g, -function(b){return"\\"+b})};c.event={add:function(a,b,d,f){if(!(a.nodeType===3||a.nodeType===8)){if(a.setInterval&&a!==A&&!a.frameElement)a=A;var e,j;if(d.handler){e=d;d=e.handler}if(!d.guid)d.guid=c.guid++;if(j=c.data(a)){var i=j.events=j.events||{},o=j.handle;if(!o)j.handle=o=function(){return typeof c!=="undefined"&&!c.event.triggered?c.event.handle.apply(o.elem,arguments):w};o.elem=a;b=b.split(" ");for(var k,n=0,r;k=b[n++];){j=e?c.extend({},e):{handler:d,data:f};if(k.indexOf(".")>-1){r=k.split("."); -k=r.shift();j.namespace=r.slice(0).sort().join(".")}else{r=[];j.namespace=""}j.type=k;j.guid=d.guid;var u=i[k],z=c.event.special[k]||{};if(!u){u=i[k]=[];if(!z.setup||z.setup.call(a,f,r,o)===false)if(a.addEventListener)a.addEventListener(k,o,false);else a.attachEvent&&a.attachEvent("on"+k,o)}if(z.add){z.add.call(a,j);if(!j.handler.guid)j.handler.guid=d.guid}u.push(j);c.event.global[k]=true}a=null}}},global:{},remove:function(a,b,d,f){if(!(a.nodeType===3||a.nodeType===8)){var e,j=0,i,o,k,n,r,u,z=c.data(a), -C=z&&z.events;if(z&&C){if(b&&b.type){d=b.handler;b=b.type}if(!b||typeof b==="string"&&b.charAt(0)==="."){b=b||"";for(e in C)c.event.remove(a,e+b)}else{for(b=b.split(" ");e=b[j++];){n=e;i=e.indexOf(".")<0;o=[];if(!i){o=e.split(".");e=o.shift();k=new RegExp("(^|\\.)"+c.map(o.slice(0).sort(),db).join("\\.(?:.*\\.)?")+"(\\.|$)")}if(r=C[e])if(d){n=c.event.special[e]||{};for(B=f||0;B=0){a.type= -e=e.slice(0,-1);a.exclusive=true}if(!d){a.stopPropagation();c.event.global[e]&&c.each(c.cache,function(){this.events&&this.events[e]&&c.event.trigger(a,b,this.handle.elem)})}if(!d||d.nodeType===3||d.nodeType===8)return w;a.result=w;a.target=d;b=c.makeArray(b);b.unshift(a)}a.currentTarget=d;(f=c.data(d,"handle"))&&f.apply(d,b);f=d.parentNode||d.ownerDocument;try{if(!(d&&d.nodeName&&c.noData[d.nodeName.toLowerCase()]))if(d["on"+e]&&d["on"+e].apply(d,b)===false)a.result=false}catch(j){}if(!a.isPropagationStopped()&& -f)c.event.trigger(a,b,f,true);else if(!a.isDefaultPrevented()){f=a.target;var i,o=c.nodeName(f,"a")&&e==="click",k=c.event.special[e]||{};if((!k._default||k._default.call(d,a)===false)&&!o&&!(f&&f.nodeName&&c.noData[f.nodeName.toLowerCase()])){try{if(f[e]){if(i=f["on"+e])f["on"+e]=null;c.event.triggered=true;f[e]()}}catch(n){}if(i)f["on"+e]=i;c.event.triggered=false}}},handle:function(a){var b,d,f,e;a=arguments[0]=c.event.fix(a||A.event);a.currentTarget=this;b=a.type.indexOf(".")<0&&!a.exclusive; -if(!b){d=a.type.split(".");a.type=d.shift();f=new RegExp("(^|\\.)"+d.slice(0).sort().join("\\.(?:.*\\.)?")+"(\\.|$)")}e=c.data(this,"events");d=e[a.type];if(e&&d){d=d.slice(0);e=0;for(var j=d.length;e-1?c.map(a.options,function(f){return f.selected}).join("-"):"";else if(a.nodeName.toLowerCase()==="select")d=a.selectedIndex;return d},fa=function(a,b){var d=a.target,f,e;if(!(!da.test(d.nodeName)||d.readOnly)){f=c.data(d,"_change_data");e=Fa(d);if(a.type!=="focusout"||d.type!=="radio")c.data(d,"_change_data", -e);if(!(f===w||e===f))if(f!=null||e){a.type="change";return c.event.trigger(a,b,d)}}};c.event.special.change={filters:{focusout:fa,click:function(a){var b=a.target,d=b.type;if(d==="radio"||d==="checkbox"||b.nodeName.toLowerCase()==="select")return fa.call(this,a)},keydown:function(a){var b=a.target,d=b.type;if(a.keyCode===13&&b.nodeName.toLowerCase()!=="textarea"||a.keyCode===32&&(d==="checkbox"||d==="radio")||d==="select-multiple")return fa.call(this,a)},beforeactivate:function(a){a=a.target;c.data(a, -"_change_data",Fa(a))}},setup:function(){if(this.type==="file")return false;for(var a in ea)c.event.add(this,a+".specialChange",ea[a]);return da.test(this.nodeName)},teardown:function(){c.event.remove(this,".specialChange");return da.test(this.nodeName)}};ea=c.event.special.change.filters}s.addEventListener&&c.each({focus:"focusin",blur:"focusout"},function(a,b){function d(f){f=c.event.fix(f);f.type=b;return c.event.handle.call(this,f)}c.event.special[b]={setup:function(){this.addEventListener(a, -d,true)},teardown:function(){this.removeEventListener(a,d,true)}}});c.each(["bind","one"],function(a,b){c.fn[b]=function(d,f,e){if(typeof d==="object"){for(var j in d)this[b](j,f,d[j],e);return this}if(c.isFunction(f)){e=f;f=w}var i=b==="one"?c.proxy(e,function(k){c(this).unbind(k,i);return e.apply(this,arguments)}):e;if(d==="unload"&&b!=="one")this.one(d,f,e);else{j=0;for(var o=this.length;j0){y=t;break}}t=t[g]}m[q]=y}}}var f=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g, -e=0,j=Object.prototype.toString,i=false,o=true;[0,0].sort(function(){o=false;return 0});var k=function(g,h,l,m){l=l||[];var q=h=h||s;if(h.nodeType!==1&&h.nodeType!==9)return[];if(!g||typeof g!=="string")return l;for(var p=[],v,t,y,S,H=true,M=x(h),I=g;(f.exec(""),v=f.exec(I))!==null;){I=v[3];p.push(v[1]);if(v[2]){S=v[3];break}}if(p.length>1&&r.exec(g))if(p.length===2&&n.relative[p[0]])t=ga(p[0]+p[1],h);else for(t=n.relative[p[0]]?[h]:k(p.shift(),h);p.length;){g=p.shift();if(n.relative[g])g+=p.shift(); -t=ga(g,t)}else{if(!m&&p.length>1&&h.nodeType===9&&!M&&n.match.ID.test(p[0])&&!n.match.ID.test(p[p.length-1])){v=k.find(p.shift(),h,M);h=v.expr?k.filter(v.expr,v.set)[0]:v.set[0]}if(h){v=m?{expr:p.pop(),set:z(m)}:k.find(p.pop(),p.length===1&&(p[0]==="~"||p[0]==="+")&&h.parentNode?h.parentNode:h,M);t=v.expr?k.filter(v.expr,v.set):v.set;if(p.length>0)y=z(t);else H=false;for(;p.length;){var D=p.pop();v=D;if(n.relative[D])v=p.pop();else D="";if(v==null)v=h;n.relative[D](y,v,M)}}else y=[]}y||(y=t);y||k.error(D|| -g);if(j.call(y)==="[object Array]")if(H)if(h&&h.nodeType===1)for(g=0;y[g]!=null;g++){if(y[g]&&(y[g]===true||y[g].nodeType===1&&E(h,y[g])))l.push(t[g])}else for(g=0;y[g]!=null;g++)y[g]&&y[g].nodeType===1&&l.push(t[g]);else l.push.apply(l,y);else z(y,l);if(S){k(S,q,l,m);k.uniqueSort(l)}return l};k.uniqueSort=function(g){if(B){i=o;g.sort(B);if(i)for(var h=1;h":function(g,h){var l=typeof h==="string";if(l&&!/\W/.test(h)){h=h.toLowerCase();for(var m=0,q=g.length;m=0))l||m.push(v);else if(l)h[p]=false;return false},ID:function(g){return g[1].replace(/\\/g,"")},TAG:function(g){return g[1].toLowerCase()}, -CHILD:function(g){if(g[1]==="nth"){var h=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(g[2]==="even"&&"2n"||g[2]==="odd"&&"2n+1"||!/\D/.test(g[2])&&"0n+"+g[2]||g[2]);g[2]=h[1]+(h[2]||1)-0;g[3]=h[3]-0}g[0]=e++;return g},ATTR:function(g,h,l,m,q,p){h=g[1].replace(/\\/g,"");if(!p&&n.attrMap[h])g[1]=n.attrMap[h];if(g[2]==="~=")g[4]=" "+g[4]+" ";return g},PSEUDO:function(g,h,l,m,q){if(g[1]==="not")if((f.exec(g[3])||"").length>1||/^\w/.test(g[3]))g[3]=k(g[3],null,null,h);else{g=k.filter(g[3],h,l,true^q);l||m.push.apply(m, -g);return false}else if(n.match.POS.test(g[0])||n.match.CHILD.test(g[0]))return true;return g},POS:function(g){g.unshift(true);return g}},filters:{enabled:function(g){return g.disabled===false&&g.type!=="hidden"},disabled:function(g){return g.disabled===true},checked:function(g){return g.checked===true},selected:function(g){return g.selected===true},parent:function(g){return!!g.firstChild},empty:function(g){return!g.firstChild},has:function(g,h,l){return!!k(l[3],g).length},header:function(g){return/h\d/i.test(g.nodeName)}, -text:function(g){return"text"===g.type},radio:function(g){return"radio"===g.type},checkbox:function(g){return"checkbox"===g.type},file:function(g){return"file"===g.type},password:function(g){return"password"===g.type},submit:function(g){return"submit"===g.type},image:function(g){return"image"===g.type},reset:function(g){return"reset"===g.type},button:function(g){return"button"===g.type||g.nodeName.toLowerCase()==="button"},input:function(g){return/input|select|textarea|button/i.test(g.nodeName)}}, -setFilters:{first:function(g,h){return h===0},last:function(g,h,l,m){return h===m.length-1},even:function(g,h){return h%2===0},odd:function(g,h){return h%2===1},lt:function(g,h,l){return hl[3]-0},nth:function(g,h,l){return l[3]-0===h},eq:function(g,h,l){return l[3]-0===h}},filter:{PSEUDO:function(g,h,l,m){var q=h[1],p=n.filters[q];if(p)return p(g,l,h,m);else if(q==="contains")return(g.textContent||g.innerText||a([g])||"").indexOf(h[3])>=0;else if(q==="not"){h= -h[3];l=0;for(m=h.length;l=0}},ID:function(g,h){return g.nodeType===1&&g.getAttribute("id")===h},TAG:function(g,h){return h==="*"&&g.nodeType===1||g.nodeName.toLowerCase()===h},CLASS:function(g,h){return(" "+(g.className||g.getAttribute("class"))+" ").indexOf(h)>-1},ATTR:function(g,h){var l=h[1];g=n.attrHandle[l]?n.attrHandle[l](g):g[l]!=null?g[l]:g.getAttribute(l);l=g+"";var m=h[2];h=h[4];return g==null?m==="!=":m=== -"="?l===h:m==="*="?l.indexOf(h)>=0:m==="~="?(" "+l+" ").indexOf(h)>=0:!h?l&&g!==false:m==="!="?l!==h:m==="^="?l.indexOf(h)===0:m==="$="?l.substr(l.length-h.length)===h:m==="|="?l===h||l.substr(0,h.length+1)===h+"-":false},POS:function(g,h,l,m){var q=n.setFilters[h[2]];if(q)return q(g,l,h,m)}}},r=n.match.POS;for(var u in n.match){n.match[u]=new RegExp(n.match[u].source+/(?![^\[]*\])(?![^\(]*\))/.source);n.leftMatch[u]=new RegExp(/(^(?:.|\r|\n)*?)/.source+n.match[u].source.replace(/\\(\d+)/g,function(g, -h){return"\\"+(h-0+1)}))}var z=function(g,h){g=Array.prototype.slice.call(g,0);if(h){h.push.apply(h,g);return h}return g};try{Array.prototype.slice.call(s.documentElement.childNodes,0)}catch(C){z=function(g,h){h=h||[];if(j.call(g)==="[object Array]")Array.prototype.push.apply(h,g);else if(typeof g.length==="number")for(var l=0,m=g.length;l";var l=s.documentElement;l.insertBefore(g,l.firstChild);if(s.getElementById(h)){n.find.ID=function(m,q,p){if(typeof q.getElementById!=="undefined"&&!p)return(q=q.getElementById(m[1]))?q.id===m[1]||typeof q.getAttributeNode!=="undefined"&& -q.getAttributeNode("id").nodeValue===m[1]?[q]:w:[]};n.filter.ID=function(m,q){var p=typeof m.getAttributeNode!=="undefined"&&m.getAttributeNode("id");return m.nodeType===1&&p&&p.nodeValue===q}}l.removeChild(g);l=g=null})();(function(){var g=s.createElement("div");g.appendChild(s.createComment(""));if(g.getElementsByTagName("*").length>0)n.find.TAG=function(h,l){l=l.getElementsByTagName(h[1]);if(h[1]==="*"){h=[];for(var m=0;l[m];m++)l[m].nodeType===1&&h.push(l[m]);l=h}return l};g.innerHTML=""; -if(g.firstChild&&typeof g.firstChild.getAttribute!=="undefined"&&g.firstChild.getAttribute("href")!=="#")n.attrHandle.href=function(h){return h.getAttribute("href",2)};g=null})();s.querySelectorAll&&function(){var g=k,h=s.createElement("div");h.innerHTML="

        ";if(!(h.querySelectorAll&&h.querySelectorAll(".TEST").length===0)){k=function(m,q,p,v){q=q||s;if(!v&&q.nodeType===9&&!x(q))try{return z(q.querySelectorAll(m),p)}catch(t){}return g(m,q,p,v)};for(var l in g)k[l]=g[l];h=null}}(); -(function(){var g=s.createElement("div");g.innerHTML="
        ";if(!(!g.getElementsByClassName||g.getElementsByClassName("e").length===0)){g.lastChild.className="e";if(g.getElementsByClassName("e").length!==1){n.order.splice(1,0,"CLASS");n.find.CLASS=function(h,l,m){if(typeof l.getElementsByClassName!=="undefined"&&!m)return l.getElementsByClassName(h[1])};g=null}}})();var E=s.compareDocumentPosition?function(g,h){return!!(g.compareDocumentPosition(h)&16)}: -function(g,h){return g!==h&&(g.contains?g.contains(h):true)},x=function(g){return(g=(g?g.ownerDocument||g:0).documentElement)?g.nodeName!=="HTML":false},ga=function(g,h){var l=[],m="",q;for(h=h.nodeType?[h]:h;q=n.match.PSEUDO.exec(g);){m+=q[0];g=g.replace(n.match.PSEUDO,"")}g=n.relative[g]?g+"*":g;q=0;for(var p=h.length;q=0===d})};c.fn.extend({find:function(a){for(var b=this.pushStack("","find",a),d=0,f=0,e=this.length;f0)for(var j=d;j0},closest:function(a,b){if(c.isArray(a)){var d=[],f=this[0],e,j= -{},i;if(f&&a.length){e=0;for(var o=a.length;e-1:c(f).is(e)){d.push({selector:i,elem:f});delete j[i]}}f=f.parentNode}}return d}var k=c.expr.match.POS.test(a)?c(a,b||this.context):null;return this.map(function(n,r){for(;r&&r.ownerDocument&&r!==b;){if(k?k.index(r)>-1:c(r).is(a))return r;r=r.parentNode}return null})},index:function(a){if(!a||typeof a=== -"string")return c.inArray(this[0],a?c(a):this.parent().children());return c.inArray(a.jquery?a[0]:a,this)},add:function(a,b){a=typeof a==="string"?c(a,b||this.context):c.makeArray(a);b=c.merge(this.get(),a);return this.pushStack(qa(a[0])||qa(b[0])?b:c.unique(b))},andSelf:function(){return this.add(this.prevObject)}});c.each({parent:function(a){return(a=a.parentNode)&&a.nodeType!==11?a:null},parents:function(a){return c.dir(a,"parentNode")},parentsUntil:function(a,b,d){return c.dir(a,"parentNode", -d)},next:function(a){return c.nth(a,2,"nextSibling")},prev:function(a){return c.nth(a,2,"previousSibling")},nextAll:function(a){return c.dir(a,"nextSibling")},prevAll:function(a){return c.dir(a,"previousSibling")},nextUntil:function(a,b,d){return c.dir(a,"nextSibling",d)},prevUntil:function(a,b,d){return c.dir(a,"previousSibling",d)},siblings:function(a){return c.sibling(a.parentNode.firstChild,a)},children:function(a){return c.sibling(a.firstChild)},contents:function(a){return c.nodeName(a,"iframe")? -a.contentDocument||a.contentWindow.document:c.makeArray(a.childNodes)}},function(a,b){c.fn[a]=function(d,f){var e=c.map(this,b,d);eb.test(a)||(f=d);if(f&&typeof f==="string")e=c.filter(f,e);e=this.length>1?c.unique(e):e;if((this.length>1||gb.test(f))&&fb.test(a))e=e.reverse();return this.pushStack(e,a,R.call(arguments).join(","))}});c.extend({filter:function(a,b,d){if(d)a=":not("+a+")";return c.find.matches(a,b)},dir:function(a,b,d){var f=[];for(a=a[b];a&&a.nodeType!==9&&(d===w||a.nodeType!==1||!c(a).is(d));){a.nodeType=== -1&&f.push(a);a=a[b]}return f},nth:function(a,b,d){b=b||1;for(var f=0;a;a=a[d])if(a.nodeType===1&&++f===b)break;return a},sibling:function(a,b){for(var d=[];a;a=a.nextSibling)a.nodeType===1&&a!==b&&d.push(a);return d}});var Ja=/ jQuery\d+="(?:\d+|null)"/g,V=/^\s+/,Ka=/(<([\w:]+)[^>]*?)\/>/g,hb=/^(?:area|br|col|embed|hr|img|input|link|meta|param)$/i,La=/<([\w:]+)/,ib=/"},F={option:[1,""],legend:[1,"
        ","
        "],thead:[1,"","
        "],tr:[2,"","
        "],td:[3,"","
        "],col:[2,"","
        "],area:[1,"",""],_default:[0,"",""]};F.optgroup=F.option;F.tbody=F.tfoot=F.colgroup=F.caption=F.thead;F.th=F.td;if(!c.support.htmlSerialize)F._default=[1,"div
        ","
        "];c.fn.extend({text:function(a){if(c.isFunction(a))return this.each(function(b){var d= -c(this);d.text(a.call(this,b,d.text()))});if(typeof a!=="object"&&a!==w)return this.empty().append((this[0]&&this[0].ownerDocument||s).createTextNode(a));return c.text(this)},wrapAll:function(a){if(c.isFunction(a))return this.each(function(d){c(this).wrapAll(a.call(this,d))});if(this[0]){var b=c(a,this[0].ownerDocument).eq(0).clone(true);this[0].parentNode&&b.insertBefore(this[0]);b.map(function(){for(var d=this;d.firstChild&&d.firstChild.nodeType===1;)d=d.firstChild;return d}).append(this)}return this}, +(function(E,B){function ka(a,b,d){if(d===B&&a.nodeType===1){d=a.getAttribute("data-"+b);if(typeof d==="string"){try{d=d==="true"?true:d==="false"?false:d==="null"?null:!c.isNaN(d)?parseFloat(d):Ja.test(d)?c.parseJSON(d):d}catch(e){}c.data(a,b,d)}else d=B}return d}function U(){return false}function ca(){return true}function la(a,b,d){d[0].type=a;return c.event.handle.apply(b,d)}function Ka(a){var b,d,e,f,h,l,k,o,x,r,A,C=[];f=[];h=c.data(this,this.nodeType?"events":"__events__");if(typeof h==="function")h= +h.events;if(!(a.liveFired===this||!h||!h.live||a.button&&a.type==="click")){if(a.namespace)A=RegExp("(^|\\.)"+a.namespace.split(".").join("\\.(?:.*\\.)?")+"(\\.|$)");a.liveFired=this;var J=h.live.slice(0);for(k=0;kd)break;a.currentTarget=f.elem;a.data=f.handleObj.data;a.handleObj=f.handleObj;A=f.handleObj.origHandler.apply(f.elem,arguments);if(A===false||a.isPropagationStopped()){d=f.level;if(A===false)b=false;if(a.isImmediatePropagationStopped())break}}return b}}function Y(a,b){return(a&&a!=="*"?a+".":"")+b.replace(La, +"`").replace(Ma,"&")}function ma(a,b,d){if(c.isFunction(b))return c.grep(a,function(f,h){return!!b.call(f,h,f)===d});else if(b.nodeType)return c.grep(a,function(f){return f===b===d});else if(typeof b==="string"){var e=c.grep(a,function(f){return f.nodeType===1});if(Na.test(b))return c.filter(b,e,!d);else b=c.filter(b,e)}return c.grep(a,function(f){return c.inArray(f,b)>=0===d})}function na(a,b){var d=0;b.each(function(){if(this.nodeName===(a[d]&&a[d].nodeName)){var e=c.data(a[d++]),f=c.data(this, +e);if(e=e&&e.events){delete f.handle;f.events={};for(var h in e)for(var l in e[h])c.event.add(this,h,e[h][l],e[h][l].data)}}})}function Oa(a,b){b.src?c.ajax({url:b.src,async:false,dataType:"script"}):c.globalEval(b.text||b.textContent||b.innerHTML||"");b.parentNode&&b.parentNode.removeChild(b)}function oa(a,b,d){var e=b==="width"?a.offsetWidth:a.offsetHeight;if(d==="border")return e;c.each(b==="width"?Pa:Qa,function(){d||(e-=parseFloat(c.css(a,"padding"+this))||0);if(d==="margin")e+=parseFloat(c.css(a, +"margin"+this))||0;else e-=parseFloat(c.css(a,"border"+this+"Width"))||0});return e}function da(a,b,d,e){if(c.isArray(b)&&b.length)c.each(b,function(f,h){d||Ra.test(a)?e(a,h):da(a+"["+(typeof h==="object"||c.isArray(h)?f:"")+"]",h,d,e)});else if(!d&&b!=null&&typeof b==="object")c.isEmptyObject(b)?e(a,""):c.each(b,function(f,h){da(a+"["+f+"]",h,d,e)});else e(a,b)}function S(a,b){var d={};c.each(pa.concat.apply([],pa.slice(0,b)),function(){d[this]=a});return d}function qa(a){if(!ea[a]){var b=c("<"+ +a+">").appendTo("body"),d=b.css("display");b.remove();if(d==="none"||d==="")d="block";ea[a]=d}return ea[a]}function fa(a){return c.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:false}var t=E.document,c=function(){function a(){if(!b.isReady){try{t.documentElement.doScroll("left")}catch(j){setTimeout(a,1);return}b.ready()}}var b=function(j,s){return new b.fn.init(j,s)},d=E.jQuery,e=E.$,f,h=/^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]+)$)/,l=/\S/,k=/^\s+/,o=/\s+$/,x=/\W/,r=/\d/,A=/^<(\w+)\s*\/?>(?:<\/\1>)?$/, +C=/^[\],:{}\s]*$/,J=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,w=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,I=/(?:^|:|,)(?:\s*\[)+/g,L=/(webkit)[ \/]([\w.]+)/,g=/(opera)(?:.*version)?[ \/]([\w.]+)/,i=/(msie) ([\w.]+)/,n=/(mozilla)(?:.*? rv:([\w.]+))?/,m=navigator.userAgent,p=false,q=[],u,y=Object.prototype.toString,F=Object.prototype.hasOwnProperty,M=Array.prototype.push,N=Array.prototype.slice,O=String.prototype.trim,D=Array.prototype.indexOf,R={};b.fn=b.prototype={init:function(j, +s){var v,z,H;if(!j)return this;if(j.nodeType){this.context=this[0]=j;this.length=1;return this}if(j==="body"&&!s&&t.body){this.context=t;this[0]=t.body;this.selector="body";this.length=1;return this}if(typeof j==="string")if((v=h.exec(j))&&(v[1]||!s))if(v[1]){H=s?s.ownerDocument||s:t;if(z=A.exec(j))if(b.isPlainObject(s)){j=[t.createElement(z[1])];b.fn.attr.call(j,s,true)}else j=[H.createElement(z[1])];else{z=b.buildFragment([v[1]],[H]);j=(z.cacheable?z.fragment.cloneNode(true):z.fragment).childNodes}return b.merge(this, +j)}else{if((z=t.getElementById(v[2]))&&z.parentNode){if(z.id!==v[2])return f.find(j);this.length=1;this[0]=z}this.context=t;this.selector=j;return this}else if(!s&&!x.test(j)){this.selector=j;this.context=t;j=t.getElementsByTagName(j);return b.merge(this,j)}else return!s||s.jquery?(s||f).find(j):b(s).find(j);else if(b.isFunction(j))return f.ready(j);if(j.selector!==B){this.selector=j.selector;this.context=j.context}return b.makeArray(j,this)},selector:"",jquery:"1.4.4",length:0,size:function(){return this.length}, +toArray:function(){return N.call(this,0)},get:function(j){return j==null?this.toArray():j<0?this.slice(j)[0]:this[j]},pushStack:function(j,s,v){var z=b();b.isArray(j)?M.apply(z,j):b.merge(z,j);z.prevObject=this;z.context=this.context;if(s==="find")z.selector=this.selector+(this.selector?" ":"")+v;else if(s)z.selector=this.selector+"."+s+"("+v+")";return z},each:function(j,s){return b.each(this,j,s)},ready:function(j){b.bindReady();if(b.isReady)j.call(t,b);else q&&q.push(j);return this},eq:function(j){return j=== +-1?this.slice(j):this.slice(j,+j+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(N.apply(this,arguments),"slice",N.call(arguments).join(","))},map:function(j){return this.pushStack(b.map(this,function(s,v){return j.call(s,v,s)}))},end:function(){return this.prevObject||b(null)},push:M,sort:[].sort,splice:[].splice};b.fn.init.prototype=b.fn;b.extend=b.fn.extend=function(){var j,s,v,z,H,G=arguments[0]||{},K=1,Q=arguments.length,ga=false; +if(typeof G==="boolean"){ga=G;G=arguments[1]||{};K=2}if(typeof G!=="object"&&!b.isFunction(G))G={};if(Q===K){G=this;--K}for(;K0))if(q){var s=0,v=q;for(q=null;j=v[s++];)j.call(t,b);b.fn.trigger&&b(t).trigger("ready").unbind("ready")}}},bindReady:function(){if(!p){p=true;if(t.readyState==="complete")return setTimeout(b.ready,1);if(t.addEventListener){t.addEventListener("DOMContentLoaded",u,false);E.addEventListener("load",b.ready,false)}else if(t.attachEvent){t.attachEvent("onreadystatechange",u);E.attachEvent("onload", +b.ready);var j=false;try{j=E.frameElement==null}catch(s){}t.documentElement.doScroll&&j&&a()}}},isFunction:function(j){return b.type(j)==="function"},isArray:Array.isArray||function(j){return b.type(j)==="array"},isWindow:function(j){return j&&typeof j==="object"&&"setInterval"in j},isNaN:function(j){return j==null||!r.test(j)||isNaN(j)},type:function(j){return j==null?String(j):R[y.call(j)]||"object"},isPlainObject:function(j){if(!j||b.type(j)!=="object"||j.nodeType||b.isWindow(j))return false;if(j.constructor&& +!F.call(j,"constructor")&&!F.call(j.constructor.prototype,"isPrototypeOf"))return false;for(var s in j);return s===B||F.call(j,s)},isEmptyObject:function(j){for(var s in j)return false;return true},error:function(j){throw j;},parseJSON:function(j){if(typeof j!=="string"||!j)return null;j=b.trim(j);if(C.test(j.replace(J,"@").replace(w,"]").replace(I,"")))return E.JSON&&E.JSON.parse?E.JSON.parse(j):(new Function("return "+j))();else b.error("Invalid JSON: "+j)},noop:function(){},globalEval:function(j){if(j&& +l.test(j)){var s=t.getElementsByTagName("head")[0]||t.documentElement,v=t.createElement("script");v.type="text/javascript";if(b.support.scriptEval)v.appendChild(t.createTextNode(j));else v.text=j;s.insertBefore(v,s.firstChild);s.removeChild(v)}},nodeName:function(j,s){return j.nodeName&&j.nodeName.toUpperCase()===s.toUpperCase()},each:function(j,s,v){var z,H=0,G=j.length,K=G===B||b.isFunction(j);if(v)if(K)for(z in j){if(s.apply(j[z],v)===false)break}else for(;H
        a";var f=d.getElementsByTagName("*"),h=d.getElementsByTagName("a")[0],l=t.createElement("select"), +k=l.appendChild(t.createElement("option"));if(!(!f||!f.length||!h)){c.support={leadingWhitespace:d.firstChild.nodeType===3,tbody:!d.getElementsByTagName("tbody").length,htmlSerialize:!!d.getElementsByTagName("link").length,style:/red/.test(h.getAttribute("style")),hrefNormalized:h.getAttribute("href")==="/a",opacity:/^0.55$/.test(h.style.opacity),cssFloat:!!h.style.cssFloat,checkOn:d.getElementsByTagName("input")[0].value==="on",optSelected:k.selected,deleteExpando:true,optDisabled:false,checkClone:false, +scriptEval:false,noCloneEvent:true,boxModel:null,inlineBlockNeedsLayout:false,shrinkWrapBlocks:false,reliableHiddenOffsets:true};l.disabled=true;c.support.optDisabled=!k.disabled;b.type="text/javascript";try{b.appendChild(t.createTextNode("window."+e+"=1;"))}catch(o){}a.insertBefore(b,a.firstChild);if(E[e]){c.support.scriptEval=true;delete E[e]}try{delete b.test}catch(x){c.support.deleteExpando=false}a.removeChild(b);if(d.attachEvent&&d.fireEvent){d.attachEvent("onclick",function r(){c.support.noCloneEvent= +false;d.detachEvent("onclick",r)});d.cloneNode(true).fireEvent("onclick")}d=t.createElement("div");d.innerHTML="";a=t.createDocumentFragment();a.appendChild(d.firstChild);c.support.checkClone=a.cloneNode(true).cloneNode(true).lastChild.checked;c(function(){var r=t.createElement("div");r.style.width=r.style.paddingLeft="1px";t.body.appendChild(r);c.boxModel=c.support.boxModel=r.offsetWidth===2;if("zoom"in r.style){r.style.display="inline";r.style.zoom= +1;c.support.inlineBlockNeedsLayout=r.offsetWidth===2;r.style.display="";r.innerHTML="
        ";c.support.shrinkWrapBlocks=r.offsetWidth!==2}r.innerHTML="
        t
        ";var A=r.getElementsByTagName("td");c.support.reliableHiddenOffsets=A[0].offsetHeight===0;A[0].style.display="";A[1].style.display="none";c.support.reliableHiddenOffsets=c.support.reliableHiddenOffsets&&A[0].offsetHeight===0;r.innerHTML="";t.body.removeChild(r).style.display= +"none"});a=function(r){var A=t.createElement("div");r="on"+r;var C=r in A;if(!C){A.setAttribute(r,"return;");C=typeof A[r]==="function"}return C};c.support.submitBubbles=a("submit");c.support.changeBubbles=a("change");a=b=d=f=h=null}})();var ra={},Ja=/^(?:\{.*\}|\[.*\])$/;c.extend({cache:{},uuid:0,expando:"jQuery"+c.now(),noData:{embed:true,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:true},data:function(a,b,d){if(c.acceptData(a)){a=a==E?ra:a;var e=a.nodeType,f=e?a[c.expando]:null,h= +c.cache;if(!(e&&!f&&typeof b==="string"&&d===B)){if(e)f||(a[c.expando]=f=++c.uuid);else h=a;if(typeof b==="object")if(e)h[f]=c.extend(h[f],b);else c.extend(h,b);else if(e&&!h[f])h[f]={};a=e?h[f]:h;if(d!==B)a[b]=d;return typeof b==="string"?a[b]:a}}},removeData:function(a,b){if(c.acceptData(a)){a=a==E?ra:a;var d=a.nodeType,e=d?a[c.expando]:a,f=c.cache,h=d?f[e]:e;if(b){if(h){delete h[b];d&&c.isEmptyObject(h)&&c.removeData(a)}}else if(d&&c.support.deleteExpando)delete a[c.expando];else if(a.removeAttribute)a.removeAttribute(c.expando); +else if(d)delete f[e];else for(var l in a)delete a[l]}},acceptData:function(a){if(a.nodeName){var b=c.noData[a.nodeName.toLowerCase()];if(b)return!(b===true||a.getAttribute("classid")!==b)}return true}});c.fn.extend({data:function(a,b){var d=null;if(typeof a==="undefined"){if(this.length){var e=this[0].attributes,f;d=c.data(this[0]);for(var h=0,l=e.length;h-1)return true;return false},val:function(a){if(!arguments.length){var b=this[0];if(b){if(c.nodeName(b,"option")){var d=b.attributes.value;return!d||d.specified?b.value:b.text}if(c.nodeName(b,"select")){var e=b.selectedIndex;d=[];var f=b.options;b=b.type==="select-one"; +if(e<0)return null;var h=b?e:0;for(e=b?e+1:f.length;h=0;else if(c.nodeName(this,"select")){var A=c.makeArray(r);c("option",this).each(function(){this.selected=c.inArray(c(this).val(),A)>=0});if(!A.length)this.selectedIndex=-1}else this.value=r}})}});c.extend({attrFn:{val:true,css:true,html:true,text:true,data:true,width:true,height:true,offset:true}, +attr:function(a,b,d,e){if(!a||a.nodeType===3||a.nodeType===8)return B;if(e&&b in c.attrFn)return c(a)[b](d);e=a.nodeType!==1||!c.isXMLDoc(a);var f=d!==B;b=e&&c.props[b]||b;var h=Ta.test(b);if((b in a||a[b]!==B)&&e&&!h){if(f){b==="type"&&Ua.test(a.nodeName)&&a.parentNode&&c.error("type property can't be changed");if(d===null)a.nodeType===1&&a.removeAttribute(b);else a[b]=d}if(c.nodeName(a,"form")&&a.getAttributeNode(b))return a.getAttributeNode(b).nodeValue;if(b==="tabIndex")return(b=a.getAttributeNode("tabIndex"))&& +b.specified?b.value:Va.test(a.nodeName)||Wa.test(a.nodeName)&&a.href?0:B;return a[b]}if(!c.support.style&&e&&b==="style"){if(f)a.style.cssText=""+d;return a.style.cssText}f&&a.setAttribute(b,""+d);if(!a.attributes[b]&&a.hasAttribute&&!a.hasAttribute(b))return B;a=!c.support.hrefNormalized&&e&&h?a.getAttribute(b,2):a.getAttribute(b);return a===null?B:a}});var X=/\.(.*)$/,ia=/^(?:textarea|input|select)$/i,La=/\./g,Ma=/ /g,Xa=/[^\w\s.|`]/g,Ya=function(a){return a.replace(Xa,"\\$&")},ua={focusin:0,focusout:0}; +c.event={add:function(a,b,d,e){if(!(a.nodeType===3||a.nodeType===8)){if(c.isWindow(a)&&a!==E&&!a.frameElement)a=E;if(d===false)d=U;else if(!d)return;var f,h;if(d.handler){f=d;d=f.handler}if(!d.guid)d.guid=c.guid++;if(h=c.data(a)){var l=a.nodeType?"events":"__events__",k=h[l],o=h.handle;if(typeof k==="function"){o=k.handle;k=k.events}else if(!k){a.nodeType||(h[l]=h=function(){});h.events=k={}}if(!o)h.handle=o=function(){return typeof c!=="undefined"&&!c.event.triggered?c.event.handle.apply(o.elem, +arguments):B};o.elem=a;b=b.split(" ");for(var x=0,r;l=b[x++];){h=f?c.extend({},f):{handler:d,data:e};if(l.indexOf(".")>-1){r=l.split(".");l=r.shift();h.namespace=r.slice(0).sort().join(".")}else{r=[];h.namespace=""}h.type=l;if(!h.guid)h.guid=d.guid;var A=k[l],C=c.event.special[l]||{};if(!A){A=k[l]=[];if(!C.setup||C.setup.call(a,e,r,o)===false)if(a.addEventListener)a.addEventListener(l,o,false);else a.attachEvent&&a.attachEvent("on"+l,o)}if(C.add){C.add.call(a,h);if(!h.handler.guid)h.handler.guid= +d.guid}A.push(h);c.event.global[l]=true}a=null}}},global:{},remove:function(a,b,d,e){if(!(a.nodeType===3||a.nodeType===8)){if(d===false)d=U;var f,h,l=0,k,o,x,r,A,C,J=a.nodeType?"events":"__events__",w=c.data(a),I=w&&w[J];if(w&&I){if(typeof I==="function"){w=I;I=I.events}if(b&&b.type){d=b.handler;b=b.type}if(!b||typeof b==="string"&&b.charAt(0)==="."){b=b||"";for(f in I)c.event.remove(a,f+b)}else{for(b=b.split(" ");f=b[l++];){r=f;k=f.indexOf(".")<0;o=[];if(!k){o=f.split(".");f=o.shift();x=RegExp("(^|\\.)"+ +c.map(o.slice(0).sort(),Ya).join("\\.(?:.*\\.)?")+"(\\.|$)")}if(A=I[f])if(d){r=c.event.special[f]||{};for(h=e||0;h=0){a.type=f=f.slice(0,-1);a.exclusive=true}if(!d){a.stopPropagation();c.event.global[f]&&c.each(c.cache,function(){this.events&&this.events[f]&&c.event.trigger(a,b,this.handle.elem)})}if(!d||d.nodeType===3||d.nodeType=== +8)return B;a.result=B;a.target=d;b=c.makeArray(b);b.unshift(a)}a.currentTarget=d;(e=d.nodeType?c.data(d,"handle"):(c.data(d,"__events__")||{}).handle)&&e.apply(d,b);e=d.parentNode||d.ownerDocument;try{if(!(d&&d.nodeName&&c.noData[d.nodeName.toLowerCase()]))if(d["on"+f]&&d["on"+f].apply(d,b)===false){a.result=false;a.preventDefault()}}catch(h){}if(!a.isPropagationStopped()&&e)c.event.trigger(a,b,e,true);else if(!a.isDefaultPrevented()){var l;e=a.target;var k=f.replace(X,""),o=c.nodeName(e,"a")&&k=== +"click",x=c.event.special[k]||{};if((!x._default||x._default.call(d,a)===false)&&!o&&!(e&&e.nodeName&&c.noData[e.nodeName.toLowerCase()])){try{if(e[k]){if(l=e["on"+k])e["on"+k]=null;c.event.triggered=true;e[k]()}}catch(r){}if(l)e["on"+k]=l;c.event.triggered=false}}},handle:function(a){var b,d,e,f;d=[];var h=c.makeArray(arguments);a=h[0]=c.event.fix(a||E.event);a.currentTarget=this;b=a.type.indexOf(".")<0&&!a.exclusive;if(!b){e=a.type.split(".");a.type=e.shift();d=e.slice(0).sort();e=RegExp("(^|\\.)"+ +d.join("\\.(?:.*\\.)?")+"(\\.|$)")}a.namespace=a.namespace||d.join(".");f=c.data(this,this.nodeType?"events":"__events__");if(typeof f==="function")f=f.events;d=(f||{})[a.type];if(f&&d){d=d.slice(0);f=0;for(var l=d.length;f-1?c.map(a.options,function(e){return e.selected}).join("-"):"";else if(a.nodeName.toLowerCase()==="select")d=a.selectedIndex;return d},Z=function(a,b){var d=a.target,e,f;if(!(!ia.test(d.nodeName)||d.readOnly)){e=c.data(d,"_change_data");f=xa(d);if(a.type!=="focusout"||d.type!=="radio")c.data(d,"_change_data",f);if(!(e===B||f===e))if(e!=null||f){a.type="change";a.liveFired= +B;return c.event.trigger(a,b,d)}}};c.event.special.change={filters:{focusout:Z,beforedeactivate:Z,click:function(a){var b=a.target,d=b.type;if(d==="radio"||d==="checkbox"||b.nodeName.toLowerCase()==="select")return Z.call(this,a)},keydown:function(a){var b=a.target,d=b.type;if(a.keyCode===13&&b.nodeName.toLowerCase()!=="textarea"||a.keyCode===32&&(d==="checkbox"||d==="radio")||d==="select-multiple")return Z.call(this,a)},beforeactivate:function(a){a=a.target;c.data(a,"_change_data",xa(a))}},setup:function(){if(this.type=== +"file")return false;for(var a in V)c.event.add(this,a+".specialChange",V[a]);return ia.test(this.nodeName)},teardown:function(){c.event.remove(this,".specialChange");return ia.test(this.nodeName)}};V=c.event.special.change.filters;V.focus=V.beforeactivate}t.addEventListener&&c.each({focus:"focusin",blur:"focusout"},function(a,b){function d(e){e=c.event.fix(e);e.type=b;return c.event.trigger(e,null,e.target)}c.event.special[b]={setup:function(){ua[b]++===0&&t.addEventListener(a,d,true)},teardown:function(){--ua[b]=== +0&&t.removeEventListener(a,d,true)}}});c.each(["bind","one"],function(a,b){c.fn[b]=function(d,e,f){if(typeof d==="object"){for(var h in d)this[b](h,e,d[h],f);return this}if(c.isFunction(e)||e===false){f=e;e=B}var l=b==="one"?c.proxy(f,function(o){c(this).unbind(o,l);return f.apply(this,arguments)}):f;if(d==="unload"&&b!=="one")this.one(d,e,f);else{h=0;for(var k=this.length;h0?this.bind(b,d,e):this.trigger(b)};if(c.attrFn)c.attrFn[b]=true});E.attachEvent&&!E.addEventListener&&c(E).bind("unload",function(){for(var a in c.cache)if(c.cache[a].handle)try{c.event.remove(c.cache[a].handle.elem)}catch(b){}}); +(function(){function a(g,i,n,m,p,q){p=0;for(var u=m.length;p0){F=y;break}}y=y[g]}m[p]=F}}}var d=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,e=0,f=Object.prototype.toString,h=false,l=true;[0,0].sort(function(){l=false;return 0});var k=function(g,i,n,m){n=n||[];var p=i=i||t;if(i.nodeType!==1&&i.nodeType!==9)return[];if(!g||typeof g!=="string")return n;var q,u,y,F,M,N=true,O=k.isXML(i),D=[],R=g;do{d.exec("");if(q=d.exec(R)){R=q[3];D.push(q[1]);if(q[2]){F=q[3]; +break}}}while(q);if(D.length>1&&x.exec(g))if(D.length===2&&o.relative[D[0]])u=L(D[0]+D[1],i);else for(u=o.relative[D[0]]?[i]:k(D.shift(),i);D.length;){g=D.shift();if(o.relative[g])g+=D.shift();u=L(g,u)}else{if(!m&&D.length>1&&i.nodeType===9&&!O&&o.match.ID.test(D[0])&&!o.match.ID.test(D[D.length-1])){q=k.find(D.shift(),i,O);i=q.expr?k.filter(q.expr,q.set)[0]:q.set[0]}if(i){q=m?{expr:D.pop(),set:C(m)}:k.find(D.pop(),D.length===1&&(D[0]==="~"||D[0]==="+")&&i.parentNode?i.parentNode:i,O);u=q.expr?k.filter(q.expr, +q.set):q.set;if(D.length>0)y=C(u);else N=false;for(;D.length;){q=M=D.pop();if(o.relative[M])q=D.pop();else M="";if(q==null)q=i;o.relative[M](y,q,O)}}else y=[]}y||(y=u);y||k.error(M||g);if(f.call(y)==="[object Array]")if(N)if(i&&i.nodeType===1)for(g=0;y[g]!=null;g++){if(y[g]&&(y[g]===true||y[g].nodeType===1&&k.contains(i,y[g])))n.push(u[g])}else for(g=0;y[g]!=null;g++)y[g]&&y[g].nodeType===1&&n.push(u[g]);else n.push.apply(n,y);else C(y,n);if(F){k(F,p,n,m);k.uniqueSort(n)}return n};k.uniqueSort=function(g){if(w){h= +l;g.sort(w);if(h)for(var i=1;i0};k.find=function(g,i,n){var m;if(!g)return[];for(var p=0,q=o.order.length;p":function(g,i){var n,m=typeof i==="string",p=0,q=g.length;if(m&&!/\W/.test(i))for(i=i.toLowerCase();p=0))n||m.push(u);else if(n)i[q]=false;return false},ID:function(g){return g[1].replace(/\\/g,"")},TAG:function(g){return g[1].toLowerCase()},CHILD:function(g){if(g[1]==="nth"){var i=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(g[2]==="even"&&"2n"||g[2]==="odd"&&"2n+1"||!/\D/.test(g[2])&&"0n+"+g[2]||g[2]);g[2]=i[1]+(i[2]||1)-0;g[3]=i[3]-0}g[0]=e++;return g},ATTR:function(g,i,n, +m,p,q){i=g[1].replace(/\\/g,"");if(!q&&o.attrMap[i])g[1]=o.attrMap[i];if(g[2]==="~=")g[4]=" "+g[4]+" ";return g},PSEUDO:function(g,i,n,m,p){if(g[1]==="not")if((d.exec(g[3])||"").length>1||/^\w/.test(g[3]))g[3]=k(g[3],null,null,i);else{g=k.filter(g[3],i,n,true^p);n||m.push.apply(m,g);return false}else if(o.match.POS.test(g[0])||o.match.CHILD.test(g[0]))return true;return g},POS:function(g){g.unshift(true);return g}},filters:{enabled:function(g){return g.disabled===false&&g.type!=="hidden"},disabled:function(g){return g.disabled=== +true},checked:function(g){return g.checked===true},selected:function(g){return g.selected===true},parent:function(g){return!!g.firstChild},empty:function(g){return!g.firstChild},has:function(g,i,n){return!!k(n[3],g).length},header:function(g){return/h\d/i.test(g.nodeName)},text:function(g){return"text"===g.type},radio:function(g){return"radio"===g.type},checkbox:function(g){return"checkbox"===g.type},file:function(g){return"file"===g.type},password:function(g){return"password"===g.type},submit:function(g){return"submit"=== +g.type},image:function(g){return"image"===g.type},reset:function(g){return"reset"===g.type},button:function(g){return"button"===g.type||g.nodeName.toLowerCase()==="button"},input:function(g){return/input|select|textarea|button/i.test(g.nodeName)}},setFilters:{first:function(g,i){return i===0},last:function(g,i,n,m){return i===m.length-1},even:function(g,i){return i%2===0},odd:function(g,i){return i%2===1},lt:function(g,i,n){return in[3]-0},nth:function(g,i,n){return n[3]- +0===i},eq:function(g,i,n){return n[3]-0===i}},filter:{PSEUDO:function(g,i,n,m){var p=i[1],q=o.filters[p];if(q)return q(g,n,i,m);else if(p==="contains")return(g.textContent||g.innerText||k.getText([g])||"").indexOf(i[3])>=0;else if(p==="not"){i=i[3];n=0;for(m=i.length;n=0}},ID:function(g,i){return g.nodeType===1&&g.getAttribute("id")===i},TAG:function(g,i){return i==="*"&&g.nodeType===1||g.nodeName.toLowerCase()=== +i},CLASS:function(g,i){return(" "+(g.className||g.getAttribute("class"))+" ").indexOf(i)>-1},ATTR:function(g,i){var n=i[1];n=o.attrHandle[n]?o.attrHandle[n](g):g[n]!=null?g[n]:g.getAttribute(n);var m=n+"",p=i[2],q=i[4];return n==null?p==="!=":p==="="?m===q:p==="*="?m.indexOf(q)>=0:p==="~="?(" "+m+" ").indexOf(q)>=0:!q?m&&n!==false:p==="!="?m!==q:p==="^="?m.indexOf(q)===0:p==="$="?m.substr(m.length-q.length)===q:p==="|="?m===q||m.substr(0,q.length+1)===q+"-":false},POS:function(g,i,n,m){var p=o.setFilters[i[2]]; +if(p)return p(g,n,i,m)}}},x=o.match.POS,r=function(g,i){return"\\"+(i-0+1)},A;for(A in o.match){o.match[A]=RegExp(o.match[A].source+/(?![^\[]*\])(?![^\(]*\))/.source);o.leftMatch[A]=RegExp(/(^(?:.|\r|\n)*?)/.source+o.match[A].source.replace(/\\(\d+)/g,r))}var C=function(g,i){g=Array.prototype.slice.call(g,0);if(i){i.push.apply(i,g);return i}return g};try{Array.prototype.slice.call(t.documentElement.childNodes,0)}catch(J){C=function(g,i){var n=0,m=i||[];if(f.call(g)==="[object Array]")Array.prototype.push.apply(m, +g);else if(typeof g.length==="number")for(var p=g.length;n";n.insertBefore(g,n.firstChild);if(t.getElementById(i)){o.find.ID=function(m,p,q){if(typeof p.getElementById!=="undefined"&&!q)return(p=p.getElementById(m[1]))?p.id===m[1]||typeof p.getAttributeNode!=="undefined"&&p.getAttributeNode("id").nodeValue===m[1]?[p]:B:[]};o.filter.ID=function(m,p){var q=typeof m.getAttributeNode!=="undefined"&&m.getAttributeNode("id");return m.nodeType===1&&q&&q.nodeValue===p}}n.removeChild(g); +n=g=null})();(function(){var g=t.createElement("div");g.appendChild(t.createComment(""));if(g.getElementsByTagName("*").length>0)o.find.TAG=function(i,n){var m=n.getElementsByTagName(i[1]);if(i[1]==="*"){for(var p=[],q=0;m[q];q++)m[q].nodeType===1&&p.push(m[q]);m=p}return m};g.innerHTML="";if(g.firstChild&&typeof g.firstChild.getAttribute!=="undefined"&&g.firstChild.getAttribute("href")!=="#")o.attrHandle.href=function(i){return i.getAttribute("href",2)};g=null})();t.querySelectorAll&& +function(){var g=k,i=t.createElement("div");i.innerHTML="

        ";if(!(i.querySelectorAll&&i.querySelectorAll(".TEST").length===0)){k=function(m,p,q,u){p=p||t;m=m.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!u&&!k.isXML(p))if(p.nodeType===9)try{return C(p.querySelectorAll(m),q)}catch(y){}else if(p.nodeType===1&&p.nodeName.toLowerCase()!=="object"){var F=p.getAttribute("id"),M=F||"__sizzle__";F||p.setAttribute("id",M);try{return C(p.querySelectorAll("#"+M+" "+m),q)}catch(N){}finally{F|| +p.removeAttribute("id")}}return g(m,p,q,u)};for(var n in g)k[n]=g[n];i=null}}();(function(){var g=t.documentElement,i=g.matchesSelector||g.mozMatchesSelector||g.webkitMatchesSelector||g.msMatchesSelector,n=false;try{i.call(t.documentElement,"[test!='']:sizzle")}catch(m){n=true}if(i)k.matchesSelector=function(p,q){q=q.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!k.isXML(p))try{if(n||!o.match.PSEUDO.test(q)&&!/!=/.test(q))return i.call(p,q)}catch(u){}return k(q,null,null,[p]).length>0}})();(function(){var g= +t.createElement("div");g.innerHTML="
        ";if(!(!g.getElementsByClassName||g.getElementsByClassName("e").length===0)){g.lastChild.className="e";if(g.getElementsByClassName("e").length!==1){o.order.splice(1,0,"CLASS");o.find.CLASS=function(i,n,m){if(typeof n.getElementsByClassName!=="undefined"&&!m)return n.getElementsByClassName(i[1])};g=null}}})();k.contains=t.documentElement.contains?function(g,i){return g!==i&&(g.contains?g.contains(i):true)}:t.documentElement.compareDocumentPosition? +function(g,i){return!!(g.compareDocumentPosition(i)&16)}:function(){return false};k.isXML=function(g){return(g=(g?g.ownerDocument||g:0).documentElement)?g.nodeName!=="HTML":false};var L=function(g,i){for(var n,m=[],p="",q=i.nodeType?[i]:i;n=o.match.PSEUDO.exec(g);){p+=n[0];g=g.replace(o.match.PSEUDO,"")}g=o.relative[g]?g+"*":g;n=0;for(var u=q.length;n0)for(var h=d;h0},closest:function(a,b){var d=[],e,f,h=this[0];if(c.isArray(a)){var l,k={},o=1;if(h&&a.length){e=0;for(f=a.length;e-1:c(h).is(e))d.push({selector:l,elem:h,level:o})}h= +h.parentNode;o++}}return d}l=cb.test(a)?c(a,b||this.context):null;e=0;for(f=this.length;e-1:c.find.matchesSelector(h,a)){d.push(h);break}else{h=h.parentNode;if(!h||!h.ownerDocument||h===b)break}d=d.length>1?c.unique(d):d;return this.pushStack(d,"closest",a)},index:function(a){if(!a||typeof a==="string")return c.inArray(this[0],a?c(a):this.parent().children());return c.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var d=typeof a==="string"?c(a,b||this.context): +c.makeArray(a),e=c.merge(this.get(),d);return this.pushStack(!d[0]||!d[0].parentNode||d[0].parentNode.nodeType===11||!e[0]||!e[0].parentNode||e[0].parentNode.nodeType===11?e:c.unique(e))},andSelf:function(){return this.add(this.prevObject)}});c.each({parent:function(a){return(a=a.parentNode)&&a.nodeType!==11?a:null},parents:function(a){return c.dir(a,"parentNode")},parentsUntil:function(a,b,d){return c.dir(a,"parentNode",d)},next:function(a){return c.nth(a,2,"nextSibling")},prev:function(a){return c.nth(a, +2,"previousSibling")},nextAll:function(a){return c.dir(a,"nextSibling")},prevAll:function(a){return c.dir(a,"previousSibling")},nextUntil:function(a,b,d){return c.dir(a,"nextSibling",d)},prevUntil:function(a,b,d){return c.dir(a,"previousSibling",d)},siblings:function(a){return c.sibling(a.parentNode.firstChild,a)},children:function(a){return c.sibling(a.firstChild)},contents:function(a){return c.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:c.makeArray(a.childNodes)}},function(a, +b){c.fn[a]=function(d,e){var f=c.map(this,b,d);Za.test(a)||(e=d);if(e&&typeof e==="string")f=c.filter(e,f);f=this.length>1?c.unique(f):f;if((this.length>1||ab.test(e))&&$a.test(a))f=f.reverse();return this.pushStack(f,a,bb.call(arguments).join(","))}});c.extend({filter:function(a,b,d){if(d)a=":not("+a+")";return b.length===1?c.find.matchesSelector(b[0],a)?[b[0]]:[]:c.find.matches(a,b)},dir:function(a,b,d){var e=[];for(a=a[b];a&&a.nodeType!==9&&(d===B||a.nodeType!==1||!c(a).is(d));){a.nodeType===1&& +e.push(a);a=a[b]}return e},nth:function(a,b,d){b=b||1;for(var e=0;a;a=a[d])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){for(var d=[];a;a=a.nextSibling)a.nodeType===1&&a!==b&&d.push(a);return d}});var za=/ jQuery\d+="(?:\d+|null)"/g,$=/^\s+/,Aa=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,Ba=/<([\w:]+)/,db=/\s]+\/)>/g,P={option:[1, +""],legend:[1,"
        ","
        "],thead:[1,"","
        "],tr:[2,"","
        "],td:[3,"","
        "],col:[2,"","
        "],area:[1,"",""],_default:[0,"",""]};P.optgroup=P.option;P.tbody=P.tfoot=P.colgroup=P.caption=P.thead;P.th=P.td;if(!c.support.htmlSerialize)P._default=[1,"div
        ","
        "];c.fn.extend({text:function(a){if(c.isFunction(a))return this.each(function(b){var d= +c(this);d.text(a.call(this,b,d.text()))});if(typeof a!=="object"&&a!==B)return this.empty().append((this[0]&&this[0].ownerDocument||t).createTextNode(a));return c.text(this)},wrapAll:function(a){if(c.isFunction(a))return this.each(function(d){c(this).wrapAll(a.call(this,d))});if(this[0]){var b=c(a,this[0].ownerDocument).eq(0).clone(true);this[0].parentNode&&b.insertBefore(this[0]);b.map(function(){for(var d=this;d.firstChild&&d.firstChild.nodeType===1;)d=d.firstChild;return d}).append(this)}return this}, wrapInner:function(a){if(c.isFunction(a))return this.each(function(b){c(this).wrapInner(a.call(this,b))});return this.each(function(){var b=c(this),d=b.contents();d.length?d.wrapAll(a):b.append(a)})},wrap:function(a){return this.each(function(){c(this).wrapAll(a)})},unwrap:function(){return this.parent().each(function(){c.nodeName(this,"body")||c(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.appendChild(a)})}, prepend:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b,this)});else if(arguments.length){var a=c(arguments[0]);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b, -this.nextSibling)});else if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,c(arguments[0]).toArray());return a}},remove:function(a,b){for(var d=0,f;(f=this[d])!=null;d++)if(!a||c.filter(a,[f]).length){if(!b&&f.nodeType===1){c.cleanData(f.getElementsByTagName("*"));c.cleanData([f])}f.parentNode&&f.parentNode.removeChild(f)}return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++)for(b.nodeType===1&&c.cleanData(b.getElementsByTagName("*"));b.firstChild;)b.removeChild(b.firstChild); -return this},clone:function(a){var b=this.map(function(){if(!c.support.noCloneEvent&&!c.isXMLDoc(this)){var d=this.outerHTML,f=this.ownerDocument;if(!d){d=f.createElement("div");d.appendChild(this.cloneNode(true));d=d.innerHTML}return c.clean([d.replace(Ja,"").replace(/=([^="'>\s]+\/)>/g,'="$1">').replace(V,"")],f)[0]}else return this.cloneNode(true)});if(a===true){ra(this,b);ra(this.find("*"),b.find("*"))}return b},html:function(a){if(a===w)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(Ja, -""):null;else if(typeof a==="string"&&!ta.test(a)&&(c.support.leadingWhitespace||!V.test(a))&&!F[(La.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Ka,Ma);try{for(var b=0,d=this.length;b0||e.cacheable||this.length>1?k.cloneNode(true):k)}o.length&&c.each(o,Qa)}return this}});c.fragments={};c.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){c.fn[a]=function(d){var f=[];d=c(d);var e=this.length===1&&this[0].parentNode;if(e&&e.nodeType===11&&e.childNodes.length===1&&d.length===1){d[b](this[0]); -return this}else{e=0;for(var j=d.length;e0?this.clone(true):this).get();c.fn[b].apply(c(d[e]),i);f=f.concat(i)}return this.pushStack(f,a,d.selector)}}});c.extend({clean:function(a,b,d,f){b=b||s;if(typeof b.createElement==="undefined")b=b.ownerDocument||b[0]&&b[0].ownerDocument||s;for(var e=[],j=0,i;(i=a[j])!=null;j++){if(typeof i==="number")i+="";if(i){if(typeof i==="string"&&!jb.test(i))i=b.createTextNode(i);else if(typeof i==="string"){i=i.replace(Ka,Ma);var o=(La.exec(i)||["", -""])[1].toLowerCase(),k=F[o]||F._default,n=k[0],r=b.createElement("div");for(r.innerHTML=k[1]+i+k[2];n--;)r=r.lastChild;if(!c.support.tbody){n=ib.test(i);o=o==="table"&&!n?r.firstChild&&r.firstChild.childNodes:k[1]===""&&!n?r.childNodes:[];for(k=o.length-1;k>=0;--k)c.nodeName(o[k],"tbody")&&!o[k].childNodes.length&&o[k].parentNode.removeChild(o[k])}!c.support.leadingWhitespace&&V.test(i)&&r.insertBefore(b.createTextNode(V.exec(i)[0]),r.firstChild);i=r.childNodes}if(i.nodeType)e.push(i);else e= -c.merge(e,i)}}if(d)for(j=0;e[j];j++)if(f&&c.nodeName(e[j],"script")&&(!e[j].type||e[j].type.toLowerCase()==="text/javascript"))f.push(e[j].parentNode?e[j].parentNode.removeChild(e[j]):e[j]);else{e[j].nodeType===1&&e.splice.apply(e,[j+1,0].concat(c.makeArray(e[j].getElementsByTagName("script"))));d.appendChild(e[j])}return e},cleanData:function(a){for(var b,d,f=c.cache,e=c.event.special,j=c.support.deleteExpando,i=0,o;(o=a[i])!=null;i++)if(d=o[c.expando]){b=f[d];if(b.events)for(var k in b.events)e[k]? -c.event.remove(o,k):Ca(o,k,b.handle);if(j)delete o[c.expando];else o.removeAttribute&&o.removeAttribute(c.expando);delete f[d]}}});var kb=/z-?index|font-?weight|opacity|zoom|line-?height/i,Na=/alpha\([^)]*\)/,Oa=/opacity=([^)]*)/,ha=/float/i,ia=/-([a-z])/ig,lb=/([A-Z])/g,mb=/^-?\d+(?:px)?$/i,nb=/^-?\d/,ob={position:"absolute",visibility:"hidden",display:"block"},pb=["Left","Right"],qb=["Top","Bottom"],rb=s.defaultView&&s.defaultView.getComputedStyle,Pa=c.support.cssFloat?"cssFloat":"styleFloat",ja= -function(a,b){return b.toUpperCase()};c.fn.css=function(a,b){return X(this,a,b,true,function(d,f,e){if(e===w)return c.curCSS(d,f);if(typeof e==="number"&&!kb.test(f))e+="px";c.style(d,f,e)})};c.extend({style:function(a,b,d){if(!a||a.nodeType===3||a.nodeType===8)return w;if((b==="width"||b==="height")&&parseFloat(d)<0)d=w;var f=a.style||a,e=d!==w;if(!c.support.opacity&&b==="opacity"){if(e){f.zoom=1;b=parseInt(d,10)+""==="NaN"?"":"alpha(opacity="+d*100+")";a=f.filter||c.curCSS(a,"filter")||"";f.filter= -Na.test(a)?a.replace(Na,b):b}return f.filter&&f.filter.indexOf("opacity=")>=0?parseFloat(Oa.exec(f.filter)[1])/100+"":""}if(ha.test(b))b=Pa;b=b.replace(ia,ja);if(e)f[b]=d;return f[b]},css:function(a,b,d,f){if(b==="width"||b==="height"){var e,j=b==="width"?pb:qb;function i(){e=b==="width"?a.offsetWidth:a.offsetHeight;f!=="border"&&c.each(j,function(){f||(e-=parseFloat(c.curCSS(a,"padding"+this,true))||0);if(f==="margin")e+=parseFloat(c.curCSS(a,"margin"+this,true))||0;else e-=parseFloat(c.curCSS(a, -"border"+this+"Width",true))||0})}a.offsetWidth!==0?i():c.swap(a,ob,i);return Math.max(0,Math.round(e))}return c.curCSS(a,b,d)},curCSS:function(a,b,d){var f,e=a.style;if(!c.support.opacity&&b==="opacity"&&a.currentStyle){f=Oa.test(a.currentStyle.filter||"")?parseFloat(RegExp.$1)/100+"":"";return f===""?"1":f}if(ha.test(b))b=Pa;if(!d&&e&&e[b])f=e[b];else if(rb){if(ha.test(b))b="float";b=b.replace(lb,"-$1").toLowerCase();e=a.ownerDocument.defaultView;if(!e)return null;if(a=e.getComputedStyle(a,null))f= -a.getPropertyValue(b);if(b==="opacity"&&f==="")f="1"}else if(a.currentStyle){d=b.replace(ia,ja);f=a.currentStyle[b]||a.currentStyle[d];if(!mb.test(f)&&nb.test(f)){b=e.left;var j=a.runtimeStyle.left;a.runtimeStyle.left=a.currentStyle.left;e.left=d==="fontSize"?"1em":f||0;f=e.pixelLeft+"px";e.left=b;a.runtimeStyle.left=j}}return f},swap:function(a,b,d){var f={};for(var e in b){f[e]=a.style[e];a.style[e]=b[e]}d.call(a);for(e in b)a.style[e]=f[e]}});if(c.expr&&c.expr.filters){c.expr.filters.hidden=function(a){var b= -a.offsetWidth,d=a.offsetHeight,f=a.nodeName.toLowerCase()==="tr";return b===0&&d===0&&!f?true:b>0&&d>0&&!f?false:c.curCSS(a,"display")==="none"};c.expr.filters.visible=function(a){return!c.expr.filters.hidden(a)}}var sb=J(),tb=//gi,ub=/select|textarea/i,vb=/color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week/i,N=/=\?(&|$)/,ka=/\?/,wb=/(\?|&)_=.*?(&|$)/,xb=/^(\w+:)?\/\/([^\/?#]+)/,yb=/%20/g,zb=c.fn.load;c.fn.extend({load:function(a,b,d){if(typeof a!== -"string")return zb.call(this,a);else if(!this.length)return this;var f=a.indexOf(" ");if(f>=0){var e=a.slice(f,a.length);a=a.slice(0,f)}f="GET";if(b)if(c.isFunction(b)){d=b;b=null}else if(typeof b==="object"){b=c.param(b,c.ajaxSettings.traditional);f="POST"}var j=this;c.ajax({url:a,type:f,dataType:"html",data:b,complete:function(i,o){if(o==="success"||o==="notmodified")j.html(e?c("
        ").append(i.responseText.replace(tb,"")).find(e):i.responseText);d&&j.each(d,[i.responseText,o,i])}});return this}, -serialize:function(){return c.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?c.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||ub.test(this.nodeName)||vb.test(this.type))}).map(function(a,b){a=c(this).val();return a==null?null:c.isArray(a)?c.map(a,function(d){return{name:b.name,value:d}}):{name:b.name,value:a}}).get()}});c.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "), -function(a,b){c.fn[b]=function(d){return this.bind(b,d)}});c.extend({get:function(a,b,d,f){if(c.isFunction(b)){f=f||d;d=b;b=null}return c.ajax({type:"GET",url:a,data:b,success:d,dataType:f})},getScript:function(a,b){return c.get(a,null,b,"script")},getJSON:function(a,b,d){return c.get(a,b,d,"json")},post:function(a,b,d,f){if(c.isFunction(b)){f=f||d;d=b;b={}}return c.ajax({type:"POST",url:a,data:b,success:d,dataType:f})},ajaxSetup:function(a){c.extend(c.ajaxSettings,a)},ajaxSettings:{url:location.href, -global:true,type:"GET",contentType:"application/x-www-form-urlencoded",processData:true,async:true,xhr:A.XMLHttpRequest&&(A.location.protocol!=="file:"||!A.ActiveXObject)?function(){return new A.XMLHttpRequest}:function(){try{return new A.ActiveXObject("Microsoft.XMLHTTP")}catch(a){}},accepts:{xml:"application/xml, text/xml",html:"text/html",script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},lastModified:{},etag:{},ajax:function(a){function b(){e.success&& -e.success.call(k,o,i,x);e.global&&f("ajaxSuccess",[x,e])}function d(){e.complete&&e.complete.call(k,x,i);e.global&&f("ajaxComplete",[x,e]);e.global&&!--c.active&&c.event.trigger("ajaxStop")}function f(q,p){(e.context?c(e.context):c.event).trigger(q,p)}var e=c.extend(true,{},c.ajaxSettings,a),j,i,o,k=a&&a.context||e,n=e.type.toUpperCase();if(e.data&&e.processData&&typeof e.data!=="string")e.data=c.param(e.data,e.traditional);if(e.dataType==="jsonp"){if(n==="GET")N.test(e.url)||(e.url+=(ka.test(e.url)? -"&":"?")+(e.jsonp||"callback")+"=?");else if(!e.data||!N.test(e.data))e.data=(e.data?e.data+"&":"")+(e.jsonp||"callback")+"=?";e.dataType="json"}if(e.dataType==="json"&&(e.data&&N.test(e.data)||N.test(e.url))){j=e.jsonpCallback||"jsonp"+sb++;if(e.data)e.data=(e.data+"").replace(N,"="+j+"$1");e.url=e.url.replace(N,"="+j+"$1");e.dataType="script";A[j]=A[j]||function(q){o=q;b();d();A[j]=w;try{delete A[j]}catch(p){}z&&z.removeChild(C)}}if(e.dataType==="script"&&e.cache===null)e.cache=false;if(e.cache=== -false&&n==="GET"){var r=J(),u=e.url.replace(wb,"$1_="+r+"$2");e.url=u+(u===e.url?(ka.test(e.url)?"&":"?")+"_="+r:"")}if(e.data&&n==="GET")e.url+=(ka.test(e.url)?"&":"?")+e.data;e.global&&!c.active++&&c.event.trigger("ajaxStart");r=(r=xb.exec(e.url))&&(r[1]&&r[1]!==location.protocol||r[2]!==location.host);if(e.dataType==="script"&&n==="GET"&&r){var z=s.getElementsByTagName("head")[0]||s.documentElement,C=s.createElement("script");C.src=e.url;if(e.scriptCharset)C.charset=e.scriptCharset;if(!j){var B= -false;C.onload=C.onreadystatechange=function(){if(!B&&(!this.readyState||this.readyState==="loaded"||this.readyState==="complete")){B=true;b();d();C.onload=C.onreadystatechange=null;z&&C.parentNode&&z.removeChild(C)}}}z.insertBefore(C,z.firstChild);return w}var E=false,x=e.xhr();if(x){e.username?x.open(n,e.url,e.async,e.username,e.password):x.open(n,e.url,e.async);try{if(e.data||a&&a.contentType)x.setRequestHeader("Content-Type",e.contentType);if(e.ifModified){c.lastModified[e.url]&&x.setRequestHeader("If-Modified-Since", -c.lastModified[e.url]);c.etag[e.url]&&x.setRequestHeader("If-None-Match",c.etag[e.url])}r||x.setRequestHeader("X-Requested-With","XMLHttpRequest");x.setRequestHeader("Accept",e.dataType&&e.accepts[e.dataType]?e.accepts[e.dataType]+", */*":e.accepts._default)}catch(ga){}if(e.beforeSend&&e.beforeSend.call(k,x,e)===false){e.global&&!--c.active&&c.event.trigger("ajaxStop");x.abort();return false}e.global&&f("ajaxSend",[x,e]);var g=x.onreadystatechange=function(q){if(!x||x.readyState===0||q==="abort"){E|| -d();E=true;if(x)x.onreadystatechange=c.noop}else if(!E&&x&&(x.readyState===4||q==="timeout")){E=true;x.onreadystatechange=c.noop;i=q==="timeout"?"timeout":!c.httpSuccess(x)?"error":e.ifModified&&c.httpNotModified(x,e.url)?"notmodified":"success";var p;if(i==="success")try{o=c.httpData(x,e.dataType,e)}catch(v){i="parsererror";p=v}if(i==="success"||i==="notmodified")j||b();else c.handleError(e,x,i,p);d();q==="timeout"&&x.abort();if(e.async)x=null}};try{var h=x.abort;x.abort=function(){x&&h.call(x); -g("abort")}}catch(l){}e.async&&e.timeout>0&&setTimeout(function(){x&&!E&&g("timeout")},e.timeout);try{x.send(n==="POST"||n==="PUT"||n==="DELETE"?e.data:null)}catch(m){c.handleError(e,x,null,m);d()}e.async||g();return x}},handleError:function(a,b,d,f){if(a.error)a.error.call(a.context||a,b,d,f);if(a.global)(a.context?c(a.context):c.event).trigger("ajaxError",[b,a,f])},active:0,httpSuccess:function(a){try{return!a.status&&location.protocol==="file:"||a.status>=200&&a.status<300||a.status===304||a.status=== -1223||a.status===0}catch(b){}return false},httpNotModified:function(a,b){var d=a.getResponseHeader("Last-Modified"),f=a.getResponseHeader("Etag");if(d)c.lastModified[b]=d;if(f)c.etag[b]=f;return a.status===304||a.status===0},httpData:function(a,b,d){var f=a.getResponseHeader("content-type")||"",e=b==="xml"||!b&&f.indexOf("xml")>=0;a=e?a.responseXML:a.responseText;e&&a.documentElement.nodeName==="parsererror"&&c.error("parsererror");if(d&&d.dataFilter)a=d.dataFilter(a,b);if(typeof a==="string")if(b=== -"json"||!b&&f.indexOf("json")>=0)a=c.parseJSON(a);else if(b==="script"||!b&&f.indexOf("javascript")>=0)c.globalEval(a);return a},param:function(a,b){function d(i,o){if(c.isArray(o))c.each(o,function(k,n){b||/\[\]$/.test(i)?f(i,n):d(i+"["+(typeof n==="object"||c.isArray(n)?k:"")+"]",n)});else!b&&o!=null&&typeof o==="object"?c.each(o,function(k,n){d(i+"["+k+"]",n)}):f(i,o)}function f(i,o){o=c.isFunction(o)?o():o;e[e.length]=encodeURIComponent(i)+"="+encodeURIComponent(o)}var e=[];if(b===w)b=c.ajaxSettings.traditional; -if(c.isArray(a)||a.jquery)c.each(a,function(){f(this.name,this.value)});else for(var j in a)d(j,a[j]);return e.join("&").replace(yb,"+")}});var la={},Ab=/toggle|show|hide/,Bb=/^([+-]=)?([\d+-.]+)(.*)$/,W,va=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]];c.fn.extend({show:function(a,b){if(a||a===0)return this.animate(K("show",3),a,b);else{a=0;for(b=this.length;a").appendTo("body");f=e.css("display");if(f==="none")f="block";e.remove();la[d]=f}c.data(this[a],"olddisplay",f)}}a=0;for(b=this.length;a=0;f--)if(d[f].elem===this){b&&d[f](true);d.splice(f,1)}});b||this.dequeue();return this}});c.each({slideDown:K("show",1),slideUp:K("hide",1),slideToggle:K("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"}},function(a,b){c.fn[a]=function(d,f){return this.animate(b,d,f)}});c.extend({speed:function(a,b,d){var f=a&&typeof a==="object"?a:{complete:d||!d&&b||c.isFunction(a)&&a,duration:a,easing:d&&b||b&&!c.isFunction(b)&&b};f.duration=c.fx.off?0:typeof f.duration=== -"number"?f.duration:c.fx.speeds[f.duration]||c.fx.speeds._default;f.old=f.complete;f.complete=function(){f.queue!==false&&c(this).dequeue();c.isFunction(f.old)&&f.old.call(this)};return f},easing:{linear:function(a,b,d,f){return d+f*a},swing:function(a,b,d,f){return(-Math.cos(a*Math.PI)/2+0.5)*f+d}},timers:[],fx:function(a,b,d){this.options=b;this.elem=a;this.prop=d;if(!b.orig)b.orig={}}});c.fx.prototype={update:function(){this.options.step&&this.options.step.call(this.elem,this.now,this);(c.fx.step[this.prop]|| -c.fx.step._default)(this);if((this.prop==="height"||this.prop==="width")&&this.elem.style)this.elem.style.display="block"},cur:function(a){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null))return this.elem[this.prop];return(a=parseFloat(c.css(this.elem,this.prop,a)))&&a>-10000?a:parseFloat(c.curCSS(this.elem,this.prop))||0},custom:function(a,b,d){function f(j){return e.step(j)}this.startTime=J();this.start=a;this.end=b;this.unit=d||this.unit||"px";this.now=this.start; -this.pos=this.state=0;var e=this;f.elem=this.elem;if(f()&&c.timers.push(f)&&!W)W=setInterval(c.fx.tick,13)},show:function(){this.options.orig[this.prop]=c.style(this.elem,this.prop);this.options.show=true;this.custom(this.prop==="width"||this.prop==="height"?1:0,this.cur());c(this.elem).show()},hide:function(){this.options.orig[this.prop]=c.style(this.elem,this.prop);this.options.hide=true;this.custom(this.cur(),0)},step:function(a){var b=J(),d=true;if(a||b>=this.options.duration+this.startTime){this.now= -this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;for(var f in this.options.curAnim)if(this.options.curAnim[f]!==true)d=false;if(d){if(this.options.display!=null){this.elem.style.overflow=this.options.overflow;a=c.data(this.elem,"olddisplay");this.elem.style.display=a?a:this.options.display;if(c.css(this.elem,"display")==="none")this.elem.style.display="block"}this.options.hide&&c(this.elem).hide();if(this.options.hide||this.options.show)for(var e in this.options.curAnim)c.style(this.elem, -e,this.options.orig[e]);this.options.complete.call(this.elem)}return false}else{e=b-this.startTime;this.state=e/this.options.duration;a=this.options.easing||(c.easing.swing?"swing":"linear");this.pos=c.easing[this.options.specialEasing&&this.options.specialEasing[this.prop]||a](this.state,e,0,1,this.options.duration);this.now=this.start+(this.end-this.start)*this.pos;this.update()}return true}};c.extend(c.fx,{tick:function(){for(var a=c.timers,b=0;b
        "; -a.insertBefore(b,a.firstChild);d=b.firstChild;f=d.firstChild;e=d.nextSibling.firstChild.firstChild;this.doesNotAddBorder=f.offsetTop!==5;this.doesAddBorderForTableAndCells=e.offsetTop===5;f.style.position="fixed";f.style.top="20px";this.supportsFixedPosition=f.offsetTop===20||f.offsetTop===15;f.style.position=f.style.top="";d.style.overflow="hidden";d.style.position="relative";this.subtractsBorderForOverflowNotVisible=f.offsetTop===-5;this.doesNotIncludeMarginInBodyOffset=a.offsetTop!==j;a.removeChild(b); -c.offset.initialize=c.noop},bodyOffset:function(a){var b=a.offsetTop,d=a.offsetLeft;c.offset.initialize();if(c.offset.doesNotIncludeMarginInBodyOffset){b+=parseFloat(c.curCSS(a,"marginTop",true))||0;d+=parseFloat(c.curCSS(a,"marginLeft",true))||0}return{top:b,left:d}},setOffset:function(a,b,d){if(/static/.test(c.curCSS(a,"position")))a.style.position="relative";var f=c(a),e=f.offset(),j=parseInt(c.curCSS(a,"top",true),10)||0,i=parseInt(c.curCSS(a,"left",true),10)||0;if(c.isFunction(b))b=b.call(a, -d,e);d={top:b.top-e.top+j,left:b.left-e.left+i};"using"in b?b.using.call(a,d):f.css(d)}};c.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),d=this.offset(),f=/^body|html$/i.test(b[0].nodeName)?{top:0,left:0}:b.offset();d.top-=parseFloat(c.curCSS(a,"marginTop",true))||0;d.left-=parseFloat(c.curCSS(a,"marginLeft",true))||0;f.top+=parseFloat(c.curCSS(b[0],"borderTopWidth",true))||0;f.left+=parseFloat(c.curCSS(b[0],"borderLeftWidth",true))||0;return{top:d.top- -f.top,left:d.left-f.left}},offsetParent:function(){return this.map(function(){for(var a=this.offsetParent||s.body;a&&!/^body|html$/i.test(a.nodeName)&&c.css(a,"position")==="static";)a=a.offsetParent;return a})}});c.each(["Left","Top"],function(a,b){var d="scroll"+b;c.fn[d]=function(f){var e=this[0],j;if(!e)return null;if(f!==w)return this.each(function(){if(j=wa(this))j.scrollTo(!a?f:c(j).scrollLeft(),a?f:c(j).scrollTop());else this[d]=f});else return(j=wa(e))?"pageXOffset"in j?j[a?"pageYOffset": -"pageXOffset"]:c.support.boxModel&&j.document.documentElement[d]||j.document.body[d]:e[d]}});c.each(["Height","Width"],function(a,b){var d=b.toLowerCase();c.fn["inner"+b]=function(){return this[0]?c.css(this[0],d,false,"padding"):null};c.fn["outer"+b]=function(f){return this[0]?c.css(this[0],d,false,f?"margin":"border"):null};c.fn[d]=function(f){var e=this[0];if(!e)return f==null?null:this;if(c.isFunction(f))return this.each(function(j){var i=c(this);i[d](f.call(this,j,i[d]()))});return"scrollTo"in -e&&e.document?e.document.compatMode==="CSS1Compat"&&e.document.documentElement["client"+b]||e.document.body["client"+b]:e.nodeType===9?Math.max(e.documentElement["client"+b],e.body["scroll"+b],e.documentElement["scroll"+b],e.body["offset"+b],e.documentElement["offset"+b]):f===w?c.css(e,d):this.css(d,typeof f==="string"?f:f+"px")}});A.jQuery=A.$=c})(window);jQuery.noConflict(); +this.nextSibling)});else if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,c(arguments[0]).toArray());return a}},remove:function(a,b){for(var d=0,e;(e=this[d])!=null;d++)if(!a||c.filter(a,[e]).length){if(!b&&e.nodeType===1){c.cleanData(e.getElementsByTagName("*"));c.cleanData([e])}e.parentNode&&e.parentNode.removeChild(e)}return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++)for(b.nodeType===1&&c.cleanData(b.getElementsByTagName("*"));b.firstChild;)b.removeChild(b.firstChild); +return this},clone:function(a){var b=this.map(function(){if(!c.support.noCloneEvent&&!c.isXMLDoc(this)){var d=this.outerHTML,e=this.ownerDocument;if(!d){d=e.createElement("div");d.appendChild(this.cloneNode(true));d=d.innerHTML}return c.clean([d.replace(za,"").replace(fb,'="$1">').replace($,"")],e)[0]}else return this.cloneNode(true)});if(a===true){na(this,b);na(this.find("*"),b.find("*"))}return b},html:function(a){if(a===B)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(za,""):null; +else if(typeof a==="string"&&!Ca.test(a)&&(c.support.leadingWhitespace||!$.test(a))&&!P[(Ba.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Aa,"<$1>");try{for(var b=0,d=this.length;b0||e.cacheable||this.length>1?h.cloneNode(true):h)}k.length&&c.each(k,Oa)}return this}});c.buildFragment=function(a,b,d){var e,f,h;b=b&&b[0]?b[0].ownerDocument||b[0]:t;if(a.length===1&&typeof a[0]==="string"&&a[0].length<512&&b===t&&!Ca.test(a[0])&&(c.support.checkClone||!Da.test(a[0]))){f=true;if(h=c.fragments[a[0]])if(h!==1)e=h}if(!e){e=b.createDocumentFragment();c.clean(a,b,e,d)}if(f)c.fragments[a[0]]=h?e:1;return{fragment:e,cacheable:f}};c.fragments={};c.each({appendTo:"append", +prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){c.fn[a]=function(d){var e=[];d=c(d);var f=this.length===1&&this[0].parentNode;if(f&&f.nodeType===11&&f.childNodes.length===1&&d.length===1){d[b](this[0]);return this}else{f=0;for(var h=d.length;f0?this.clone(true):this).get();c(d[f])[b](l);e=e.concat(l)}return this.pushStack(e,a,d.selector)}}});c.extend({clean:function(a,b,d,e){b=b||t;if(typeof b.createElement==="undefined")b=b.ownerDocument|| +b[0]&&b[0].ownerDocument||t;for(var f=[],h=0,l;(l=a[h])!=null;h++){if(typeof l==="number")l+="";if(l){if(typeof l==="string"&&!eb.test(l))l=b.createTextNode(l);else if(typeof l==="string"){l=l.replace(Aa,"<$1>");var k=(Ba.exec(l)||["",""])[1].toLowerCase(),o=P[k]||P._default,x=o[0],r=b.createElement("div");for(r.innerHTML=o[1]+l+o[2];x--;)r=r.lastChild;if(!c.support.tbody){x=db.test(l);k=k==="table"&&!x?r.firstChild&&r.firstChild.childNodes:o[1]===""&&!x?r.childNodes:[];for(o=k.length- +1;o>=0;--o)c.nodeName(k[o],"tbody")&&!k[o].childNodes.length&&k[o].parentNode.removeChild(k[o])}!c.support.leadingWhitespace&&$.test(l)&&r.insertBefore(b.createTextNode($.exec(l)[0]),r.firstChild);l=r.childNodes}if(l.nodeType)f.push(l);else f=c.merge(f,l)}}if(d)for(h=0;f[h];h++)if(e&&c.nodeName(f[h],"script")&&(!f[h].type||f[h].type.toLowerCase()==="text/javascript"))e.push(f[h].parentNode?f[h].parentNode.removeChild(f[h]):f[h]);else{f[h].nodeType===1&&f.splice.apply(f,[h+1,0].concat(c.makeArray(f[h].getElementsByTagName("script")))); +d.appendChild(f[h])}return f},cleanData:function(a){for(var b,d,e=c.cache,f=c.event.special,h=c.support.deleteExpando,l=0,k;(k=a[l])!=null;l++)if(!(k.nodeName&&c.noData[k.nodeName.toLowerCase()]))if(d=k[c.expando]){if((b=e[d])&&b.events)for(var o in b.events)f[o]?c.event.remove(k,o):c.removeEvent(k,o,b.handle);if(h)delete k[c.expando];else k.removeAttribute&&k.removeAttribute(c.expando);delete e[d]}}});var Ea=/alpha\([^)]*\)/i,gb=/opacity=([^)]*)/,hb=/-([a-z])/ig,ib=/([A-Z])/g,Fa=/^-?\d+(?:px)?$/i, +jb=/^-?\d/,kb={position:"absolute",visibility:"hidden",display:"block"},Pa=["Left","Right"],Qa=["Top","Bottom"],W,Ga,aa,lb=function(a,b){return b.toUpperCase()};c.fn.css=function(a,b){if(arguments.length===2&&b===B)return this;return c.access(this,a,b,true,function(d,e,f){return f!==B?c.style(d,e,f):c.css(d,e)})};c.extend({cssHooks:{opacity:{get:function(a,b){if(b){var d=W(a,"opacity","opacity");return d===""?"1":d}else return a.style.opacity}}},cssNumber:{zIndex:true,fontWeight:true,opacity:true, +zoom:true,lineHeight:true},cssProps:{"float":c.support.cssFloat?"cssFloat":"styleFloat"},style:function(a,b,d,e){if(!(!a||a.nodeType===3||a.nodeType===8||!a.style)){var f,h=c.camelCase(b),l=a.style,k=c.cssHooks[h];b=c.cssProps[h]||h;if(d!==B){if(!(typeof d==="number"&&isNaN(d)||d==null)){if(typeof d==="number"&&!c.cssNumber[h])d+="px";if(!k||!("set"in k)||(d=k.set(a,d))!==B)try{l[b]=d}catch(o){}}}else{if(k&&"get"in k&&(f=k.get(a,false,e))!==B)return f;return l[b]}}},css:function(a,b,d){var e,f=c.camelCase(b), +h=c.cssHooks[f];b=c.cssProps[f]||f;if(h&&"get"in h&&(e=h.get(a,true,d))!==B)return e;else if(W)return W(a,b,f)},swap:function(a,b,d){var e={},f;for(f in b){e[f]=a.style[f];a.style[f]=b[f]}d.call(a);for(f in b)a.style[f]=e[f]},camelCase:function(a){return a.replace(hb,lb)}});c.curCSS=c.css;c.each(["height","width"],function(a,b){c.cssHooks[b]={get:function(d,e,f){var h;if(e){if(d.offsetWidth!==0)h=oa(d,b,f);else c.swap(d,kb,function(){h=oa(d,b,f)});if(h<=0){h=W(d,b,b);if(h==="0px"&&aa)h=aa(d,b,b); +if(h!=null)return h===""||h==="auto"?"0px":h}if(h<0||h==null){h=d.style[b];return h===""||h==="auto"?"0px":h}return typeof h==="string"?h:h+"px"}},set:function(d,e){if(Fa.test(e)){e=parseFloat(e);if(e>=0)return e+"px"}else return e}}});if(!c.support.opacity)c.cssHooks.opacity={get:function(a,b){return gb.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var d=a.style;d.zoom=1;var e=c.isNaN(b)?"":"alpha(opacity="+b*100+")",f= +d.filter||"";d.filter=Ea.test(f)?f.replace(Ea,e):d.filter+" "+e}};if(t.defaultView&&t.defaultView.getComputedStyle)Ga=function(a,b,d){var e;d=d.replace(ib,"-$1").toLowerCase();if(!(b=a.ownerDocument.defaultView))return B;if(b=b.getComputedStyle(a,null)){e=b.getPropertyValue(d);if(e===""&&!c.contains(a.ownerDocument.documentElement,a))e=c.style(a,d)}return e};if(t.documentElement.currentStyle)aa=function(a,b){var d,e,f=a.currentStyle&&a.currentStyle[b],h=a.style;if(!Fa.test(f)&&jb.test(f)){d=h.left; +e=a.runtimeStyle.left;a.runtimeStyle.left=a.currentStyle.left;h.left=b==="fontSize"?"1em":f||0;f=h.pixelLeft+"px";h.left=d;a.runtimeStyle.left=e}return f===""?"auto":f};W=Ga||aa;if(c.expr&&c.expr.filters){c.expr.filters.hidden=function(a){var b=a.offsetHeight;return a.offsetWidth===0&&b===0||!c.support.reliableHiddenOffsets&&(a.style.display||c.css(a,"display"))==="none"};c.expr.filters.visible=function(a){return!c.expr.filters.hidden(a)}}var mb=c.now(),nb=/)<[^<]*)*<\/script>/gi, +ob=/^(?:select|textarea)/i,pb=/^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,qb=/^(?:GET|HEAD)$/,Ra=/\[\]$/,T=/\=\?(&|$)/,ja=/\?/,rb=/([?&])_=[^&]*/,sb=/^(\w+:)?\/\/([^\/?#]+)/,tb=/%20/g,ub=/#.*$/,Ha=c.fn.load;c.fn.extend({load:function(a,b,d){if(typeof a!=="string"&&Ha)return Ha.apply(this,arguments);else if(!this.length)return this;var e=a.indexOf(" ");if(e>=0){var f=a.slice(e,a.length);a=a.slice(0,e)}e="GET";if(b)if(c.isFunction(b)){d=b;b=null}else if(typeof b=== +"object"){b=c.param(b,c.ajaxSettings.traditional);e="POST"}var h=this;c.ajax({url:a,type:e,dataType:"html",data:b,complete:function(l,k){if(k==="success"||k==="notmodified")h.html(f?c("
        ").append(l.responseText.replace(nb,"")).find(f):l.responseText);d&&h.each(d,[l.responseText,k,l])}});return this},serialize:function(){return c.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?c.makeArray(this.elements):this}).filter(function(){return this.name&& +!this.disabled&&(this.checked||ob.test(this.nodeName)||pb.test(this.type))}).map(function(a,b){var d=c(this).val();return d==null?null:c.isArray(d)?c.map(d,function(e){return{name:b.name,value:e}}):{name:b.name,value:d}}).get()}});c.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){c.fn[b]=function(d){return this.bind(b,d)}});c.extend({get:function(a,b,d,e){if(c.isFunction(b)){e=e||d;d=b;b=null}return c.ajax({type:"GET",url:a,data:b,success:d,dataType:e})}, +getScript:function(a,b){return c.get(a,null,b,"script")},getJSON:function(a,b,d){return c.get(a,b,d,"json")},post:function(a,b,d,e){if(c.isFunction(b)){e=e||d;d=b;b={}}return c.ajax({type:"POST",url:a,data:b,success:d,dataType:e})},ajaxSetup:function(a){c.extend(c.ajaxSettings,a)},ajaxSettings:{url:location.href,global:true,type:"GET",contentType:"application/x-www-form-urlencoded",processData:true,async:true,xhr:function(){return new E.XMLHttpRequest},accepts:{xml:"application/xml, text/xml",html:"text/html", +script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},ajax:function(a){var b=c.extend(true,{},c.ajaxSettings,a),d,e,f,h=b.type.toUpperCase(),l=qb.test(h);b.url=b.url.replace(ub,"");b.context=a&&a.context!=null?a.context:b;if(b.data&&b.processData&&typeof b.data!=="string")b.data=c.param(b.data,b.traditional);if(b.dataType==="jsonp"){if(h==="GET")T.test(b.url)||(b.url+=(ja.test(b.url)?"&":"?")+(b.jsonp||"callback")+"=?");else if(!b.data|| +!T.test(b.data))b.data=(b.data?b.data+"&":"")+(b.jsonp||"callback")+"=?";b.dataType="json"}if(b.dataType==="json"&&(b.data&&T.test(b.data)||T.test(b.url))){d=b.jsonpCallback||"jsonp"+mb++;if(b.data)b.data=(b.data+"").replace(T,"="+d+"$1");b.url=b.url.replace(T,"="+d+"$1");b.dataType="script";var k=E[d];E[d]=function(m){if(c.isFunction(k))k(m);else{E[d]=B;try{delete E[d]}catch(p){}}f=m;c.handleSuccess(b,w,e,f);c.handleComplete(b,w,e,f);r&&r.removeChild(A)}}if(b.dataType==="script"&&b.cache===null)b.cache= +false;if(b.cache===false&&l){var o=c.now(),x=b.url.replace(rb,"$1_="+o);b.url=x+(x===b.url?(ja.test(b.url)?"&":"?")+"_="+o:"")}if(b.data&&l)b.url+=(ja.test(b.url)?"&":"?")+b.data;b.global&&c.active++===0&&c.event.trigger("ajaxStart");o=(o=sb.exec(b.url))&&(o[1]&&o[1].toLowerCase()!==location.protocol||o[2].toLowerCase()!==location.host);if(b.dataType==="script"&&h==="GET"&&o){var r=t.getElementsByTagName("head")[0]||t.documentElement,A=t.createElement("script");if(b.scriptCharset)A.charset=b.scriptCharset; +A.src=b.url;if(!d){var C=false;A.onload=A.onreadystatechange=function(){if(!C&&(!this.readyState||this.readyState==="loaded"||this.readyState==="complete")){C=true;c.handleSuccess(b,w,e,f);c.handleComplete(b,w,e,f);A.onload=A.onreadystatechange=null;r&&A.parentNode&&r.removeChild(A)}}}r.insertBefore(A,r.firstChild);return B}var J=false,w=b.xhr();if(w){b.username?w.open(h,b.url,b.async,b.username,b.password):w.open(h,b.url,b.async);try{if(b.data!=null&&!l||a&&a.contentType)w.setRequestHeader("Content-Type", +b.contentType);if(b.ifModified){c.lastModified[b.url]&&w.setRequestHeader("If-Modified-Since",c.lastModified[b.url]);c.etag[b.url]&&w.setRequestHeader("If-None-Match",c.etag[b.url])}o||w.setRequestHeader("X-Requested-With","XMLHttpRequest");w.setRequestHeader("Accept",b.dataType&&b.accepts[b.dataType]?b.accepts[b.dataType]+", */*; q=0.01":b.accepts._default)}catch(I){}if(b.beforeSend&&b.beforeSend.call(b.context,w,b)===false){b.global&&c.active--===1&&c.event.trigger("ajaxStop");w.abort();return false}b.global&& +c.triggerGlobal(b,"ajaxSend",[w,b]);var L=w.onreadystatechange=function(m){if(!w||w.readyState===0||m==="abort"){J||c.handleComplete(b,w,e,f);J=true;if(w)w.onreadystatechange=c.noop}else if(!J&&w&&(w.readyState===4||m==="timeout")){J=true;w.onreadystatechange=c.noop;e=m==="timeout"?"timeout":!c.httpSuccess(w)?"error":b.ifModified&&c.httpNotModified(w,b.url)?"notmodified":"success";var p;if(e==="success")try{f=c.httpData(w,b.dataType,b)}catch(q){e="parsererror";p=q}if(e==="success"||e==="notmodified")d|| +c.handleSuccess(b,w,e,f);else c.handleError(b,w,e,p);d||c.handleComplete(b,w,e,f);m==="timeout"&&w.abort();if(b.async)w=null}};try{var g=w.abort;w.abort=function(){w&&Function.prototype.call.call(g,w);L("abort")}}catch(i){}b.async&&b.timeout>0&&setTimeout(function(){w&&!J&&L("timeout")},b.timeout);try{w.send(l||b.data==null?null:b.data)}catch(n){c.handleError(b,w,null,n);c.handleComplete(b,w,e,f)}b.async||L();return w}},param:function(a,b){var d=[],e=function(h,l){l=c.isFunction(l)?l():l;d[d.length]= +encodeURIComponent(h)+"="+encodeURIComponent(l)};if(b===B)b=c.ajaxSettings.traditional;if(c.isArray(a)||a.jquery)c.each(a,function(){e(this.name,this.value)});else for(var f in a)da(f,a[f],b,e);return d.join("&").replace(tb,"+")}});c.extend({active:0,lastModified:{},etag:{},handleError:function(a,b,d,e){a.error&&a.error.call(a.context,b,d,e);a.global&&c.triggerGlobal(a,"ajaxError",[b,a,e])},handleSuccess:function(a,b,d,e){a.success&&a.success.call(a.context,e,d,b);a.global&&c.triggerGlobal(a,"ajaxSuccess", +[b,a])},handleComplete:function(a,b,d){a.complete&&a.complete.call(a.context,b,d);a.global&&c.triggerGlobal(a,"ajaxComplete",[b,a]);a.global&&c.active--===1&&c.event.trigger("ajaxStop")},triggerGlobal:function(a,b,d){(a.context&&a.context.url==null?c(a.context):c.event).trigger(b,d)},httpSuccess:function(a){try{return!a.status&&location.protocol==="file:"||a.status>=200&&a.status<300||a.status===304||a.status===1223}catch(b){}return false},httpNotModified:function(a,b){var d=a.getResponseHeader("Last-Modified"), +e=a.getResponseHeader("Etag");if(d)c.lastModified[b]=d;if(e)c.etag[b]=e;return a.status===304},httpData:function(a,b,d){var e=a.getResponseHeader("content-type")||"",f=b==="xml"||!b&&e.indexOf("xml")>=0;a=f?a.responseXML:a.responseText;f&&a.documentElement.nodeName==="parsererror"&&c.error("parsererror");if(d&&d.dataFilter)a=d.dataFilter(a,b);if(typeof a==="string")if(b==="json"||!b&&e.indexOf("json")>=0)a=c.parseJSON(a);else if(b==="script"||!b&&e.indexOf("javascript")>=0)c.globalEval(a);return a}}); +if(E.ActiveXObject)c.ajaxSettings.xhr=function(){if(E.location.protocol!=="file:")try{return new E.XMLHttpRequest}catch(a){}try{return new E.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}};c.support.ajax=!!c.ajaxSettings.xhr();var ea={},vb=/^(?:toggle|show|hide)$/,wb=/^([+\-]=)?([\d+.\-]+)(.*)$/,ba,pa=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]];c.fn.extend({show:function(a,b,d){if(a||a===0)return this.animate(S("show", +3),a,b,d);else{d=0;for(var e=this.length;d=0;e--)if(d[e].elem===this){b&&d[e](true);d.splice(e,1)}});b||this.dequeue();return this}});c.each({slideDown:S("show",1),slideUp:S("hide",1),slideToggle:S("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){c.fn[a]=function(d,e,f){return this.animate(b, +d,e,f)}});c.extend({speed:function(a,b,d){var e=a&&typeof a==="object"?c.extend({},a):{complete:d||!d&&b||c.isFunction(a)&&a,duration:a,easing:d&&b||b&&!c.isFunction(b)&&b};e.duration=c.fx.off?0:typeof e.duration==="number"?e.duration:e.duration in c.fx.speeds?c.fx.speeds[e.duration]:c.fx.speeds._default;e.old=e.complete;e.complete=function(){e.queue!==false&&c(this).dequeue();c.isFunction(e.old)&&e.old.call(this)};return e},easing:{linear:function(a,b,d,e){return d+e*a},swing:function(a,b,d,e){return(-Math.cos(a* +Math.PI)/2+0.5)*e+d}},timers:[],fx:function(a,b,d){this.options=b;this.elem=a;this.prop=d;if(!b.orig)b.orig={}}});c.fx.prototype={update:function(){this.options.step&&this.options.step.call(this.elem,this.now,this);(c.fx.step[this.prop]||c.fx.step._default)(this)},cur:function(){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null))return this.elem[this.prop];var a=parseFloat(c.css(this.elem,this.prop));return a&&a>-1E4?a:0},custom:function(a,b,d){function e(l){return f.step(l)} +var f=this,h=c.fx;this.startTime=c.now();this.start=a;this.end=b;this.unit=d||this.unit||"px";this.now=this.start;this.pos=this.state=0;e.elem=this.elem;if(e()&&c.timers.push(e)&&!ba)ba=setInterval(h.tick,h.interval)},show:function(){this.options.orig[this.prop]=c.style(this.elem,this.prop);this.options.show=true;this.custom(this.prop==="width"||this.prop==="height"?1:0,this.cur());c(this.elem).show()},hide:function(){this.options.orig[this.prop]=c.style(this.elem,this.prop);this.options.hide=true; +this.custom(this.cur(),0)},step:function(a){var b=c.now(),d=true;if(a||b>=this.options.duration+this.startTime){this.now=this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;for(var e in this.options.curAnim)if(this.options.curAnim[e]!==true)d=false;if(d){if(this.options.overflow!=null&&!c.support.shrinkWrapBlocks){var f=this.elem,h=this.options;c.each(["","X","Y"],function(k,o){f.style["overflow"+o]=h.overflow[k]})}this.options.hide&&c(this.elem).hide();if(this.options.hide|| +this.options.show)for(var l in this.options.curAnim)c.style(this.elem,l,this.options.orig[l]);this.options.complete.call(this.elem)}return false}else{a=b-this.startTime;this.state=a/this.options.duration;b=this.options.easing||(c.easing.swing?"swing":"linear");this.pos=c.easing[this.options.specialEasing&&this.options.specialEasing[this.prop]||b](this.state,a,0,1,this.options.duration);this.now=this.start+(this.end-this.start)*this.pos;this.update()}return true}};c.extend(c.fx,{tick:function(){for(var a= +c.timers,b=0;b-1;e={};var x={};if(o)x=f.position();l=o?x.top:parseInt(l,10)||0;k=o?x.left:parseInt(k,10)||0;if(c.isFunction(b))b=b.call(a,d,h);if(b.top!=null)e.top=b.top-h.top+l;if(b.left!=null)e.left=b.left-h.left+k;"using"in b?b.using.call(a, +e):f.css(e)}};c.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),d=this.offset(),e=Ia.test(b[0].nodeName)?{top:0,left:0}:b.offset();d.top-=parseFloat(c.css(a,"marginTop"))||0;d.left-=parseFloat(c.css(a,"marginLeft"))||0;e.top+=parseFloat(c.css(b[0],"borderTopWidth"))||0;e.left+=parseFloat(c.css(b[0],"borderLeftWidth"))||0;return{top:d.top-e.top,left:d.left-e.left}},offsetParent:function(){return this.map(function(){for(var a=this.offsetParent||t.body;a&&!Ia.test(a.nodeName)&& +c.css(a,"position")==="static";)a=a.offsetParent;return a})}});c.each(["Left","Top"],function(a,b){var d="scroll"+b;c.fn[d]=function(e){var f=this[0],h;if(!f)return null;if(e!==B)return this.each(function(){if(h=fa(this))h.scrollTo(!a?e:c(h).scrollLeft(),a?e:c(h).scrollTop());else this[d]=e});else return(h=fa(f))?"pageXOffset"in h?h[a?"pageYOffset":"pageXOffset"]:c.support.boxModel&&h.document.documentElement[d]||h.document.body[d]:f[d]}});c.each(["Height","Width"],function(a,b){var d=b.toLowerCase(); +c.fn["inner"+b]=function(){return this[0]?parseFloat(c.css(this[0],d,"padding")):null};c.fn["outer"+b]=function(e){return this[0]?parseFloat(c.css(this[0],d,e?"margin":"border")):null};c.fn[d]=function(e){var f=this[0];if(!f)return e==null?null:this;if(c.isFunction(e))return this.each(function(l){var k=c(this);k[d](e.call(this,l,k[d]()))});if(c.isWindow(f))return f.document.compatMode==="CSS1Compat"&&f.document.documentElement["client"+b]||f.document.body["client"+b];else if(f.nodeType===9)return Math.max(f.documentElement["client"+ +b],f.body["scroll"+b],f.documentElement["scroll"+b],f.body["offset"+b],f.documentElement["offset"+b]);else if(e===B){f=c.css(f,d);var h=parseFloat(f);return c.isNaN(h)?f:h}else return this.css(d,typeof e==="string"?e:e+"px")}})})(window);jQuery.noConflict(); \ No newline at end of file diff --git a/wp-includes/js/jquery/jquery.query.js b/wp-includes/js/jquery/jquery.query.js new file mode 100644 index 00000000..214ca369 --- /dev/null +++ b/wp-includes/js/jquery/jquery.query.js @@ -0,0 +1,11 @@ +/** + * jQuery.query - Query String Modification and Creation for jQuery + * Written by Blair Mitchelmore (blair DOT mitchelmore AT gmail DOT com) + * Licensed under the WTFPL (http://sam.zoy.org/wtfpl/). + * Date: 2009/8/13 + * + * @author Blair Mitchelmore + * @version 2.1.7 + * + **/ +new function(e){var d=e.separator||"&";var c=e.spaces===false?false:true;var a=e.suffix===false?"":"[]";var g=e.prefix===false?false:true;var b=g?e.hash===true?"#":"?":"";var f=e.numbers===false?false:true;jQuery.query=new function(){var h=function(m,l){return m!=undefined&&m!==null&&(!!l?m.constructor==l:true)};var i=function(r){var l,q=/\[([^[]*)\]/g,n=/^([^[]+)(\[.*\])?$/.exec(r),o=n[1],p=[];while(l=q.exec(n[2])){p.push(l[1])}return[o,p]};var k=function(s,r,q){var t,p=r.shift();if(typeof s!="object"){s=null}if(p===""){if(!s){s=[]}if(h(s,Array)){s.push(r.length==0?q:k(null,r.slice(0),q))}else{if(h(s,Object)){var n=0;while(s[n++]!=null){}s[--n]=r.length==0?q:k(s[n],r.slice(0),q)}else{s=[];s.push(r.length==0?q:k(null,r.slice(0),q))}}}else{if(p&&p.match(/^\s*[0-9]+\s*$/)){var m=parseInt(p,10);if(!s){s=[]}s[m]=r.length==0?q:k(s[m],r.slice(0),q)}else{if(p){var m=p.replace(/^\s*|\s*$/g,"");if(!s){s={}}if(h(s,Array)){var l={};for(var n=0;n0){r.push(b)}r.push(q.join(d));return r.join("")}};return new j(location.search,location.hash)}}(jQuery.query||{}); diff --git a/wp-includes/js/jquery/jquery.serialize-object.js b/wp-includes/js/jquery/jquery.serialize-object.js new file mode 100644 index 00000000..03b905bf --- /dev/null +++ b/wp-includes/js/jquery/jquery.serialize-object.js @@ -0,0 +1,31 @@ +/*! + * jQuery serializeObject - v0.2 - 1/20/2010 + * http://benalman.com/projects/jquery-misc-plugins/ + * + * Copyright (c) 2010 "Cowboy" Ben Alman + * Dual licensed under the MIT and GPL licenses. + * http://benalman.com/about/license/ + */ + +// Whereas .serializeArray() serializes a form into an array, .serializeObject() +// serializes a form into an (arguably more useful) object. + +(function($,undefined){ + '$:nomunge'; // Used by YUI compressor. + + $.fn.serializeObject = function(){ + var obj = {}; + + $.each( this.serializeArray(), function(i,o){ + var n = o.name, + v = o.value; + + obj[n] = obj[n] === undefined ? v + : $.isArray( obj[n] ) ? obj[n].concat( v ) + : [ obj[n], v ]; + }); + + return obj; + }; + +})(jQuery); diff --git a/wp-includes/js/jquery/suggest.js b/wp-includes/js/jquery/suggest.js index 5e15c430..904936f3 100644 --- a/wp-includes/js/jquery/suggest.js +++ b/wp-includes/js/jquery/suggest.js @@ -1 +1 @@ -(function($){$.suggest=function(input,options){var $input,$results,timeout,prevLength,cache,cacheSize;$input=$(input).attr("autocomplete","off");$results=$(document.createElement("ul"));timeout=false;prevLength=0;cache=[];cacheSize=0;$results.addClass(options.resultsClass).appendTo("body");resetPosition();$(window).load(resetPosition).resize(resetPosition);$input.blur(function(){setTimeout(function(){$results.hide()},200)});if($.browser.msie){try{$results.bgiframe()}catch(e){}}if($.browser.mozilla){$input.keypress(processKey)}else{$input.keydown(processKey)}function resetPosition(){var offset=$input.offset();$results.css({top:(offset.top+input.offsetHeight)+"px",left:offset.left+"px"})}function processKey(e){if((/27$|38$|40$/.test(e.keyCode)&&$results.is(":visible"))||(/^13$|^9$/.test(e.keyCode)&&getCurrentResult())){if(e.preventDefault){e.preventDefault()}if(e.stopPropagation){e.stopPropagation()}e.cancelBubble=true;e.returnValue=false;switch(e.keyCode){case 38:prevResult();break;case 40:nextResult();break;case 9:case 13:selectCurrentResult();break;case 27:$results.hide();break}}else{if($input.val().length!=prevLength){if(timeout){clearTimeout(timeout)}timeout=setTimeout(suggest,options.delay);prevLength=$input.val().length}}}function suggest(){var q=$.trim($input.val()),multipleSepPos,items;if(options.multiple){multipleSepPos=q.lastIndexOf(options.multipleSep);if(multipleSepPos!=-1){q=$.trim(q.substr(multipleSepPos+options.multipleSep.length))}}if(q.length>=options.minchars){cached=checkCache(q);if(cached){displayItems(cached.items)}else{$.get(options.source,{q:q},function(txt){$results.hide();items=parseTxt(txt,q);displayItems(items);addToCache(q,items,txt.length)})}}else{$results.hide()}}function checkCache(q){var i;for(i=0;ioptions.maxCacheSize)){cached=cache.pop();cacheSize-=cached.size}cache.push({q:q,size:size,items:items});cacheSize+=size}function displayItems(items){var html="",i;if(!items){return}if(!items.length){$results.hide();return}resetPosition();for(i=0;i"+items[i]+""}$results.html(html).show();$results.children("li").mouseover(function(){$results.children("li").removeClass(options.selectClass);$(this).addClass(options.selectClass)}).click(function(e){e.preventDefault();e.stopPropagation();selectCurrentResult()})}function parseTxt(txt,q){var items=[],tokens=txt.split(options.delimiter),i,token;for(i=0;i'+q+""});items[items.length]=token}}return items}function getCurrentResult(){var $currentResult;if(!$results.is(":visible")){return false}$currentResult=$results.children("li."+options.selectClass);if(!$currentResult.length){$currentResult=false}return $currentResult}function selectCurrentResult(){$currentResult=getCurrentResult();if($currentResult){if(options.multiple){if($input.val().indexOf(options.multipleSep)!=-1){$currentVal=$input.val().substr(0,($input.val().lastIndexOf(options.multipleSep)+options.multipleSep.length))}else{$currentVal=""}$input.val($currentVal+$currentResult.text()+options.multipleSep);$input.focus()}else{$input.val($currentResult.text())}$results.hide();if(options.onSelect){options.onSelect.apply($input[0])}}}function nextResult(){$currentResult=getCurrentResult();if($currentResult){$currentResult.removeClass(options.selectClass).next().addClass(options.selectClass)}else{$results.children("li:first-child").addClass(options.selectClass)}}function prevResult(){var $currentResult=getCurrentResult();if($currentResult){$currentResult.removeClass(options.selectClass).prev().addClass(options.selectClass)}else{$results.children("li:last-child").addClass(options.selectClass)}}};$.fn.suggest=function(source,options){if(!source){return}options=options||{};options.multiple=options.multiple||false;options.multipleSep=options.multipleSep||", ";options.source=source;options.delay=options.delay||100;options.resultsClass=options.resultsClass||"ac_results";options.selectClass=options.selectClass||"ac_over";options.matchClass=options.matchClass||"ac_match";options.minchars=options.minchars||2;options.delimiter=options.delimiter||"\n";options.onSelect=options.onSelect||false;options.maxCacheSize=options.maxCacheSize||65536;this.each(function(){new $.suggest(this,options)});return this}})(jQuery); \ No newline at end of file +(function(a){a.suggest=function(o,g){var c,f,n,d,q,p;c=a(o).attr("autocomplete","off");f=a(document.createElement("ul"));n=false;d=0;q=[];p=0;f.addClass(g.resultsClass).appendTo("body");j();a(window).load(j).resize(j);c.blur(function(){setTimeout(function(){f.hide()},200)});if(a.browser.msie){try{f.bgiframe()}catch(s){}}if(a.browser.mozilla){c.keypress(m)}else{c.keydown(m)}function j(){var e=c.offset();f.css({top:(e.top+o.offsetHeight)+"px",left:e.left+"px"})}function m(w){if((/27$|38$|40$/.test(w.keyCode)&&f.is(":visible"))||(/^13$|^9$/.test(w.keyCode)&&u())){if(w.preventDefault){w.preventDefault()}if(w.stopPropagation){w.stopPropagation()}w.cancelBubble=true;w.returnValue=false;switch(w.keyCode){case 38:k();break;case 40:t();break;case 9:case 13:r();break;case 27:f.hide();break}}else{if(c.val().length!=d){if(n){clearTimeout(n)}n=setTimeout(l,g.delay);d=c.val().length}}}function l(){var x=a.trim(c.val()),w,e;if(g.multiple){w=x.lastIndexOf(g.multipleSep);if(w!=-1){x=a.trim(x.substr(w+g.multipleSep.length))}}if(x.length>=g.minchars){cached=v(x);if(cached){i(cached.items)}else{a.get(g.source,{q:x},function(y){f.hide();e=b(y,x);i(e);h(x,e,y.length)})}}else{f.hide()}}function v(w){var e;for(e=0;eg.maxCacheSize)){x=q.pop();p-=x.size}q.push({q:y,size:w,items:e});p+=w}function i(e){var x="",w;if(!e){return}if(!e.length){f.hide();return}j();for(w=0;w"+e[w]+""}f.html(x).show();f.children("li").mouseover(function(){f.children("li").removeClass(g.selectClass);a(this).addClass(g.selectClass)}).click(function(y){y.preventDefault();y.stopPropagation();r()})}function b(e,z){var w=[],A=e.split(g.delimiter),y,x;for(y=0;y'+B+""});w[w.length]=x}}return w}function u(){var e;if(!f.is(":visible")){return false}e=f.children("li."+g.selectClass);if(!e.length){e=false}return e}function r(){$currentResult=u();if($currentResult){if(g.multiple){if(c.val().indexOf(g.multipleSep)!=-1){$currentVal=c.val().substr(0,(c.val().lastIndexOf(g.multipleSep)+g.multipleSep.length))}else{$currentVal=""}c.val($currentVal+$currentResult.text()+g.multipleSep);c.focus()}else{c.val($currentResult.text())}f.hide();if(g.onSelect){g.onSelect.apply(c[0])}}}function t(){$currentResult=u();if($currentResult){$currentResult.removeClass(g.selectClass).next().addClass(g.selectClass)}else{f.children("li:first-child").addClass(g.selectClass)}}function k(){var e=u();if(e){e.removeClass(g.selectClass).prev().addClass(g.selectClass)}else{f.children("li:last-child").addClass(g.selectClass)}}};a.fn.suggest=function(c,b){if(!c){return}b=b||{};b.multiple=b.multiple||false;b.multipleSep=b.multipleSep||", ";b.source=c;b.delay=b.delay||100;b.resultsClass=b.resultsClass||"ac_results";b.selectClass=b.selectClass||"ac_over";b.matchClass=b.matchClass||"ac_match";b.minchars=b.minchars||2;b.delimiter=b.delimiter||"\n";b.onSelect=b.onSelect||false;b.maxCacheSize=b.maxCacheSize||65536;this.each(function(){new a.suggest(this,b)});return this}})(jQuery); \ No newline at end of file diff --git a/wp-includes/js/jquery/ui.button.js b/wp-includes/js/jquery/ui.button.js new file mode 100644 index 00000000..c658c116 --- /dev/null +++ b/wp-includes/js/jquery/ui.button.js @@ -0,0 +1,25 @@ +/* + * jQuery UI Button 1.8.9 + * + * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * http://docs.jquery.com/UI/Button + * + * Depends: + * jquery.ui.core.js + * jquery.ui.widget.js + */ +(function(a){var g,i=function(b){a(":ui-button",b.target.form).each(function(){var c=a(this).data("button");setTimeout(function(){c.refresh()},1)})},h=function(b){var c=b.name,d=b.form,e=a([]);if(c)e=d?a(d).find("[name='"+c+"']"):a("[name='"+c+"']",b.ownerDocument).filter(function(){return!this.form});return e};a.widget("ui.button",{options:{disabled:null,text:true,label:null,icons:{primary:null,secondary:null}},_create:function(){this.element.closest("form").unbind("reset.button").bind("reset.button", +i);if(typeof this.options.disabled!=="boolean")this.options.disabled=this.element.attr("disabled");this._determineButtonType();this.hasTitle=!!this.buttonElement.attr("title");var b=this,c=this.options,d=this.type==="checkbox"||this.type==="radio",e="ui-state-hover"+(!d?" ui-state-active":"");if(c.label===null)c.label=this.buttonElement.html();if(this.element.is(":disabled"))c.disabled=true;this.buttonElement.addClass("ui-button ui-widget ui-state-default ui-corner-all").attr("role","button").bind("mouseenter.button", +function(){if(!c.disabled){a(this).addClass("ui-state-hover");this===g&&a(this).addClass("ui-state-active")}}).bind("mouseleave.button",function(){c.disabled||a(this).removeClass(e)}).bind("focus.button",function(){a(this).addClass("ui-state-focus")}).bind("blur.button",function(){a(this).removeClass("ui-state-focus")});d&&this.element.bind("change.button",function(){b.refresh()});if(this.type==="checkbox")this.buttonElement.bind("click.button",function(){if(c.disabled)return false;a(this).toggleClass("ui-state-active"); +b.buttonElement.attr("aria-pressed",b.element[0].checked)});else if(this.type==="radio")this.buttonElement.bind("click.button",function(){if(c.disabled)return false;a(this).addClass("ui-state-active");b.buttonElement.attr("aria-pressed",true);var f=b.element[0];h(f).not(f).map(function(){return a(this).button("widget")[0]}).removeClass("ui-state-active").attr("aria-pressed",false)});else{this.buttonElement.bind("mousedown.button",function(){if(c.disabled)return false;a(this).addClass("ui-state-active"); +g=this;a(document).one("mouseup",function(){g=null})}).bind("mouseup.button",function(){if(c.disabled)return false;a(this).removeClass("ui-state-active")}).bind("keydown.button",function(f){if(c.disabled)return false;if(f.keyCode==a.ui.keyCode.SPACE||f.keyCode==a.ui.keyCode.ENTER)a(this).addClass("ui-state-active")}).bind("keyup.button",function(){a(this).removeClass("ui-state-active")});this.buttonElement.is("a")&&this.buttonElement.keyup(function(f){f.keyCode===a.ui.keyCode.SPACE&&a(this).click()})}this._setOption("disabled", +c.disabled)},_determineButtonType:function(){this.type=this.element.is(":checkbox")?"checkbox":this.element.is(":radio")?"radio":this.element.is("input")?"input":"button";if(this.type==="checkbox"||this.type==="radio"){this.buttonElement=this.element.parents().last().find("label[for="+this.element.attr("id")+"]");this.element.addClass("ui-helper-hidden-accessible");var b=this.element.is(":checked");b&&this.buttonElement.addClass("ui-state-active");this.buttonElement.attr("aria-pressed",b)}else this.buttonElement= +this.element},widget:function(){return this.buttonElement},destroy:function(){this.element.removeClass("ui-helper-hidden-accessible");this.buttonElement.removeClass("ui-button ui-widget ui-state-default ui-corner-all ui-state-hover ui-state-active ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary ui-button-text-only").removeAttr("role").removeAttr("aria-pressed").html(this.buttonElement.find(".ui-button-text").html());this.hasTitle|| +this.buttonElement.removeAttr("title");a.Widget.prototype.destroy.call(this)},_setOption:function(b,c){a.Widget.prototype._setOption.apply(this,arguments);if(b==="disabled")c?this.element.attr("disabled",true):this.element.removeAttr("disabled");this._resetButton()},refresh:function(){var b=this.element.is(":disabled");b!==this.options.disabled&&this._setOption("disabled",b);if(this.type==="radio")h(this.element[0]).each(function(){a(this).is(":checked")?a(this).button("widget").addClass("ui-state-active").attr("aria-pressed", +true):a(this).button("widget").removeClass("ui-state-active").attr("aria-pressed",false)});else if(this.type==="checkbox")this.element.is(":checked")?this.buttonElement.addClass("ui-state-active").attr("aria-pressed",true):this.buttonElement.removeClass("ui-state-active").attr("aria-pressed",false)},_resetButton:function(){if(this.type==="input")this.options.label&&this.element.val(this.options.label);else{var b=this.buttonElement.removeClass("ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary ui-button-text-only"), +c=a("").addClass("ui-button-text").html(this.options.label).appendTo(b.empty()).text(),d=this.options.icons,e=d.primary&&d.secondary;if(d.primary||d.secondary){b.addClass("ui-button-text-icon"+(e?"s":d.primary?"-primary":"-secondary"));d.primary&&b.prepend("");d.secondary&&b.append("");if(!this.options.text){b.addClass(e?"ui-button-icons-only":"ui-button-icon-only").removeClass("ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary"); +this.hasTitle||b.attr("title",c)}}else b.addClass("ui-button-text-only")}}});a.widget("ui.buttonset",{options:{items:":button, :submit, :reset, :checkbox, :radio, a, :data(button)"},_create:function(){this.element.addClass("ui-buttonset")},_init:function(){this.refresh()},_setOption:function(b,c){b==="disabled"&&this.buttons.button("option",b,c);a.Widget.prototype._setOption.apply(this,arguments)},refresh:function(){this.buttons=this.element.find(this.options.items).filter(":ui-button").button("refresh").end().not(":ui-button").button().end().map(function(){return a(this).button("widget")[0]}).removeClass("ui-corner-all ui-corner-left ui-corner-right").filter(":first").addClass("ui-corner-left").end().filter(":last").addClass("ui-corner-right").end().end()}, +destroy:function(){this.element.removeClass("ui-buttonset");this.buttons.map(function(){return a(this).button("widget")[0]}).removeClass("ui-corner-left ui-corner-right").end().button("destroy");a.Widget.prototype.destroy.call(this)}})})(jQuery); diff --git a/wp-includes/js/jquery/ui.core.js b/wp-includes/js/jquery/ui.core.js index 0aecd2a0..bc00dc40 100644 --- a/wp-includes/js/jquery/ui.core.js +++ b/wp-includes/js/jquery/ui.core.js @@ -1,10 +1,17 @@ -/* - * jQuery UI 1.7.3 +/*! + * jQuery UI 1.8.9 * - * Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT (MIT-LICENSE.txt) - * and GPL (GPL-LICENSE.txt) licenses. + * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license * * http://docs.jquery.com/UI */ -jQuery.ui||(function(c){var i=c.fn.remove,d=c.browser.mozilla&&(parseFloat(c.browser.version)<1.9);c.ui={version:"1.7.3",plugin:{add:function(k,l,n){var m=c.ui[k].prototype;for(var j in n){m.plugins[j]=m.plugins[j]||[];m.plugins[j].push([l,n[j]])}},call:function(j,l,k){var n=j.plugins[l];if(!n||!j.element[0].parentNode){return}for(var m=0;m0){return true}m[j]=1;l=(m[j]>0);m[j]=0;return l},isOverAxis:function(k,j,l){return(k>j)&&(k<(j+l))},isOver:function(o,k,n,m,j,l){return c.ui.isOverAxis(o,n,j)&&c.ui.isOverAxis(k,m,l)},keyCode:{BACKSPACE:8,CAPS_LOCK:20,COMMA:188,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38}};if(d){var f=c.attr,e=c.fn.removeAttr,h="http://www.w3.org/2005/07/aaa",a=/^aria-/,b=/^wairole:/;c.attr=function(k,j,l){var m=l!==undefined;return(j=="role"?(m?f.call(this,k,j,"wairole:"+l):(f.apply(this,arguments)||"").replace(b,"")):(a.test(j)?(m?k.setAttributeNS(h,j.replace(a,"aaa:"),l):f.call(this,k,j.replace(a,"aaa:"))):f.apply(this,arguments)))};c.fn.removeAttr=function(j){return(a.test(j)?this.each(function(){this.removeAttributeNS(h,j.replace(a,""))}):e.call(this,j))}}c.fn.extend({remove:function(j,k){return this.each(function(){if(!k){if(!j||c.filter(j,[this]).length){c("*",this).add(this).each(function(){c(this).triggerHandler("remove")})}}return i.call(c(this),j,k)})},enableSelection:function(){return this.attr("unselectable","off").css("MozUserSelect","").unbind("selectstart.ui")},disableSelection:function(){return this.attr("unselectable","on").css("MozUserSelect","none").bind("selectstart.ui",function(){return false})},scrollParent:function(){var j;if((c.browser.msie&&(/(static|relative)/).test(this.css("position")))||(/absolute/).test(this.css("position"))){j=this.parents().filter(function(){return(/(relative|absolute|fixed)/).test(c.curCSS(this,"position",1))&&(/(auto|scroll)/).test(c.curCSS(this,"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0)}else{j=this.parents().filter(function(){return(/(auto|scroll)/).test(c.curCSS(this,"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0)}return(/fixed/).test(this.css("position"))||!j.length?c(document):j}});c.extend(c.expr[":"],{data:function(l,k,j){return !!c.data(l,j[3])},focusable:function(k){var l=k.nodeName.toLowerCase(),j=c.attr(k,"tabindex");return(/input|select|textarea|button|object/.test(l)?!k.disabled:"a"==l||"area"==l?k.href||!isNaN(j):!isNaN(j))&&!c(k)["area"==l?"parents":"closest"](":hidden").length},tabbable:function(k){var j=c.attr(k,"tabindex");return(isNaN(j)||j>=0)&&c(k).is(":focusable")}});function g(m,n,o,l){function k(q){var p=c[m][n][q]||[];return(typeof p=="string"?p.split(/,?\s+/):p)}var j=k("getter");if(l.length==1&&typeof l[0]=="string"){j=j.concat(k("getterSetter"))}return(c.inArray(o,j)!=-1)}c.widget=function(k,j){var l=k.split(".")[0];k=k.split(".")[1];c.fn[k]=function(p){var n=(typeof p=="string"),o=Array.prototype.slice.call(arguments,1);if(n&&p.substring(0,1)=="_"){return this}if(n&&g(l,k,p,o)){var m=c.data(this[0],k);return(m?m[p].apply(m,o):undefined)}return this.each(function(){var q=c.data(this,k);(!q&&!n&&c.data(this,k,new c[l][k](this,p))._init());(q&&n&&c.isFunction(q[p])&&q[p].apply(q,o))})};c[l]=c[l]||{};c[l][k]=function(o,n){var m=this;this.namespace=l;this.widgetName=k;this.widgetEventPrefix=c[l][k].eventPrefix||k;this.widgetBaseClass=l+"-"+k;this.options=c.extend({},c.widget.defaults,c[l][k].defaults,c.metadata&&c.metadata.get(o)[k],n);this.element=c(o).bind("setData."+k,function(q,p,r){if(q.target==o){return m._setData(p,r)}}).bind("getData."+k,function(q,p){if(q.target==o){return m._getData(p)}}).bind("remove",function(){return m.destroy()})};c[l][k].prototype=c.extend({},c.widget.prototype,j);c[l][k].getterSetter="option"};c.widget.prototype={_init:function(){},destroy:function(){this.element.removeData(this.widgetName).removeClass(this.widgetBaseClass+"-disabled "+this.namespace+"-state-disabled").removeAttr("aria-disabled")},option:function(l,m){var k=l,j=this;if(typeof l=="string"){if(m===undefined){return this._getData(l)}k={};k[l]=m}c.each(k,function(n,o){j._setData(n,o)})},_getData:function(j){return this.options[j]},_setData:function(j,k){this.options[j]=k;if(j=="disabled"){this.element[k?"addClass":"removeClass"](this.widgetBaseClass+"-disabled "+this.namespace+"-state-disabled").attr("aria-disabled",k)}},enable:function(){this._setData("disabled",false)},disable:function(){this._setData("disabled",true)},_trigger:function(l,m,n){var p=this.options[l],j=(l==this.widgetEventPrefix?l:this.widgetEventPrefix+l);m=c.Event(m);m.type=j;if(m.originalEvent){for(var k=c.event.props.length,o;k;){o=c.event.props[--k];m[o]=m.originalEvent[o]}}this.element.trigger(m,n);return !(c.isFunction(p)&&p.call(this.element[0],m,n)===false||m.isDefaultPrevented())}};c.widget.defaults={disabled:false};c.ui.mouse={_mouseInit:function(){var j=this;this.element.bind("mousedown."+this.widgetName,function(k){return j._mouseDown(k)}).bind("click."+this.widgetName,function(k){if(j._preventClickEvent){j._preventClickEvent=false;k.stopImmediatePropagation();return false}});if(c.browser.msie){this._mouseUnselectable=this.element.attr("unselectable");this.element.attr("unselectable","on")}this.started=false},_mouseDestroy:function(){this.element.unbind("."+this.widgetName);(c.browser.msie&&this.element.attr("unselectable",this._mouseUnselectable))},_mouseDown:function(l){l.originalEvent=l.originalEvent||{};if(l.originalEvent.mouseHandled){return}(this._mouseStarted&&this._mouseUp(l));this._mouseDownEvent=l;var k=this,m=(l.which==1),j=(typeof this.options.cancel=="string"?c(l.target).parents().add(l.target).filter(this.options.cancel).length:false);if(!m||j||!this._mouseCapture(l)){return true}this.mouseDelayMet=!this.options.delay;if(!this.mouseDelayMet){this._mouseDelayTimer=setTimeout(function(){k.mouseDelayMet=true},this.options.delay)}if(this._mouseDistanceMet(l)&&this._mouseDelayMet(l)){this._mouseStarted=(this._mouseStart(l)!==false);if(!this._mouseStarted){l.preventDefault();return true}}this._mouseMoveDelegate=function(n){return k._mouseMove(n)};this._mouseUpDelegate=function(n){return k._mouseUp(n)};c(document).bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate);(c.browser.safari||l.preventDefault());l.originalEvent.mouseHandled=true;return true},_mouseMove:function(j){if(c.browser.msie&&!j.button){return this._mouseUp(j)}if(this._mouseStarted){this._mouseDrag(j);return j.preventDefault()}if(this._mouseDistanceMet(j)&&this._mouseDelayMet(j)){this._mouseStarted=(this._mouseStart(this._mouseDownEvent,j)!==false);(this._mouseStarted?this._mouseDrag(j):this._mouseUp(j))}return !this._mouseStarted},_mouseUp:function(j){c(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate);if(this._mouseStarted){this._mouseStarted=false;this._preventClickEvent=(j.target==this._mouseDownEvent.target);this._mouseStop(j)}return false},_mouseDistanceMet:function(j){return(Math.max(Math.abs(this._mouseDownEvent.pageX-j.pageX),Math.abs(this._mouseDownEvent.pageY-j.pageY))>=this.options.distance)},_mouseDelayMet:function(j){return this.mouseDelayMet},_mouseStart:function(j){},_mouseDrag:function(j){},_mouseStop:function(j){},_mouseCapture:function(j){return true}};c.ui.mouse.defaults={cancel:null,distance:1,delay:0}})(jQuery); +(function(c,j){function k(a){return!c(a).parents().andSelf().filter(function(){return c.curCSS(this,"visibility")==="hidden"||c.expr.filters.hidden(this)}).length}c.ui=c.ui||{};if(!c.ui.version){c.extend(c.ui,{version:"1.8.9",keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,COMMAND:91,COMMAND_LEFT:91,COMMAND_RIGHT:93,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,MENU:93,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106, +NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38,WINDOWS:91}});c.fn.extend({_focus:c.fn.focus,focus:function(a,b){return typeof a==="number"?this.each(function(){var d=this;setTimeout(function(){c(d).focus();b&&b.call(d)},a)}):this._focus.apply(this,arguments)},scrollParent:function(){var a;a=c.browser.msie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?this.parents().filter(function(){return/(relative|absolute|fixed)/.test(c.curCSS(this, +"position",1))&&/(auto|scroll)/.test(c.curCSS(this,"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0):this.parents().filter(function(){return/(auto|scroll)/.test(c.curCSS(this,"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0);return/fixed/.test(this.css("position"))||!a.length?c(document):a},zIndex:function(a){if(a!==j)return this.css("zIndex",a);if(this.length){a=c(this[0]);for(var b;a.length&&a[0]!==document;){b=a.css("position"); +if(b==="absolute"||b==="relative"||b==="fixed"){b=parseInt(a.css("zIndex"),10);if(!isNaN(b)&&b!==0)return b}a=a.parent()}}return 0},disableSelection:function(){return this.bind((c.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",function(a){a.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}});c.each(["Width","Height"],function(a,b){function d(f,g,l,m){c.each(e,function(){g-=parseFloat(c.curCSS(f,"padding"+this,true))||0;if(l)g-=parseFloat(c.curCSS(f, +"border"+this+"Width",true))||0;if(m)g-=parseFloat(c.curCSS(f,"margin"+this,true))||0});return g}var e=b==="Width"?["Left","Right"]:["Top","Bottom"],h=b.toLowerCase(),i={innerWidth:c.fn.innerWidth,innerHeight:c.fn.innerHeight,outerWidth:c.fn.outerWidth,outerHeight:c.fn.outerHeight};c.fn["inner"+b]=function(f){if(f===j)return i["inner"+b].call(this);return this.each(function(){c(this).css(h,d(this,f)+"px")})};c.fn["outer"+b]=function(f,g){if(typeof f!=="number")return i["outer"+b].call(this,f);return this.each(function(){c(this).css(h, +d(this,f,true,g)+"px")})}});c.extend(c.expr[":"],{data:function(a,b,d){return!!c.data(a,d[3])},focusable:function(a){var b=a.nodeName.toLowerCase(),d=c.attr(a,"tabindex");if("area"===b){b=a.parentNode;d=b.name;if(!a.href||!d||b.nodeName.toLowerCase()!=="map")return false;a=c("img[usemap=#"+d+"]")[0];return!!a&&k(a)}return(/input|select|textarea|button|object/.test(b)?!a.disabled:"a"==b?a.href||!isNaN(d):!isNaN(d))&&k(a)},tabbable:function(a){var b=c.attr(a,"tabindex");return(isNaN(b)||b>=0)&&c(a).is(":focusable")}}); +c(function(){var a=document.body,b=a.appendChild(b=document.createElement("div"));c.extend(b.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0});c.support.minHeight=b.offsetHeight===100;c.support.selectstart="onselectstart"in b;a.removeChild(b).style.display="none"});c.extend(c.ui,{plugin:{add:function(a,b,d){a=c.ui[a].prototype;for(var e in d){a.plugins[e]=a.plugins[e]||[];a.plugins[e].push([b,d[e]])}},call:function(a,b,d){if((b=a.plugins[b])&&a.element[0].parentNode)for(var e=0;e0)return true;a[b]=1;d=a[b]>0;a[b]=0;return d},isOverAxis:function(a,b,d){return a>b&&a")).appendTo(document.body).hide().addClass(a+m.dialogClass).css({position:"absolute",overflow:"hidden",zIndex:m.zIndex}).attr("tabIndex",-1).css("outline",0).keydown(function(n){(m.closeOnEscape&&n.keyCode&&n.keyCode==c.ui.keyCode.ESCAPE&&l.close(n))}).attr({role:"dialog","aria-labelledby":e}).mousedown(function(n){l.moveToTop(false,n)}),g=this.element.show().removeAttr("title").addClass("ui-dialog-content ui-widget-content").appendTo(k),f=(this.uiDialogTitlebar=c("
        ")).addClass("ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix").prependTo(k),i=c('').addClass("ui-dialog-titlebar-close ui-corner-all").attr("role","button").hover(function(){i.addClass("ui-state-hover")},function(){i.removeClass("ui-state-hover")}).focus(function(){i.addClass("ui-state-focus")}).blur(function(){i.removeClass("ui-state-focus")}).mousedown(function(n){n.stopPropagation()}).click(function(n){l.close(n);return false}).appendTo(f),h=(this.uiDialogTitlebarCloseText=c("")).addClass("ui-icon ui-icon-closethick").text(m.closeText).appendTo(i),d=c("").addClass("ui-dialog-title").attr("id",e).html(j).prependTo(f);f.find("*").add(f).disableSelection();(m.draggable&&c.fn.draggable&&this._makeDraggable());(m.resizable&&c.fn.resizable&&this._makeResizable());this._createButtons(m.buttons);this._isOpen=false;(m.bgiframe&&c.fn.bgiframe&&k.bgiframe());(m.autoOpen&&this.open())},destroy:function(){(this.overlay&&this.overlay.destroy());this.uiDialog.hide();this.element.unbind(".dialog").removeData("dialog").removeClass("ui-dialog-content ui-widget-content").hide().appendTo("body");this.uiDialog.remove();(this.originalTitle&&this.element.attr("title",this.originalTitle))},close:function(f){var d=this;if(false===d._trigger("beforeclose",f)){return}(d.overlay&&d.overlay.destroy());d.uiDialog.unbind("keypress.ui-dialog");(d.options.hide?d.uiDialog.hide(d.options.hide,function(){d._trigger("close",f)}):d.uiDialog.hide()&&d._trigger("close",f));c.ui.dialog.overlay.resize();d._isOpen=false;if(d.options.modal){var e=0;c(".ui-dialog").each(function(){if(this!=d.uiDialog[0]){e=Math.max(e,c(this).css("z-index"))}});c.ui.dialog.maxZ=e}},isOpen:function(){return this._isOpen},moveToTop:function(f,e){if((this.options.modal&&!f)||(!this.options.stack&&!this.options.modal)){return this._trigger("focus",e)}if(this.options.zIndex>c.ui.dialog.maxZ){c.ui.dialog.maxZ=this.options.zIndex}(this.overlay&&this.overlay.$el.css("z-index",c.ui.dialog.overlay.maxZ=++c.ui.dialog.maxZ));var d={scrollTop:this.element.attr("scrollTop"),scrollLeft:this.element.attr("scrollLeft")};this.uiDialog.css("z-index",++c.ui.dialog.maxZ);this.element.attr(d);this._trigger("focus",e)},open:function(){if(this._isOpen){return}var e=this.options,d=this.uiDialog;this.overlay=e.modal?new c.ui.dialog.overlay(this):null;(d.next().length&&d.appendTo("body"));this._size();this._position(e.position);d.show(e.show);this.moveToTop(true);(e.modal&&d.bind("keypress.ui-dialog",function(h){if(h.keyCode!=c.ui.keyCode.TAB){return}var g=c(":tabbable",this),i=g.filter(":first")[0],f=g.filter(":last")[0];if(h.target==f&&!h.shiftKey){setTimeout(function(){i.focus()},1)}else{if(h.target==i&&h.shiftKey){setTimeout(function(){f.focus()},1)}}}));c([]).add(d.find(".ui-dialog-content :tabbable:first")).add(d.find(".ui-dialog-buttonpane :tabbable:first")).add(d).filter(":first").focus();this._trigger("open");this._isOpen=true},_createButtons:function(g){var f=this,d=false,e=c("
        ").addClass("ui-dialog-buttonpane ui-widget-content ui-helper-clearfix");this.uiDialog.find(".ui-dialog-buttonpane").remove();(typeof g=="object"&&g!==null&&c.each(g,function(){return !(d=true)}));if(d){c.each(g,function(h,i){c('').addClass("ui-state-default ui-corner-all").text(h).click(function(){i.apply(f.element[0],arguments)}).hover(function(){c(this).addClass("ui-state-hover")},function(){c(this).removeClass("ui-state-hover")}).focus(function(){c(this).addClass("ui-state-focus")}).blur(function(){c(this).removeClass("ui-state-focus")}).appendTo(e)});e.appendTo(this.uiDialog)}},_makeDraggable:function(){var d=this,f=this.options,e;this.uiDialog.draggable({cancel:".ui-dialog-content",handle:".ui-dialog-titlebar",containment:"document",start:function(){e=f.height;c(this).height(c(this).height()).addClass("ui-dialog-dragging");(f.dragStart&&f.dragStart.apply(d.element[0],arguments))},drag:function(){(f.drag&&f.drag.apply(d.element[0],arguments))},stop:function(){c(this).removeClass("ui-dialog-dragging").height(e);(f.dragStop&&f.dragStop.apply(d.element[0],arguments));c.ui.dialog.overlay.resize()}})},_makeResizable:function(g){g=(g===undefined?this.options.resizable:g);var d=this,f=this.options,e=typeof g=="string"?g:"n,e,s,w,se,sw,ne,nw";this.uiDialog.resizable({cancel:".ui-dialog-content",alsoResize:this.element,maxWidth:f.maxWidth,maxHeight:f.maxHeight,minWidth:f.minWidth,minHeight:f.minHeight,start:function(){c(this).addClass("ui-dialog-resizing");(f.resizeStart&&f.resizeStart.apply(d.element[0],arguments))},resize:function(){(f.resize&&f.resize.apply(d.element[0],arguments))},handles:e,stop:function(){c(this).removeClass("ui-dialog-resizing");f.height=c(this).height();f.width=c(this).width();(f.resizeStop&&f.resizeStop.apply(d.element[0],arguments));c.ui.dialog.overlay.resize()}}).find(".ui-resizable-se").addClass("ui-icon ui-icon-grip-diagonal-se")},_position:function(i){var e=c(window),f=c(document),g=f.scrollTop(),d=f.scrollLeft(),h=g;if(c.inArray(i,["center","top","right","bottom","left"])>=0){i=[i=="right"||i=="left"?i:"center",i=="top"||i=="bottom"?i:"middle"]}if(i.constructor!=Array){i=["center","middle"]}if(i[0].constructor==Number){d+=i[0]}else{switch(i[0]){case"left":d+=0;break;case"right":d+=e.width()-this.uiDialog.outerWidth();break;default:case"center":d+=(e.width()-this.uiDialog.outerWidth())/2}}if(i[1].constructor==Number){g+=i[1]}else{switch(i[1]){case"top":g+=0;break;case"bottom":g+=e.height()-this.uiDialog.outerHeight();break;default:case"middle":g+=(e.height()-this.uiDialog.outerHeight())/2}}g=Math.max(g,h);this.uiDialog.css({top:g,left:d})},_setData:function(e,f){(b[e]&&this.uiDialog.data(b[e],f));switch(e){case"buttons":this._createButtons(f);break;case"closeText":this.uiDialogTitlebarCloseText.text(f);break;case"dialogClass":this.uiDialog.removeClass(this.options.dialogClass).addClass(a+f);break;case"draggable":(f?this._makeDraggable():this.uiDialog.draggable("destroy"));break;case"height":this.uiDialog.height(f);break;case"position":this._position(f);break;case"resizable":var d=this.uiDialog,g=this.uiDialog.is(":data(resizable)");(g&&!f&&d.resizable("destroy"));(g&&typeof f=="string"&&d.resizable("option","handles",f));(g||this._makeResizable(f));break;case"title":c(".ui-dialog-title",this.uiDialogTitlebar).html(f||" ");break;case"width":this.uiDialog.width(f);break}c.widget.prototype._setData.apply(this,arguments)},_size:function(){var e=this.options;this.element.css({height:0,minHeight:0,width:"auto"});var d=this.uiDialog.css({height:"auto",width:e.width}).height();this.element.css({minHeight:Math.max(e.minHeight-d,0),height:e.height=="auto"?"auto":Math.max(e.height-d,0)})}});c.extend(c.ui.dialog,{version:"1.7.3",defaults:{autoOpen:true,bgiframe:false,buttons:{},closeOnEscape:true,closeText:"close",dialogClass:"",draggable:true,hide:null,height:"auto",maxHeight:false,maxWidth:false,minHeight:150,minWidth:150,modal:false,position:"center",resizable:true,show:null,stack:true,title:"",width:300,zIndex:1000},getter:"isOpen",uuid:0,maxZ:0,getTitleId:function(d){return"ui-dialog-title-"+(d.attr("id")||++this.uuid)},overlay:function(d){this.$el=c.ui.dialog.overlay.create(d)}});c.extend(c.ui.dialog.overlay,{instances:[],maxZ:0,events:c.map("focus,mousedown,mouseup,keydown,keypress,click".split(","),function(d){return d+".dialog-overlay"}).join(" "),create:function(e){if(this.instances.length===0){setTimeout(function(){if(c.ui.dialog.overlay.instances.length){c(document).bind(c.ui.dialog.overlay.events,function(f){var g=c(f.target).parents(".ui-dialog").css("zIndex")||0;return(g>c.ui.dialog.overlay.maxZ)})}},1);c(document).bind("keydown.dialog-overlay",function(f){(e.options.closeOnEscape&&f.keyCode&&f.keyCode==c.ui.keyCode.ESCAPE&&e.close(f))});c(window).bind("resize.dialog-overlay",c.ui.dialog.overlay.resize)}var d=c("
        ").appendTo(document.body).addClass("ui-widget-overlay").css({width:this.width(),height:this.height()});(e.options.bgiframe&&c.fn.bgiframe&&d.bgiframe());this.instances.push(d);return d},destroy:function(d){this.instances.splice(c.inArray(this.instances,d),1);if(this.instances.length===0){c([document,window]).unbind(".dialog-overlay")}d.remove();var e=0;c.each(this.instances,function(){e=Math.max(e,this.css("z-index"))});this.maxZ=e},height:function(){if(c.browser.msie&&c.browser.version<7){var e=Math.max(document.documentElement.scrollHeight,document.body.scrollHeight);var d=Math.max(document.documentElement.offsetHeight,document.body.offsetHeight);if(e
        ")).appendTo(document.body).hide().addClass("ui-dialog ui-widget ui-widget-content ui-corner-all "+b.dialogClass).css({zIndex:b.zIndex}).attr("tabIndex", +-1).css("outline",0).keydown(function(i){if(b.closeOnEscape&&i.keyCode&&i.keyCode===c.ui.keyCode.ESCAPE){a.close(i);i.preventDefault()}}).attr({role:"dialog","aria-labelledby":e}).mousedown(function(i){a.moveToTop(false,i)});a.element.show().removeAttr("title").addClass("ui-dialog-content ui-widget-content").appendTo(g);var f=(a.uiDialogTitlebar=c("
        ")).addClass("ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix").prependTo(g),h=c('
        ').addClass("ui-dialog-titlebar-close ui-corner-all").attr("role", +"button").hover(function(){h.addClass("ui-state-hover")},function(){h.removeClass("ui-state-hover")}).focus(function(){h.addClass("ui-state-focus")}).blur(function(){h.removeClass("ui-state-focus")}).click(function(i){a.close(i);return false}).appendTo(f);(a.uiDialogTitlebarCloseText=c("")).addClass("ui-icon ui-icon-closethick").text(b.closeText).appendTo(h);c("").addClass("ui-dialog-title").attr("id",e).html(d).prependTo(f);if(c.isFunction(b.beforeclose)&&!c.isFunction(b.beforeClose))b.beforeClose= +b.beforeclose;f.find("*").add(f).disableSelection();b.draggable&&c.fn.draggable&&a._makeDraggable();b.resizable&&c.fn.resizable&&a._makeResizable();a._createButtons(b.buttons);a._isOpen=false;c.fn.bgiframe&&g.bgiframe()},_init:function(){this.options.autoOpen&&this.open()},destroy:function(){var a=this;a.overlay&&a.overlay.destroy();a.uiDialog.hide();a.element.unbind(".dialog").removeData("dialog").removeClass("ui-dialog-content ui-widget-content").hide().appendTo("body");a.uiDialog.remove();a.originalTitle&& +a.element.attr("title",a.originalTitle);return a},widget:function(){return this.uiDialog},close:function(a){var b=this,d,e;if(false!==b._trigger("beforeClose",a)){b.overlay&&b.overlay.destroy();b.uiDialog.unbind("keypress.ui-dialog");b._isOpen=false;if(b.options.hide)b.uiDialog.hide(b.options.hide,function(){b._trigger("close",a)});else{b.uiDialog.hide();b._trigger("close",a)}c.ui.dialog.overlay.resize();if(b.options.modal){d=0;c(".ui-dialog").each(function(){if(this!==b.uiDialog[0]){e=c(this).css("z-index"); +isNaN(e)||(d=Math.max(d,e))}});c.ui.dialog.maxZ=d}return b}},isOpen:function(){return this._isOpen},moveToTop:function(a,b){var d=this,e=d.options;if(e.modal&&!a||!e.stack&&!e.modal)return d._trigger("focus",b);if(e.zIndex>c.ui.dialog.maxZ)c.ui.dialog.maxZ=e.zIndex;if(d.overlay){c.ui.dialog.maxZ+=1;d.overlay.$el.css("z-index",c.ui.dialog.overlay.maxZ=c.ui.dialog.maxZ)}a={scrollTop:d.element.attr("scrollTop"),scrollLeft:d.element.attr("scrollLeft")};c.ui.dialog.maxZ+=1;d.uiDialog.css("z-index",c.ui.dialog.maxZ); +d.element.attr(a);d._trigger("focus",b);return d},open:function(){if(!this._isOpen){var a=this,b=a.options,d=a.uiDialog;a.overlay=b.modal?new c.ui.dialog.overlay(a):null;a._size();a._position(b.position);d.show(b.show);a.moveToTop(true);b.modal&&d.bind("keypress.ui-dialog",function(e){if(e.keyCode===c.ui.keyCode.TAB){var g=c(":tabbable",this),f=g.filter(":first");g=g.filter(":last");if(e.target===g[0]&&!e.shiftKey){f.focus(1);return false}else if(e.target===f[0]&&e.shiftKey){g.focus(1);return false}}}); +c(a.element.find(":tabbable").get().concat(d.find(".ui-dialog-buttonpane :tabbable").get().concat(d.get()))).eq(0).focus();a._isOpen=true;a._trigger("open");return a}},_createButtons:function(a){var b=this,d=false,e=c("
        ").addClass("ui-dialog-buttonpane ui-widget-content ui-helper-clearfix"),g=c("
        ").addClass("ui-dialog-buttonset").appendTo(e);b.uiDialog.find(".ui-dialog-buttonpane").remove();typeof a==="object"&&a!==null&&c.each(a,function(){return!(d=true)});if(d){c.each(a,function(f, +h){h=c.isFunction(h)?{click:h,text:f}:h;f=c('').attr(h,true).unbind("click").click(function(){h.click.apply(b.element[0],arguments)}).appendTo(g);c.fn.button&&f.button()});e.appendTo(b.uiDialog)}},_makeDraggable:function(){function a(f){return{position:f.position,offset:f.offset}}var b=this,d=b.options,e=c(document),g;b.uiDialog.draggable({cancel:".ui-dialog-content, .ui-dialog-titlebar-close",handle:".ui-dialog-titlebar",containment:"document",start:function(f,h){g= +d.height==="auto"?"auto":c(this).height();c(this).height(c(this).height()).addClass("ui-dialog-dragging");b._trigger("dragStart",f,a(h))},drag:function(f,h){b._trigger("drag",f,a(h))},stop:function(f,h){d.position=[h.position.left-e.scrollLeft(),h.position.top-e.scrollTop()];c(this).removeClass("ui-dialog-dragging").height(g);b._trigger("dragStop",f,a(h));c.ui.dialog.overlay.resize()}})},_makeResizable:function(a){function b(f){return{originalPosition:f.originalPosition,originalSize:f.originalSize, +position:f.position,size:f.size}}a=a===j?this.options.resizable:a;var d=this,e=d.options,g=d.uiDialog.css("position");a=typeof a==="string"?a:"n,e,s,w,se,sw,ne,nw";d.uiDialog.resizable({cancel:".ui-dialog-content",containment:"document",alsoResize:d.element,maxWidth:e.maxWidth,maxHeight:e.maxHeight,minWidth:e.minWidth,minHeight:d._minHeight(),handles:a,start:function(f,h){c(this).addClass("ui-dialog-resizing");d._trigger("resizeStart",f,b(h))},resize:function(f,h){d._trigger("resize",f,b(h))},stop:function(f, +h){c(this).removeClass("ui-dialog-resizing");e.height=c(this).height();e.width=c(this).width();d._trigger("resizeStop",f,b(h));c.ui.dialog.overlay.resize()}}).css("position",g).find(".ui-resizable-se").addClass("ui-icon ui-icon-grip-diagonal-se")},_minHeight:function(){var a=this.options;return a.height==="auto"?a.minHeight:Math.min(a.minHeight,a.height)},_position:function(a){var b=[],d=[0,0],e;if(a){if(typeof a==="string"||typeof a==="object"&&"0"in a){b=a.split?a.split(" "):[a[0],a[1]];if(b.length=== +1)b[1]=b[0];c.each(["left","top"],function(g,f){if(+b[g]===b[g]){d[g]=b[g];b[g]=f}});a={my:b.join(" "),at:b.join(" "),offset:d.join(" ")}}a=c.extend({},c.ui.dialog.prototype.options.position,a)}else a=c.ui.dialog.prototype.options.position;(e=this.uiDialog.is(":visible"))||this.uiDialog.show();this.uiDialog.css({top:0,left:0}).position(c.extend({of:window},a));e||this.uiDialog.hide()},_setOptions:function(a){var b=this,d={},e=false;c.each(a,function(g,f){b._setOption(g,f);if(g in k)e=true;if(g in +l)d[g]=f});e&&this._size();this.uiDialog.is(":data(resizable)")&&this.uiDialog.resizable("option",d)},_setOption:function(a,b){var d=this,e=d.uiDialog;switch(a){case "beforeclose":a="beforeClose";break;case "buttons":d._createButtons(b);break;case "closeText":d.uiDialogTitlebarCloseText.text(""+b);break;case "dialogClass":e.removeClass(d.options.dialogClass).addClass("ui-dialog ui-widget ui-widget-content ui-corner-all "+b);break;case "disabled":b?e.addClass("ui-dialog-disabled"):e.removeClass("ui-dialog-disabled"); +break;case "draggable":var g=e.is(":data(draggable)");g&&!b&&e.draggable("destroy");!g&&b&&d._makeDraggable();break;case "position":d._position(b);break;case "resizable":(g=e.is(":data(resizable)"))&&!b&&e.resizable("destroy");g&&typeof b==="string"&&e.resizable("option","handles",b);!g&&b!==false&&d._makeResizable(b);break;case "title":c(".ui-dialog-title",d.uiDialogTitlebar).html(""+(b||" "));break}c.Widget.prototype._setOption.apply(d,arguments)},_size:function(){var a=this.options,b,d,e= +this.uiDialog.is(":visible");this.element.show().css({width:"auto",minHeight:0,height:0});if(a.minWidth>a.width)a.width=a.minWidth;b=this.uiDialog.css({height:"auto",width:a.width}).height();d=Math.max(0,a.minHeight-b);if(a.height==="auto")if(c.support.minHeight)this.element.css({minHeight:d,height:"auto"});else{this.uiDialog.show();a=this.element.css("height","auto").height();e||this.uiDialog.hide();this.element.height(Math.max(a,d))}else this.element.height(Math.max(a.height-b,0));this.uiDialog.is(":data(resizable)")&& +this.uiDialog.resizable("option","minHeight",this._minHeight())}});c.extend(c.ui.dialog,{version:"1.8.9",uuid:0,maxZ:0,getTitleId:function(a){a=a.attr("id");if(!a){this.uuid+=1;a=this.uuid}return"ui-dialog-title-"+a},overlay:function(a){this.$el=c.ui.dialog.overlay.create(a)}});c.extend(c.ui.dialog.overlay,{instances:[],oldInstances:[],maxZ:0,events:c.map("focus,mousedown,mouseup,keydown,keypress,click".split(","),function(a){return a+".dialog-overlay"}).join(" "),create:function(a){if(this.instances.length=== +0){setTimeout(function(){c.ui.dialog.overlay.instances.length&&c(document).bind(c.ui.dialog.overlay.events,function(d){if(c(d.target).zIndex()").addClass("ui-widget-overlay")).appendTo(document.body).css({width:this.width(), +height:this.height()});c.fn.bgiframe&&b.bgiframe();this.instances.push(b);return b},destroy:function(a){var b=c.inArray(a,this.instances);b!=-1&&this.oldInstances.push(this.instances.splice(b,1)[0]);this.instances.length===0&&c([document,window]).unbind(".dialog-overlay");a.remove();var d=0;c.each(this.instances,function(){d=Math.max(d,this.css("z-index"))});this.maxZ=d},height:function(){var a,b;if(c.browser.msie&&c.browser.version<7){a=Math.max(document.documentElement.scrollHeight,document.body.scrollHeight); +b=Math.max(document.documentElement.offsetHeight,document.body.offsetHeight);return athis.containment[2]){d=this.containment[2]+this.offset.click.left}if(e.pageY-this.offset.click.top>this.containment[3]){c=this.containment[3]+this.offset.click.top}}if(h.grid){var g=this.originalPageY+Math.round((c-this.originalPageY)/h.grid[1])*h.grid[1];c=this.containment?(!(g-this.offset.click.topthis.containment[3])?g:(!(g-this.offset.click.topthis.containment[2])?f:(!(f-this.offset.click.left').css({width:this.offsetWidth+"px",height:this.offsetHeight+"px",position:"absolute",opacity:"0.001",zIndex:1000}).css(a(this).offset()).appendTo("body")})},stop:function(b,c){a("div.ui-draggable-iframeFix").each(function(){this.parentNode.removeChild(this)})}});a.ui.plugin.add("draggable","opacity",{start:function(c,d){var b=a(d.helper),e=a(this).data("draggable").options;if(b.css("opacity")){e._opacity=b.css("opacity")}b.css("opacity",e.opacity)},stop:function(b,c){var d=a(this).data("draggable").options;if(d._opacity){a(c.helper).css("opacity",d._opacity)}}});a.ui.plugin.add("draggable","scroll",{start:function(c,d){var b=a(this).data("draggable");if(b.scrollParent[0]!=document&&b.scrollParent[0].tagName!="HTML"){b.overflowOffset=b.scrollParent.offset()}},drag:function(d,e){var c=a(this).data("draggable"),f=c.options,b=false;if(c.scrollParent[0]!=document&&c.scrollParent[0].tagName!="HTML"){if(!f.axis||f.axis!="x"){if((c.overflowOffset.top+c.scrollParent[0].offsetHeight)-d.pageY=0;v--){var s=g.snapElements[v].left,n=s+g.snapElements[v].width,m=g.snapElements[v].top,A=m+g.snapElements[v].height;if(!((s-ythis.containment[2])e=this.containment[2]+this.offset.click.left;if(a.pageY-this.offset.click.top>this.containment[3])g=this.containment[3]+this.offset.click.top}if(b.grid){g=this.originalPageY+Math.round((g-this.originalPageY)/ +b.grid[1])*b.grid[1];g=this.containment?!(g-this.offset.click.topthis.containment[3])?g:!(g-this.offset.click.topthis.containment[2])?e:!(e-this.offset.click.left').css({width:this.offsetWidth+"px",height:this.offsetHeight+"px",position:"absolute",opacity:"0.001",zIndex:1E3}).css(d(this).offset()).appendTo("body")})}, +stop:function(){d("div.ui-draggable-iframeFix").each(function(){this.parentNode.removeChild(this)})}});d.ui.plugin.add("draggable","opacity",{start:function(a,b){a=d(b.helper);b=d(this).data("draggable").options;if(a.css("opacity"))b._opacity=a.css("opacity");a.css("opacity",b.opacity)},stop:function(a,b){a=d(this).data("draggable").options;a._opacity&&d(b.helper).css("opacity",a._opacity)}});d.ui.plugin.add("draggable","scroll",{start:function(){var a=d(this).data("draggable");if(a.scrollParent[0]!= +document&&a.scrollParent[0].tagName!="HTML")a.overflowOffset=a.scrollParent.offset()},drag:function(a){var b=d(this).data("draggable"),c=b.options,f=false;if(b.scrollParent[0]!=document&&b.scrollParent[0].tagName!="HTML"){if(!c.axis||c.axis!="x")if(b.overflowOffset.top+b.scrollParent[0].offsetHeight-a.pageY=0;h--){var i=c.snapElements[h].left,k=i+c.snapElements[h].width,j=c.snapElements[h].top,l=j+c.snapElements[h].height;if(i-e=p&&n<=k)||(m>=p&&m<=k)||(nk))&&((e>=g&&e<=c)||(d>=g&&d<=c)||(ec));break;default:return false;break}};a.ui.ddmanager={current:null,droppables:{"default":[]},prepareOffsets:function(e,g){var b=a.ui.ddmanager.droppables[e.options.scope];var f=g?g.type:null;var h=(e.currentItem||e.element).find(":data(droppable)").andSelf();droppablesLoop:for(var d=0;d=j&&f<=l||h>=j&&h<=l||fl)&&(e>= +i&&e<=k||g>=i&&g<=k||ek);default:return false}};d.ui.ddmanager={current:null,droppables:{"default":[]},prepareOffsets:function(a,b){var c=d.ui.ddmanager.droppables[a.options.scope]||[],e=b?b.type:null,g=(a.currentItem||a.element).find(":data(droppable)").andSelf(),f=0;a:for(;f=9)&&!a.button)return this._mouseUp(a);if(this._mouseStarted){this._mouseDrag(a); +return a.preventDefault()}if(this._mouseDistanceMet(a)&&this._mouseDelayMet(a))(this._mouseStarted=this._mouseStart(this._mouseDownEvent,a)!==false)?this._mouseDrag(a):this._mouseUp(a);return!this._mouseStarted},_mouseUp:function(a){c(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate);if(this._mouseStarted){this._mouseStarted=false;a.target==this._mouseDownEvent.target&&c.data(a.target,this.widgetName+".preventClickEvent", +true);this._mouseStop(a)}return false},_mouseDistanceMet:function(a){return Math.max(Math.abs(this._mouseDownEvent.pageX-a.pageX),Math.abs(this._mouseDownEvent.pageY-a.pageY))>=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return true}})})(jQuery); diff --git a/wp-includes/js/jquery/ui.position.js b/wp-includes/js/jquery/ui.position.js new file mode 100644 index 00000000..c2ec6e45 --- /dev/null +++ b/wp-includes/js/jquery/ui.position.js @@ -0,0 +1,16 @@ +/* + * jQuery UI Position 1.8.9 + * + * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * http://docs.jquery.com/UI/Position + */ +(function(c){c.ui=c.ui||{};var n=/left|center|right/,o=/top|center|bottom/,t=c.fn.position,u=c.fn.offset;c.fn.position=function(b){if(!b||!b.of)return t.apply(this,arguments);b=c.extend({},b);var a=c(b.of),d=a[0],g=(b.collision||"flip").split(" "),e=b.offset?b.offset.split(" "):[0,0],h,k,j;if(d.nodeType===9){h=a.width();k=a.height();j={top:0,left:0}}else if(d.setTimeout){h=a.width();k=a.height();j={top:a.scrollTop(),left:a.scrollLeft()}}else if(d.preventDefault){b.at="left top";h=k=0;j={top:b.of.pageY, +left:b.of.pageX}}else{h=a.outerWidth();k=a.outerHeight();j=a.offset()}c.each(["my","at"],function(){var f=(b[this]||"").split(" ");if(f.length===1)f=n.test(f[0])?f.concat(["center"]):o.test(f[0])?["center"].concat(f):["center","center"];f[0]=n.test(f[0])?f[0]:"center";f[1]=o.test(f[1])?f[1]:"center";b[this]=f});if(g.length===1)g[1]=g[0];e[0]=parseInt(e[0],10)||0;if(e.length===1)e[1]=e[0];e[1]=parseInt(e[1],10)||0;if(b.at[0]==="right")j.left+=h;else if(b.at[0]==="center")j.left+=h/2;if(b.at[1]==="bottom")j.top+= +k;else if(b.at[1]==="center")j.top+=k/2;j.left+=e[0];j.top+=e[1];return this.each(function(){var f=c(this),l=f.outerWidth(),m=f.outerHeight(),p=parseInt(c.curCSS(this,"marginLeft",true))||0,q=parseInt(c.curCSS(this,"marginTop",true))||0,v=l+p+(parseInt(c.curCSS(this,"marginRight",true))||0),w=m+q+(parseInt(c.curCSS(this,"marginBottom",true))||0),i=c.extend({},j),r;if(b.my[0]==="right")i.left-=l;else if(b.my[0]==="center")i.left-=l/2;if(b.my[1]==="bottom")i.top-=m;else if(b.my[1]==="center")i.top-= +m/2;i.left=Math.round(i.left);i.top=Math.round(i.top);r={left:i.left-p,top:i.top-q};c.each(["left","top"],function(s,x){c.ui.position[g[s]]&&c.ui.position[g[s]][x](i,{targetWidth:h,targetHeight:k,elemWidth:l,elemHeight:m,collisionPosition:r,collisionWidth:v,collisionHeight:w,offset:e,my:b.my,at:b.at})});c.fn.bgiframe&&f.bgiframe();f.offset(c.extend(i,{using:b.using}))})};c.ui.position={fit:{left:function(b,a){var d=c(window);d=a.collisionPosition.left+a.collisionWidth-d.width()-d.scrollLeft();b.left= +d>0?b.left-d:Math.max(b.left-a.collisionPosition.left,b.left)},top:function(b,a){var d=c(window);d=a.collisionPosition.top+a.collisionHeight-d.height()-d.scrollTop();b.top=d>0?b.top-d:Math.max(b.top-a.collisionPosition.top,b.top)}},flip:{left:function(b,a){if(a.at[0]!=="center"){var d=c(window);d=a.collisionPosition.left+a.collisionWidth-d.width()-d.scrollLeft();var g=a.my[0]==="left"?-a.elemWidth:a.my[0]==="right"?a.elemWidth:0,e=a.at[0]==="left"?a.targetWidth:-a.targetWidth,h=-2*a.offset[0];b.left+= +a.collisionPosition.left<0?g+e+h:d>0?g+e+h:0}},top:function(b,a){if(a.at[1]!=="center"){var d=c(window);d=a.collisionPosition.top+a.collisionHeight-d.height()-d.scrollTop();var g=a.my[1]==="top"?-a.elemHeight:a.my[1]==="bottom"?a.elemHeight:0,e=a.at[1]==="top"?a.targetHeight:-a.targetHeight,h=-2*a.offset[1];b.top+=a.collisionPosition.top<0?g+e+h:d>0?g+e+h:0}}}};if(!c.offset.setOffset){c.offset.setOffset=function(b,a){if(/static/.test(c.curCSS(b,"position")))b.style.position="relative";var d=c(b), +g=d.offset(),e=parseInt(c.curCSS(b,"top",true),10)||0,h=parseInt(c.curCSS(b,"left",true),10)||0;g={top:a.top-g.top+e,left:a.left-g.left+h};"using"in a?a.using.call(b,g):d.css(g)};c.fn.offset=function(b){var a=this[0];if(!a||!a.ownerDocument)return null;if(b)return this.each(function(){c.offset.setOffset(this,b)});return u.call(this)}}})(jQuery); diff --git a/wp-includes/js/jquery/ui.resizable.js b/wp-includes/js/jquery/ui.resizable.js index 13cd12b6..c1117f3e 100644 --- a/wp-includes/js/jquery/ui.resizable.js +++ b/wp-includes/js/jquery/ui.resizable.js @@ -1,13 +1,47 @@ /* - * jQuery UI Resizable 1.7.3 + * jQuery UI Resizable 1.8.9 * - * Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT (MIT-LICENSE.txt) - * and GPL (GPL-LICENSE.txt) licenses. + * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license * * http://docs.jquery.com/UI/Resizables * * Depends: - * ui.core.js + * jquery.ui.core.js + * jquery.ui.mouse.js + * jquery.ui.widget.js */ -(function(c){c.widget("ui.resizable",c.extend({},c.ui.mouse,{_init:function(){var e=this,j=this.options;this.element.addClass("ui-resizable");c.extend(this,{_aspectRatio:!!(j.aspectRatio),aspectRatio:j.aspectRatio,originalElement:this.element,_proportionallyResizeElements:[],_helper:j.helper||j.ghost||j.animate?j.helper||"ui-resizable-helper":null});if(this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)){if(/relative/.test(this.element.css("position"))&&c.browser.opera){this.element.css({position:"relative",top:"auto",left:"auto"})}this.element.wrap(c('
        ').css({position:this.element.css("position"),width:this.element.outerWidth(),height:this.element.outerHeight(),top:this.element.css("top"),left:this.element.css("left")}));this.element=this.element.parent().data("resizable",this.element.data("resizable"));this.elementIsWrapper=true;this.element.css({marginLeft:this.originalElement.css("marginLeft"),marginTop:this.originalElement.css("marginTop"),marginRight:this.originalElement.css("marginRight"),marginBottom:this.originalElement.css("marginBottom")});this.originalElement.css({marginLeft:0,marginTop:0,marginRight:0,marginBottom:0});this.originalResizeStyle=this.originalElement.css("resize");this.originalElement.css("resize","none");this._proportionallyResizeElements.push(this.originalElement.css({position:"static",zoom:1,display:"block"}));this.originalElement.css({margin:this.originalElement.css("margin")});this._proportionallyResize()}this.handles=j.handles||(!c(".ui-resizable-handle",this.element).length?"e,s,se":{n:".ui-resizable-n",e:".ui-resizable-e",s:".ui-resizable-s",w:".ui-resizable-w",se:".ui-resizable-se",sw:".ui-resizable-sw",ne:".ui-resizable-ne",nw:".ui-resizable-nw"});if(this.handles.constructor==String){if(this.handles=="all"){this.handles="n,e,s,w,se,sw,ne,nw"}var k=this.handles.split(",");this.handles={};for(var f=0;f');if(/sw|se|ne|nw/.test(h)){g.css({zIndex:++j.zIndex})}if("se"==h){g.addClass("ui-icon ui-icon-gripsmall-diagonal-se")}this.handles[h]=".ui-resizable-"+h;this.element.append(g)}}this._renderAxis=function(p){p=p||this.element;for(var m in this.handles){if(this.handles[m].constructor==String){this.handles[m]=c(this.handles[m],this.element).show()}if(this.elementIsWrapper&&this.originalElement[0].nodeName.match(/textarea|input|select|button/i)){var n=c(this.handles[m],this.element),o=0;o=/sw|ne|nw|se|n|s/.test(m)?n.outerHeight():n.outerWidth();var l=["padding",/ne|nw|n/.test(m)?"Top":/se|sw|s/.test(m)?"Bottom":/^e$/.test(m)?"Right":"Left"].join("");p.css(l,o);this._proportionallyResize()}if(!c(this.handles[m]).length){continue}}};this._renderAxis(this.element);this._handles=c(".ui-resizable-handle",this.element).disableSelection();this._handles.mouseover(function(){if(!e.resizing){if(this.className){var i=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i)}e.axis=i&&i[1]?i[1]:"se"}});if(j.autoHide){this._handles.hide();c(this.element).addClass("ui-resizable-autohide").hover(function(){c(this).removeClass("ui-resizable-autohide");e._handles.show()},function(){if(!e.resizing){c(this).addClass("ui-resizable-autohide");e._handles.hide()}})}this._mouseInit()},destroy:function(){this._mouseDestroy();var d=function(f){c(f).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing").removeData("resizable").unbind(".resizable").find(".ui-resizable-handle").remove()};if(this.elementIsWrapper){d(this.element);var e=this.element;e.parent().append(this.originalElement.css({position:e.css("position"),width:e.outerWidth(),height:e.outerHeight(),top:e.css("top"),left:e.css("left")})).end().remove()}this.originalElement.css("resize",this.originalResizeStyle);d(this.originalElement)},_mouseCapture:function(e){var f=false;for(var d in this.handles){if(c(this.handles[d])[0]==e.target){f=true}}return this.options.disabled||!!f},_mouseStart:function(f){var i=this.options,e=this.element.position(),d=this.element;this.resizing=true;this.documentScroll={top:c(document).scrollTop(),left:c(document).scrollLeft()};if(d.is(".ui-draggable")||(/absolute/).test(d.css("position"))){d.css({position:"absolute",top:e.top,left:e.left})}if(c.browser.opera&&(/relative/).test(d.css("position"))){d.css({position:"relative",top:"auto",left:"auto"})}this._renderProxy();var j=b(this.helper.css("left")),g=b(this.helper.css("top"));if(i.containment){j+=c(i.containment).scrollLeft()||0;g+=c(i.containment).scrollTop()||0}this.offset=this.helper.offset();this.position={left:j,top:g};this.size=this._helper?{width:d.outerWidth(),height:d.outerHeight()}:{width:d.width(),height:d.height()};this.originalSize=this._helper?{width:d.outerWidth(),height:d.outerHeight()}:{width:d.width(),height:d.height()};this.originalPosition={left:j,top:g};this.sizeDiff={width:d.outerWidth()-d.width(),height:d.outerHeight()-d.height()};this.originalMousePosition={left:f.pageX,top:f.pageY};this.aspectRatio=(typeof i.aspectRatio=="number")?i.aspectRatio:((this.originalSize.width/this.originalSize.height)||1);var h=c(".ui-resizable-"+this.axis).css("cursor");c("body").css("cursor",h=="auto"?this.axis+"-resize":h);d.addClass("ui-resizable-resizing");this._propagate("start",f);return true},_mouseDrag:function(d){var g=this.helper,f=this.options,l={},p=this,i=this.originalMousePosition,m=this.axis;var q=(d.pageX-i.left)||0,n=(d.pageY-i.top)||0;var h=this._change[m];if(!h){return false}var k=h.apply(this,[d,q,n]),j=c.browser.msie&&c.browser.version<7,e=this.sizeDiff;if(this._aspectRatio||d.shiftKey){k=this._updateRatio(k,d)}k=this._respectSize(k,d);this._propagate("resize",d);g.css({top:this.position.top+"px",left:this.position.left+"px",width:this.size.width+"px",height:this.size.height+"px"});if(!this._helper&&this._proportionallyResizeElements.length){this._proportionallyResize()}this._updateCache(k);this._trigger("resize",d,this.ui());return false},_mouseStop:function(g){this.resizing=false;var h=this.options,l=this;if(this._helper){var f=this._proportionallyResizeElements,d=f.length&&(/textarea/i).test(f[0].nodeName),e=d&&c.ui.hasScroll(f[0],"left")?0:l.sizeDiff.height,j=d?0:l.sizeDiff.width;var m={width:(l.size.width-j),height:(l.size.height-e)},i=(parseInt(l.element.css("left"),10)+(l.position.left-l.originalPosition.left))||null,k=(parseInt(l.element.css("top"),10)+(l.position.top-l.originalPosition.top))||null;if(!h.animate){this.element.css(c.extend(m,{top:k,left:i}))}l.helper.height(l.size.height);l.helper.width(l.size.width);if(this._helper&&!h.animate){this._proportionallyResize()}}c("body").css("cursor","auto");this.element.removeClass("ui-resizable-resizing");this._propagate("stop",g);if(this._helper){this.helper.remove()}return false},_updateCache:function(d){var e=this.options;this.offset=this.helper.offset();if(a(d.left)){this.position.left=d.left}if(a(d.top)){this.position.top=d.top}if(a(d.height)){this.size.height=d.height}if(a(d.width)){this.size.width=d.width}},_updateRatio:function(g,f){var h=this.options,i=this.position,e=this.size,d=this.axis;if(g.height){g.width=(e.height*this.aspectRatio)}else{if(g.width){g.height=(e.width/this.aspectRatio)}}if(d=="sw"){g.left=i.left+(e.width-g.width);g.top=null}if(d=="nw"){g.top=i.top+(e.height-g.height);g.left=i.left+(e.width-g.width)}return g},_respectSize:function(k,f){var i=this.helper,h=this.options,q=this._aspectRatio||f.shiftKey,p=this.axis,s=a(k.width)&&h.maxWidth&&(h.maxWidthk.width),r=a(k.height)&&h.minHeight&&(h.minHeight>k.height);if(g){k.width=h.minWidth}if(r){k.height=h.minHeight}if(s){k.width=h.maxWidth}if(l){k.height=h.maxHeight}var e=this.originalPosition.left+this.originalSize.width,n=this.position.top+this.size.height;var j=/sw|nw|w/.test(p),d=/nw|ne|n/.test(p);if(g&&j){k.left=e-h.minWidth}if(s&&j){k.left=e-h.maxWidth}if(r&&d){k.top=n-h.minHeight}if(l&&d){k.top=n-h.maxHeight}var m=!k.width&&!k.height;if(m&&!k.left&&k.top){k.top=null}else{if(m&&!k.top&&k.left){k.left=null}}return k},_proportionallyResize:function(){var j=this.options;if(!this._proportionallyResizeElements.length){return}var f=this.helper||this.element;for(var e=0;e');var d=c.browser.msie&&c.browser.version<7,f=(d?1:0),g=(d?2:-1);this.helper.addClass(this._helper).css({width:this.element.outerWidth()+g,height:this.element.outerHeight()+g,position:"absolute",left:this.elementOffset.left-f+"px",top:this.elementOffset.top-f+"px",zIndex:++h.zIndex});this.helper.appendTo("body").disableSelection()}else{this.helper=this.element}},_change:{e:function(f,e,d){return{width:this.originalSize.width+e}},w:function(g,e,d){var i=this.options,f=this.originalSize,h=this.originalPosition;return{left:h.left+e,width:f.width-e}},n:function(g,e,d){var i=this.options,f=this.originalSize,h=this.originalPosition;return{top:h.top+d,height:f.height-d}},s:function(f,e,d){return{height:this.originalSize.height+d}},se:function(f,e,d){return c.extend(this._change.s.apply(this,arguments),this._change.e.apply(this,[f,e,d]))},sw:function(f,e,d){return c.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[f,e,d]))},ne:function(f,e,d){return c.extend(this._change.n.apply(this,arguments),this._change.e.apply(this,[f,e,d]))},nw:function(f,e,d){return c.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[f,e,d]))}},_propagate:function(e,d){c.ui.plugin.call(this,e,[d,this.ui()]);(e!="resize"&&this._trigger(e,d,this.ui()))},plugins:{},ui:function(){return{originalElement:this.originalElement,element:this.element,helper:this.helper,position:this.position,size:this.size,originalSize:this.originalSize,originalPosition:this.originalPosition}}}));c.extend(c.ui.resizable,{version:"1.7.3",eventPrefix:"resize",defaults:{alsoResize:false,animate:false,animateDuration:"slow",animateEasing:"swing",aspectRatio:false,autoHide:false,cancel:":input,option",containment:false,delay:0,distance:1,ghost:false,grid:false,handles:"e,s,se",helper:false,maxHeight:null,maxWidth:null,minHeight:10,minWidth:10,zIndex:1000}});c.ui.plugin.add("resizable","alsoResize",{start:function(e,f){var d=c(this).data("resizable"),g=d.options;_store=function(h){c(h).each(function(){c(this).data("resizable-alsoresize",{width:parseInt(c(this).width(),10),height:parseInt(c(this).height(),10),left:parseInt(c(this).css("left"),10),top:parseInt(c(this).css("top"),10)})})};if(typeof(g.alsoResize)=="object"&&!g.alsoResize.parentNode){if(g.alsoResize.length){g.alsoResize=g.alsoResize[0];_store(g.alsoResize)}else{c.each(g.alsoResize,function(h,i){_store(h)})}}else{_store(g.alsoResize)}},resize:function(f,h){var e=c(this).data("resizable"),i=e.options,g=e.originalSize,k=e.originalPosition;var j={height:(e.size.height-g.height)||0,width:(e.size.width-g.width)||0,top:(e.position.top-k.top)||0,left:(e.position.left-k.left)||0},d=function(l,m){c(l).each(function(){var p=c(this),q=c(this).data("resizable-alsoresize"),o={},n=m&&m.length?m:["width","height","top","left"];c.each(n||["width","height","top","left"],function(r,t){var s=(q[t]||0)+(j[t]||0);if(s&&s>=0){o[t]=s||null}});if(/relative/.test(p.css("position"))&&c.browser.opera){e._revertToRelativePosition=true;p.css({position:"absolute",top:"auto",left:"auto"})}p.css(o)})};if(typeof(i.alsoResize)=="object"&&!i.alsoResize.nodeType){c.each(i.alsoResize,function(l,m){d(l,m)})}else{d(i.alsoResize)}},stop:function(e,f){var d=c(this).data("resizable");if(d._revertToRelativePosition&&c.browser.opera){d._revertToRelativePosition=false;el.css({position:"relative"})}c(this).removeData("resizable-alsoresize-start")}});c.ui.plugin.add("resizable","animate",{stop:function(h,m){var n=c(this).data("resizable"),i=n.options;var g=n._proportionallyResizeElements,d=g.length&&(/textarea/i).test(g[0].nodeName),e=d&&c.ui.hasScroll(g[0],"left")?0:n.sizeDiff.height,k=d?0:n.sizeDiff.width;var f={width:(n.size.width-k),height:(n.size.height-e)},j=(parseInt(n.element.css("left"),10)+(n.position.left-n.originalPosition.left))||null,l=(parseInt(n.element.css("top"),10)+(n.position.top-n.originalPosition.top))||null;n.element.animate(c.extend(f,l&&j?{top:l,left:j}:{}),{duration:i.animateDuration,easing:i.animateEasing,step:function(){var o={width:parseInt(n.element.css("width"),10),height:parseInt(n.element.css("height"),10),top:parseInt(n.element.css("top"),10),left:parseInt(n.element.css("left"),10)};if(g&&g.length){c(g[0]).css({width:o.width,height:o.height})}n._updateCache(o);n._propagate("resize",h)}})}});c.ui.plugin.add("resizable","containment",{start:function(e,q){var s=c(this).data("resizable"),i=s.options,k=s.element;var f=i.containment,j=(f instanceof c)?f.get(0):(/parent/.test(f))?k.parent().get(0):f;if(!j){return}s.containerElement=c(j);if(/document/.test(f)||f==document){s.containerOffset={left:0,top:0};s.containerPosition={left:0,top:0};s.parentData={element:c(document),left:0,top:0,width:c(document).width(),height:c(document).height()||document.body.parentNode.scrollHeight}}else{var m=c(j),h=[];c(["Top","Right","Left","Bottom"]).each(function(p,o){h[p]=b(m.css("padding"+o))});s.containerOffset=m.offset();s.containerPosition=m.position();s.containerSize={height:(m.innerHeight()-h[3]),width:(m.innerWidth()-h[1])};var n=s.containerOffset,d=s.containerSize.height,l=s.containerSize.width,g=(c.ui.hasScroll(j,"left")?j.scrollWidth:l),r=(c.ui.hasScroll(j)?j.scrollHeight:d);s.parentData={element:j,left:n.left,top:n.top,width:g,height:r}}},resize:function(f,p){var s=c(this).data("resizable"),h=s.options,e=s.containerSize,n=s.containerOffset,l=s.size,m=s.position,q=s._aspectRatio||f.shiftKey,d={top:0,left:0},g=s.containerElement;if(g[0]!=document&&(/static/).test(g.css("position"))){d=n}if(m.left<(s._helper?n.left:0)){s.size.width=s.size.width+(s._helper?(s.position.left-n.left):(s.position.left-d.left));if(q){s.size.height=s.size.width/h.aspectRatio}s.position.left=h.helper?n.left:0}if(m.top<(s._helper?n.top:0)){s.size.height=s.size.height+(s._helper?(s.position.top-n.top):s.position.top);if(q){s.size.width=s.size.height*h.aspectRatio}s.position.top=s._helper?n.top:0}s.offset.left=s.parentData.left+s.position.left;s.offset.top=s.parentData.top+s.position.top;var k=Math.abs((s._helper?s.offset.left-d.left:(s.offset.left-d.left))+s.sizeDiff.width),r=Math.abs((s._helper?s.offset.top-d.top:(s.offset.top-n.top))+s.sizeDiff.height);var j=s.containerElement.get(0)==s.element.parent().get(0),i=/relative|absolute/.test(s.containerElement.css("position"));if(j&&i){k-=s.parentData.left}if(k+s.size.width>=s.parentData.width){s.size.width=s.parentData.width-k;if(q){s.size.height=s.size.width/s.aspectRatio}}if(r+s.size.height>=s.parentData.height){s.size.height=s.parentData.height-r;if(q){s.size.width=s.size.height*s.aspectRatio}}},stop:function(e,m){var p=c(this).data("resizable"),f=p.options,k=p.position,l=p.containerOffset,d=p.containerPosition,g=p.containerElement;var i=c(p.helper),q=i.offset(),n=i.outerWidth()-p.sizeDiff.width,j=i.outerHeight()-p.sizeDiff.height;if(p._helper&&!f.animate&&(/relative/).test(g.css("position"))){c(this).css({left:q.left-d.left-l.left,width:n,height:j})}if(p._helper&&!f.animate&&(/static/).test(g.css("position"))){c(this).css({left:q.left-d.left-l.left,width:n,height:j})}}});c.ui.plugin.add("resizable","ghost",{start:function(f,g){var d=c(this).data("resizable"),h=d.options,e=d.size;d.ghost=d.originalElement.clone();d.ghost.css({opacity:0.25,display:"block",position:"relative",height:e.height,width:e.width,margin:0,left:0,top:0}).addClass("ui-resizable-ghost").addClass(typeof h.ghost=="string"?h.ghost:"");d.ghost.appendTo(d.helper)},resize:function(e,f){var d=c(this).data("resizable"),g=d.options;if(d.ghost){d.ghost.css({position:"relative",height:d.size.height,width:d.size.width})}},stop:function(e,f){var d=c(this).data("resizable"),g=d.options;if(d.ghost&&d.helper){d.helper.get(0).removeChild(d.ghost.get(0))}}});c.ui.plugin.add("resizable","grid",{resize:function(d,l){var n=c(this).data("resizable"),g=n.options,j=n.size,h=n.originalSize,i=n.originalPosition,m=n.axis,k=g._aspectRatio||d.shiftKey;g.grid=typeof g.grid=="number"?[g.grid,g.grid]:g.grid;var f=Math.round((j.width-h.width)/(g.grid[0]||1))*(g.grid[0]||1),e=Math.round((j.height-h.height)/(g.grid[1]||1))*(g.grid[1]||1);if(/^(se|s|e)$/.test(m)){n.size.width=h.width+f;n.size.height=h.height+e}else{if(/^(ne)$/.test(m)){n.size.width=h.width+f;n.size.height=h.height+e;n.position.top=i.top-e}else{if(/^(sw)$/.test(m)){n.size.width=h.width+f;n.size.height=h.height+e;n.position.left=i.left-f}else{n.size.width=h.width+f;n.size.height=h.height+e;n.position.top=i.top-e;n.position.left=i.left-f}}}}});var b=function(d){return parseInt(d,10)||0};var a=function(d){return !isNaN(parseInt(d,10))}})(jQuery); +(function(e){e.widget("ui.resizable",e.ui.mouse,{widgetEventPrefix:"resize",options:{alsoResize:false,animate:false,animateDuration:"slow",animateEasing:"swing",aspectRatio:false,autoHide:false,containment:false,ghost:false,grid:false,handles:"e,s,se",helper:false,maxHeight:null,maxWidth:null,minHeight:10,minWidth:10,zIndex:1E3},_create:function(){var b=this,a=this.options;this.element.addClass("ui-resizable");e.extend(this,{_aspectRatio:!!a.aspectRatio,aspectRatio:a.aspectRatio,originalElement:this.element, +_proportionallyResizeElements:[],_helper:a.helper||a.ghost||a.animate?a.helper||"ui-resizable-helper":null});if(this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)){/relative/.test(this.element.css("position"))&&e.browser.opera&&this.element.css({position:"relative",top:"auto",left:"auto"});this.element.wrap(e('
        ').css({position:this.element.css("position"),width:this.element.outerWidth(),height:this.element.outerHeight(), +top:this.element.css("top"),left:this.element.css("left")}));this.element=this.element.parent().data("resizable",this.element.data("resizable"));this.elementIsWrapper=true;this.element.css({marginLeft:this.originalElement.css("marginLeft"),marginTop:this.originalElement.css("marginTop"),marginRight:this.originalElement.css("marginRight"),marginBottom:this.originalElement.css("marginBottom")});this.originalElement.css({marginLeft:0,marginTop:0,marginRight:0,marginBottom:0});this.originalResizeStyle= +this.originalElement.css("resize");this.originalElement.css("resize","none");this._proportionallyResizeElements.push(this.originalElement.css({position:"static",zoom:1,display:"block"}));this.originalElement.css({margin:this.originalElement.css("margin")});this._proportionallyResize()}this.handles=a.handles||(!e(".ui-resizable-handle",this.element).length?"e,s,se":{n:".ui-resizable-n",e:".ui-resizable-e",s:".ui-resizable-s",w:".ui-resizable-w",se:".ui-resizable-se",sw:".ui-resizable-sw",ne:".ui-resizable-ne", +nw:".ui-resizable-nw"});if(this.handles.constructor==String){if(this.handles=="all")this.handles="n,e,s,w,se,sw,ne,nw";var c=this.handles.split(",");this.handles={};for(var d=0;d');/sw|se|ne|nw/.test(f)&&g.css({zIndex:++a.zIndex});"se"==f&&g.addClass("ui-icon ui-icon-gripsmall-diagonal-se");this.handles[f]=".ui-resizable-"+f;this.element.append(g)}}this._renderAxis=function(h){h=h||this.element;for(var i in this.handles){if(this.handles[i].constructor== +String)this.handles[i]=e(this.handles[i],this.element).show();if(this.elementIsWrapper&&this.originalElement[0].nodeName.match(/textarea|input|select|button/i)){var j=e(this.handles[i],this.element),k=0;k=/sw|ne|nw|se|n|s/.test(i)?j.outerHeight():j.outerWidth();j=["padding",/ne|nw|n/.test(i)?"Top":/se|sw|s/.test(i)?"Bottom":/^e$/.test(i)?"Right":"Left"].join("");h.css(j,k);this._proportionallyResize()}e(this.handles[i])}};this._renderAxis(this.element);this._handles=e(".ui-resizable-handle",this.element).disableSelection(); +this._handles.mouseover(function(){if(!b.resizing){if(this.className)var h=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);b.axis=h&&h[1]?h[1]:"se"}});if(a.autoHide){this._handles.hide();e(this.element).addClass("ui-resizable-autohide").hover(function(){e(this).removeClass("ui-resizable-autohide");b._handles.show()},function(){if(!b.resizing){e(this).addClass("ui-resizable-autohide");b._handles.hide()}})}this._mouseInit()},destroy:function(){this._mouseDestroy();var b=function(c){e(c).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing").removeData("resizable").unbind(".resizable").find(".ui-resizable-handle").remove()}; +if(this.elementIsWrapper){b(this.element);var a=this.element;a.after(this.originalElement.css({position:a.css("position"),width:a.outerWidth(),height:a.outerHeight(),top:a.css("top"),left:a.css("left")})).remove()}this.originalElement.css("resize",this.originalResizeStyle);b(this.originalElement);return this},_mouseCapture:function(b){var a=false;for(var c in this.handles)if(e(this.handles[c])[0]==b.target)a=true;return!this.options.disabled&&a},_mouseStart:function(b){var a=this.options,c=this.element.position(), +d=this.element;this.resizing=true;this.documentScroll={top:e(document).scrollTop(),left:e(document).scrollLeft()};if(d.is(".ui-draggable")||/absolute/.test(d.css("position")))d.css({position:"absolute",top:c.top,left:c.left});e.browser.opera&&/relative/.test(d.css("position"))&&d.css({position:"relative",top:"auto",left:"auto"});this._renderProxy();c=m(this.helper.css("left"));var f=m(this.helper.css("top"));if(a.containment){c+=e(a.containment).scrollLeft()||0;f+=e(a.containment).scrollTop()||0}this.offset= +this.helper.offset();this.position={left:c,top:f};this.size=this._helper?{width:d.outerWidth(),height:d.outerHeight()}:{width:d.width(),height:d.height()};this.originalSize=this._helper?{width:d.outerWidth(),height:d.outerHeight()}:{width:d.width(),height:d.height()};this.originalPosition={left:c,top:f};this.sizeDiff={width:d.outerWidth()-d.width(),height:d.outerHeight()-d.height()};this.originalMousePosition={left:b.pageX,top:b.pageY};this.aspectRatio=typeof a.aspectRatio=="number"?a.aspectRatio: +this.originalSize.width/this.originalSize.height||1;a=e(".ui-resizable-"+this.axis).css("cursor");e("body").css("cursor",a=="auto"?this.axis+"-resize":a);d.addClass("ui-resizable-resizing");this._propagate("start",b);return true},_mouseDrag:function(b){var a=this.helper,c=this.originalMousePosition,d=this._change[this.axis];if(!d)return false;c=d.apply(this,[b,b.pageX-c.left||0,b.pageY-c.top||0]);if(this._aspectRatio||b.shiftKey)c=this._updateRatio(c,b);c=this._respectSize(c,b);this._propagate("resize", +b);a.css({top:this.position.top+"px",left:this.position.left+"px",width:this.size.width+"px",height:this.size.height+"px"});!this._helper&&this._proportionallyResizeElements.length&&this._proportionallyResize();this._updateCache(c);this._trigger("resize",b,this.ui());return false},_mouseStop:function(b){this.resizing=false;var a=this.options,c=this;if(this._helper){var d=this._proportionallyResizeElements,f=d.length&&/textarea/i.test(d[0].nodeName);d=f&&e.ui.hasScroll(d[0],"left")?0:c.sizeDiff.height; +f={width:c.size.width-(f?0:c.sizeDiff.width),height:c.size.height-d};d=parseInt(c.element.css("left"),10)+(c.position.left-c.originalPosition.left)||null;var g=parseInt(c.element.css("top"),10)+(c.position.top-c.originalPosition.top)||null;a.animate||this.element.css(e.extend(f,{top:g,left:d}));c.helper.height(c.size.height);c.helper.width(c.size.width);this._helper&&!a.animate&&this._proportionallyResize()}e("body").css("cursor","auto");this.element.removeClass("ui-resizable-resizing");this._propagate("stop", +b);this._helper&&this.helper.remove();return false},_updateCache:function(b){this.offset=this.helper.offset();if(l(b.left))this.position.left=b.left;if(l(b.top))this.position.top=b.top;if(l(b.height))this.size.height=b.height;if(l(b.width))this.size.width=b.width},_updateRatio:function(b){var a=this.position,c=this.size,d=this.axis;if(b.height)b.width=c.height*this.aspectRatio;else if(b.width)b.height=c.width/this.aspectRatio;if(d=="sw"){b.left=a.left+(c.width-b.width);b.top=null}if(d=="nw"){b.top= +a.top+(c.height-b.height);b.left=a.left+(c.width-b.width)}return b},_respectSize:function(b){var a=this.options,c=this.axis,d=l(b.width)&&a.maxWidth&&a.maxWidthb.width,h=l(b.height)&&a.minHeight&&a.minHeight>b.height;if(g)b.width=a.minWidth;if(h)b.height=a.minHeight;if(d)b.width=a.maxWidth;if(f)b.height=a.maxHeight;var i=this.originalPosition.left+this.originalSize.width,j=this.position.top+this.size.height, +k=/sw|nw|w/.test(c);c=/nw|ne|n/.test(c);if(g&&k)b.left=i-a.minWidth;if(d&&k)b.left=i-a.maxWidth;if(h&&c)b.top=j-a.minHeight;if(f&&c)b.top=j-a.maxHeight;if((a=!b.width&&!b.height)&&!b.left&&b.top)b.top=null;else if(a&&!b.top&&b.left)b.left=null;return b},_proportionallyResize:function(){if(this._proportionallyResizeElements.length)for(var b=this.helper||this.element,a=0;a');var a=e.browser.msie&&e.browser.version<7,c=a?1:0;a=a?2:-1;this.helper.addClass(this._helper).css({width:this.element.outerWidth()+a,height:this.element.outerHeight()+a,position:"absolute",left:this.elementOffset.left-c+"px",top:this.elementOffset.top-c+"px",zIndex:++b.zIndex});this.helper.appendTo("body").disableSelection()}else this.helper=this.element},_change:{e:function(b,a){return{width:this.originalSize.width+ +a}},w:function(b,a){return{left:this.originalPosition.left+a,width:this.originalSize.width-a}},n:function(b,a,c){return{top:this.originalPosition.top+c,height:this.originalSize.height-c}},s:function(b,a,c){return{height:this.originalSize.height+c}},se:function(b,a,c){return e.extend(this._change.s.apply(this,arguments),this._change.e.apply(this,[b,a,c]))},sw:function(b,a,c){return e.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[b,a,c]))},ne:function(b,a,c){return e.extend(this._change.n.apply(this, +arguments),this._change.e.apply(this,[b,a,c]))},nw:function(b,a,c){return e.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[b,a,c]))}},_propagate:function(b,a){e.ui.plugin.call(this,b,[a,this.ui()]);b!="resize"&&this._trigger(b,a,this.ui())},plugins:{},ui:function(){return{originalElement:this.originalElement,element:this.element,helper:this.helper,position:this.position,size:this.size,originalSize:this.originalSize,originalPosition:this.originalPosition}}});e.extend(e.ui.resizable, +{version:"1.8.9"});e.ui.plugin.add("resizable","alsoResize",{start:function(){var b=e(this).data("resizable").options,a=function(c){e(c).each(function(){var d=e(this);d.data("resizable-alsoresize",{width:parseInt(d.width(),10),height:parseInt(d.height(),10),left:parseInt(d.css("left"),10),top:parseInt(d.css("top"),10),position:d.css("position")})})};if(typeof b.alsoResize=="object"&&!b.alsoResize.parentNode)if(b.alsoResize.length){b.alsoResize=b.alsoResize[0];a(b.alsoResize)}else e.each(b.alsoResize, +function(c){a(c)});else a(b.alsoResize)},resize:function(b,a){var c=e(this).data("resizable");b=c.options;var d=c.originalSize,f=c.originalPosition,g={height:c.size.height-d.height||0,width:c.size.width-d.width||0,top:c.position.top-f.top||0,left:c.position.left-f.left||0},h=function(i,j){e(i).each(function(){var k=e(this),q=e(this).data("resizable-alsoresize"),p={},r=j&&j.length?j:k.parents(a.originalElement[0]).length?["width","height"]:["width","height","top","left"];e.each(r,function(n,o){if((n= +(q[o]||0)+(g[o]||0))&&n>=0)p[o]=n||null});if(e.browser.opera&&/relative/.test(k.css("position"))){c._revertToRelativePosition=true;k.css({position:"absolute",top:"auto",left:"auto"})}k.css(p)})};typeof b.alsoResize=="object"&&!b.alsoResize.nodeType?e.each(b.alsoResize,function(i,j){h(i,j)}):h(b.alsoResize)},stop:function(){var b=e(this).data("resizable"),a=b.options,c=function(d){e(d).each(function(){var f=e(this);f.css({position:f.data("resizable-alsoresize").position})})};if(b._revertToRelativePosition){b._revertToRelativePosition= +false;typeof a.alsoResize=="object"&&!a.alsoResize.nodeType?e.each(a.alsoResize,function(d){c(d)}):c(a.alsoResize)}e(this).removeData("resizable-alsoresize")}});e.ui.plugin.add("resizable","animate",{stop:function(b){var a=e(this).data("resizable"),c=a.options,d=a._proportionallyResizeElements,f=d.length&&/textarea/i.test(d[0].nodeName),g=f&&e.ui.hasScroll(d[0],"left")?0:a.sizeDiff.height;f={width:a.size.width-(f?0:a.sizeDiff.width),height:a.size.height-g};g=parseInt(a.element.css("left"),10)+(a.position.left- +a.originalPosition.left)||null;var h=parseInt(a.element.css("top"),10)+(a.position.top-a.originalPosition.top)||null;a.element.animate(e.extend(f,h&&g?{top:h,left:g}:{}),{duration:c.animateDuration,easing:c.animateEasing,step:function(){var i={width:parseInt(a.element.css("width"),10),height:parseInt(a.element.css("height"),10),top:parseInt(a.element.css("top"),10),left:parseInt(a.element.css("left"),10)};d&&d.length&&e(d[0]).css({width:i.width,height:i.height});a._updateCache(i);a._propagate("resize", +b)}})}});e.ui.plugin.add("resizable","containment",{start:function(){var b=e(this).data("resizable"),a=b.element,c=b.options.containment;if(a=c instanceof e?c.get(0):/parent/.test(c)?a.parent().get(0):c){b.containerElement=e(a);if(/document/.test(c)||c==document){b.containerOffset={left:0,top:0};b.containerPosition={left:0,top:0};b.parentData={element:e(document),left:0,top:0,width:e(document).width(),height:e(document).height()||document.body.parentNode.scrollHeight}}else{var d=e(a),f=[];e(["Top", +"Right","Left","Bottom"]).each(function(i,j){f[i]=m(d.css("padding"+j))});b.containerOffset=d.offset();b.containerPosition=d.position();b.containerSize={height:d.innerHeight()-f[3],width:d.innerWidth()-f[1]};c=b.containerOffset;var g=b.containerSize.height,h=b.containerSize.width;h=e.ui.hasScroll(a,"left")?a.scrollWidth:h;g=e.ui.hasScroll(a)?a.scrollHeight:g;b.parentData={element:a,left:c.left,top:c.top,width:h,height:g}}}},resize:function(b){var a=e(this).data("resizable"),c=a.options,d=a.containerOffset, +f=a.position;b=a._aspectRatio||b.shiftKey;var g={top:0,left:0},h=a.containerElement;if(h[0]!=document&&/static/.test(h.css("position")))g=d;if(f.left<(a._helper?d.left:0)){a.size.width+=a._helper?a.position.left-d.left:a.position.left-g.left;if(b)a.size.height=a.size.width/c.aspectRatio;a.position.left=c.helper?d.left:0}if(f.top<(a._helper?d.top:0)){a.size.height+=a._helper?a.position.top-d.top:a.position.top;if(b)a.size.width=a.size.height*c.aspectRatio;a.position.top=a._helper?d.top:0}a.offset.left= +a.parentData.left+a.position.left;a.offset.top=a.parentData.top+a.position.top;c=Math.abs((a._helper?a.offset.left-g.left:a.offset.left-g.left)+a.sizeDiff.width);d=Math.abs((a._helper?a.offset.top-g.top:a.offset.top-d.top)+a.sizeDiff.height);f=a.containerElement.get(0)==a.element.parent().get(0);g=/relative|absolute/.test(a.containerElement.css("position"));if(f&&g)c-=a.parentData.left;if(c+a.size.width>=a.parentData.width){a.size.width=a.parentData.width-c;if(b)a.size.height=a.size.width/a.aspectRatio}if(d+ +a.size.height>=a.parentData.height){a.size.height=a.parentData.height-d;if(b)a.size.width=a.size.height*a.aspectRatio}},stop:function(){var b=e(this).data("resizable"),a=b.options,c=b.containerOffset,d=b.containerPosition,f=b.containerElement,g=e(b.helper),h=g.offset(),i=g.outerWidth()-b.sizeDiff.width;g=g.outerHeight()-b.sizeDiff.height;b._helper&&!a.animate&&/relative/.test(f.css("position"))&&e(this).css({left:h.left-d.left-c.left,width:i,height:g});b._helper&&!a.animate&&/static/.test(f.css("position"))&& +e(this).css({left:h.left-d.left-c.left,width:i,height:g})}});e.ui.plugin.add("resizable","ghost",{start:function(){var b=e(this).data("resizable"),a=b.options,c=b.size;b.ghost=b.originalElement.clone();b.ghost.css({opacity:0.25,display:"block",position:"relative",height:c.height,width:c.width,margin:0,left:0,top:0}).addClass("ui-resizable-ghost").addClass(typeof a.ghost=="string"?a.ghost:"");b.ghost.appendTo(b.helper)},resize:function(){var b=e(this).data("resizable");b.ghost&&b.ghost.css({position:"relative", +height:b.size.height,width:b.size.width})},stop:function(){var b=e(this).data("resizable");b.ghost&&b.helper&&b.helper.get(0).removeChild(b.ghost.get(0))}});e.ui.plugin.add("resizable","grid",{resize:function(){var b=e(this).data("resizable"),a=b.options,c=b.size,d=b.originalSize,f=b.originalPosition,g=b.axis;a.grid=typeof a.grid=="number"?[a.grid,a.grid]:a.grid;var h=Math.round((c.width-d.width)/(a.grid[0]||1))*(a.grid[0]||1);a=Math.round((c.height-d.height)/(a.grid[1]||1))*(a.grid[1]||1);if(/^(se|s|e)$/.test(g)){b.size.width= +d.width+h;b.size.height=d.height+a}else if(/^(ne)$/.test(g)){b.size.width=d.width+h;b.size.height=d.height+a;b.position.top=f.top-a}else{if(/^(sw)$/.test(g)){b.size.width=d.width+h;b.size.height=d.height+a}else{b.size.width=d.width+h;b.size.height=d.height+a;b.position.top=f.top-a}b.position.left=f.left-h}}});var m=function(b){return parseInt(b,10)||0},l=function(b){return!isNaN(parseInt(b,10))}})(jQuery); diff --git a/wp-includes/js/jquery/ui.selectable.js b/wp-includes/js/jquery/ui.selectable.js index 90202165..c4abc33a 100644 --- a/wp-includes/js/jquery/ui.selectable.js +++ b/wp-includes/js/jquery/ui.selectable.js @@ -1,13 +1,22 @@ /* - * jQuery UI Selectable 1.7.3 + * jQuery UI Selectable 1.8.9 * - * Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT (MIT-LICENSE.txt) - * and GPL (GPL-LICENSE.txt) licenses. + * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license * * http://docs.jquery.com/UI/Selectables * * Depends: - * ui.core.js + * jquery.ui.core.js + * jquery.ui.mouse.js + * jquery.ui.widget.js */ -(function(a){a.widget("ui.selectable",a.extend({},a.ui.mouse,{_init:function(){var b=this;this.element.addClass("ui-selectable");this.dragged=false;var c;this.refresh=function(){c=a(b.options.filter,b.element[0]);c.each(function(){var d=a(this);var e=d.offset();a.data(this,"selectable-item",{element:this,$element:d,left:e.left,top:e.top,right:e.left+d.outerWidth(),bottom:e.top+d.outerHeight(),startselected:false,selected:d.hasClass("ui-selected"),selecting:d.hasClass("ui-selecting"),unselecting:d.hasClass("ui-unselecting")})})};this.refresh();this.selectees=c.addClass("ui-selectee");this._mouseInit();this.helper=a(document.createElement("div")).css({border:"1px dotted black"}).addClass("ui-selectable-helper")},destroy:function(){this.element.removeClass("ui-selectable ui-selectable-disabled").removeData("selectable").unbind(".selectable");this._mouseDestroy()},_mouseStart:function(d){var b=this;this.opos=[d.pageX,d.pageY];if(this.options.disabled){return}var c=this.options;this.selectees=a(c.filter,this.element[0]);this._trigger("start",d);a(c.appendTo).append(this.helper);this.helper.css({"z-index":100,position:"absolute",left:d.clientX,top:d.clientY,width:0,height:0});if(c.autoRefresh){this.refresh()}this.selectees.filter(".ui-selected").each(function(){var e=a.data(this,"selectable-item");e.startselected=true;if(!d.metaKey){e.$element.removeClass("ui-selected");e.selected=false;e.$element.addClass("ui-unselecting");e.unselecting=true;b._trigger("unselecting",d,{unselecting:e.element})}});a(d.target).parents().andSelf().each(function(){var e=a.data(this,"selectable-item");if(e){e.$element.removeClass("ui-unselecting").addClass("ui-selecting");e.unselecting=false;e.selecting=true;e.selected=true;b._trigger("selecting",d,{selecting:e.element});return false}})},_mouseDrag:function(i){var c=this;this.dragged=true;if(this.options.disabled){return}var e=this.options;var d=this.opos[0],h=this.opos[1],b=i.pageX,g=i.pageY;if(d>b){var f=b;b=d;d=f}if(h>g){var f=g;g=h;h=f}this.helper.css({left:d,top:h,width:b-d,height:g-h});this.selectees.each(function(){var j=a.data(this,"selectable-item");if(!j||j.element==c.element[0]){return}var k=false;if(e.tolerance=="touch"){k=(!(j.left>b||j.rightg||j.bottomd&&j.righth&&j.bottom")},destroy:function(){this.selectees.removeClass("ui-selectee").removeData("selectable-item");this.element.removeClass("ui-selectable ui-selectable-disabled").removeData("selectable").unbind(".selectable");this._mouseDestroy();return this},_mouseStart:function(c){var f=this;this.opos=[c.pageX, +c.pageY];if(!this.options.disabled){var d=this.options;this.selectees=e(d.filter,this.element[0]);this._trigger("start",c);e(d.appendTo).append(this.helper);this.helper.css({left:c.clientX,top:c.clientY,width:0,height:0});d.autoRefresh&&this.refresh();this.selectees.filter(".ui-selected").each(function(){var b=e.data(this,"selectable-item");b.startselected=true;if(!c.metaKey){b.$element.removeClass("ui-selected");b.selected=false;b.$element.addClass("ui-unselecting");b.unselecting=true;f._trigger("unselecting", +c,{unselecting:b.element})}});e(c.target).parents().andSelf().each(function(){var b=e.data(this,"selectable-item");if(b){var g=!c.metaKey||!b.$element.hasClass("ui-selected");b.$element.removeClass(g?"ui-unselecting":"ui-selected").addClass(g?"ui-selecting":"ui-unselecting");b.unselecting=!g;b.selecting=g;(b.selected=g)?f._trigger("selecting",c,{selecting:b.element}):f._trigger("unselecting",c,{unselecting:b.element});return false}})}},_mouseDrag:function(c){var f=this;this.dragged=true;if(!this.options.disabled){var d= +this.options,b=this.opos[0],g=this.opos[1],h=c.pageX,i=c.pageY;if(b>h){var j=h;h=b;b=j}if(g>i){j=i;i=g;g=j}this.helper.css({left:b,top:g,width:h-b,height:i-g});this.selectees.each(function(){var a=e.data(this,"selectable-item");if(!(!a||a.element==f.element[0])){var k=false;if(d.tolerance=="touch")k=!(a.left>h||a.righti||a.bottomb&&a.rightg&&a.bottom=0;b--){this.items[b].item.removeData("sortable-item")}},_mouseCapture:function(e,f){if(this.reverting){return false}if(this.options.disabled||this.options.type=="static"){return false}this._refreshItems(e);var d=null,c=this,b=a(e.target).parents().each(function(){if(a.data(this,"sortable-item")==c){d=a(this);return false}});if(a.data(e.target,"sortable-item")==c){d=a(e.target)}if(!d){return false}if(this.options.handle&&!f){var g=false;a(this.options.handle,d).find("*").andSelf().each(function(){if(this==e.target){g=true}});if(!g){return false}}this.currentItem=d;this._removeCurrentsFromItems();return true},_mouseStart:function(e,f,b){var g=this.options,c=this;this.currentContainer=this;this.refreshPositions();this.helper=this._createHelper(e);this._cacheHelperProportions();this._cacheMargins();this.scrollParent=this.helper.scrollParent();this.offset=this.currentItem.offset();this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left};this.helper.css("position","absolute");this.cssPosition=this.helper.css("position");a.extend(this.offset,{click:{left:e.pageX-this.offset.left,top:e.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()});this.originalPosition=this._generatePosition(e);this.originalPageX=e.pageX;this.originalPageY=e.pageY;if(g.cursorAt){this._adjustOffsetFromHelper(g.cursorAt)}this.domPosition={prev:this.currentItem.prev()[0],parent:this.currentItem.parent()[0]};if(this.helper[0]!=this.currentItem[0]){this.currentItem.hide()}this._createPlaceholder();if(g.containment){this._setContainment()}if(g.cursor){if(a("body").css("cursor")){this._storedCursor=a("body").css("cursor")}a("body").css("cursor",g.cursor)}if(g.opacity){if(this.helper.css("opacity")){this._storedOpacity=this.helper.css("opacity")}this.helper.css("opacity",g.opacity)}if(g.zIndex){if(this.helper.css("zIndex")){this._storedZIndex=this.helper.css("zIndex")}this.helper.css("zIndex",g.zIndex)}if(this.scrollParent[0]!=document&&this.scrollParent[0].tagName!="HTML"){this.overflowOffset=this.scrollParent.offset()}this._trigger("start",e,this._uiHash());if(!this._preserveHelperProportions){this._cacheHelperProportions()}if(!b){for(var d=this.containers.length-1;d>=0;d--){this.containers[d]._trigger("activate",e,c._uiHash(this))}}if(a.ui.ddmanager){a.ui.ddmanager.current=this}if(a.ui.ddmanager&&!g.dropBehaviour){a.ui.ddmanager.prepareOffsets(this,e)}this.dragging=true;this.helper.addClass("ui-sortable-helper");this._mouseDrag(e);return true},_mouseDrag:function(f){this.position=this._generatePosition(f);this.positionAbs=this._convertPositionTo("absolute");if(!this.lastPositionAbs){this.lastPositionAbs=this.positionAbs}if(this.options.scroll){var g=this.options,b=false;if(this.scrollParent[0]!=document&&this.scrollParent[0].tagName!="HTML"){if((this.overflowOffset.top+this.scrollParent[0].offsetHeight)-f.pageY=0;d--){var e=this.items[d],c=e.item[0],h=this._intersectsWithPointer(e);if(!h){continue}if(c!=this.currentItem[0]&&this.placeholder[h==1?"next":"prev"]()[0]!=c&&!a.ui.contains(this.placeholder[0],c)&&(this.options.type=="semi-dynamic"?!a.ui.contains(this.element[0],c):true)){this.direction=h==1?"down":"up";if(this.options.tolerance=="pointer"||this._intersectsWithSides(e)){this._rearrange(f,e)}else{break}this._trigger("change",f,this._uiHash());break}}this._contactContainers(f);if(a.ui.ddmanager){a.ui.ddmanager.drag(this,f)}this._trigger("sort",f,this._uiHash());this.lastPositionAbs=this.positionAbs;return false},_mouseStop:function(c,d){if(!c){return}if(a.ui.ddmanager&&!this.options.dropBehaviour){a.ui.ddmanager.drop(this,c)}if(this.options.revert){var b=this;var e=b.placeholder.offset();b.reverting=true;a(this.helper).animate({left:e.left-this.offset.parent.left-b.margins.left+(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollLeft),top:e.top-this.offset.parent.top-b.margins.top+(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollTop)},parseInt(this.options.revert,10)||500,function(){b._clear(c)})}else{this._clear(c,d)}return false},cancel:function(){var b=this;if(this.dragging){this._mouseUp();if(this.options.helper=="original"){this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper")}else{this.currentItem.show()}for(var c=this.containers.length-1;c>=0;c--){this.containers[c]._trigger("deactivate",null,b._uiHash(this));if(this.containers[c].containerCache.over){this.containers[c]._trigger("out",null,b._uiHash(this));this.containers[c].containerCache.over=0}}}if(this.placeholder[0].parentNode){this.placeholder[0].parentNode.removeChild(this.placeholder[0])}if(this.options.helper!="original"&&this.helper&&this.helper[0].parentNode){this.helper.remove()}a.extend(this,{helper:null,dragging:false,reverting:false,_noFinalSort:null});if(this.domPosition.prev){a(this.domPosition.prev).after(this.currentItem)}else{a(this.domPosition.parent).prepend(this.currentItem)}return true},serialize:function(d){var b=this._getItemsAsjQuery(d&&d.connected);var c=[];d=d||{};a(b).each(function(){var e=(a(d.item||this).attr(d.attribute||"id")||"").match(d.expression||(/(.+)[-=_](.+)/));if(e){c.push((d.key||e[1]+"[]")+"="+(d.key&&d.expression?e[1]:e[2]))}});return c.join("&")},toArray:function(d){var b=this._getItemsAsjQuery(d&&d.connected);var c=[];d=d||{};b.each(function(){c.push(a(d.item||this).attr(d.attribute||"id")||"")});return c},_intersectsWith:function(m){var e=this.positionAbs.left,d=e+this.helperProportions.width,k=this.positionAbs.top,j=k+this.helperProportions.height;var f=m.left,c=f+m.width,n=m.top,i=n+m.height;var o=this.offset.click.top,h=this.offset.click.left;var g=(k+o)>n&&(k+o)f&&(e+h)m[this.floating?"width":"height"])){return g}else{return(f0?"down":"up")},_getDragHorizontalDirection:function(){var b=this.positionAbs.left-this.lastPositionAbs.left;return b!=0&&(b>0?"right":"left")},refresh:function(b){this._refreshItems(b);this.refreshPositions()},_connectWith:function(){var b=this.options;return b.connectWith.constructor==String?[b.connectWith]:b.connectWith},_getItemsAsjQuery:function(b){var l=this;var g=[];var e=[];var h=this._connectWith();if(h&&b){for(var d=h.length-1;d>=0;d--){var k=a(h[d]);for(var c=k.length-1;c>=0;c--){var f=a.data(k[c],"sortable");if(f&&f!=this&&!f.options.disabled){e.push([a.isFunction(f.options.items)?f.options.items.call(f.element):a(f.options.items,f.element).not(".ui-sortable-helper"),f])}}}}e.push([a.isFunction(this.options.items)?this.options.items.call(this.element,null,{options:this.options,item:this.currentItem}):a(this.options.items,this.element).not(".ui-sortable-helper"),this]);for(var d=e.length-1;d>=0;d--){e[d][0].each(function(){g.push(this)})}return a(g)},_removeCurrentsFromItems:function(){var d=this.currentItem.find(":data(sortable-item)");for(var c=0;c=0;e--){var m=a(l[e]);for(var d=m.length-1;d>=0;d--){var g=a.data(m[d],"sortable");if(g&&g!=this&&!g.options.disabled){f.push([a.isFunction(g.options.items)?g.options.items.call(g.element[0],b,{item:this.currentItem}):a(g.options.items,g.element),g]);this.containers.push(g)}}}}for(var e=f.length-1;e>=0;e--){var k=f[e][1];var c=f[e][0];for(var d=0,n=c.length;d=0;d--){var e=this.items[d];if(e.instance!=this.currentContainer&&this.currentContainer&&e.item[0]!=this.currentItem[0]){continue}var c=this.options.toleranceElement?a(this.options.toleranceElement,e.item):e.item;if(!b){e.width=c.outerWidth();e.height=c.outerHeight()}var f=c.offset();e.left=f.left;e.top=f.top}if(this.options.custom&&this.options.custom.refreshContainers){this.options.custom.refreshContainers.call(this)}else{for(var d=this.containers.length-1;d>=0;d--){var f=this.containers[d].element.offset();this.containers[d].containerCache.left=f.left;this.containers[d].containerCache.top=f.top;this.containers[d].containerCache.width=this.containers[d].element.outerWidth();this.containers[d].containerCache.height=this.containers[d].element.outerHeight()}}},_createPlaceholder:function(d){var b=d||this,e=b.options;if(!e.placeholder||e.placeholder.constructor==String){var c=e.placeholder;e.placeholder={element:function(){var f=a(document.createElement(b.currentItem[0].nodeName)).addClass(c||b.currentItem[0].className+" ui-sortable-placeholder").removeClass("ui-sortable-helper")[0];if(!c){f.style.visibility="hidden"}return f},update:function(f,g){if(c&&!e.forcePlaceholderSize){return}if(!g.height()){g.height(b.currentItem.innerHeight()-parseInt(b.currentItem.css("paddingTop")||0,10)-parseInt(b.currentItem.css("paddingBottom")||0,10))}if(!g.width()){g.width(b.currentItem.innerWidth()-parseInt(b.currentItem.css("paddingLeft")||0,10)-parseInt(b.currentItem.css("paddingRight")||0,10))}}}}b.placeholder=a(e.placeholder.element.call(b.element,b.currentItem));b.currentItem.after(b.placeholder);e.placeholder.update(b,b.placeholder)},_contactContainers:function(d){for(var c=this.containers.length-1;c>=0;c--){if(this._intersectsWith(this.containers[c].containerCache)){if(!this.containers[c].containerCache.over){if(this.currentContainer!=this.containers[c]){var h=10000;var g=null;var e=this.positionAbs[this.containers[c].floating?"left":"top"];for(var b=this.items.length-1;b>=0;b--){if(!a.ui.contains(this.containers[c].element[0],this.items[b].item[0])){continue}var f=this.items[b][this.containers[c].floating?"left":"top"];if(Math.abs(f-e)this.containment[2]){d=this.containment[2]+this.offset.click.left}if(e.pageY-this.offset.click.top>this.containment[3]){c=this.containment[3]+this.offset.click.top}}if(h.grid){var g=this.originalPageY+Math.round((c-this.originalPageY)/h.grid[1])*h.grid[1];c=this.containment?(!(g-this.offset.click.topthis.containment[3])?g:(!(g-this.offset.click.topthis.containment[2])?f:(!(f-this.offset.click.left=0;c--){if(a.ui.contains(this.containers[c].element[0],this.currentItem[0])&&!e){f.push((function(g){return function(h){g._trigger("receive",h,this._uiHash(this))}}).call(this,this.containers[c]));f.push((function(g){return function(h){g._trigger("update",h,this._uiHash(this))}}).call(this,this.containers[c]))}}}for(var c=this.containers.length-1;c>=0;c--){if(!e){f.push((function(g){return function(h){g._trigger("deactivate",h,this._uiHash(this))}}).call(this,this.containers[c]))}if(this.containers[c].containerCache.over){f.push((function(g){return function(h){g._trigger("out",h,this._uiHash(this))}}).call(this,this.containers[c]));this.containers[c].containerCache.over=0}}if(this._storedCursor){a("body").css("cursor",this._storedCursor)}if(this._storedOpacity){this.helper.css("opacity",this._storedOpacity)}if(this._storedZIndex){this.helper.css("zIndex",this._storedZIndex=="auto"?"":this._storedZIndex)}this.dragging=false;if(this.cancelHelperRemoval){if(!e){this._trigger("beforeStop",d,this._uiHash());for(var c=0;c *",opacity:false,placeholder:false,revert:false,scroll:true,scrollSensitivity:20,scrollSpeed:20,scope:"default",tolerance:"intersect",zIndex:1000}})})(jQuery); +(function(d){d.widget("ui.sortable",d.ui.mouse,{widgetEventPrefix:"sort",options:{appendTo:"parent",axis:false,connectWith:false,containment:false,cursor:"auto",cursorAt:false,dropOnEmpty:true,forcePlaceholderSize:false,forceHelperSize:false,grid:false,handle:false,helper:"original",items:"> *",opacity:false,placeholder:false,revert:false,scroll:true,scrollSensitivity:20,scrollSpeed:20,scope:"default",tolerance:"intersect",zIndex:1E3},_create:function(){this.containerCache={};this.element.addClass("ui-sortable"); +this.refresh();this.floating=this.items.length?/left|right/.test(this.items[0].item.css("float")):false;this.offset=this.element.offset();this._mouseInit()},destroy:function(){this.element.removeClass("ui-sortable ui-sortable-disabled").removeData("sortable").unbind(".sortable");this._mouseDestroy();for(var a=this.items.length-1;a>=0;a--)this.items[a].item.removeData("sortable-item");return this},_setOption:function(a,b){if(a==="disabled"){this.options[a]=b;this.widget()[b?"addClass":"removeClass"]("ui-sortable-disabled")}else d.Widget.prototype._setOption.apply(this, +arguments)},_mouseCapture:function(a,b){if(this.reverting)return false;if(this.options.disabled||this.options.type=="static")return false;this._refreshItems(a);var c=null,e=this;d(a.target).parents().each(function(){if(d.data(this,"sortable-item")==e){c=d(this);return false}});if(d.data(a.target,"sortable-item")==e)c=d(a.target);if(!c)return false;if(this.options.handle&&!b){var f=false;d(this.options.handle,c).find("*").andSelf().each(function(){if(this==a.target)f=true});if(!f)return false}this.currentItem= +c;this._removeCurrentsFromItems();return true},_mouseStart:function(a,b,c){b=this.options;var e=this;this.currentContainer=this;this.refreshPositions();this.helper=this._createHelper(a);this._cacheHelperProportions();this._cacheMargins();this.scrollParent=this.helper.scrollParent();this.offset=this.currentItem.offset();this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left};this.helper.css("position","absolute");this.cssPosition=this.helper.css("position");d.extend(this.offset, +{click:{left:a.pageX-this.offset.left,top:a.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()});this.originalPosition=this._generatePosition(a);this.originalPageX=a.pageX;this.originalPageY=a.pageY;b.cursorAt&&this._adjustOffsetFromHelper(b.cursorAt);this.domPosition={prev:this.currentItem.prev()[0],parent:this.currentItem.parent()[0]};this.helper[0]!=this.currentItem[0]&&this.currentItem.hide();this._createPlaceholder();b.containment&&this._setContainment(); +if(b.cursor){if(d("body").css("cursor"))this._storedCursor=d("body").css("cursor");d("body").css("cursor",b.cursor)}if(b.opacity){if(this.helper.css("opacity"))this._storedOpacity=this.helper.css("opacity");this.helper.css("opacity",b.opacity)}if(b.zIndex){if(this.helper.css("zIndex"))this._storedZIndex=this.helper.css("zIndex");this.helper.css("zIndex",b.zIndex)}if(this.scrollParent[0]!=document&&this.scrollParent[0].tagName!="HTML")this.overflowOffset=this.scrollParent.offset();this._trigger("start", +a,this._uiHash());this._preserveHelperProportions||this._cacheHelperProportions();if(!c)for(c=this.containers.length-1;c>=0;c--)this.containers[c]._trigger("activate",a,e._uiHash(this));if(d.ui.ddmanager)d.ui.ddmanager.current=this;d.ui.ddmanager&&!b.dropBehaviour&&d.ui.ddmanager.prepareOffsets(this,a);this.dragging=true;this.helper.addClass("ui-sortable-helper");this._mouseDrag(a);return true},_mouseDrag:function(a){this.position=this._generatePosition(a);this.positionAbs=this._convertPositionTo("absolute"); +if(!this.lastPositionAbs)this.lastPositionAbs=this.positionAbs;if(this.options.scroll){var b=this.options,c=false;if(this.scrollParent[0]!=document&&this.scrollParent[0].tagName!="HTML"){if(this.overflowOffset.top+this.scrollParent[0].offsetHeight-a.pageY=0;b--){c=this.items[b];var e=c.item[0],f=this._intersectsWithPointer(c);if(f)if(e!=this.currentItem[0]&&this.placeholder[f==1?"next":"prev"]()[0]!=e&&!d.ui.contains(this.placeholder[0],e)&&(this.options.type=="semi-dynamic"?!d.ui.contains(this.element[0],e):true)){this.direction=f==1?"down":"up";if(this.options.tolerance=="pointer"||this._intersectsWithSides(c))this._rearrange(a, +c);else break;this._trigger("change",a,this._uiHash());break}}this._contactContainers(a);d.ui.ddmanager&&d.ui.ddmanager.drag(this,a);this._trigger("sort",a,this._uiHash());this.lastPositionAbs=this.positionAbs;return false},_mouseStop:function(a,b){if(a){d.ui.ddmanager&&!this.options.dropBehaviour&&d.ui.ddmanager.drop(this,a);if(this.options.revert){var c=this;b=c.placeholder.offset();c.reverting=true;d(this.helper).animate({left:b.left-this.offset.parent.left-c.margins.left+(this.offsetParent[0]== +document.body?0:this.offsetParent[0].scrollLeft),top:b.top-this.offset.parent.top-c.margins.top+(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollTop)},parseInt(this.options.revert,10)||500,function(){c._clear(a)})}else this._clear(a,b);return false}},cancel:function(){var a=this;if(this.dragging){this._mouseUp({target:null});this.options.helper=="original"?this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper"):this.currentItem.show();for(var b=this.containers.length- +1;b>=0;b--){this.containers[b]._trigger("deactivate",null,a._uiHash(this));if(this.containers[b].containerCache.over){this.containers[b]._trigger("out",null,a._uiHash(this));this.containers[b].containerCache.over=0}}}if(this.placeholder){this.placeholder[0].parentNode&&this.placeholder[0].parentNode.removeChild(this.placeholder[0]);this.options.helper!="original"&&this.helper&&this.helper[0].parentNode&&this.helper.remove();d.extend(this,{helper:null,dragging:false,reverting:false,_noFinalSort:null}); +this.domPosition.prev?d(this.domPosition.prev).after(this.currentItem):d(this.domPosition.parent).prepend(this.currentItem)}return this},serialize:function(a){var b=this._getItemsAsjQuery(a&&a.connected),c=[];a=a||{};d(b).each(function(){var e=(d(a.item||this).attr(a.attribute||"id")||"").match(a.expression||/(.+)[-=_](.+)/);if(e)c.push((a.key||e[1]+"[]")+"="+(a.key&&a.expression?e[1]:e[2]))});!c.length&&a.key&&c.push(a.key+"=");return c.join("&")},toArray:function(a){var b=this._getItemsAsjQuery(a&& +a.connected),c=[];a=a||{};b.each(function(){c.push(d(a.item||this).attr(a.attribute||"id")||"")});return c},_intersectsWith:function(a){var b=this.positionAbs.left,c=b+this.helperProportions.width,e=this.positionAbs.top,f=e+this.helperProportions.height,g=a.left,h=g+a.width,i=a.top,k=i+a.height,j=this.offset.click.top,l=this.offset.click.left;j=e+j>i&&e+jg&&b+la[this.floating?"width":"height"]?j:g0?"down":"up")},_getDragHorizontalDirection:function(){var a=this.positionAbs.left-this.lastPositionAbs.left;return a!=0&&(a>0?"right":"left")},refresh:function(a){this._refreshItems(a);this.refreshPositions();return this},_connectWith:function(){var a=this.options;return a.connectWith.constructor==String?[a.connectWith]:a.connectWith},_getItemsAsjQuery:function(a){var b=[],c=[],e=this._connectWith();if(e&&a)for(a=e.length-1;a>=0;a--)for(var f=d(e[a]),g=f.length-1;g>=0;g--){var h= +d.data(f[g],"sortable");if(h&&h!=this&&!h.options.disabled)c.push([d.isFunction(h.options.items)?h.options.items.call(h.element):d(h.options.items,h.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),h])}c.push([d.isFunction(this.options.items)?this.options.items.call(this.element,null,{options:this.options,item:this.currentItem}):d(this.options.items,this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),this]);for(a=c.length-1;a>=0;a--)c[a][0].each(function(){b.push(this)}); +return d(b)},_removeCurrentsFromItems:function(){for(var a=this.currentItem.find(":data(sortable-item)"),b=0;b=0;f--)for(var g= +d(e[f]),h=g.length-1;h>=0;h--){var i=d.data(g[h],"sortable");if(i&&i!=this&&!i.options.disabled){c.push([d.isFunction(i.options.items)?i.options.items.call(i.element[0],a,{item:this.currentItem}):d(i.options.items,i.element),i]);this.containers.push(i)}}for(f=c.length-1;f>=0;f--){a=c[f][1];e=c[f][0];h=0;for(g=e.length;h=0;b--){var c=this.items[b],e=this.options.toleranceElement?d(this.options.toleranceElement,c.item):c.item;if(!a){c.width=e.outerWidth();c.height=e.outerHeight()}e=e.offset();c.left=e.left;c.top=e.top}if(this.options.custom&&this.options.custom.refreshContainers)this.options.custom.refreshContainers.call(this);else for(b=this.containers.length-1;b>=0;b--){e=this.containers[b].element.offset();this.containers[b].containerCache.left=e.left;this.containers[b].containerCache.top= +e.top;this.containers[b].containerCache.width=this.containers[b].element.outerWidth();this.containers[b].containerCache.height=this.containers[b].element.outerHeight()}return this},_createPlaceholder:function(a){var b=a||this,c=b.options;if(!c.placeholder||c.placeholder.constructor==String){var e=c.placeholder;c.placeholder={element:function(){var f=d(document.createElement(b.currentItem[0].nodeName)).addClass(e||b.currentItem[0].className+" ui-sortable-placeholder").removeClass("ui-sortable-helper")[0]; +if(!e)f.style.visibility="hidden";return f},update:function(f,g){if(!(e&&!c.forcePlaceholderSize)){g.height()||g.height(b.currentItem.innerHeight()-parseInt(b.currentItem.css("paddingTop")||0,10)-parseInt(b.currentItem.css("paddingBottom")||0,10));g.width()||g.width(b.currentItem.innerWidth()-parseInt(b.currentItem.css("paddingLeft")||0,10)-parseInt(b.currentItem.css("paddingRight")||0,10))}}}}b.placeholder=d(c.placeholder.element.call(b.element,b.currentItem));b.currentItem.after(b.placeholder); +c.placeholder.update(b,b.placeholder)},_contactContainers:function(a){for(var b=null,c=null,e=this.containers.length-1;e>=0;e--)if(!d.ui.contains(this.currentItem[0],this.containers[e].element[0]))if(this._intersectsWith(this.containers[e].containerCache)){if(!(b&&d.ui.contains(this.containers[e].element[0],b.element[0]))){b=this.containers[e];c=e}}else if(this.containers[e].containerCache.over){this.containers[e]._trigger("out",a,this._uiHash(this));this.containers[e].containerCache.over=0}if(b)if(this.containers.length=== +1){this.containers[c]._trigger("over",a,this._uiHash(this));this.containers[c].containerCache.over=1}else if(this.currentContainer!=this.containers[c]){b=1E4;e=null;for(var f=this.positionAbs[this.containers[c].floating?"left":"top"],g=this.items.length-1;g>=0;g--)if(d.ui.contains(this.containers[c].element[0],this.items[g].item[0])){var h=this.items[g][this.containers[c].floating?"left":"top"];if(Math.abs(h-f)this.containment[2])f=this.containment[2]+this.offset.click.left;if(a.pageY-this.offset.click.top>this.containment[3])g=this.containment[3]+this.offset.click.top}if(b.grid){g=this.originalPageY+Math.round((g-this.originalPageY)/b.grid[1])*b.grid[1];g=this.containment?!(g-this.offset.click.top< +this.containment[1]||g-this.offset.click.top>this.containment[3])?g:!(g-this.offset.click.topthis.containment[2])?f:!(f-this.offset.click.left=0;e--)if(d.ui.contains(this.containers[e].element[0], +this.currentItem[0])&&!b){c.push(function(f){return function(g){f._trigger("receive",g,this._uiHash(this))}}.call(this,this.containers[e]));c.push(function(f){return function(g){f._trigger("update",g,this._uiHash(this))}}.call(this,this.containers[e]))}}for(e=this.containers.length-1;e>=0;e--){b||c.push(function(f){return function(g){f._trigger("deactivate",g,this._uiHash(this))}}.call(this,this.containers[e]));if(this.containers[e].containerCache.over){c.push(function(f){return function(g){f._trigger("out", +g,this._uiHash(this))}}.call(this,this.containers[e]));this.containers[e].containerCache.over=0}}this._storedCursor&&d("body").css("cursor",this._storedCursor);this._storedOpacity&&this.helper.css("opacity",this._storedOpacity);if(this._storedZIndex)this.helper.css("zIndex",this._storedZIndex=="auto"?"":this._storedZIndex);this.dragging=false;if(this.cancelHelperRemoval){if(!b){this._trigger("beforeStop",a,this._uiHash());for(e=0;e=0&&this.anchors[f.selected])||f.selected<0)?f.selected:0;f.disabled=c.unique(f.disabled.concat(c.map(this.lis.filter(".ui-state-disabled"),function(s,o){return r.lis.index(s)}))).sort();if(c.inArray(f.selected,f.disabled)!=-1){f.disabled.splice(c.inArray(f.selected,f.disabled),1)}this.panels.addClass("ui-tabs-hide");this.lis.removeClass("ui-tabs-selected ui-state-active");if(f.selected>=0&&this.anchors.length){this.panels.eq(f.selected).removeClass("ui-tabs-hide");this.lis.eq(f.selected).addClass("ui-tabs-selected ui-state-active");r.element.queue("tabs",function(){r._trigger("show",null,r._ui(r.anchors[f.selected],r.panels[f.selected]))});this.load(f.selected)}c(window).bind("unload",function(){r.lis.add(r.anchors).unbind(".tabs");r.lis=r.anchors=r.panels=null})}else{f.selected=this.lis.index(this.lis.filter(".ui-tabs-selected"))}this.element[f.collapsible?"addClass":"removeClass"]("ui-tabs-collapsible");if(f.cookie){this._cookie(f.selected,f.cookie)}for(var j=0,p;(p=this.lis[j]);j++){c(p)[c.inArray(j,f.disabled)!=-1&&!c(p).hasClass("ui-tabs-selected")?"addClass":"removeClass"]("ui-state-disabled")}if(f.cache===false){this.anchors.removeData("cache.tabs")}this.lis.add(this.anchors).unbind(".tabs");if(f.event!="mouseover"){var h=function(o,i){if(i.is(":not(.ui-state-disabled)")){i.addClass("ui-state-"+o)}};var l=function(o,i){i.removeClass("ui-state-"+o)};this.lis.bind("mouseover.tabs",function(){h("hover",c(this))});this.lis.bind("mouseout.tabs",function(){l("hover",c(this))});this.anchors.bind("focus.tabs",function(){h("focus",c(this).closest("li"))});this.anchors.bind("blur.tabs",function(){l("focus",c(this).closest("li"))})}var d,k;if(f.fx){if(c.isArray(f.fx)){d=f.fx[0];k=f.fx[1]}else{d=k=f.fx}}function g(i,o){i.css({display:""});if(c.browser.msie&&o.opacity){i[0].style.removeAttribute("filter")}}var m=k?function(i,o){c(i).closest("li").removeClass("ui-state-default").addClass("ui-tabs-selected ui-state-active");o.hide().removeClass("ui-tabs-hide").animate(k,k.duration||"normal",function(){g(o,k);r._trigger("show",null,r._ui(i,o[0]))})}:function(i,o){c(i).closest("li").removeClass("ui-state-default").addClass("ui-tabs-selected ui-state-active");o.removeClass("ui-tabs-hide");r._trigger("show",null,r._ui(i,o[0]))};var n=d?function(o,i){i.animate(d,d.duration||"normal",function(){r.lis.removeClass("ui-tabs-selected ui-state-active").addClass("ui-state-default");i.addClass("ui-tabs-hide");g(i,d);r.element.dequeue("tabs")})}:function(o,i,s){r.lis.removeClass("ui-tabs-selected ui-state-active").addClass("ui-state-default");i.addClass("ui-tabs-hide");r.element.dequeue("tabs")};this.anchors.bind(f.event+".tabs",function(){var o=this,u=c(this).closest("li"),i=r.panels.filter(":not(.ui-tabs-hide)"),s=c(r._sanitizeSelector(this.hash));if((u.hasClass("ui-tabs-selected")&&!f.collapsible)||u.hasClass("ui-state-disabled")||u.hasClass("ui-state-processing")||r._trigger("select",null,r._ui(this,s[0]))===false){this.blur();return false}f.selected=r.anchors.index(this);r.abort();if(f.collapsible){if(u.hasClass("ui-tabs-selected")){f.selected=-1;if(f.cookie){r._cookie(f.selected,f.cookie)}r.element.queue("tabs",function(){n(o,i)}).dequeue("tabs");this.blur();return false}else{if(!i.length){if(f.cookie){r._cookie(f.selected,f.cookie)}r.element.queue("tabs",function(){m(o,s)});r.load(r.anchors.index(this));this.blur();return false}}}if(f.cookie){r._cookie(f.selected,f.cookie)}if(s.length){if(i.length){r.element.queue("tabs",function(){n(o,i)})}r.element.queue("tabs",function(){m(o,s)});r.load(r.anchors.index(this))}else{throw"jQuery UI Tabs: Mismatching fragment identifier."}if(c.browser.msie){this.blur()}});this.anchors.bind("click.tabs",function(){return false})},destroy:function(){var d=this.options;this.abort();this.element.unbind(".tabs").removeClass("ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible").removeData("tabs");this.list.removeClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all");this.anchors.each(function(){var e=c.data(this,"href.tabs");if(e){this.href=e}var f=c(this).unbind(".tabs");c.each(["href","load","cache"],function(g,h){f.removeData(h+".tabs")})});this.lis.unbind(".tabs").add(this.panels).each(function(){if(c.data(this,"destroy.tabs")){c(this).remove()}else{c(this).removeClass(["ui-state-default","ui-corner-top","ui-tabs-selected","ui-state-active","ui-state-hover","ui-state-focus","ui-state-disabled","ui-tabs-panel","ui-widget-content","ui-corner-bottom","ui-tabs-hide"].join(" "))}});if(d.cookie){this._cookie(null,d.cookie)}},add:function(g,f,e){if(e===undefined){e=this.anchors.length}var d=this,i=this.options,k=c(i.tabTemplate.replace(/#\{href\}/g,g).replace(/#\{label\}/g,f)),j=!g.indexOf("#")?g.replace("#",""):this._tabId(c("a",k)[0]);k.addClass("ui-state-default ui-corner-top").data("destroy.tabs",true);var h=c("#"+j);if(!h.length){h=c(i.panelTemplate).attr("id",j).data("destroy.tabs",true)}h.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide");if(e>=this.lis.length){k.appendTo(this.list);h.appendTo(this.list[0].parentNode)}else{k.insertBefore(this.lis[e]);h.insertBefore(this.panels[e])}i.disabled=c.map(i.disabled,function(m,l){return m>=e?++m:m});this._tabify();if(this.anchors.length==1){k.addClass("ui-tabs-selected ui-state-active");h.removeClass("ui-tabs-hide");this.element.queue("tabs",function(){d._trigger("show",null,d._ui(d.anchors[0],d.panels[0]))});this.load(0)}this._trigger("add",null,this._ui(this.anchors[e],this.panels[e]))},remove:function(d){var f=this.options,g=this.lis.eq(d).remove(),e=this.panels.eq(d).remove();if(g.hasClass("ui-tabs-selected")&&this.anchors.length>1){this.select(d+(d+1=d?--j:j});this._tabify();this._trigger("remove",null,this._ui(g.find("a")[0],e[0]))},enable:function(d){var e=this.options;if(c.inArray(d,e.disabled)==-1){return}this.lis.eq(d).removeClass("ui-state-disabled");e.disabled=c.grep(e.disabled,function(g,f){return g!=d});this._trigger("enable",null,this._ui(this.anchors[d],this.panels[d]))},disable:function(e){var d=this,f=this.options;if(e!=f.selected){this.lis.eq(e).addClass("ui-state-disabled");f.disabled.push(e);f.disabled.sort();this._trigger("disable",null,this._ui(this.anchors[e],this.panels[e]))}},select:function(d){if(typeof d=="string"){d=this.anchors.index(this.anchors.filter("[href$="+d+"]"))}else{if(d===null){d=-1}}if(d==-1&&this.options.collapsible){d=this.options.selected}this.anchors.eq(d).trigger(this.options.event+".tabs")},load:function(g){var e=this,i=this.options,d=this.anchors.eq(g)[0],f=c.data(d,"load.tabs");this.abort();if(!f||this.element.queue("tabs").length!==0&&c.data(d,"cache.tabs")){this.element.dequeue("tabs");return}this.lis.eq(g).addClass("ui-state-processing");if(i.spinner){var h=c("span",d);h.data("label.tabs",h.html()).html(i.spinner)}this.xhr=c.ajax(c.extend({},i.ajaxOptions,{url:f,success:function(k,j){c(e._sanitizeSelector(d.hash)).html(k);e._cleanup();if(i.cache){c.data(d,"cache.tabs",true)}e._trigger("load",null,e._ui(e.anchors[g],e.panels[g]));try{i.ajaxOptions.success(k,j)}catch(l){}e.element.dequeue("tabs")}}))},abort:function(){this.element.queue([]);this.panels.stop(false,true);if(this.xhr){this.xhr.abort();delete this.xhr}this._cleanup()},url:function(e,d){this.anchors.eq(e).removeData("cache.tabs").data("load.tabs",d)},length:function(){return this.anchors.length}});c.extend(c.ui.tabs,{version:"1.7.3",getter:"length",defaults:{ajaxOptions:null,cache:false,cookie:null,collapsible:false,disabled:[],event:"click",fx:null,idPrefix:"ui-tabs-",panelTemplate:"
        ",spinner:"Loading…",tabTemplate:'
      • #{label}
      • '}});c.extend(c.ui.tabs.prototype,{rotation:null,rotate:function(f,h){var d=this,i=this.options;var e=d._rotate||(d._rotate=function(j){clearTimeout(d.rotation);d.rotation=setTimeout(function(){var k=i.selected;d.select(++k",remove:null,select:null,show:null,spinner:"Loading…",tabTemplate:"
      • #{label}
      • "},_create:function(){this._tabify(true)},_setOption:function(b,e){if(b=="selected")this.options.collapsible&& +e==this.options.selected||this.select(e);else{this.options[b]=e;this._tabify()}},_tabId:function(b){return b.title&&b.title.replace(/\s/g,"_").replace(/[^\w\u00c0-\uFFFF-]/g,"")||this.options.idPrefix+u()},_sanitizeSelector:function(b){return b.replace(/:/g,"\\:")},_cookie:function(){var b=this.cookie||(this.cookie=this.options.cookie.name||"ui-tabs-"+w());return d.cookie.apply(null,[b].concat(d.makeArray(arguments)))},_ui:function(b,e){return{tab:b,panel:e,index:this.anchors.index(b)}},_cleanup:function(){this.lis.filter(".ui-state-processing").removeClass("ui-state-processing").find("span:data(label.tabs)").each(function(){var b= +d(this);b.html(b.data("label.tabs")).removeData("label.tabs")})},_tabify:function(b){function e(g,f){g.css("display","");!d.support.opacity&&f.opacity&&g[0].style.removeAttribute("filter")}var a=this,c=this.options,h=/^#.+/;this.list=this.element.find("ol,ul").eq(0);this.lis=d(" > li:has(a[href])",this.list);this.anchors=this.lis.map(function(){return d("a",this)[0]});this.panels=d([]);this.anchors.each(function(g,f){var i=d(f).attr("href"),l=i.split("#")[0],q;if(l&&(l===location.toString().split("#")[0]|| +(q=d("base")[0])&&l===q.href)){i=f.hash;f.href=i}if(h.test(i))a.panels=a.panels.add(a.element.find(a._sanitizeSelector(i)));else if(i&&i!=="#"){d.data(f,"href.tabs",i);d.data(f,"load.tabs",i.replace(/#.*$/,""));i=a._tabId(f);f.href="#"+i;f=a.element.find("#"+i);if(!f.length){f=d(c.panelTemplate).attr("id",i).addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").insertAfter(a.panels[g-1]||a.list);f.data("destroy.tabs",true)}a.panels=a.panels.add(f)}else c.disabled.push(g)});if(b){this.element.addClass("ui-tabs ui-widget ui-widget-content ui-corner-all"); +this.list.addClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all");this.lis.addClass("ui-state-default ui-corner-top");this.panels.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom");if(c.selected===p){location.hash&&this.anchors.each(function(g,f){if(f.hash==location.hash){c.selected=g;return false}});if(typeof c.selected!=="number"&&c.cookie)c.selected=parseInt(a._cookie(),10);if(typeof c.selected!=="number"&&this.lis.filter(".ui-tabs-selected").length)c.selected= +this.lis.index(this.lis.filter(".ui-tabs-selected"));c.selected=c.selected||(this.lis.length?0:-1)}else if(c.selected===null)c.selected=-1;c.selected=c.selected>=0&&this.anchors[c.selected]||c.selected<0?c.selected:0;c.disabled=d.unique(c.disabled.concat(d.map(this.lis.filter(".ui-state-disabled"),function(g){return a.lis.index(g)}))).sort();d.inArray(c.selected,c.disabled)!=-1&&c.disabled.splice(d.inArray(c.selected,c.disabled),1);this.panels.addClass("ui-tabs-hide");this.lis.removeClass("ui-tabs-selected ui-state-active"); +if(c.selected>=0&&this.anchors.length){a.element.find(a._sanitizeSelector(a.anchors[c.selected].hash)).removeClass("ui-tabs-hide");this.lis.eq(c.selected).addClass("ui-tabs-selected ui-state-active");a.element.queue("tabs",function(){a._trigger("show",null,a._ui(a.anchors[c.selected],a.element.find(a._sanitizeSelector(a.anchors[c.selected].hash))[0]))});this.load(c.selected)}d(window).bind("unload",function(){a.lis.add(a.anchors).unbind(".tabs");a.lis=a.anchors=a.panels=null})}else c.selected=this.lis.index(this.lis.filter(".ui-tabs-selected")); +this.element[c.collapsible?"addClass":"removeClass"]("ui-tabs-collapsible");c.cookie&&this._cookie(c.selected,c.cookie);b=0;for(var j;j=this.lis[b];b++)d(j)[d.inArray(b,c.disabled)!=-1&&!d(j).hasClass("ui-tabs-selected")?"addClass":"removeClass"]("ui-state-disabled");c.cache===false&&this.anchors.removeData("cache.tabs");this.lis.add(this.anchors).unbind(".tabs");if(c.event!=="mouseover"){var k=function(g,f){f.is(":not(.ui-state-disabled)")&&f.addClass("ui-state-"+g)},n=function(g,f){f.removeClass("ui-state-"+ +g)};this.lis.bind("mouseover.tabs",function(){k("hover",d(this))});this.lis.bind("mouseout.tabs",function(){n("hover",d(this))});this.anchors.bind("focus.tabs",function(){k("focus",d(this).closest("li"))});this.anchors.bind("blur.tabs",function(){n("focus",d(this).closest("li"))})}var m,o;if(c.fx)if(d.isArray(c.fx)){m=c.fx[0];o=c.fx[1]}else m=o=c.fx;var r=o?function(g,f){d(g).closest("li").addClass("ui-tabs-selected ui-state-active");f.hide().removeClass("ui-tabs-hide").animate(o,o.duration||"normal", +function(){e(f,o);a._trigger("show",null,a._ui(g,f[0]))})}:function(g,f){d(g).closest("li").addClass("ui-tabs-selected ui-state-active");f.removeClass("ui-tabs-hide");a._trigger("show",null,a._ui(g,f[0]))},s=m?function(g,f){f.animate(m,m.duration||"normal",function(){a.lis.removeClass("ui-tabs-selected ui-state-active");f.addClass("ui-tabs-hide");e(f,m);a.element.dequeue("tabs")})}:function(g,f){a.lis.removeClass("ui-tabs-selected ui-state-active");f.addClass("ui-tabs-hide");a.element.dequeue("tabs")}; +this.anchors.bind(c.event+".tabs",function(){var g=this,f=d(g).closest("li"),i=a.panels.filter(":not(.ui-tabs-hide)"),l=a.element.find(a._sanitizeSelector(g.hash));if(f.hasClass("ui-tabs-selected")&&!c.collapsible||f.hasClass("ui-state-disabled")||f.hasClass("ui-state-processing")||a.panels.filter(":animated").length||a._trigger("select",null,a._ui(this,l[0]))===false){this.blur();return false}c.selected=a.anchors.index(this);a.abort();if(c.collapsible)if(f.hasClass("ui-tabs-selected")){c.selected= +-1;c.cookie&&a._cookie(c.selected,c.cookie);a.element.queue("tabs",function(){s(g,i)}).dequeue("tabs");this.blur();return false}else if(!i.length){c.cookie&&a._cookie(c.selected,c.cookie);a.element.queue("tabs",function(){r(g,l)});a.load(a.anchors.index(this));this.blur();return false}c.cookie&&a._cookie(c.selected,c.cookie);if(l.length){i.length&&a.element.queue("tabs",function(){s(g,i)});a.element.queue("tabs",function(){r(g,l)});a.load(a.anchors.index(this))}else throw"jQuery UI Tabs: Mismatching fragment identifier."; +d.browser.msie&&this.blur()});this.anchors.bind("click.tabs",function(){return false})},_getIndex:function(b){if(typeof b=="string")b=this.anchors.index(this.anchors.filter("[href$="+b+"]"));return b},destroy:function(){var b=this.options;this.abort();this.element.unbind(".tabs").removeClass("ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible").removeData("tabs");this.list.removeClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all");this.anchors.each(function(){var e= +d.data(this,"href.tabs");if(e)this.href=e;var a=d(this).unbind(".tabs");d.each(["href","load","cache"],function(c,h){a.removeData(h+".tabs")})});this.lis.unbind(".tabs").add(this.panels).each(function(){d.data(this,"destroy.tabs")?d(this).remove():d(this).removeClass("ui-state-default ui-corner-top ui-tabs-selected ui-state-active ui-state-hover ui-state-focus ui-state-disabled ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide")});b.cookie&&this._cookie(null,b.cookie);return this},add:function(b, +e,a){if(a===p)a=this.anchors.length;var c=this,h=this.options;e=d(h.tabTemplate.replace(/#\{href\}/g,b).replace(/#\{label\}/g,e));b=!b.indexOf("#")?b.replace("#",""):this._tabId(d("a",e)[0]);e.addClass("ui-state-default ui-corner-top").data("destroy.tabs",true);var j=c.element.find("#"+b);j.length||(j=d(h.panelTemplate).attr("id",b).data("destroy.tabs",true));j.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide");if(a>=this.lis.length){e.appendTo(this.list);j.appendTo(this.list[0].parentNode)}else{e.insertBefore(this.lis[a]); +j.insertBefore(this.panels[a])}h.disabled=d.map(h.disabled,function(k){return k>=a?++k:k});this._tabify();if(this.anchors.length==1){h.selected=0;e.addClass("ui-tabs-selected ui-state-active");j.removeClass("ui-tabs-hide");this.element.queue("tabs",function(){c._trigger("show",null,c._ui(c.anchors[0],c.panels[0]))});this.load(0)}this._trigger("add",null,this._ui(this.anchors[a],this.panels[a]));return this},remove:function(b){b=this._getIndex(b);var e=this.options,a=this.lis.eq(b).remove(),c=this.panels.eq(b).remove(); +if(a.hasClass("ui-tabs-selected")&&this.anchors.length>1)this.select(b+(b+1=b?--h:h});this._tabify();this._trigger("remove",null,this._ui(a.find("a")[0],c[0]));return this},enable:function(b){b=this._getIndex(b);var e=this.options;if(d.inArray(b,e.disabled)!=-1){this.lis.eq(b).removeClass("ui-state-disabled");e.disabled=d.grep(e.disabled,function(a){return a!=b});this._trigger("enable",null, +this._ui(this.anchors[b],this.panels[b]));return this}},disable:function(b){b=this._getIndex(b);var e=this.options;if(b!=e.selected){this.lis.eq(b).addClass("ui-state-disabled");e.disabled.push(b);e.disabled.sort();this._trigger("disable",null,this._ui(this.anchors[b],this.panels[b]))}return this},select:function(b){b=this._getIndex(b);if(b==-1)if(this.options.collapsible&&this.options.selected!=-1)b=this.options.selected;else return this;this.anchors.eq(b).trigger(this.options.event+".tabs");return this}, +load:function(b){b=this._getIndex(b);var e=this,a=this.options,c=this.anchors.eq(b)[0],h=d.data(c,"load.tabs");this.abort();if(!h||this.element.queue("tabs").length!==0&&d.data(c,"cache.tabs"))this.element.dequeue("tabs");else{this.lis.eq(b).addClass("ui-state-processing");if(a.spinner){var j=d("span",c);j.data("label.tabs",j.html()).html(a.spinner)}this.xhr=d.ajax(d.extend({},a.ajaxOptions,{url:h,success:function(k,n){e.element.find(e._sanitizeSelector(c.hash)).html(k);e._cleanup();a.cache&&d.data(c, +"cache.tabs",true);e._trigger("load",null,e._ui(e.anchors[b],e.panels[b]));try{a.ajaxOptions.success(k,n)}catch(m){}},error:function(k,n){e._cleanup();e._trigger("load",null,e._ui(e.anchors[b],e.panels[b]));try{a.ajaxOptions.error(k,n,b,c)}catch(m){}}}));e.element.dequeue("tabs");return this}},abort:function(){this.element.queue([]);this.panels.stop(false,true);this.element.queue("tabs",this.element.queue("tabs").splice(-2,2));if(this.xhr){this.xhr.abort();delete this.xhr}this._cleanup();return this}, +url:function(b,e){this.anchors.eq(b).removeData("cache.tabs").data("load.tabs",e);return this},length:function(){return this.anchors.length}});d.extend(d.ui.tabs,{version:"1.8.9"});d.extend(d.ui.tabs.prototype,{rotation:null,rotate:function(b,e){var a=this,c=this.options,h=a._rotate||(a._rotate=function(j){clearTimeout(a.rotation);a.rotation=setTimeout(function(){var k=c.selected;a.select(++k0){jQuery(".describe-toggle-on").show();jQuery(".describe-toggle-off").hide();jQuery(".slidetoggle").slideUp(200).siblings().removeClass("hidden")}jQuery("#media-items").append('
        '+fileObj.name+"
        ");jQuery(".progress","#media-item-"+fileObj.id).show();jQuery("#insert-gallery").attr("disabled","disabled");jQuery("#cancel-upload").attr("disabled","")}function uploadStart(fileObj){try{if(typeof topWin.tb_remove!="undefined"){topWin.jQuery("#TB_overlay").unbind("click",topWin.tb_remove)}}catch(e){}return true}function uploadProgress(fileObj,bytesDone,bytesTotal){var w=jQuery("#media-items").width()-2,item=jQuery("#media-item-"+fileObj.id);jQuery(".bar",item).width(w*bytesDone/bytesTotal);jQuery(".percent",item).html(Math.ceil(bytesDone/bytesTotal*100)+"%");if(bytesDone==bytesTotal){jQuery(".bar",item).html(''+swfuploadL10n.crunching+"")}}function prepareMediaItem(fileObj,serverData){var f=(typeof shortform=="undefined")?1:2,item=jQuery("#media-item-"+fileObj.id);jQuery(".bar",item).remove();jQuery(".progress",item).hide();try{if(typeof topWin.tb_remove!="undefined"){topWin.jQuery("#TB_overlay").click(topWin.tb_remove)}}catch(e){}if(isNaN(serverData)||!serverData){item.append(serverData);prepareMediaItemInit(fileObj)}else{item.load("async-upload.php",{attachment_id:serverData,fetch:f},function(){prepareMediaItemInit(fileObj);updateMediaForm()})}}function prepareMediaItemInit(fileObj){var item=jQuery("#media-item-"+fileObj.id);jQuery(".thumbnail",item).clone().attr("className","pinkynail toggle").prependTo(item);jQuery(".filename.original",item).replaceWith(jQuery(".filename.new",item));jQuery("a.toggle",item).click(function(){jQuery(this).siblings(".slidetoggle").slideToggle(350,function(){var w=jQuery(window).height(),t=jQuery(this).offset().top,h=jQuery(this).height(),b;if(w&&t&&h){b=t+h;if(b>w&&(h+48)w){window.scrollTo(0,t-36)}}}});jQuery(this).siblings(".toggle").andSelf().toggle();jQuery(this).siblings("a.toggle").focus();return false});jQuery("a.delete",item).click(function(){jQuery.ajax({url:"admin-ajax.php",type:"post",success:deleteSuccess,error:deleteError,id:fileObj.id,data:{id:this.id.replace(/[^0-9]/g,""),action:"trash-post",_ajax_nonce:this.href.replace(/^.*wpnonce=/,"")}});return false});jQuery("a.undo",item).click(function(){jQuery.ajax({url:"admin-ajax.php",type:"post",id:fileObj.id,data:{id:this.id.replace(/[^0-9]/g,""),action:"untrash-post",_ajax_nonce:this.href.replace(/^.*wpnonce=/,"")},success:function(data,textStatus){var item=jQuery("#media-item-"+fileObj.id);if(type=jQuery("#type-of-"+fileObj.id).val()){jQuery("#"+type+"-counter").text(jQuery("#"+type+"-counter").text()-0+1)}if(item.hasClass("child-of-"+post_id)){jQuery("#attachments-count").text(jQuery("#attachments-count").text()-0+1)}jQuery(".filename .trashnotice",item).remove();jQuery(".filename .title",item).css("font-weight","normal");jQuery("a.undo",item).addClass("hidden");jQuery("a.describe-toggle-on, .menu_order_input",item).show();item.css({backgroundColor:"#ceb"}).animate({backgroundColor:"#fff"},{queue:false,duration:500,complete:function(){jQuery(this).css({backgroundColor:""})}}).removeClass("undo")}});return false});jQuery("#media-item-"+fileObj.id+".startopen").removeClass("startopen").slideToggle(500).siblings(".toggle").toggle()}function itemAjaxError(id,html){var item=jQuery("#media-item-"+id);var filename=jQuery(".filename",item).text();item.html('
        '+swfuploadL10n.dismiss+""+swfuploadL10n.error_uploading.replace("%s",filename)+"
        "+html+"
        ");item.find("a.dismiss").click(function(){jQuery(this).parents(".media-item").slideUp(200,function(){jQuery(this).remove()})})}function deleteSuccess(data,textStatus){if(data=="-1"){return itemAjaxError(this.id,"You do not have permission. Has your session expired?")}if(data=="0"){return itemAjaxError(this.id,"Could not be deleted. Has it been deleted already?")}var id=this.id,item=jQuery("#media-item-"+id);if(type=jQuery("#type-of-"+id).val()){jQuery("#"+type+"-counter").text(jQuery("#"+type+"-counter").text()-1)}if(item.hasClass("child-of-"+post_id)){jQuery("#attachments-count").text(jQuery("#attachments-count").text()-1)}if(jQuery("form.type-form #media-items").children().length==1&&jQuery(".hidden","#media-items").length>0){jQuery(".toggle").toggle();jQuery(".slidetoggle").slideUp(200).siblings().removeClass("hidden")}jQuery(".toggle",item).toggle();jQuery(".slidetoggle",item).slideUp(200).siblings().removeClass("hidden");item.css({backgroundColor:"#faa"}).animate({backgroundColor:"#f4f4f4"},{queue:false,duration:500}).addClass("undo");jQuery(".filename:empty",item).remove();jQuery(".filename .title",item).css("font-weight","bold");jQuery(".filename",item).append(' '+swfuploadL10n.deleted+" ").siblings("a.toggle").hide();jQuery(".filename",item).append(jQuery("a.undo",item).removeClass("hidden"));jQuery(".menu_order_input",item).hide();return}function deleteError(X,textStatus,errorThrown){}function updateMediaForm(){var one=jQuery("form.type-form #media-items").children(),items=jQuery("#media-items").children();if(one.length==1){jQuery(".slidetoggle",one).slideDown(500).siblings().addClass("hidden").filter(".toggle").toggle()}if(items.not(".media-blank").length>0){jQuery(".savebutton").show()}else{jQuery(".savebutton").hide()}if(items.length>1){jQuery(".insert-gallery").show()}else{jQuery(".insert-gallery").hide()}}function uploadSuccess(fileObj,serverData){if(serverData.match("media-upload-error")){jQuery("#media-item-"+fileObj.id).html(serverData);return}prepareMediaItem(fileObj,serverData);updateMediaForm();if(jQuery("#media-item-"+fileObj.id).hasClass("child-of-"+post_id)){jQuery("#attachments-count").text(1*jQuery("#attachments-count").text()+1)}}function uploadComplete(fileObj){if(swfu.getStats().files_queued==0){jQuery("#cancel-upload").attr("disabled","disabled");jQuery("#insert-gallery").attr("disabled","")}}function wpQueueError(message){jQuery("#media-upload-error").show().text(message)}function wpFileError(fileObj,message){var item=jQuery("#media-item-"+fileObj.id);var filename=jQuery(".filename",item).text();item.html('
        '+swfuploadL10n.dismiss+""+swfuploadL10n.error_uploading.replace("%s",filename)+"
        "+message+"
        ");item.find("a.dismiss").click(function(){jQuery(this).parents(".media-item").slideUp(200,function(){jQuery(this).remove()})})}function fileQueueError(fileObj,error_code,message){if(error_code==SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED){wpQueueError(swfuploadL10n.queue_limit_exceeded)}else{if(error_code==SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT){fileQueued(fileObj);wpFileError(fileObj,swfuploadL10n.file_exceeds_size_limit)}else{if(error_code==SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE){fileQueued(fileObj);wpFileError(fileObj,swfuploadL10n.zero_byte_file)}else{if(error_code==SWFUpload.QUEUE_ERROR.INVALID_FILETYPE){fileQueued(fileObj);wpFileError(fileObj,swfuploadL10n.invalid_filetype)}else{wpQueueError(swfuploadL10n.default_error)}}}}}function fileDialogComplete(num_files_queued){try{if(num_files_queued>0){this.startUpload()}}catch(ex){this.debug(ex)}}function switchUploader(s){var f=document.getElementById(swfu.customSettings.swfupload_element_id),h=document.getElementById(swfu.customSettings.degraded_element_id);if(s){f.style.display="block";h.style.display="none"}else{f.style.display="none";h.style.display="block"}}function swfuploadPreLoad(){if(!uploaderMode){switchUploader(1)}else{switchUploader(0)}}function swfuploadLoadFailed(){switchUploader(0);jQuery(".upload-html-bypass").hide()}function uploadError(fileObj,errorCode,message){switch(errorCode){case SWFUpload.UPLOAD_ERROR.MISSING_UPLOAD_URL:wpFileError(fileObj,swfuploadL10n.missing_upload_url);break;case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED:wpFileError(fileObj,swfuploadL10n.upload_limit_exceeded);break;case SWFUpload.UPLOAD_ERROR.HTTP_ERROR:wpQueueError(swfuploadL10n.http_error);break;case SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED:wpQueueError(swfuploadL10n.upload_failed);break;case SWFUpload.UPLOAD_ERROR.IO_ERROR:wpQueueError(swfuploadL10n.io_error);break;case SWFUpload.UPLOAD_ERROR.SECURITY_ERROR:wpQueueError(swfuploadL10n.security_error);break;case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED:case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED:jQuery("#media-item-"+fileObj.id).remove();break;default:wpFileError(fileObj,swfuploadL10n.default_error)}}function cancelUpload(){swfu.cancelQueue()}jQuery(document).ready(function($){$('input[type="radio"]',"#media-items").live("click",function(){var tr=$(this).closest("tr");if($(tr).hasClass("align")){setUserSetting("align",$(this).val())}else{if($(tr).hasClass("image-size")){setUserSetting("imgsize",$(this).val())}}});$("button.button","#media-items").live("click",function(){var c=this.className||"";c=c.match(/url([^ '"]+)/);if(c&&c[1]){setUserSetting("urlbutton",c[1]);$(this).siblings(".urlfield").val($(this).attr("title"))}})}); \ No newline at end of file +var topWin=window.dialogArguments||opener||parent||top;function fileDialogStart(){jQuery("#media-upload-error").empty()}function fileQueued(a){jQuery(".media-blank").remove();if(jQuery("form.type-form #media-items").children().length==1&&jQuery(".hidden","#media-items").length>0){jQuery(".describe-toggle-on").show();jQuery(".describe-toggle-off").hide();jQuery(".slidetoggle").slideUp(200).siblings().removeClass("hidden")}jQuery("#media-items").append('
        '+a.name+"
        ");jQuery(".progress","#media-item-"+a.id).show();jQuery("#insert-gallery").attr("disabled","disabled");jQuery("#cancel-upload").attr("disabled","")}function uploadStart(a){try{if(typeof topWin.tb_remove!="undefined"){topWin.jQuery("#TB_overlay").unbind("click",topWin.tb_remove)}}catch(b){}return true}function uploadProgress(e,b,d){var a=jQuery("#media-items").width()-2,c=jQuery("#media-item-"+e.id);jQuery(".bar",c).width(a*b/d);jQuery(".percent",c).html(Math.ceil(b/d*100)+"%");if(b==d){jQuery(".bar",c).html(''+swfuploadL10n.crunching+"")}}function prepareMediaItem(c,a){var d=(typeof shortform=="undefined")?1:2,b=jQuery("#media-item-"+c.id);jQuery(".bar",b).remove();jQuery(".progress",b).hide();try{if(typeof topWin.tb_remove!="undefined"){topWin.jQuery("#TB_overlay").click(topWin.tb_remove)}}catch(g){}if(isNaN(a)||!a){b.append(a);prepareMediaItemInit(c)}else{b.load("async-upload.php",{attachment_id:a,fetch:d},function(){prepareMediaItemInit(c);updateMediaForm()})}}function prepareMediaItemInit(b){var a=jQuery("#media-item-"+b.id);jQuery(".thumbnail",a).clone().attr("className","pinkynail toggle").prependTo(a);jQuery(".filename.original",a).replaceWith(jQuery(".filename.new",a));jQuery("a.toggle",a).click(function(){jQuery(this).siblings(".slidetoggle").slideToggle(350,function(){var d=jQuery(window).height(),e=jQuery(this).offset().top,f=jQuery(this).height(),c;if(d&&e&&f){c=e+f;if(c>d&&(f+48)d){window.scrollTo(0,e-36)}}}});jQuery(this).siblings(".toggle").andSelf().toggle();jQuery(this).siblings("a.toggle").focus();return false});jQuery("a.delete",a).click(function(){jQuery.ajax({url:"admin-ajax.php",type:"post",success:deleteSuccess,error:deleteError,id:b.id,data:{id:this.id.replace(/[^0-9]/g,""),action:"trash-post",_ajax_nonce:this.href.replace(/^.*wpnonce=/,"")}});return false});jQuery("a.undo",a).click(function(){jQuery.ajax({url:"admin-ajax.php",type:"post",id:b.id,data:{id:this.id.replace(/[^0-9]/g,""),action:"untrash-post",_ajax_nonce:this.href.replace(/^.*wpnonce=/,"")},success:function(d,e){var c=jQuery("#media-item-"+b.id);if(type=jQuery("#type-of-"+b.id).val()){jQuery("#"+type+"-counter").text(jQuery("#"+type+"-counter").text()-0+1)}if(c.hasClass("child-of-"+post_id)){jQuery("#attachments-count").text(jQuery("#attachments-count").text()-0+1)}jQuery(".filename .trashnotice",c).remove();jQuery(".filename .title",c).css("font-weight","normal");jQuery("a.undo",c).addClass("hidden");jQuery("a.describe-toggle-on, .menu_order_input",c).show();c.css({backgroundColor:"#ceb"}).animate({backgroundColor:"#fff"},{queue:false,duration:500,complete:function(){jQuery(this).css({backgroundColor:""})}}).removeClass("undo")}});return false});jQuery("#media-item-"+b.id+".startopen").removeClass("startopen").slideToggle(500).siblings(".toggle").toggle()}function itemAjaxError(d,b){var c=jQuery("#media-item-"+d);var a=jQuery(".filename",c).text();c.html('
        '+swfuploadL10n.dismiss+""+swfuploadL10n.error_uploading.replace("%s",a)+"
        "+b+"
        ");c.find("a.dismiss").click(function(){jQuery(this).parents(".media-item").slideUp(200,function(){jQuery(this).remove()})})}function deleteSuccess(b,d){if(b=="-1"){return itemAjaxError(this.id,"You do not have permission. Has your session expired?")}if(b=="0"){return itemAjaxError(this.id,"Could not be deleted. Has it been deleted already?")}var c=this.id,a=jQuery("#media-item-"+c);if(type=jQuery("#type-of-"+c).val()){jQuery("#"+type+"-counter").text(jQuery("#"+type+"-counter").text()-1)}if(a.hasClass("child-of-"+post_id)){jQuery("#attachments-count").text(jQuery("#attachments-count").text()-1)}if(jQuery("form.type-form #media-items").children().length==1&&jQuery(".hidden","#media-items").length>0){jQuery(".toggle").toggle();jQuery(".slidetoggle").slideUp(200).siblings().removeClass("hidden")}jQuery(".toggle",a).toggle();jQuery(".slidetoggle",a).slideUp(200).siblings().removeClass("hidden");a.css({backgroundColor:"#faa"}).animate({backgroundColor:"#f4f4f4"},{queue:false,duration:500}).addClass("undo");jQuery(".filename:empty",a).remove();jQuery(".filename .title",a).css("font-weight","bold");jQuery(".filename",a).append(' '+swfuploadL10n.deleted+" ").siblings("a.toggle").hide();jQuery(".filename",a).append(jQuery("a.undo",a).removeClass("hidden"));jQuery(".menu_order_input",a).hide();return}function deleteError(c,b,a){}function updateMediaForm(){var b=jQuery("form.type-form #media-items").children(),a=jQuery("#media-items").children();if(b.length==1){jQuery(".slidetoggle",b).slideDown(500).siblings().addClass("hidden").filter(".toggle").toggle()}if(a.not(".media-blank").length>0){jQuery(".savebutton").show()}else{jQuery(".savebutton").hide()}if(a.length>1){jQuery(".insert-gallery").show()}else{jQuery(".insert-gallery").hide()}}function uploadSuccess(b,a){if(a.match("media-upload-error")){jQuery("#media-item-"+b.id).html(a);return}prepareMediaItem(b,a);updateMediaForm();if(jQuery("#media-item-"+b.id).hasClass("child-of-"+post_id)){jQuery("#attachments-count").text(1*jQuery("#attachments-count").text()+1)}}function uploadComplete(a){if(swfu.getStats().files_queued==0){jQuery("#cancel-upload").attr("disabled","disabled");jQuery("#insert-gallery").attr("disabled","")}}function wpQueueError(a){jQuery("#media-upload-error").show().text(a)}function wpFileError(d,c){var b=jQuery("#media-item-"+d.id);var a=jQuery(".filename",b).text();b.html('
        '+swfuploadL10n.dismiss+""+swfuploadL10n.error_uploading.replace("%s",a)+"
        "+c+"
        ");b.find("a.dismiss").click(function(){jQuery(this).parents(".media-item").slideUp(200,function(){jQuery(this).remove()})})}function fileQueueError(c,a,b){if(a==SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED){wpQueueError(swfuploadL10n.queue_limit_exceeded)}else{if(a==SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT){fileQueued(c);wpFileError(c,swfuploadL10n.file_exceeds_size_limit)}else{if(a==SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE){fileQueued(c);wpFileError(c,swfuploadL10n.zero_byte_file)}else{if(a==SWFUpload.QUEUE_ERROR.INVALID_FILETYPE){fileQueued(c);wpFileError(c,swfuploadL10n.invalid_filetype)}else{wpQueueError(swfuploadL10n.default_error)}}}}}function fileDialogComplete(b){try{if(b>0){this.startUpload()}}catch(a){this.debug(a)}}function switchUploader(b){var c=document.getElementById(swfu.customSettings.swfupload_element_id),a=document.getElementById(swfu.customSettings.degraded_element_id);if(b){c.style.display="block";a.style.display="none"}else{c.style.display="none";a.style.display="block"}}function swfuploadPreLoad(){if(!uploaderMode){switchUploader(1)}else{switchUploader(0)}}function swfuploadLoadFailed(){switchUploader(0);jQuery(".upload-html-bypass").hide()}function uploadError(b,c,a){switch(c){case SWFUpload.UPLOAD_ERROR.MISSING_UPLOAD_URL:wpFileError(b,swfuploadL10n.missing_upload_url);break;case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED:wpFileError(b,swfuploadL10n.upload_limit_exceeded);break;case SWFUpload.UPLOAD_ERROR.HTTP_ERROR:wpQueueError(swfuploadL10n.http_error);break;case SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED:wpQueueError(swfuploadL10n.upload_failed);break;case SWFUpload.UPLOAD_ERROR.IO_ERROR:wpQueueError(swfuploadL10n.io_error);break;case SWFUpload.UPLOAD_ERROR.SECURITY_ERROR:wpQueueError(swfuploadL10n.security_error);break;case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED:case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED:jQuery("#media-item-"+b.id).remove();break;default:wpFileError(b,swfuploadL10n.default_error)}}function cancelUpload(){swfu.cancelQueue()}jQuery(document).ready(function(a){a('input[type="radio"]',"#media-items").live("click",function(){var b=a(this).closest("tr");if(a(b).hasClass("align")){setUserSetting("align",a(this).val())}else{if(a(b).hasClass("image-size")){setUserSetting("imgsize",a(this).val())}}});a("button.button","#media-items").live("click",function(){var b=this.className||"";b=b.match(/url([^ '"]+)/);if(b&&b[1]){setUserSetting("urlbutton",b[1]);a(this).siblings(".urlfield").val(a(this).attr("title"))}})}); \ No newline at end of file diff --git a/wp-includes/js/swfupload/license.txt b/wp-includes/js/swfupload/license.txt new file mode 100644 index 00000000..8252ca9e --- /dev/null +++ b/wp-includes/js/swfupload/license.txt @@ -0,0 +1,32 @@ +/** + * SWFUpload: http://www.swfupload.org, http://swfupload.googlecode.com + * + * mmSWFUpload 1.0: Flash upload dialog - http://profandesign.se/swfupload/, http://www.vinterwebb.se/ + * + * SWFUpload is (c) 2006-2007 Lars Huring, Olov Nilzén and Mammon Media and is released under the MIT License: + * http://www.opensource.org/licenses/mit-license.php + * + * SWFUpload 2 is (c) 2007-2008 Jake Roberts and is released under the MIT License: + * http://www.opensource.org/licenses/mit-license.php + * + */ + +The MIT License + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/wp-includes/js/tinymce/blank.htm b/wp-includes/js/tinymce/blank.htm deleted file mode 100644 index 0ef25247..00000000 --- a/wp-includes/js/tinymce/blank.htm +++ /dev/null @@ -1,9 +0,0 @@ - - - - blank_page - - - - - diff --git a/wp-includes/js/tinymce/langs/wp-langs-en.js b/wp-includes/js/tinymce/langs/wp-langs-en.js index e464a8ef..32935a75 100644 --- a/wp-includes/js/tinymce/langs/wp-langs-en.js +++ b/wp-includes/js/tinymce/langs/wp-langs-en.js @@ -425,7 +425,7 @@ s100:"100%", s110:"110%", s120:"120%", s130:"130%", -img_title:"Edit Image Title", -caption:"Edit Image Caption", -alt:"Edit Alternate Text" +img_title:"Title", +caption:"Caption", +alt:"Alternate Text" }); diff --git a/wp-includes/js/tinymce/langs/wp-langs.php b/wp-includes/js/tinymce/langs/wp-langs.php index d1ac555f..52fc15b5 100644 --- a/wp-includes/js/tinymce/langs/wp-langs.php +++ b/wp-includes/js/tinymce/langs/wp-langs.php @@ -448,8 +448,8 @@ s100:"' . mce_escape( __('100%') ) . '", s110:"' . mce_escape( __('110%') ) . '", s120:"' . mce_escape( __('120%') ) . '", s130:"' . mce_escape( __('130%') ) . '", -img_title:"' . mce_escape( __('Edit Image Title') ) . '", -caption:"' . mce_escape( __('Edit Image Caption') ) . '", -alt:"' . mce_escape( __('Edit Alternate Text') ) . '" +img_title:"' . mce_escape( __('Title') ) . '", +caption:"' . mce_escape( __('Caption') ) . '", +alt:"' . mce_escape( __('Alternate Text') ) . '" }); '; diff --git a/wp-includes/js/tinymce/plugins/fullscreen/editor_plugin.js b/wp-includes/js/tinymce/plugins/fullscreen/editor_plugin.js index dfb3f16c..4437bd26 100644 --- a/wp-includes/js/tinymce/plugins/fullscreen/editor_plugin.js +++ b/wp-includes/js/tinymce/plugins/fullscreen/editor_plugin.js @@ -1 +1 @@ -(function(){var a=tinymce.DOM;tinymce.create("tinymce.plugins.FullScreenPlugin",{init:function(c,d){var e=this,f={},b;e.editor=c;c.addCommand("mceFullScreen",function(){var h,i=a.doc.documentElement;if(c.getParam("fullscreen_is_enabled")){if(c.getParam("fullscreen_new_window")){closeFullscreen()}else{a.win.setTimeout(function(){tinymce.dom.Event.remove(a.win,"resize",e.resizeFunc);tinyMCE.get(c.getParam("fullscreen_editor_id")).setContent(c.getContent({format:"raw"}),{format:"raw"});tinyMCE.remove(c);a.remove("mce_fullscreen_container");i.style.overflow=c.getParam("fullscreen_html_overflow");a.setStyle(a.doc.body,"overflow",c.getParam("fullscreen_overflow"));a.win.scrollTo(c.getParam("fullscreen_scrollx"),c.getParam("fullscreen_scrolly"));tinyMCE.settings=tinyMCE.oldSettings},10)}return}if(c.getParam("fullscreen_new_window")){h=a.win.open(d+"/fullscreen.htm","mceFullScreenPopup","fullscreen=yes,menubar=no,toolbar=no,scrollbars=no,resizable=yes,left=0,top=0,width="+screen.availWidth+",height="+screen.availHeight);try{h.resizeTo(screen.availWidth,screen.availHeight)}catch(g){}}else{tinyMCE.oldSettings=tinyMCE.settings;f.fullscreen_overflow=a.getStyle(a.doc.body,"overflow",1)||"auto";f.fullscreen_html_overflow=a.getStyle(i,"overflow",1);b=a.getViewPort();f.fullscreen_scrollx=b.x;f.fullscreen_scrolly=b.y;if(tinymce.isOpera&&f.fullscreen_overflow=="visible"){f.fullscreen_overflow="auto"}if(tinymce.isIE&&f.fullscreen_overflow=="scroll"){f.fullscreen_overflow="auto"}if(tinymce.isIE&&(f.fullscreen_html_overflow=="visible"||f.fullscreen_html_overflow=="scroll")){f.fullscreen_html_overflow="auto"}if(f.fullscreen_overflow=="0px"){f.fullscreen_overflow=""}a.setStyle(a.doc.body,"overflow","hidden");i.style.overflow="hidden";b=a.getViewPort();a.win.scrollTo(0,0);if(tinymce.isIE){b.h-=1}n=a.add(a.doc.body,"div",{id:"mce_fullscreen_container",style:"position:"+(tinymce.isIE6||(tinymce.isIE&&!a.boxModel)?"absolute":"fixed")+";top:0;left:0;width:"+b.w+"px;height:"+b.h+"px;z-index:200000;"});a.add(n,"div",{id:"mce_fullscreen"});tinymce.each(c.settings,function(j,k){f[k]=j});f.id="mce_fullscreen";f.width=n.clientWidth;f.height=n.clientHeight-15;f.fullscreen_is_enabled=true;f.fullscreen_editor_id=c.id;f.theme_advanced_resizing=false;f.save_onsavecallback=function(){c.setContent(tinyMCE.get(f.id).getContent({format:"raw"}),{format:"raw"});c.execCommand("mceSave")};tinymce.each(c.getParam("fullscreen_settings"),function(l,j){f[j]=l});if(f.theme_advanced_toolbar_location==="external"){f.theme_advanced_toolbar_location="top"}e.fullscreenEditor=new tinymce.Editor("mce_fullscreen",f);e.fullscreenEditor.onInit.add(function(){e.fullscreenEditor.setContent(c.getContent());e.fullscreenEditor.focus()});e.fullscreenEditor.render();tinyMCE.add(e.fullscreenEditor);e.fullscreenElement=new tinymce.dom.Element("mce_fullscreen_container");e.fullscreenElement.update();e.resizeFunc=tinymce.dom.Event.add(a.win,"resize",function(){var j=tinymce.DOM.getViewPort();e.fullscreenEditor.theme.resizeTo(j.w,j.h)})}});c.addButton("fullscreen",{title:"fullscreen.desc",cmd:"mceFullScreen"});c.onNodeChange.add(function(h,g){g.setActive("fullscreen",h.getParam("fullscreen_is_enabled"))})},getInfo:function(){return{longname:"Fullscreen",author:"Moxiecode Systems AB",authorurl:"http://tinymce.moxiecode.com",infourl:"http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/fullscreen",version:tinymce.majorVersion+"."+tinymce.minorVersion}}});tinymce.PluginManager.add("fullscreen",tinymce.plugins.FullScreenPlugin)})(); \ No newline at end of file +(function(){var a=tinymce.DOM;tinymce.create("tinymce.plugins.FullScreenPlugin",{init:function(c,d){var e=this,f={},b;e.editor=c;c.addCommand("mceFullScreen",function(){var h,i=a.doc.documentElement;if(c.getParam("fullscreen_is_enabled")){if(c.getParam("fullscreen_new_window")){closeFullscreen()}else{a.win.setTimeout(function(){tinymce.dom.Event.remove(a.win,"resize",e.resizeFunc);tinyMCE.get(c.getParam("fullscreen_editor_id")).setContent(c.getContent({format:"raw"}),{format:"raw"});tinyMCE.remove(c);a.remove("mce_fullscreen_container");i.style.overflow=c.getParam("fullscreen_html_overflow");a.setStyle(a.doc.body,"overflow",c.getParam("fullscreen_overflow"));a.win.scrollTo(c.getParam("fullscreen_scrollx"),c.getParam("fullscreen_scrolly"));tinyMCE.settings=tinyMCE.oldSettings},10)}return}if(c.getParam("fullscreen_new_window")){h=a.win.open(d+"/fullscreen.htm","mceFullScreenPopup","fullscreen=yes,menubar=no,toolbar=no,scrollbars=no,resizable=yes,left=0,top=0,width="+screen.availWidth+",height="+screen.availHeight);try{h.resizeTo(screen.availWidth,screen.availHeight)}catch(g){}}else{tinyMCE.oldSettings=tinyMCE.settings;f.fullscreen_overflow=a.getStyle(a.doc.body,"overflow",1)||"auto";f.fullscreen_html_overflow=a.getStyle(i,"overflow",1);b=a.getViewPort();f.fullscreen_scrollx=b.x;f.fullscreen_scrolly=b.y;if(tinymce.isOpera&&f.fullscreen_overflow=="visible"){f.fullscreen_overflow="auto"}if(tinymce.isIE&&f.fullscreen_overflow=="scroll"){f.fullscreen_overflow="auto"}if(tinymce.isIE&&(f.fullscreen_html_overflow=="visible"||f.fullscreen_html_overflow=="scroll")){f.fullscreen_html_overflow="auto"}if(f.fullscreen_overflow=="0px"){f.fullscreen_overflow=""}a.setStyle(a.doc.body,"overflow","hidden");i.style.overflow="hidden";b=a.getViewPort();a.win.scrollTo(0,0);if(tinymce.isIE){b.h-=1}n=a.add(a.doc.body,"div",{id:"mce_fullscreen_container",style:"position:"+(tinymce.isIE6||(tinymce.isIE&&!a.boxModel)?"absolute":"fixed")+";top:0;left:0;width:"+b.w+"px;height:"+b.h+"px;z-index:200000;"});a.add(n,"div",{id:"mce_fullscreen"});tinymce.each(c.settings,function(j,k){f[k]=j});f.id="mce_fullscreen";f.width=n.clientWidth;f.height=n.clientHeight-15;f.fullscreen_is_enabled=true;f.fullscreen_editor_id=c.id;f.theme_advanced_resizing=false;f.save_onsavecallback=function(){c.setContent(tinyMCE.get(f.id).getContent({format:"raw"}),{format:"raw"});c.execCommand("mceSave")};tinymce.each(c.getParam("fullscreen_settings"),function(l,j){f[j]=l});if(f.theme_advanced_toolbar_location==="external"){f.theme_advanced_toolbar_location="top"}e.fullscreenEditor=new tinymce.Editor("mce_fullscreen",f);e.fullscreenEditor.onInit.add(function(){e.fullscreenEditor.setContent(c.getContent());e.fullscreenEditor.focus()});e.fullscreenEditor.render();e.fullscreenElement=new tinymce.dom.Element("mce_fullscreen_container");e.fullscreenElement.update();e.resizeFunc=tinymce.dom.Event.add(a.win,"resize",function(){var m=tinymce.DOM.getViewPort(),k=e.fullscreenEditor,j,l;j=k.dom.getSize(k.getContainer().firstChild);l=k.dom.getSize(k.getContainer().getElementsByTagName("iframe")[0]);k.theme.resizeTo(m.w-j.w+l.w,m.h-j.h+l.h)})}});c.addButton("fullscreen",{title:"fullscreen.desc",cmd:"mceFullScreen"});c.onNodeChange.add(function(h,g){g.setActive("fullscreen",h.getParam("fullscreen_is_enabled"))})},getInfo:function(){return{longname:"Fullscreen",author:"Moxiecode Systems AB",authorurl:"http://tinymce.moxiecode.com",infourl:"http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/fullscreen",version:tinymce.majorVersion+"."+tinymce.minorVersion}}});tinymce.PluginManager.add("fullscreen",tinymce.plugins.FullScreenPlugin)})(); \ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/fullscreen/fullscreen.htm b/wp-includes/js/tinymce/plugins/fullscreen/fullscreen.htm index b1243a08..ae5c3b25 100644 --- a/wp-includes/js/tinymce/plugins/fullscreen/fullscreen.htm +++ b/wp-includes/js/tinymce/plugins/fullscreen/fullscreen.htm @@ -2,8 +2,7 @@ - - + '); - -function init() { - var pl = "", f, val; - var type = "flash", fe, i; - - ed = tinyMCEPopup.editor; - - tinyMCEPopup.resizeToInnerSize(); - f = document.forms[0] - - fe = ed.selection.getNode(); - if (/mceItem(Flash|ShockWave|WindowsMedia|QuickTime|RealMedia)/.test(ed.dom.getAttrib(fe, 'class'))) { - pl = fe.title; - - switch (ed.dom.getAttrib(fe, 'class')) { - case 'mceItemFlash': - type = 'flash'; - break; - - case 'mceItemFlashVideo': - type = 'flv'; - break; - - case 'mceItemShockWave': - type = 'shockwave'; - break; - - case 'mceItemWindowsMedia': - type = 'wmp'; - break; - - case 'mceItemQuickTime': - type = 'qt'; - break; - - case 'mceItemRealMedia': - type = 'rmp'; - break; - } - - document.forms[0].insert.value = ed.getLang('update', 'Insert', true); - } - - document.getElementById('filebrowsercontainer').innerHTML = getBrowserHTML('filebrowser','src','media','media'); - document.getElementById('qtsrcfilebrowsercontainer').innerHTML = getBrowserHTML('qtsrcfilebrowser','qt_qtsrc','media','media'); - document.getElementById('bgcolor_pickcontainer').innerHTML = getColorPickerHTML('bgcolor_pick','bgcolor'); - - var html = getMediaListHTML('medialist','src','media','media'); - if (html == "") - document.getElementById("linklistrow").style.display = 'none'; - else - document.getElementById("linklistcontainer").innerHTML = html; - - // Resize some elements - if (isVisible('filebrowser')) - document.getElementById('src').style.width = '230px'; - - // Setup form - if (pl != "") { - pl = tinyMCEPopup.editor.plugins.media._parse(pl); - - switch (type) { - case "flash": - setBool(pl, 'flash', 'play'); - setBool(pl, 'flash', 'loop'); - setBool(pl, 'flash', 'menu'); - setBool(pl, 'flash', 'swliveconnect'); - setStr(pl, 'flash', 'quality'); - setStr(pl, 'flash', 'scale'); - setStr(pl, 'flash', 'salign'); - setStr(pl, 'flash', 'wmode'); - setStr(pl, 'flash', 'base'); - setStr(pl, 'flash', 'flashvars'); - break; - - case "qt": - setBool(pl, 'qt', 'loop'); - setBool(pl, 'qt', 'autoplay'); - setBool(pl, 'qt', 'cache'); - setBool(pl, 'qt', 'controller'); - setBool(pl, 'qt', 'correction'); - setBool(pl, 'qt', 'enablejavascript'); - setBool(pl, 'qt', 'kioskmode'); - setBool(pl, 'qt', 'autohref'); - setBool(pl, 'qt', 'playeveryframe'); - setBool(pl, 'qt', 'tarsetcache'); - setStr(pl, 'qt', 'scale'); - setStr(pl, 'qt', 'starttime'); - setStr(pl, 'qt', 'endtime'); - setStr(pl, 'qt', 'tarset'); - setStr(pl, 'qt', 'qtsrcchokespeed'); - setStr(pl, 'qt', 'volume'); - setStr(pl, 'qt', 'qtsrc'); - break; - - case "shockwave": - setBool(pl, 'shockwave', 'sound'); - setBool(pl, 'shockwave', 'progress'); - setBool(pl, 'shockwave', 'autostart'); - setBool(pl, 'shockwave', 'swliveconnect'); - setStr(pl, 'shockwave', 'swvolume'); - setStr(pl, 'shockwave', 'swstretchstyle'); - setStr(pl, 'shockwave', 'swstretchhalign'); - setStr(pl, 'shockwave', 'swstretchvalign'); - break; - - case "wmp": - setBool(pl, 'wmp', 'autostart'); - setBool(pl, 'wmp', 'enabled'); - setBool(pl, 'wmp', 'enablecontextmenu'); - setBool(pl, 'wmp', 'fullscreen'); - setBool(pl, 'wmp', 'invokeurls'); - setBool(pl, 'wmp', 'mute'); - setBool(pl, 'wmp', 'stretchtofit'); - setBool(pl, 'wmp', 'windowlessvideo'); - setStr(pl, 'wmp', 'balance'); - setStr(pl, 'wmp', 'baseurl'); - setStr(pl, 'wmp', 'captioningid'); - setStr(pl, 'wmp', 'currentmarker'); - setStr(pl, 'wmp', 'currentposition'); - setStr(pl, 'wmp', 'defaultframe'); - setStr(pl, 'wmp', 'playcount'); - setStr(pl, 'wmp', 'rate'); - setStr(pl, 'wmp', 'uimode'); - setStr(pl, 'wmp', 'volume'); - break; - - case "rmp": - setBool(pl, 'rmp', 'autostart'); - setBool(pl, 'rmp', 'loop'); - setBool(pl, 'rmp', 'autogotourl'); - setBool(pl, 'rmp', 'center'); - setBool(pl, 'rmp', 'imagestatus'); - setBool(pl, 'rmp', 'maintainaspect'); - setBool(pl, 'rmp', 'nojava'); - setBool(pl, 'rmp', 'prefetch'); - setBool(pl, 'rmp', 'shuffle'); - setStr(pl, 'rmp', 'console'); - setStr(pl, 'rmp', 'controls'); - setStr(pl, 'rmp', 'numloop'); - setStr(pl, 'rmp', 'scriptcallbacks'); - break; - } - - setStr(pl, null, 'src'); - setStr(pl, null, 'id'); - setStr(pl, null, 'name'); - setStr(pl, null, 'vspace'); - setStr(pl, null, 'hspace'); - setStr(pl, null, 'bgcolor'); - setStr(pl, null, 'align'); - setStr(pl, null, 'width'); - setStr(pl, null, 'height'); - - if ((val = ed.dom.getAttrib(fe, "width")) != "") - pl.width = f.width.value = val; - - if ((val = ed.dom.getAttrib(fe, "height")) != "") - pl.height = f.height.value = val; - - oldWidth = pl.width ? parseInt(pl.width) : 0; - oldHeight = pl.height ? parseInt(pl.height) : 0; - } else - oldWidth = oldHeight = 0; - - selectByValue(f, 'media_type', type); - changedType(type); - updateColor('bgcolor_pick', 'bgcolor'); - - TinyMCE_EditableSelects.init(); - generatePreview(); -} - -function insertMedia() { - var fe, f = document.forms[0], h; - - tinyMCEPopup.restoreSelection(); - - if (!AutoValidator.validate(f)) { - tinyMCEPopup.alert(ed.getLang('invalid_data')); - return false; - } - - f.width.value = f.width.value == "" ? 100 : f.width.value; - f.height.value = f.height.value == "" ? 100 : f.height.value; - - fe = ed.selection.getNode(); - if (fe != null && /mceItem(Flash|ShockWave|WindowsMedia|QuickTime|RealMedia)/.test(ed.dom.getAttrib(fe, 'class'))) { - switch (f.media_type.options[f.media_type.selectedIndex].value) { - case "flash": - fe.className = "mceItemFlash"; - break; - - case "flv": - fe.className = "mceItemFlashVideo"; - break; - - case "shockwave": - fe.className = "mceItemShockWave"; - break; - - case "qt": - fe.className = "mceItemQuickTime"; - break; - - case "wmp": - fe.className = "mceItemWindowsMedia"; - break; - - case "rmp": - fe.className = "mceItemRealMedia"; - break; - } - - if (fe.width != f.width.value || fe.height != f.height.value) - ed.execCommand('mceRepaint'); - - fe.title = serializeParameters(); - fe.width = f.width.value; - fe.height = f.height.value; - fe.style.width = f.width.value + (f.width.value.indexOf('%') == -1 ? 'px' : ''); - fe.style.height = f.height.value + (f.height.value.indexOf('%') == -1 ? 'px' : ''); - fe.align = f.align.options[f.align.selectedIndex].value; - } else { - h = ' 0) { - var html = ""; - - html += ''; - - return html; - } - - return ""; -} - -function getType(v) { - var fo, i, c, el, x, f = document.forms[0]; - - fo = ed.getParam("media_types", "flash=swf;flv=flv;shockwave=dcr;qt=mov,qt,mpg,mp3,mp4,mpeg;shockwave=dcr;wmp=avi,wmv,wm,asf,asx,wmx,wvx;rmp=rm,ra,ram").split(';'); - - // YouTube - if (v.match(/watch\?v=(.+)(.*)/)) { - f.width.value = '425'; - f.height.value = '350'; - f.src.value = 'http://www.youtube.com/v/' + v.match(/v=(.*)(.*)/)[0].split('=')[1]; - return 'flash'; - } - - // Google video - if (v.indexOf('http://video.google.com/videoplay?docid=') == 0) { - f.width.value = '425'; - f.height.value = '326'; - f.src.value = 'http://video.google.com/googleplayer.swf?docId=' + v.substring('http://video.google.com/videoplay?docid='.length) + '&hl=en'; - return 'flash'; - } - - for (i=0; i 0 ? s.substring(0, s.length - 1) : s; - - return s; -} - -function setBool(pl, p, n) { - if (typeof(pl[n]) == "undefined") - return; - - document.forms[0].elements[p + "_" + n].checked = pl[n] != 'false'; -} - -function setStr(pl, p, n) { - var f = document.forms[0], e = f.elements[(p != null ? p + "_" : '') + n]; - - if (typeof(pl[n]) == "undefined") - return; - - if (e.type == "text") - e.value = pl[n]; - else - selectByValue(f, (p != null ? p + "_" : '') + n, pl[n]); -} - -function getBool(p, n, d, tv, fv) { - var v = document.forms[0].elements[p + "_" + n].checked; - - tv = typeof(tv) == 'undefined' ? 'true' : "'" + jsEncode(tv) + "'"; - fv = typeof(fv) == 'undefined' ? 'false' : "'" + jsEncode(fv) + "'"; - - return (v == d) ? '' : n + (v ? ':' + tv + ',' : ":\'" + fv + "\',"); -} - -function getStr(p, n, d) { - var e = document.forms[0].elements[(p != null ? p + "_" : "") + n]; - var v = e.type == "text" ? e.value : e.options[e.selectedIndex].value; - - if (n == 'src') - v = tinyMCEPopup.editor.convertURL(v, 'src', null); - - return ((n == d || v == '') ? '' : n + ":'" + jsEncode(v) + "',"); -} - -function getInt(p, n, d) { - var e = document.forms[0].elements[(p != null ? p + "_" : "") + n]; - var v = e.type == "text" ? e.value : e.options[e.selectedIndex].value; - - return ((n == d || v == '') ? '' : n + ":" + v.replace(/[^0-9]+/g, '') + ","); -} - -function jsEncode(s) { - s = s.replace(new RegExp('\\\\', 'g'), '\\\\'); - s = s.replace(new RegExp('"', 'g'), '\\"'); - s = s.replace(new RegExp("'", 'g'), "\\'"); - - return s; -} - -function generatePreview(c) { - var f = document.forms[0], p = document.getElementById('prev'), h = '', cls, pl, n, type, codebase, wp, hp, nw, nh; - - p.innerHTML = ''; - - nw = parseInt(f.width.value); - nh = parseInt(f.height.value); - - if (f.width.value != "" && f.height.value != "") { - if (f.constrain.checked) { - if (c == 'width' && oldWidth != 0) { - wp = nw / oldWidth; - nh = Math.round(wp * nh); - f.height.value = nh; - } else if (c == 'height' && oldHeight != 0) { - hp = nh / oldHeight; - nw = Math.round(hp * nw); - f.width.value = nw; - } - } - } - - if (f.width.value != "") - oldWidth = nw; - - if (f.height.value != "") - oldHeight = nh; - - // After constrain - pl = serializeParameters(); - - switch (f.media_type.options[f.media_type.selectedIndex].value) { - case "flash": - cls = 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'; - codebase = 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0'; - type = 'application/x-shockwave-flash'; - break; - - case "shockwave": - cls = 'clsid:166B1BCA-3F9C-11CF-8075-444553540000'; - codebase = 'http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=8,5,1,0'; - type = 'application/x-director'; - break; - - case "qt": - cls = 'clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B'; - codebase = 'http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0'; - type = 'video/quicktime'; - break; - - case "wmp": - cls = ed.getParam('media_wmp6_compatible') ? 'clsid:05589FA1-C356-11CE-BF01-00AA0055595A' : 'clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6'; - codebase = 'http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701'; - type = 'application/x-mplayer2'; - break; - - case "rmp": - cls = 'clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA'; - codebase = 'http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701'; - type = 'audio/x-pn-realaudio-plugin'; - break; - } - - if (pl == '') { - p.innerHTML = ''; - return; - } - - pl = tinyMCEPopup.editor.plugins.media._parse(pl); - - if (!pl.src) { - p.innerHTML = ''; - return; - } - - pl.src = tinyMCEPopup.editor.documentBaseURI.toAbsolute(pl.src); - pl.width = !pl.width ? 100 : pl.width; - pl.height = !pl.height ? 100 : pl.height; - pl.id = !pl.id ? 'obj' : pl.id; - pl.name = !pl.name ? 'eobj' : pl.name; - pl.align = !pl.align ? '' : pl.align; - - // Avoid annoying warning about insecure items - if (!tinymce.isIE || document.location.protocol != 'https:') { - h += ''; - - for (n in pl) { - h += ''; - - // Add extra url parameter if it's an absolute URL - if (n == 'src' && pl[n].indexOf('://') != -1) - h += ''; - } - } - - h += ' - - - {#media_dlg.title} - - - - - - - - - -
        - - -
        -
        -
        - {#media_dlg.general} - -
        - - - - - - - - - - - - - - - - -
        - -
        - - - - - -
         
        -
        - - - - - - -
        x   
        -
        - - -
        - {#media_dlg.preview} - -
        -
        - -
        -
        - {#media_dlg.advanced} - - - - - - - - - - - - - - - - - - - - - - - -
        - - - - - - - -
         
        -
        -
        - -
        - {#media_dlg.flash_options} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        - - - -
        - - - -
        - - - - - -
        -
        - - - - - -
        -
        - - - - - -
        -
        - - - - - -
        -
        - - - - - - - - - - - -
        -
        - -
        - {#media_dlg.flv_options} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        - -
        - - - - - -
        -
        - - - - - -
        -
        - - - - - -
        -
        - - - - - -
        -
        - - - - - -
        -
        - - - - - -
        -
        -
        - -
        - {#media_dlg.qt_options} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        - - - - - -
        -
        - - - - - -
        -
        - - - - - -
        -
        - - - - - -
        -
        - - - - - -
        -
        - - - - - -
        -
        - - - - - -
        -
        - - - - - -
        -
        - - - - - -
        -
        - - - - - -
        -
        -  
        - - - - - -
         
        -
        -
        - -
        - {#media_dlg.wmp_options} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        - - - - - -
        -
        - - - - - -
        -
        - - - - - -
        -
        - - - - - -
        -
        - - - - - -
        -
        - - - - - -
        -
        - - - - - -
        -
        - - - - - -
        -
        -
        - -
        - {#media_dlg.rmp_options} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        - - - - - -
        -
        - - - - - -
        -
        - - - - - -
        -
        - - - - - -
        -
        - - - - - -
        -
        - - - - - -
        -
        - - - - - -
        -
        - - - - - -
        -
        - - - - - -
        -
        -   -
        -
        - -
        - {#media_dlg.shockwave_options} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        - -
        - - - -
        - - - - - -
        -
        - - - - - -
        -
        - - - - - -
        -
        - - - - - -
        -
        -
        -
        -
        - -
        -
        - -
        - -
        - -
        -
        - - - diff --git a/wp-includes/js/tinymce/plugins/paste/editor_plugin.js b/wp-includes/js/tinymce/plugins/paste/editor_plugin.js index 7b2bbd9b..55205957 100644 --- a/wp-includes/js/tinymce/plugins/paste/editor_plugin.js +++ b/wp-includes/js/tinymce/plugins/paste/editor_plugin.js @@ -1 +1 @@ -(function(){var a=tinymce.each;tinymce.create("tinymce.plugins.PastePlugin",{init:function(c,d){var e=this,b;e.editor=c;e.url=d;e.onPreProcess=new tinymce.util.Dispatcher(e);e.onPostProcess=new tinymce.util.Dispatcher(e);e.onPreProcess.add(e._preProcess);e.onPostProcess.add(e._postProcess);e.onPreProcess.add(function(h,i){c.execCallback("paste_preprocess",h,i)});e.onPostProcess.add(function(h,i){c.execCallback("paste_postprocess",h,i)});function g(i){var h=c.dom;e.onPreProcess.dispatch(e,i);i.node=h.create("div",0,i.content);e.onPostProcess.dispatch(e,i);i.content=c.serializer.serialize(i.node,{getInner:1});if(/<(p|h[1-6]|ul|ol)/.test(i.content)){e._insertBlockContent(c,h,i.content)}else{e._insert(i.content)}}c.addCommand("mceInsertClipboardContent",function(h,i){g(i)});function f(l){var p,k,i,j=c.selection,o=c.dom,h=c.getBody(),m;if(o.get("_mcePaste")){return}p=o.add(h,"div",{id:"_mcePaste"},"\uFEFF");if(h!=c.getDoc().body){m=o.getPos(c.selection.getStart(),h).y}else{m=h.scrollTop}o.setStyles(p,{position:"absolute",left:-10000,top:m,width:1,height:1,overflow:"hidden"});if(tinymce.isIE){i=o.doc.body.createTextRange();i.moveToElementText(p);i.execCommand("Paste");o.remove(p);if(p.innerHTML==="\uFEFF"){c.execCommand("mcePasteWord");l.preventDefault();return}g({content:p.innerHTML});return tinymce.dom.Event.cancel(l)}else{k=c.selection.getRng();p=p.firstChild;i=c.getDoc().createRange();i.setStart(p,0);i.setEnd(p,1);j.setRng(i);window.setTimeout(function(){var q="",n=o.select("div[id=_mcePaste]");a(n,function(r){q+=(o.select("> span.Apple-style-span div",r)[0]||o.select("> span.Apple-style-span",r)[0]||r).innerHTML});a(n,function(r){o.remove(r)});if(k){j.setRng(k)}g({content:q})},0)}}if(c.getParam("paste_auto_cleanup_on_paste",true)){if(tinymce.isOpera||/Firefox\/2/.test(navigator.userAgent)){c.onKeyDown.add(function(h,i){if(((tinymce.isMac?i.metaKey:i.ctrlKey)&&i.keyCode==86)||(i.shiftKey&&i.keyCode==45)){f(i)}})}else{c.onPaste.addToTop(function(h,i){return f(i)})}}if(c.getParam("paste_block_drop")){c.onInit.add(function(){c.dom.bind(c.getBody(),["dragend","dragover","draggesture","dragdrop","drop","drag"],function(h){h.preventDefault();h.stopPropagation();return false})})}e._legacySupport()},getInfo:function(){return{longname:"Paste text/word",author:"Moxiecode Systems AB",authorurl:"http://tinymce.moxiecode.com",infourl:"http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/paste",version:tinymce.majorVersion+"."+tinymce.minorVersion}},_preProcess:function(d,i){var b=this.editor,c=i.content,g,f;function g(h){a(h,function(j){if(j.constructor==RegExp){c=c.replace(j,"")}else{c=c.replace(j[0],j[1])}})}if(/(class=\"?Mso|style=\"[^\"]*\bmso\-|w:WordDocument)/.test(c)||i.wordContent){i.wordContent=true;g([/^\s*( )+/g,/( |]*>)+\s*$/g]);if(b.getParam("paste_convert_middot_lists",true)){g([[//gi,"$&__MCE_ITEM__"],[/(]+:\s*symbol[^>]+>)/gi,"$1__MCE_ITEM__"],[/(]+mso-list:[^>]+>)/gi,"$1__MCE_ITEM__"]])}g([//gi,/<\/?(img|font|meta|link|style|div|v:\w+)[^>]*>/gi,/<\\?\?xml[^>]*>/gi,/<\/?o:[^>]*>/gi,/ (id|name|language|type|on\w+|v:\w+)=\"([^\"]*)\"/gi,/ (id|name|language|type|on\w+|v:\w+)=(\w+)/gi,[/<(\/?)s>/gi,"<$1strike>"],/]+>[\s\S]*?<\/script>/gi,[/ /g,"\u00a0"]]);if(!b.getParam("paste_retain_style_properties")){g([/<\/?(span)[^>]*>/gi])}}f=b.getParam("paste_strip_class_attributes");if(f!="none"){function e(l,h){var k,j="";if(f=="all"){return""}h=tinymce.explode(h," ");for(k=h.length-1;k>=0;k--){if(!/^(Mso)/i.test(h[k])){j+=(!j?"":" ")+h[k]}}return' class="'+j+'"'}g([[/ class=\"([^\"]*)\"/gi,e],[/ class=(\w+)/gi,e]])}if(b.getParam("paste_remove_spans")){g([/<\/?(span)[^>]*>/gi])}i.content=c},_postProcess:function(e,g){var d=this,c=d.editor,f=c.dom,b;if(g.wordContent){a(f.select("a",g.node),function(h){if(!h.href||h.href.indexOf("#_Toc")!=-1){f.remove(h,1)}});if(d.editor.getParam("paste_convert_middot_lists",true)){d._convertLists(e,g)}b=c.getParam("paste_retain_style_properties");if(tinymce.is(b,"string")){b=tinymce.explode(b)}a(f.select("*",g.node),function(l){var m={},j=0,k,n,h;if(b){for(k=0;k0){f.setStyles(l,m)}else{if(l.nodeName=="SPAN"&&!l.className){f.remove(l,true)}}})}if(c.getParam("paste_remove_styles")||(c.getParam("paste_remove_styles_if_webkit")&&tinymce.isWebKit)){a(f.select("*[style]",g.node),function(h){h.removeAttribute("style");h.removeAttribute("mce_style")})}else{if(tinymce.isWebKit){a(f.select("*",g.node),function(h){h.removeAttribute("mce_style")})}}},_convertLists:function(e,c){var g=e.editor.dom,f,j,b=-1,d,k=[],i,h;a(g.select("p",c.node),function(r){var n,s="",q,o,l,m;for(n=r.firstChild;n&&n.nodeType==3;n=n.nextSibling){s+=n.nodeValue}s=r.innerHTML.replace(/<\/?\w+[^>]*>/gi,"").replace(/ /g,"\u00a0");if(/^(__MCE_ITEM__)+[\u2022\u00b7\u00a7\u00d8o]\s*\u00a0*/.test(s)){q="ul"}if(/^__MCE_ITEM__\s*\w+\.\s*\u00a0{2,}/.test(s)){q="ol"}if(q){d=parseFloat(r.style.marginLeft||0);if(d>b){k.push(d)}if(!f||q!=i){f=g.create(q);g.insertAfter(f,r)}else{if(d>b){f=j.appendChild(g.create(q))}else{if(d]*>/gi,"");if(q=="ul"&&/^[\u2022\u00b7\u00a7\u00d8o]/.test(p)){g.remove(t)}else{if(/^[\s\S]*\w+\.( |\u00a0)*\s*/.test(p)){g.remove(t)}}});o=r.innerHTML;if(q=="ul"){o=r.innerHTML.replace(/__MCE_ITEM__/g,"").replace(/^[\u2022\u00b7\u00a7\u00d8o]\s*( |\u00a0)+\s*/,"")}else{o=r.innerHTML.replace(/__MCE_ITEM__/g,"").replace(/^\s*\w+\.( |\u00a0)+\s*/,"")}j=f.appendChild(g.create("li",0,o));g.remove(r);b=d;i=q}else{f=b=0}});h=c.node.innerHTML;if(h.indexOf("__MCE_ITEM__")!=-1){c.node.innerHTML=h.replace(/__MCE_ITEM__/g,"")}},_insertBlockContent:function(h,e,i){var c,g,d=h.selection,m,j,b,k,f;function l(p){var o;if(tinymce.isIE){o=h.getDoc().body.createTextRange();o.moveToElementText(p);o.collapse(false);o.select()}else{d.select(p,1);d.collapse(false)}}this._insert(' ',1);g=e.get("_marker");c=e.getParent(g,"p,h1,h2,h3,h4,h5,h6,ul,ol,th,td");if(c&&!/TD|TH/.test(c.nodeName)){g=e.split(c,g);a(e.create("div",0,i).childNodes,function(o){m=g.parentNode.insertBefore(o.cloneNode(true),g)});l(m)}else{e.setOuterHTML(g,i);d.select(h.getBody(),1);d.collapse(0)}e.remove("_marker");j=d.getStart();b=e.getViewPort(h.getWin());k=h.dom.getPos(j).y;f=j.clientHeight;if(kb.y+b.h){h.getDoc().body.scrollTop=k')});return}if(p.get("_mcePaste")){return}m=p.add(r,"div",{id:"_mcePaste","class":"mcePaste"},'\uFEFF
        ');if(r!=e.getDoc().body){j=p.getPos(e.selection.getStart(),r).y}else{j=r.scrollTop}p.setStyles(m,{position:"absolute",left:-10000,top:j,width:1,height:1,overflow:"hidden"});if(tinymce.isIE){k=p.doc.body.createTextRange();k.moveToElementText(m);k.execCommand("Paste");p.remove(m);if(m.innerHTML==="\uFEFF"){e.execCommand("mcePasteWord");s.preventDefault();return}i({content:m.innerHTML});return tinymce.dom.Event.cancel(s)}else{function o(n){n.preventDefault()}p.bind(e.getDoc(),"mousedown",o);p.bind(e.getDoc(),"keydown",o);q=e.selection.getRng();m=m.firstChild;k=e.getDoc().createRange();k.setStart(m,0);k.setEnd(m,1);l.setRng(k);window.setTimeout(function(){var t="",n=p.select("div.mcePaste");c(n,function(v){var u=v.firstChild;if(u&&u.nodeName=="DIV"&&u.style.marginTop&&u.style.backgroundColor){p.remove(u,1)}c(p.select("div.mcePaste",v),function(w){p.remove(w,1)});c(p.select("span.Apple-style-span",v),function(w){p.remove(w,1)});c(p.select("br[_mce_bogus]",v),function(w){p.remove(w)});t+=v.innerHTML});c(n,function(u){p.remove(u)});if(q){l.setRng(q)}i({content:t});p.unbind(e.getDoc(),"mousedown",o);p.unbind(e.getDoc(),"keydown",o)},0)}}if(b(e,"paste_auto_cleanup_on_paste")){if(tinymce.isOpera||/Firefox\/2/.test(navigator.userAgent)){e.onKeyDown.add(function(j,k){if(((tinymce.isMac?k.metaKey:k.ctrlKey)&&k.keyCode==86)||(k.shiftKey&&k.keyCode==45)){h(k)}})}else{e.onPaste.addToTop(function(j,k){return h(k)})}}if(b(e,"paste_block_drop")){e.onInit.add(function(){e.dom.bind(e.getBody(),["dragend","dragover","draggesture","dragdrop","drop","drag"],function(j){j.preventDefault();j.stopPropagation();return false})})}g._legacySupport()},getInfo:function(){return{longname:"Paste text/word",author:"Moxiecode Systems AB",authorurl:"http://tinymce.moxiecode.com",infourl:"http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/paste",version:tinymce.majorVersion+"."+tinymce.minorVersion}},_preProcess:function(i,f){var l=this.editor,k=f.content,q=tinymce.grep,p=tinymce.explode,g=tinymce.trim,m,j;function e(h){c(h,function(o){if(o.constructor==RegExp){k=k.replace(o,"")}else{k=k.replace(o[0],o[1])}})}if(/class="?Mso|style="[^"]*\bmso-|w:WordDocument/i.test(k)||f.wordContent){f.wordContent=true;e([/^\s*( )+/gi,/( |]*>)+\s*$/gi]);if(b(l,"paste_convert_headers_to_strong")){k=k.replace(/

        ]*class="?MsoHeading"?[^>]*>(.*?)<\/p>/gi,"

        $1

        ")}if(b(l,"paste_convert_middot_lists")){e([[//gi,"$&__MCE_ITEM__"],[/(]+(?:mso-list:|:\s*symbol)[^>]+>)/gi,"$1__MCE_ITEM__"]])}e([//gi,/<(!|script[^>]*>.*?<\/script(?=[>\s])|\/?(\?xml(:\w+)?|img|meta|link|style|\w:\w+)(?=[\s\/>]))[^>]*>/gi,[/<(\/?)s>/gi,"<$1strike>"],[/ /gi,"\u00a0"]]);do{m=k.length;k=k.replace(/(<[a-z][^>]*\s)(?:id|name|language|type|on\w+|\w+:\w+)=(?:"[^"]*"|\w+)\s?/gi,"$1")}while(m!=k.length);if(b(l,"paste_retain_style_properties").replace(/^none$/i,"").length==0){k=k.replace(/<\/?span[^>]*>/gi,"")}else{e([[/([\s\u00a0]*)<\/span>/gi,function(o,h){return(h.length>0)?h.replace(/./," ").slice(Math.floor(h.length/2)).split("").join("\u00a0"):""}],[/(<[a-z][^>]*)\sstyle="([^"]*)"/gi,function(u,h,t){var v=[],o=0,r=p(g(t).replace(/"/gi,"'"),";");c(r,function(s){var w,y,z=p(s,":");function x(A){return A+((A!=="0")&&(/\d$/.test(A)))?"px":""}if(z.length==2){w=z[0].toLowerCase();y=z[1].toLowerCase();switch(w){case"mso-padding-alt":case"mso-padding-top-alt":case"mso-padding-right-alt":case"mso-padding-bottom-alt":case"mso-padding-left-alt":case"mso-margin-alt":case"mso-margin-top-alt":case"mso-margin-right-alt":case"mso-margin-bottom-alt":case"mso-margin-left-alt":case"mso-table-layout-alt":case"mso-height":case"mso-width":case"mso-vertical-align-alt":v[o++]=w.replace(/^mso-|-alt$/g,"")+":"+x(y);return;case"horiz-align":v[o++]="text-align:"+y;return;case"vert-align":v[o++]="vertical-align:"+y;return;case"font-color":case"mso-foreground":v[o++]="color:"+y;return;case"mso-background":case"mso-highlight":v[o++]="background:"+y;return;case"mso-default-height":v[o++]="min-height:"+x(y);return;case"mso-default-width":v[o++]="min-width:"+x(y);return;case"mso-padding-between-alt":v[o++]="border-collapse:separate;border-spacing:"+x(y);return;case"text-line-through":if((y=="single")||(y=="double")){v[o++]="text-decoration:line-through"}return;case"mso-zero-height":if(y=="yes"){v[o++]="display:none"}return}if(/^(mso|column|font-emph|lang|layout|line-break|list-image|nav|panose|punct|row|ruby|sep|size|src|tab-|table-border|text-(?!align|decor|indent|trans)|top-bar|version|vnd|word-break)/.test(w)){return}v[o++]=w+":"+z[1]}});if(o>0){return h+' style="'+v.join(";")+'"'}else{return h}}]])}}if(b(l,"paste_convert_headers_to_strong")){e([[/]*>/gi,"

        "],[/<\/h[1-6][^>]*>/gi,"

        "]])}j=b(l,"paste_strip_class_attributes");if(j!=="none"){function n(r,o){if(j==="all"){return""}var h=q(p(o.replace(/^(["'])(.*)\1$/,"$2")," "),function(s){return(/^(?!mso)/i.test(s))});return h.length?' class="'+h.join(" ")+'"':""}k=k.replace(/ class="([^"]+)"/gi,n);k=k.replace(/ class=(\w+)/gi,n)}if(b(l,"paste_remove_spans")){k=k.replace(/<\/?span[^>]*>/gi,"")}f.content=k},_postProcess:function(h,j){var g=this,f=g.editor,i=f.dom,e;if(j.wordContent){c(i.select("a",j.node),function(k){if(!k.href||k.href.indexOf("#_Toc")!=-1){i.remove(k,1)}});if(b(f,"paste_convert_middot_lists")){g._convertLists(h,j)}e=b(f,"paste_retain_style_properties");if((tinymce.is(e,"string"))&&(e!=="all")&&(e!=="*")){e=tinymce.explode(e.replace(/^none$/i,""));c(i.select("*",j.node),function(n){var o={},l=0,m,p,k;if(e){for(m=0;m0){i.setStyles(n,o)}else{if(n.nodeName=="SPAN"&&!n.className){i.remove(n,true)}}})}}if(b(f,"paste_remove_styles")||(b(f,"paste_remove_styles_if_webkit")&&tinymce.isWebKit)){c(i.select("*[style]",j.node),function(k){k.removeAttribute("style");k.removeAttribute("_mce_style")})}else{if(tinymce.isWebKit){c(i.select("*",j.node),function(k){k.removeAttribute("_mce_style")})}}},_convertLists:function(h,f){var j=h.editor.dom,i,m,e=-1,g,n=[],l,k;c(j.select("p",f.node),function(u){var r,v="",t,s,o,q;for(r=u.firstChild;r&&r.nodeType==3;r=r.nextSibling){v+=r.nodeValue}v=u.innerHTML.replace(/<\/?\w+[^>]*>/gi,"").replace(/ /g,"\u00a0");if(/^(__MCE_ITEM__)+[\u2022\u00b7\u00a7\u00d8o]\s*\u00a0*/.test(v)){t="ul"}if(/^__MCE_ITEM__\s*\w+\.\s*\u00a0{2,}/.test(v)){t="ol"}if(t){g=parseFloat(u.style.marginLeft||0);if(g>e){n.push(g)}if(!i||t!=l){i=j.create(t);j.insertAfter(i,u)}else{if(g>e){i=m.appendChild(j.create(t))}else{if(g]*>/gi,"");if(t=="ul"&&/^[\u2022\u00b7\u00a7\u00d8o]/.test(p)){j.remove(w)}else{if(/^[\s\S]*\w+\.( |\u00a0)*\s*/.test(p)){j.remove(w)}}});s=u.innerHTML;if(t=="ul"){s=u.innerHTML.replace(/__MCE_ITEM__/g,"").replace(/^[\u2022\u00b7\u00a7\u00d8o]\s*( |\u00a0)+\s*/,"")}else{s=u.innerHTML.replace(/__MCE_ITEM__/g,"").replace(/^\s*\w+\.( |\u00a0)+\s*/,"")}m=i.appendChild(j.create("li",0,s));j.remove(u);e=g;l=t}else{i=e=0}});k=f.node.innerHTML;if(k.indexOf("__MCE_ITEM__")!=-1){f.node.innerHTML=k.replace(/__MCE_ITEM__/g,"")}},_insertBlockContent:function(l,h,m){var f,j,g=l.selection,q,n,e,o,i,k="mce_marker";function p(t){var s;if(tinymce.isIE){s=l.getDoc().body.createTextRange();s.moveToElementText(t);s.collapse(false);s.select()}else{g.select(t,1);g.collapse(false)}}this._insert('',1);j=h.get(k);f=h.getParent(j,"p,h1,h2,h3,h4,h5,h6,ul,ol,th,td");if(f&&!/TD|TH/.test(f.nodeName)){j=h.split(f,j);c(h.create("div",0,m).childNodes,function(r){q=j.parentNode.insertBefore(r.cloneNode(true),j)});p(q)}else{h.setOuterHTML(j,m);g.select(l.getBody(),1);g.collapse(0)}while(n=h.get(k)){h.remove(n)}n=g.getStart();e=h.getViewPort(l.getWin());o=l.dom.getPos(n).y;i=n.clientHeight;if(oe.y+e.h){l.getDoc().body.scrollTop=o0)){if(!d){d=("34,quot,38,amp,39,apos,60,lt,62,gt,"+j.serializer.settings.entities).split(",")}if(/<(?:p|br|h[1-6]|ul|ol|dl|table|t[rdh]|div|blockquote|fieldset|pre|address|center)[^>]*>/i.test(v)){q([/[\n\r]+/g])}else{q([/\r+/g])}q([[/<\/(?:p|h[1-6]|ul|ol|dl|table|div|blockquote|fieldset|pre|address|center)>/gi,"\n\n"],[/]*>|<\/tr>/gi,"\n"],[/<\/t[dh]>\s*]*>/gi,"\t"],/<[a-z!\/?][^>]*>/gi,[/ /gi," "],[/&(#\d+|[a-z0-9]{1,10});/gi,function(i,h){if(h.charAt(0)==="#"){return String.fromCharCode(h.slice(1))}else{return((i=y(d,h))>0)?String.fromCharCode(d[i-1]):" "}}],[/(?:(?!\n)\s)*(\n+)(?:(?!\n)\s)*/gi,"$1"],[/\n{3,}/g,"\n\n"],/^\s+|\s+$/g]);v=x.encode(v);if(!s.isCollapsed()){z.execCommand("Delete",false,null)}if(m(o,"array")||(m(o,"array"))){q(o)}else{if(m(o,"string")){q(new RegExp(o,"gi"))}}if(g=="none"){q([[/\n+/g," "]])}else{if(g=="br"){q([[/\n/g,"
        "]])}else{q([/^\s+|\s+$/g,[/\n\n/g,"

        "],[/\n/g,"
        "]])}}if((l=v.indexOf("

        "))!=-1){k=v.lastIndexOf("

        ");r=s.getNode();e=[];do{if(r.nodeType==1){if(r.nodeName=="TD"||r.nodeName=="BODY"){break}e[e.length]=r}}while(r=r.parentNode);if(e.length>0){p=v.substring(0,l);f="";for(t=0,u=e.length;t";f+="<"+e[e.length-t-1].nodeName.toLowerCase()+">"}if(l==k){v=p+f+v.substring(l+7)}else{v=p+v.substring(l+4,k+4)+f+v.substring(k+7)}}}j.execCommand("mceInsertRawHTML",false,v+' ');window.setTimeout(function(){var h=x.get("_plain_text_marker"),B,i,A,w;s.select(h,false);z.execCommand("Delete",false,null);h=null;B=s.getStart();i=x.getViewPort(n);A=x.getPos(B).y;w=B.clientHeight;if((Ai.y+i.h)){z.body.scrollTop=A {#paste.paste_text_desc} - - - + +

        diff --git a/wp-includes/js/tinymce/plugins/paste/pasteword.htm b/wp-includes/js/tinymce/plugins/paste/pasteword.htm index 68dab3ec..7b42d8ca 100644 --- a/wp-includes/js/tinymce/plugins/paste/pasteword.htm +++ b/wp-includes/js/tinymce/plugins/paste/pasteword.htm @@ -1,9 +1,8 @@ - {#paste.paste_word_desc} - - + + diff --git a/wp-includes/js/tinymce/plugins/safari/blank.htm b/wp-includes/js/tinymce/plugins/safari/blank.htm deleted file mode 100644 index 266808ce..00000000 --- a/wp-includes/js/tinymce/plugins/safari/blank.htm +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/safari/editor_plugin.js b/wp-includes/js/tinymce/plugins/safari/editor_plugin.js deleted file mode 100644 index 794477c9..00000000 --- a/wp-includes/js/tinymce/plugins/safari/editor_plugin.js +++ /dev/null @@ -1 +0,0 @@ -(function(){var a=tinymce.dom.Event,c=tinymce.grep,d=tinymce.each,b=tinymce.inArray;function e(j,i,h){var g,k;g=j.createTreeWalker(i,NodeFilter.SHOW_ALL,null,false);while(k=g.nextNode()){if(h){if(!h(k)){return false}}if(k.nodeType==3&&k.nodeValue&&/[^\s\u00a0]+/.test(k.nodeValue)){return false}if(k.nodeType==1&&/^(HR|IMG|TABLE)$/.test(k.nodeName)){return false}}return true}tinymce.create("tinymce.plugins.Safari",{init:function(f){var g=this,h;if(!tinymce.isWebKit){return}g.editor=f;g.webKitFontSizes=["x-small","small","medium","large","x-large","xx-large","-webkit-xxx-large"];g.namedFontSizes=["xx-small","x-small","small","medium","large","x-large","xx-large"];f.addCommand("CreateLink",function(k,j){var m=f.selection.getNode(),l=f.dom,i;if(m&&(/^(left|right)$/i.test(l.getStyle(m,"float",1))||/^(left|right)$/i.test(l.getAttrib(m,"align")))){i=l.create("a",{href:j},m.cloneNode());m.parentNode.replaceChild(i,m);f.selection.select(i)}else{f.getDoc().execCommand("CreateLink",false,j)}});f.onKeyUp.add(function(j,o){var l,i,m,p,k;if(o.keyCode==46||o.keyCode==8){i=j.getBody();l=i.innerHTML;k=j.selection;if(i.childNodes.length==1&&!/<(img|hr)/.test(l)&&tinymce.trim(l.replace(/<[^>]+>/g,"")).length==0){j.setContent('


        ',{format:"raw"});p=i.firstChild;m=k.getRng();m.setStart(p,0);m.setEnd(p,0);k.setRng(m)}}});f.addCommand("FormatBlock",function(j,i){var l=f.dom,k=l.getParent(f.selection.getNode(),l.isBlock);if(k){l.replace(l.create(i),k,1)}else{f.getDoc().execCommand("FormatBlock",false,i)}});f.addCommand("mceInsertContent",function(j,i){f.getDoc().execCommand("InsertText",false,"mce_marker");f.getBody().innerHTML=f.getBody().innerHTML.replace(/mce_marker/g,f.dom.processHTML(i)+'XX');f.selection.select(f.dom.get("_mce_tmp"));f.getDoc().execCommand("Delete",false," ")});f.onKeyPress.add(function(o,p){var q,v,r,l,j,k,i,u,m,t,s;if(p.keyCode==13){i=o.selection;q=i.getNode();if(p.shiftKey||o.settings.force_br_newlines&&q.nodeName!="LI"){g._insertBR(o);a.cancel(p)}if(v=h.getParent(q,"LI")){r=h.getParent(v,"OL,UL");u=o.getDoc();s=h.create("p");h.add(s,"br",{mce_bogus:"1"});if(e(u,v)){if(k=h.getParent(r.parentNode,"LI,OL,UL")){return}k=h.getParent(r,"p,h1,h2,h3,h4,h5,h6,div")||r;l=u.createRange();l.setStartBefore(k);l.setEndBefore(v);j=u.createRange();j.setStartAfter(v);j.setEndAfter(k);m=l.cloneContents();t=j.cloneContents();if(!e(u,t)){h.insertAfter(t,k)}h.insertAfter(s,k);if(!e(u,m)){h.insertAfter(m,k)}h.remove(k);k=s.firstChild;l=u.createRange();l.setStartBefore(k);l.setEndBefore(k);i.setRng(l);return a.cancel(p)}}}});f.onExecCommand.add(function(i,k){var j,m,n,l;if(k=="InsertUnorderedList"||k=="InsertOrderedList"){j=i.selection;m=i.dom;if(n=m.getParent(j.getNode(),function(o){return/^(H[1-6]|P|ADDRESS|PRE)$/.test(o.nodeName)})){l=j.getBookmark();m.remove(n,1);j.moveToBookmark(l)}}});f.onClick.add(function(i,j){j=j.target;if(j.nodeName=="IMG"){g.selElm=j;i.selection.select(j)}else{g.selElm=null}});f.onInit.add(function(){g._fixWebKitSpans()});f.onSetContent.add(function(){h=f.dom;d(["strong","b","em","u","strike","sub","sup","a"],function(i){d(c(h.select(i)).reverse(),function(l){var k=l.nodeName.toLowerCase(),j;if(k=="a"){if(l.name){h.replace(h.create("img",{mce_name:"a",name:l.name,"class":"mceItemAnchor"}),l)}return}switch(k){case"b":case"strong":if(k=="b"){k="strong"}j="font-weight: bold;";break;case"em":j="font-style: italic;";break;case"u":j="text-decoration: underline;";break;case"sub":j="vertical-align: sub;";break;case"sup":j="vertical-align: super;";break;case"strike":j="text-decoration: line-through;";break}h.replace(h.create("span",{mce_name:k,style:j,"class":"Apple-style-span"}),l,1)})})});f.onPreProcess.add(function(i,j){h=i.dom;d(c(j.node.getElementsByTagName("span")).reverse(),function(m){var k,l;if(j.get){if(h.hasClass(m,"Apple-style-span")){l=m.style.backgroundColor;switch(h.getAttrib(m,"mce_name")){case"font":if(!i.settings.convert_fonts_to_spans){h.setAttrib(m,"style","")}break;case"strong":case"em":case"sub":case"sup":h.setAttrib(m,"style","");break;case"strike":case"u":if(!i.settings.inline_styles){h.setAttrib(m,"style","")}else{h.setAttrib(m,"mce_name","")}break;default:if(!i.settings.inline_styles){h.setAttrib(m,"style","")}}if(l){m.style.backgroundColor=l}}}if(h.hasClass(m,"mceItemRemoved")){h.remove(m,1)}})});f.onPostProcess.add(function(i,j){j.content=j.content.replace(/
        <\/(h[1-6]|div|p|address|pre)>/g,"");j.content=j.content.replace(/ id=\"undefined\"/g,"")})},getInfo:function(){return{longname:"Safari compatibility",author:"Moxiecode Systems AB",authorurl:"http://tinymce.moxiecode.com",infourl:"http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/safari",version:tinymce.majorVersion+"."+tinymce.minorVersion}},_fixWebKitSpans:function(){var g=this,f=g.editor;a.add(f.getDoc(),"DOMNodeInserted",function(h){h=h.target;if(h&&h.nodeType==1){g._fixAppleSpan(h)}})},_fixAppleSpan:function(l){var g=this.editor,m=g.dom,i=this.webKitFontSizes,f=this.namedFontSizes,j=g.settings,h,k;if(m.getAttrib(l,"mce_fixed")){return}if(l.nodeName=="SPAN"&&l.className=="Apple-style-span"){h=l.style;if(!j.convert_fonts_to_spans){if(h.fontSize){m.setAttrib(l,"mce_name","font");m.setAttrib(l,"size",b(i,h.fontSize)+1)}if(h.fontFamily){m.setAttrib(l,"mce_name","font");m.setAttrib(l,"face",h.fontFamily)}if(h.color){m.setAttrib(l,"mce_name","font");m.setAttrib(l,"color",m.toHex(h.color))}if(h.backgroundColor){m.setAttrib(l,"mce_name","font");m.setStyle(l,"background-color",h.backgroundColor)}}else{if(h.fontSize){m.setStyle(l,"fontSize",f[b(i,h.fontSize)])}}if(h.fontWeight=="bold"){m.setAttrib(l,"mce_name","strong")}if(h.fontStyle=="italic"){m.setAttrib(l,"mce_name","em")}if(h.textDecoration=="underline"){m.setAttrib(l,"mce_name","u")}if(h.textDecoration=="line-through"){m.setAttrib(l,"mce_name","strike")}if(h.verticalAlign=="super"){m.setAttrib(l,"mce_name","sup")}if(h.verticalAlign=="sub"){m.setAttrib(l,"mce_name","sub")}m.setAttrib(l,"mce_fixed","1")}},_insertBR:function(f){var j=f.dom,h=f.selection,i=h.getRng(),g;i.insertNode(g=j.create("br"));i.setStartAfter(g);i.setEndAfter(g);h.setRng(i);if(h.getSel().focusNode==g.previousSibling){h.select(j.insertAfter(j.doc.createTextNode("\u00a0"),g));h.collapse(1)}f.getWin().scrollTo(0,j.getPos(h.getRng().startContainer).y)}});tinymce.PluginManager.add("safari",tinymce.plugins.Safari)})(); \ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/spellchecker/classes/utils/JSON.php b/wp-includes/js/tinymce/plugins/spellchecker/classes/utils/JSON.php index 1c461167..1f2b92ca 100644 --- a/wp-includes/js/tinymce/plugins/spellchecker/classes/utils/JSON.php +++ b/wp-includes/js/tinymce/plugins/spellchecker/classes/utils/JSON.php @@ -532,15 +532,15 @@ class Moxiecode_JSON { $i += 2; $output .= sprintf('\u%04s', bin2hex($this->_utf82utf16($char))); } if (($byte & 0xF8) == 0xF0) { - $char = pack('C*', $byte, ord($input[$i + 1]), ord($input[$i + 2], ord($input[$i + 3]))); + $char = pack('C*', $byte, ord($input[$i + 1]), ord($input[$i + 2]), ord($input[$i + 3])); $i += 3; $output .= sprintf('\u%04s', bin2hex($this->_utf82utf16($char))); } if (($byte & 0xFC) == 0xF8) { - $char = pack('C*', $byte, ord($input[$i + 1]), ord($input[$i + 2], ord($input[$i + 3]), ord($input[$i + 4]))); + $char = pack('C*', $byte, ord($input[$i + 1]), ord($input[$i + 2]), ord($input[$i + 3]), ord($input[$i + 4])); $i += 4; $output .= sprintf('\u%04s', bin2hex($this->_utf82utf16($char))); } if (($byte & 0xFE) == 0xFC) { - $char = pack('C*', $byte, ord($input[$i + 1]), ord($input[$i + 2], ord($input[$i + 3]), ord($input[$i + 4]), ord($input[$i + 5]))); + $char = pack('C*', $byte, ord($input[$i + 1]), ord($input[$i + 2]), ord($input[$i + 3]), ord($input[$i + 4]), ord($input[$i + 5])); $i += 5; $output .= sprintf('\u%04s', bin2hex($this->_utf82utf16($char))); } else if ($byte < 128) diff --git a/wp-includes/js/tinymce/plugins/spellchecker/config.php b/wp-includes/js/tinymce/plugins/spellchecker/config.php index fb15b809..795495a6 100644 --- a/wp-includes/js/tinymce/plugins/spellchecker/config.php +++ b/wp-includes/js/tinymce/plugins/spellchecker/config.php @@ -1,9 +1,8 @@ 0) { - t.active = 1; - t._markWords(r); - ed.setProgressState(0); - ed.nodeChanged(); - } else { - ed.setProgressState(0); - ed.windowManager.alert('spellchecker.no_mpell'); - } - }); - } else - t._done(); - }); - - ed.onInit.add(function() { - if (ed.settings.content_css !== false) - ed.dom.loadCSS(url + '/css/content.css'); - }); - - ed.onClick.add(t._showMenu, t); - ed.onContextMenu.add(t._showMenu, t); - ed.onBeforeGetContent.add(function() { - if (t.active) - t._removeWords(); - }); - - ed.onNodeChange.add(function(ed, cm) { - cm.setActive('spellchecker', t.active); - }); - - ed.onSetContent.add(function() { - t._done(); - }); - - ed.onBeforeGetContent.add(function() { - t._done(); - }); - - ed.onBeforeExecCommand.add(function(ed, cmd) { - if (cmd == 'mceFullScreen') - t._done(); - }); - - // Find selected language - t.languages = {}; - each(ed.getParam('spellchecker_languages', '+English=en,Danish=da,Dutch=nl,Finnish=fi,French=fr,German=de,Italian=it,Polish=pl,Portuguese=pt,Spanish=es,Swedish=sv', 'hash'), function(v, k) { - if (k.indexOf('+') === 0) { - k = k.substring(1); - t.selectedLang = v; - } - - t.languages[k] = v; - }); - }, - - createControl : function(n, cm) { - var t = this, c, ed = t.editor; - - if (n == 'spellchecker') { - c = cm.createSplitButton(n, {title : 'spellchecker.desc', cmd : 'mceSpellCheck', scope : t}); - - c.onRenderMenu.add(function(c, m) { - m.add({title : 'spellchecker.langs', 'class' : 'mceMenuItemTitle'}).setDisabled(1); - each(t.languages, function(v, k) { - var o = {icon : 1}, mi; - - o.onclick = function() { - mi.setSelected(1); - t.selectedItem.setSelected(0); - t.selectedItem = mi; - t.selectedLang = v; - }; - - o.title = k; - mi = m.add(o); - mi.setSelected(v == t.selectedLang); - - if (v == t.selectedLang) - t.selectedItem = mi; - }) - }); - - return c; - } - }, - - // Internal functions - - _walk : function(n, f) { - var d = this.editor.getDoc(), w; - - if (d.createTreeWalker) { - w = d.createTreeWalker(n, NodeFilter.SHOW_TEXT, null, false); - - while ((n = w.nextNode()) != null) - f.call(this, n); - } else - tinymce.walk(n, f, 'childNodes'); - }, - - _getSeparators : function() { - var re = '', i, str = this.editor.getParam('spellchecker_word_separator_chars', '\\s!"#$%&()*+,-./:;<=>?@[\]^_{|}§©«®±¶·¸»¼½¾¿×÷¤\u201d\u201c'); - - // Build word separator regexp - for (i=0; i$1$2'); - v = v.replace(r3, '$1$2'); - - dom.replace(dom.create('span', {'class' : 'mceItemHidden'}, v), n); - } - } - }); - - se.moveToBookmark(b); - }, - - _showMenu : function(ed, e) { - var t = this, ed = t.editor, m = t._menu, p1, dom = ed.dom, vp = dom.getViewPort(ed.getWin()); - - if (!m) { - p1 = DOM.getPos(ed.getContentAreaContainer()); - //p2 = DOM.getPos(ed.getContainer()); - - m = ed.controlManager.createDropMenu('spellcheckermenu', { - offset_x : p1.x, - offset_y : p1.y, - 'class' : 'mceNoIcons' - }); - - t._menu = m; - } - - if (dom.hasClass(e.target, 'mceItemHiddenSpellWord')) { - m.removeAll(); - m.add({title : 'spellchecker.wait', 'class' : 'mceMenuItemTitle'}).setDisabled(1); - - t._sendRPC('getSuggestions', [t.selectedLang, dom.decode(e.target.innerHTML)], function(r) { - m.removeAll(); - - if (r.length > 0) { - m.add({title : 'spellchecker.sug', 'class' : 'mceMenuItemTitle'}).setDisabled(1); - each(r, function(v) { - m.add({title : v, onclick : function() { - dom.replace(ed.getDoc().createTextNode(v), e.target); - t._checkDone(); - }}); - }); - - m.addSeparator(); - } else - m.add({title : 'spellchecker.no_sug', 'class' : 'mceMenuItemTitle'}).setDisabled(1); - - m.add({ - title : 'spellchecker.ignore_word', - onclick : function() { - dom.remove(e.target, 1); - t._checkDone(); - } - }); - - m.add({ - title : 'spellchecker.ignore_words', - onclick : function() { - t._removeWords(dom.decode(e.target.innerHTML)); - t._checkDone(); - } - }); - - m.update(); - }); - - ed.selection.select(e.target); - p1 = dom.getPos(e.target); - m.showMenu(p1.x, p1.y + e.target.offsetHeight - vp.y); - - return tinymce.dom.Event.cancel(e); - } else - m.hideMenu(); - }, - - _checkDone : function() { - var t = this, ed = t.editor, dom = ed.dom, o; - - each(dom.select('span'), function(n) { - if (n && dom.hasClass(n, 'mceItemHiddenSpellWord')) { - o = true; - return false; - } - }); - - if (!o) - t._done(); - }, - - _done : function() { - var t = this, la = t.active; - - if (t.active) { - t.active = 0; - t._removeWords(); - - if (t._menu) - t._menu.hideMenu(); - - if (la) - t.editor.nodeChanged(); - } - }, - - _sendRPC : function(m, p, cb) { - var t = this, url = t.editor.getParam("spellchecker_rpc_url", this.url+'/rpc.php'); - - if (url == '{backend}') { - t.editor.setProgressState(0); - alert('Please specify: spellchecker_rpc_url'); - return; - } - - JSONRequest.sendRPC({ - url : url, - method : m, - params : p, - success : cb, - error : function(e, x) { - t.editor.setProgressState(0); - t.editor.windowManager.alert(e.errstr || ('Error response: ' + x.responseText)); - } - }); - } - }); - - // Register plugin - tinymce.PluginManager.add('spellchecker', tinymce.plugins.SpellcheckerPlugin); -})(); \ No newline at end of file +(function(){var a=tinymce.util.JSONRequest,c=tinymce.each,b=tinymce.DOM;tinymce.create("tinymce.plugins.SpellcheckerPlugin",{getInfo:function(){return{longname:"Spellchecker",author:"Moxiecode Systems AB",authorurl:"http://tinymce.moxiecode.com",infourl:"http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/spellchecker",version:tinymce.majorVersion+"."+tinymce.minorVersion}},init:function(e,f){var g=this,d;g.url=f;g.editor=e;g.rpcUrl=e.getParam("spellchecker_rpc_url",this.url+'/rpc.php');if(g.rpcUrl=="{backend}"){if(tinymce.isIE){return}g.hasSupport=true;e.onContextMenu.addToTop(function(h,i){if(g.active){return false}})}e.addCommand("mceSpellCheck",function(){if(g.rpcUrl=="{backend}"){g.editor.getBody().spellcheck=g.active=!g.active;return}if(!g.active){e.setProgressState(1);g._sendRPC("checkWords",[g.selectedLang,g._getWords()],function(h){if(h.length>0){g.active=1;g._markWords(h);e.setProgressState(0);e.nodeChanged()}else{e.setProgressState(0);if(e.getParam("spellchecker_report_no_misspellings",true)){e.windowManager.alert("spellchecker.no_mpell")}}})}else{g._done()}});e.onInit.add(function(){if(e.settings.content_css!==false){e.dom.loadCSS(f+"/css/content.css")}});e.onClick.add(g._showMenu,g);e.onContextMenu.add(g._showMenu,g);e.onBeforeGetContent.add(function(){if(g.active){g._removeWords()}});e.onNodeChange.add(function(i,h){h.setActive("spellchecker",g.active)});e.onSetContent.add(function(){g._done()});e.onBeforeGetContent.add(function(){g._done()});e.onBeforeExecCommand.add(function(h,i){if(i=="mceFullScreen"){g._done()}});g.languages={};c(e.getParam("spellchecker_languages","+English=en,Danish=da,Dutch=nl,Finnish=fi,French=fr,German=de,Italian=it,Polish=pl,Portuguese=pt,Spanish=es,Swedish=sv","hash"),function(i,h){if(h.indexOf("+")===0){h=h.substring(1);g.selectedLang=i}g.languages[h]=i})},createControl:function(h,d){var f=this,g,e=f.editor;if(h=="spellchecker"){if(f.rpcUrl=="{backend}"){if(f.hasSupport){g=d.createButton(h,{title:"spellchecker.desc",cmd:"mceSpellCheck",scope:f})}return g}g=d.createSplitButton(h,{title:"spellchecker.desc",cmd:"mceSpellCheck",scope:f});g.onRenderMenu.add(function(j,i){i.add({title:"spellchecker.langs","class":"mceMenuItemTitle"}).setDisabled(1);c(f.languages,function(n,m){var p={icon:1},l;p.onclick=function(){l.setSelected(1);f.selectedItem.setSelected(0);f.selectedItem=l;f.selectedLang=n};p.title=m;l=i.add(p);l.setSelected(n==f.selectedLang);if(n==f.selectedLang){f.selectedItem=l}})});return g}},_walk:function(i,g){var h=this.editor.getDoc(),e;if(h.createTreeWalker){e=h.createTreeWalker(i,NodeFilter.SHOW_TEXT,null,false);while((i=e.nextNode())!=null){g.call(this,i)}}else{tinymce.walk(i,g,"childNodes")}},_getSeparators:function(){var e="",d,f=this.editor.getParam("spellchecker_word_separator_chars",'\\s!"#$%&()*+,-./:;<=>?@[]^_{|}§©«®±¶·¸»¼½¾¿×÷¤\u201d\u201c');for(d=0;d$1$2');q=q.replace(g,'$1$2');j.replace(j.create("span",{"class":"mceItemHidden"},q),r)}}});l.moveToBookmark(m)},_showMenu:function(g,i){var h=this,g=h.editor,d=h._menu,k,j=g.dom,f=j.getViewPort(g.getWin());if(!d){k=b.getPos(g.getContentAreaContainer());d=g.controlManager.createDropMenu("spellcheckermenu",{offset_x:k.x,offset_y:k.y,"class":"mceNoIcons"});h._menu=d}if(j.hasClass(i.target,"mceItemHiddenSpellWord")){d.removeAll();d.add({title:"spellchecker.wait","class":"mceMenuItemTitle"}).setDisabled(1);h._sendRPC("getSuggestions",[h.selectedLang,j.decode(i.target.innerHTML)],function(l){var e;d.removeAll();if(l.length>0){d.add({title:"spellchecker.sug","class":"mceMenuItemTitle"}).setDisabled(1);c(l,function(m){d.add({title:m,onclick:function(){j.replace(g.getDoc().createTextNode(m),i.target);h._checkDone()}})});d.addSeparator()}else{d.add({title:"spellchecker.no_sug","class":"mceMenuItemTitle"}).setDisabled(1)}e=h.editor.getParam("spellchecker_enable_ignore_rpc","");d.add({title:"spellchecker.ignore_word",onclick:function(){var m=i.target.innerHTML;j.remove(i.target,1);h._checkDone();if(ignore_rpc){g.setProgressState(1);h._sendRPC("ignoreWord",[h.selectedLang,m],function(n){g.setProgressState(0)})}}});d.add({title:"spellchecker.ignore_words",onclick:function(){var m=i.target.innerHTML;h._removeWords(j.decode(m));h._checkDone();if(ignore_rpc){g.setProgressState(1);h._sendRPC("ignoreWords",[h.selectedLang,m],function(n){g.setProgressState(0)})}}});if(h.editor.getParam("spellchecker_enable_learn_rpc")){d.add({title:"spellchecker.learn_word",onclick:function(){var m=i.target.innerHTML;j.remove(i.target,1);h._checkDone();g.setProgressState(1);h._sendRPC("learnWord",[h.selectedLang,m],function(n){g.setProgressState(0)})}})}d.update()});g.selection.select(i.target);k=j.getPos(i.target);d.showMenu(k.x,k.y+i.target.offsetHeight-f.y);return tinymce.dom.Event.cancel(i)}else{d.hideMenu()}},_checkDone:function(){var e=this,d=e.editor,g=d.dom,f;c(g.select("span"),function(h){if(h&&g.hasClass(h,"mceItemHiddenSpellWord")){f=true;return false}});if(!f){e._done()}},_done:function(){var d=this,e=d.active;if(d.active){d.active=0;d._removeWords();if(d._menu){d._menu.hideMenu()}if(e){d.editor.nodeChanged()}}},_sendRPC:function(e,g,d){var f=this;a.sendRPC({url:f.rpcUrl,method:e,params:g,success:d,error:function(i,h){f.editor.setProgressState(0);f.editor.windowManager.alert(i.errstr||("Error response: "+h.responseText))}})}});tinymce.PluginManager.add("spellchecker",tinymce.plugins.SpellcheckerPlugin)})(); \ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/spellchecker/includes/general.php b/wp-includes/js/tinymce/plugins/spellchecker/includes/general.php index 9a121456..ffea3a0c 100644 --- a/wp-includes/js/tinymce/plugins/spellchecker/includes/general.php +++ b/wp-includes/js/tinymce/plugins/spellchecker/includes/general.php @@ -25,7 +25,7 @@ if (isset($config['general.engine'])) * @param String $default_value Default value to return if value not found. * @return String request value by name without magic quoting or default value. */ -function getRequestParam($name, $default_value = false, $sanitize = false) { +function getRequestParam($name, $default_value = false) { if (!isset($_REQUEST[$name])) return $default_value; @@ -33,12 +33,12 @@ function getRequestParam($name, $default_value = false, $sanitize = false) { $newarray = array(); foreach ($_REQUEST[$name] as $name => $value) - $newarray[formatParam($name, $sanitize)] = formatParam($value, $sanitize); + $newarray[$name] = $value; return $newarray; } - return formatParam($_REQUEST[$name], $sanitize); + return $_REQUEST[$name]; } function &getLogger() { diff --git a/wp-includes/js/tinymce/plugins/spellchecker/rpc.php b/wp-includes/js/tinymce/plugins/spellchecker/rpc.php index d996c5dd..6a567348 100644 --- a/wp-includes/js/tinymce/plugins/spellchecker/rpc.php +++ b/wp-includes/js/tinymce/plugins/spellchecker/rpc.php @@ -1,6 +1,6 @@ encode($output); -?> \ No newline at end of file +?> diff --git a/wp-includes/js/tinymce/plugins/tabfocus/editor_plugin.js b/wp-includes/js/tinymce/plugins/tabfocus/editor_plugin.js index 7f1fe261..27d24402 100644 --- a/wp-includes/js/tinymce/plugins/tabfocus/editor_plugin.js +++ b/wp-includes/js/tinymce/plugins/tabfocus/editor_plugin.js @@ -1 +1 @@ -(function(){var c=tinymce.DOM,a=tinymce.dom.Event,d=tinymce.each,b=tinymce.explode;tinymce.create("tinymce.plugins.TabFocusPlugin",{init:function(f,g){function e(i,j){if(j.keyCode===9){return a.cancel(j)}}function h(l,p){var j,m,o,n,k;function q(i){o=c.getParent(l.id,"form");n=o.elements;if(o){d(n,function(s,r){if(s.id==l.id){j=r;return false}});if(i>0){for(m=j+1;m=0;m--){if(n[m].type!="hidden"){return n[m]}}}}return null}if(p.keyCode===9){k=b(l.getParam("tab_focus",l.getParam("tabfocus_elements",":prev,:next")));if(k.length==1){k[1]=k[0];k[0]=":prev"}if(p.shiftKey){if(k[0]==":prev"){n=q(-1)}else{n=c.get(k[0])}}else{if(k[1]==":next"){n=q(1)}else{n=c.get(k[1])}}if(n){if(l=tinymce.EditorManager.get(n.id||n.name)){l.focus()}else{window.setTimeout(function(){window.focus();n.focus()},10)}return a.cancel(p)}}}f.onKeyUp.add(e);if(tinymce.isGecko){f.onKeyPress.add(h);f.onKeyDown.add(e)}else{f.onKeyDown.add(h)}f.onInit.add(function(){d(c.select("a:first,a:last",f.getContainer()),function(i){a.add(i,"focus",function(){f.focus()})})})},getInfo:function(){return{longname:"Tabfocus",author:"Moxiecode Systems AB",authorurl:"http://tinymce.moxiecode.com",infourl:"http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/tabfocus",version:tinymce.majorVersion+"."+tinymce.minorVersion}}});tinymce.PluginManager.add("tabfocus",tinymce.plugins.TabFocusPlugin)})(); \ No newline at end of file +(function(){var c=tinymce.DOM,a=tinymce.dom.Event,d=tinymce.each,b=tinymce.explode;tinymce.create("tinymce.plugins.TabFocusPlugin",{init:function(f,g){function e(i,j){if(j.keyCode===9){return a.cancel(j)}}function h(l,p){var j,m,o,n,k;function q(i){o=c.getParent(l.id,"form");n=o.elements;if(o){d(n,function(s,r){if(s.id==l.id){j=r;return false}});if(i>0){for(m=j+1;m=0;m--){if(n[m].type!="hidden"){return n[m]}}}}return null}if(p.keyCode===9){k=b(l.getParam("tab_focus",l.getParam("tabfocus_elements",":prev,:next")));if(k.length==1){k[1]=k[0];k[0]=":prev"}if(p.shiftKey){if(k[0]==":prev"){n=q(-1)}else{n=c.get(k[0])}}else{if(k[1]==":next"){n=q(1)}else{n=c.get(k[1])}}if(n){if(l=tinymce.get(n.id||n.name)){l.focus()}else{window.setTimeout(function(){window.focus();n.focus()},10)}return a.cancel(p)}}}f.onKeyUp.add(e);if(tinymce.isGecko){f.onKeyPress.add(h);f.onKeyDown.add(e)}else{f.onKeyDown.add(h)}f.onInit.add(function(){d(c.select("a:first,a:last",f.getContainer()),function(i){a.add(i,"focus",function(){f.focus()})})})},getInfo:function(){return{longname:"Tabfocus",author:"Moxiecode Systems AB",authorurl:"http://tinymce.moxiecode.com",infourl:"http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/tabfocus",version:tinymce.majorVersion+"."+tinymce.minorVersion}}});tinymce.PluginManager.add("tabfocus",tinymce.plugins.TabFocusPlugin)})(); \ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.dev.js b/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.dev.js index 0cc2bab9..f8998688 100644 --- a/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.dev.js +++ b/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.dev.js @@ -35,13 +35,13 @@ }); ed.addCommand('WP_Help', function() { - ed.windowManager.open({ - url : tinymce.baseURL + '/wp-mce-help.php', - width : 450, - height : 420, - inline : 1 - }); + ed.windowManager.open({ + url : tinymce.baseURL + '/wp-mce-help.php', + width : 450, + height : 420, + inline : 1 }); + }); ed.addCommand('WP_Adv', function() { var cm = ed.controlManager, id = cm.get(tbId).id; @@ -126,37 +126,76 @@ } }); - // Add Media buttons to fullscreen - ed.onBeforeExecCommand.add(function(ed, cmd, ui, val) { - var DOM = tinymce.DOM; - if ( 'mceFullScreen' != cmd ) return; - if ( 'mce_fullscreen' != ed.id && DOM.get('add_audio') && DOM.get('add_video') && DOM.get('add_image') && DOM.get('add_media') ) - ed.settings.theme_advanced_buttons1 += ',|,add_image,add_video,add_audio,add_media'; - }); - - // Add class "alignleft", "alignright" and "aligncenter" when selecting align for images. - ed.addCommand('JustifyLeft', function() { - var n = ed.selection.getNode(); - - if ( n.nodeName != 'IMG' ) - ed.editorCommands.mceJustify('JustifyLeft', 'left'); - else ed.plugins.wordpress.do_align(n, 'alignleft'); - }); - - ed.addCommand('JustifyRight', function() { - var n = ed.selection.getNode(); + // Add Media buttons to fullscreen and handle align buttons for image captions + ed.onBeforeExecCommand.add(function(ed, cmd, ui, val, o) { + var DOM = tinymce.DOM, n, DL, DIV, cls, a, align; + if ( 'mceFullScreen' == cmd ) { + if ( 'mce_fullscreen' != ed.id && DOM.get('add_audio') && DOM.get('add_video') && DOM.get('add_image') && DOM.get('add_media') ) + ed.settings.theme_advanced_buttons1 += ',|,add_image,add_video,add_audio,add_media'; + } - if ( n.nodeName != 'IMG' ) - ed.editorCommands.mceJustify('JustifyRight', 'right'); - else ed.plugins.wordpress.do_align(n, 'alignright'); + if ( 'JustifyLeft' == cmd || 'JustifyRight' == cmd || 'JustifyCenter' == cmd ) { + n = ed.selection.getNode(); + + if ( n.nodeName == 'IMG' ) { + align = cmd.substr(7).toLowerCase(); + a = 'align' + align; + DL = ed.dom.getParent(n, 'dl.wp-caption'); + DIV = ed.dom.getParent(n, 'div.mceTemp'); + + if ( DL && DIV ) { + cls = ed.dom.hasClass(DL, a) ? 'alignnone' : a; + DL.className = DL.className.replace(/align[^ '"]+\s?/g, ''); + ed.dom.addClass(DL, cls); + + if (cls == 'aligncenter') + ed.dom.addClass(DIV, 'mceIEcenter'); + else + ed.dom.removeClass(DIV, 'mceIEcenter'); + + o.terminate = true; + ed.execCommand('mceRepaint'); + } else { + if ( ed.dom.hasClass(n, a) ) + ed.dom.addClass(n, 'alignnone'); + else + ed.dom.removeClass(n, 'alignnone'); + } + } + } }); + + ed.onInit.add(function(ed) { + // make sure these run last + ed.onNodeChange.add( function(ed, cm, e) { + var DL; + + if ( e.nodeName == 'IMG' ) { + DL = ed.dom.getParent(e, 'dl.wp-caption'); + } else if ( e.nodeName == 'DIV' && ed.dom.hasClass(e, 'mceTemp') ) { + DL = e.firstChild; + + if ( ! ed.dom.hasClass(DL, 'wp-caption') ) + DL = false; + } + + if ( DL ) { + if ( ed.dom.hasClass(DL, 'alignleft') ) + cm.setActive('justifyleft', 1); + else if ( ed.dom.hasClass(DL, 'alignright') ) + cm.setActive('justifyright', 1); + else if ( ed.dom.hasClass(DL, 'aligncenter') ) + cm.setActive('justifycenter', 1); + } + }); - ed.addCommand('JustifyCenter', function() { - var n = ed.selection.getNode(), P = ed.dom.getParent(n, 'p'), DL = ed.dom.getParent(n, 'dl'); - - if ( n.nodeName == 'IMG' && ( P || DL ) ) - ed.plugins.wordpress.do_align(n, 'aligncenter'); - else ed.editorCommands.mceJustify('JustifyCenter', 'center'); + // remove invalid parent paragraphs when pasting HTML and/or switching to the HTML editor and back + ed.onBeforeSetContent.add(function(ed, o) { + if ( o.content ) { + o.content = o.content.replace(/

        \s*<(p|div|ul|ol|dl|table|blockquote|h[1-6]|fieldset|pre|address)( [^>]*)?>/gi, '<$1$2>'); + o.content = o.content.replace(/<\/(p|div|ul|ol|dl|table|blockquote|h[1-6]|fieldset|pre|address)>\s*<\/p>/gi, ''); + } + }); }); // Word count if script is loaded @@ -303,34 +342,6 @@ this.mceTout = 0; }, - do_align : function(n, a) { - var P, DL, DIV, cls, c, ed = tinyMCE.activeEditor; - - if ( /^(mceItemFlash|mceItemShockWave|mceItemWindowsMedia|mceItemQuickTime|mceItemRealMedia)$/.test(n.className) ) - return; - - P = ed.dom.getParent(n, 'p'); - DL = ed.dom.getParent(n, 'dl'); - DIV = ed.dom.getParent(n, 'div'); - - if ( DL && DIV ) { - cls = ed.dom.hasClass(DL, a) ? 'alignnone' : a; - DL.className = DL.className.replace(/align[^ '"]+\s?/g, ''); - ed.dom.addClass(DL, cls); - c = (cls == 'aligncenter') ? ed.dom.addClass(DIV, 'mceIEcenter') : ed.dom.removeClass(DIV, 'mceIEcenter'); - } else if ( P ) { - cls = ed.dom.hasClass(n, a) ? 'alignnone' : a; - n.className = n.className.replace(/align[^ '"]+\s?/g, ''); - ed.dom.addClass(n, cls); - if ( cls == 'aligncenter' ) - ed.dom.setStyle(P, 'textAlign', 'center'); - else if (P.style && P.style.textAlign == 'center') - ed.dom.setStyle(P, 'textAlign', ''); - } - - ed.execCommand('mceRepaint'); - }, - // Resizes the iframe by a relative height value _resizeIframe : function(ed, tb_id, dy) { var ifr = ed.getContentAreaContainer().firstChild; @@ -367,8 +378,10 @@ // Replace morebreak with images ed.onBeforeSetContent.add(function(ed, o) { - o.content = o.content.replace(//g, moreHTML); - o.content = o.content.replace(//g, nextpageHTML); + if ( o.content ) { + o.content = o.content.replace(//g, moreHTML); + o.content = o.content.replace(//g, nextpageHTML); + } }); // Replace images with morebreak diff --git a/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js b/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js index ec97912d..3d215bd8 100644 --- a/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js +++ b/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js @@ -1 +1 @@ -(function(){var a=tinymce.DOM;tinymce.create("tinymce.plugins.WordPress",{mceTout:0,init:function(c,d){var e=this,h=c.getParam("wordpress_adv_toolbar","toolbar2"),g=0,f,b;f='';b='';if(getUserSetting("hidetb","0")=="1"){c.settings.wordpress_adv_hidden=0}c.onPostRender.add(function(){var i=c.controlManager.get(h);if(c.getParam("wordpress_adv_hidden",1)&&i){a.hide(i.id);e._resizeIframe(c,h,28)}});c.addCommand("WP_More",function(){c.execCommand("mceInsertContent",0,f)});c.addCommand("WP_Page",function(){c.execCommand("mceInsertContent",0,b)});c.addCommand("WP_Help",function(){c.windowManager.open({url:tinymce.baseURL+"/wp-mce-help.php",width:450,height:420,inline:1})});c.addCommand("WP_Adv",function(){var i=c.controlManager,j=i.get(h).id;if("undefined"==j){return}if(a.isHidden(j)){i.setActive("wp_adv",1);a.show(j);e._resizeIframe(c,h,-28);c.settings.wordpress_adv_hidden=0;setUserSetting("hidetb","1")}else{i.setActive("wp_adv",0);a.hide(j);e._resizeIframe(c,h,28);c.settings.wordpress_adv_hidden=1;setUserSetting("hidetb","0")}});c.addButton("wp_more",{title:"wordpress.wp_more_desc",image:d+"/img/more.gif",cmd:"WP_More"});c.addButton("wp_page",{title:"wordpress.wp_page_desc",image:d+"/img/page.gif",cmd:"WP_Page"});c.addButton("wp_help",{title:"wordpress.wp_help_desc",image:d+"/img/help.gif",cmd:"WP_Help"});c.addButton("wp_adv",{title:"wordpress.wp_adv_desc",image:d+"/img/toolbars.gif",cmd:"WP_Adv"});c.addButton("add_media",{title:"wordpress.add_media",image:d+"/img/media.gif",onclick:function(){tb_show("",tinymce.DOM.get("add_media").href);tinymce.DOM.setStyle(["TB_overlay","TB_window","TB_load"],"z-index","999999")}});c.addButton("add_image",{title:"wordpress.add_image",image:d+"/img/image.gif",onclick:function(){tb_show("",tinymce.DOM.get("add_image").href);tinymce.DOM.setStyle(["TB_overlay","TB_window","TB_load"],"z-index","999999")}});c.addButton("add_video",{title:"wordpress.add_video",image:d+"/img/video.gif",onclick:function(){tb_show("",tinymce.DOM.get("add_video").href);tinymce.DOM.setStyle(["TB_overlay","TB_window","TB_load"],"z-index","999999")}});c.addButton("add_audio",{title:"wordpress.add_audio",image:d+"/img/audio.gif",onclick:function(){tb_show("",tinymce.DOM.get("add_audio").href);tinymce.DOM.setStyle(["TB_overlay","TB_window","TB_load"],"z-index","999999")}});c.onBeforeExecCommand.add(function(i,l,k,m){var j=tinymce.DOM;if("mceFullScreen"!=l){return}if("mce_fullscreen"!=i.id&&j.get("add_audio")&&j.get("add_video")&&j.get("add_image")&&j.get("add_media")){i.settings.theme_advanced_buttons1+=",|,add_image,add_video,add_audio,add_media"}});c.addCommand("JustifyLeft",function(){var i=c.selection.getNode();if(i.nodeName!="IMG"){c.editorCommands.mceJustify("JustifyLeft","left")}else{c.plugins.wordpress.do_align(i,"alignleft")}});c.addCommand("JustifyRight",function(){var i=c.selection.getNode();if(i.nodeName!="IMG"){c.editorCommands.mceJustify("JustifyRight","right")}else{c.plugins.wordpress.do_align(i,"alignright")}});c.addCommand("JustifyCenter",function(){var k=c.selection.getNode(),j=c.dom.getParent(k,"p"),i=c.dom.getParent(k,"dl");if(k.nodeName=="IMG"&&(j||i)){c.plugins.wordpress.do_align(k,"aligncenter")}else{c.editorCommands.mceJustify("JustifyCenter","center")}});if("undefined"!=typeof wpWordCount){c.onKeyUp.add(function(i,j){if(j.keyCode==g){return}if(13==j.keyCode||8==g||46==g){wpWordCount.wc(i.getContent({format:"raw"}))}g=j.keyCode})}c.onSaveContent.add(function(i,j){if(typeof(switchEditors)=="object"){if(i.isHidden()){j.content=j.element.value}else{j.content=switchEditors.pre_wpautop(j.content)}}});e._handleMoreBreak(c,d);c.addShortcut("alt+shift+c",c.getLang("justifycenter_desc"),"JustifyCenter");c.addShortcut("alt+shift+r",c.getLang("justifyright_desc"),"JustifyRight");c.addShortcut("alt+shift+l",c.getLang("justifyleft_desc"),"JustifyLeft");c.addShortcut("alt+shift+j",c.getLang("justifyfull_desc"),"JustifyFull");c.addShortcut("alt+shift+q",c.getLang("blockquote_desc"),"mceBlockQuote");c.addShortcut("alt+shift+u",c.getLang("bullist_desc"),"InsertUnorderedList");c.addShortcut("alt+shift+o",c.getLang("numlist_desc"),"InsertOrderedList");c.addShortcut("alt+shift+d",c.getLang("striketrough_desc"),"Strikethrough");c.addShortcut("alt+shift+n",c.getLang("spellchecker.desc"),"mceSpellCheck");c.addShortcut("alt+shift+a",c.getLang("link_desc"),"mceLink");c.addShortcut("alt+shift+s",c.getLang("unlink_desc"),"unlink");c.addShortcut("alt+shift+m",c.getLang("image_desc"),"mceImage");c.addShortcut("alt+shift+g",c.getLang("fullscreen.desc"),"mceFullScreen");c.addShortcut("alt+shift+z",c.getLang("wp_adv_desc"),"WP_Adv");c.addShortcut("alt+shift+h",c.getLang("help_desc"),"WP_Help");c.addShortcut("alt+shift+t",c.getLang("wp_more_desc"),"WP_More");c.addShortcut("alt+shift+p",c.getLang("wp_page_desc"),"WP_Page");c.addShortcut("ctrl+s",c.getLang("save_desc"),function(){if("function"==typeof autosave){autosave()}});if(tinymce.isWebKit){c.addShortcut("alt+shift+b",c.getLang("bold_desc"),"Bold");c.addShortcut("alt+shift+i",c.getLang("italic_desc"),"Italic")}c.onInit.add(function(i){tinymce.dom.Event.add(i.getWin(),"scroll",function(j){i.plugins.wordpress._hideButtons()});tinymce.dom.Event.add(i.getBody(),"dragstart",function(j){i.plugins.wordpress._hideButtons()})});c.onBeforeExecCommand.add(function(i,k,j,l){i.plugins.wordpress._hideButtons()});c.onSaveContent.add(function(i,j){i.plugins.wordpress._hideButtons()});c.onMouseDown.add(function(i,j){if(j.target.nodeName!="IMG"){i.plugins.wordpress._hideButtons()}})},getInfo:function(){return{longname:"WordPress Plugin",author:"WordPress",authorurl:"http://wordpress.org",infourl:"http://wordpress.org",version:"3.0"}},_setEmbed:function(b){return b.replace(/\[embed\]([\s\S]+?)\[\/embed\][\s\u00a0]*/g,function(d,c){return''+c+''})},_getEmbed:function(b){return b.replace(/]+>/g,function(c){if(c.indexOf('class="wp-oembed')!=-1){var d=c.match(/alt="([^\"]+)"/);if(d[1]){c="[embed]"+d[1]+"[/embed]"}}return c})},_showButtons:function(f,d){var g=tinyMCE.activeEditor,i,h,b,j=tinymce.DOM,e,c;b=g.dom.getViewPort(g.getWin());i=j.getPos(g.getContentAreaContainer());h=g.dom.getPos(f);e=Math.max(h.x-b.x,0)+i.x;c=Math.max(h.y-b.y,0)+i.y;j.setStyles(d,{top:c+5+"px",left:e+5+"px",display:"block"});if(this.mceTout){clearTimeout(this.mceTout)}this.mceTout=setTimeout(function(){g.plugins.wordpress._hideButtons()},5000)},_hideButtons:function(){if(!this.mceTout){return}if(document.getElementById("wp_editbtns")){tinymce.DOM.hide("wp_editbtns")}if(document.getElementById("wp_gallerybtns")){tinymce.DOM.hide("wp_gallerybtns")}clearTimeout(this.mceTout);this.mceTout=0},do_align:function(j,d){var h,f,g,b,i,e=tinyMCE.activeEditor;if(/^(mceItemFlash|mceItemShockWave|mceItemWindowsMedia|mceItemQuickTime|mceItemRealMedia)$/.test(j.className)){return}h=e.dom.getParent(j,"p");f=e.dom.getParent(j,"dl");g=e.dom.getParent(j,"div");if(f&&g){b=e.dom.hasClass(f,d)?"alignnone":d;f.className=f.className.replace(/align[^ '"]+\s?/g,"");e.dom.addClass(f,b);i=(b=="aligncenter")?e.dom.addClass(g,"mceIEcenter"):e.dom.removeClass(g,"mceIEcenter")}else{if(h){b=e.dom.hasClass(j,d)?"alignnone":d;j.className=j.className.replace(/align[^ '"]+\s?/g,"");e.dom.addClass(j,b);if(b=="aligncenter"){e.dom.setStyle(h,"textAlign","center")}else{if(h.style&&h.style.textAlign=="center"){e.dom.setStyle(h,"textAlign","")}}}}e.execCommand("mceRepaint")},_resizeIframe:function(c,e,b){var d=c.getContentAreaContainer().firstChild;a.setStyle(d,"height",d.clientHeight+b);c.theme.deltaHeight+=b},_handleMoreBreak:function(c,d){var e,b;e='$1';b='';c.onInit.add(function(){c.dom.loadCSS(d+"/css/content.css")});c.onPostRender.add(function(){if(c.theme.onResolveName){c.theme.onResolveName.add(function(f,g){if(g.node.nodeName=="IMG"){if(c.dom.hasClass(g.node,"mceWPmore")){g.name="wpmore"}if(c.dom.hasClass(g.node,"mceWPnextpage")){g.name="wppage"}}})}});c.onBeforeSetContent.add(function(f,g){g.content=g.content.replace(//g,e);g.content=g.content.replace(//g,b)});c.onPostProcess.add(function(f,g){if(g.get){g.content=g.content.replace(/]+>/g,function(i){if(i.indexOf('class="mceWPmore')!==-1){var h,j=(h=i.match(/alt="(.*?)"/))?h[1]:"";i=""}if(i.indexOf('class="mceWPnextpage')!==-1){i=""}return i})}});c.onNodeChange.add(function(g,f,h){f.setActive("wp_page",h.nodeName==="IMG"&&g.dom.hasClass(h,"mceWPnextpage"));f.setActive("wp_more",h.nodeName==="IMG"&&g.dom.hasClass(h,"mceWPmore"))})}});tinymce.PluginManager.add("wordpress",tinymce.plugins.WordPress)})(); \ No newline at end of file +(function(){var a=tinymce.DOM;tinymce.create("tinymce.plugins.WordPress",{mceTout:0,init:function(c,d){var e=this,h=c.getParam("wordpress_adv_toolbar","toolbar2"),g=0,f,b;f='';b='';if(getUserSetting("hidetb","0")=="1"){c.settings.wordpress_adv_hidden=0}c.onPostRender.add(function(){var i=c.controlManager.get(h);if(c.getParam("wordpress_adv_hidden",1)&&i){a.hide(i.id);e._resizeIframe(c,h,28)}});c.addCommand("WP_More",function(){c.execCommand("mceInsertContent",0,f)});c.addCommand("WP_Page",function(){c.execCommand("mceInsertContent",0,b)});c.addCommand("WP_Help",function(){c.windowManager.open({url:tinymce.baseURL+"/wp-mce-help.php",width:450,height:420,inline:1})});c.addCommand("WP_Adv",function(){var i=c.controlManager,j=i.get(h).id;if("undefined"==j){return}if(a.isHidden(j)){i.setActive("wp_adv",1);a.show(j);e._resizeIframe(c,h,-28);c.settings.wordpress_adv_hidden=0;setUserSetting("hidetb","1")}else{i.setActive("wp_adv",0);a.hide(j);e._resizeIframe(c,h,28);c.settings.wordpress_adv_hidden=1;setUserSetting("hidetb","0")}});c.addButton("wp_more",{title:"wordpress.wp_more_desc",image:d+"/img/more.gif",cmd:"WP_More"});c.addButton("wp_page",{title:"wordpress.wp_page_desc",image:d+"/img/page.gif",cmd:"WP_Page"});c.addButton("wp_help",{title:"wordpress.wp_help_desc",image:d+"/img/help.gif",cmd:"WP_Help"});c.addButton("wp_adv",{title:"wordpress.wp_adv_desc",image:d+"/img/toolbars.gif",cmd:"WP_Adv"});c.addButton("add_media",{title:"wordpress.add_media",image:d+"/img/media.gif",onclick:function(){tb_show("",tinymce.DOM.get("add_media").href);tinymce.DOM.setStyle(["TB_overlay","TB_window","TB_load"],"z-index","999999")}});c.addButton("add_image",{title:"wordpress.add_image",image:d+"/img/image.gif",onclick:function(){tb_show("",tinymce.DOM.get("add_image").href);tinymce.DOM.setStyle(["TB_overlay","TB_window","TB_load"],"z-index","999999")}});c.addButton("add_video",{title:"wordpress.add_video",image:d+"/img/video.gif",onclick:function(){tb_show("",tinymce.DOM.get("add_video").href);tinymce.DOM.setStyle(["TB_overlay","TB_window","TB_load"],"z-index","999999")}});c.addButton("add_audio",{title:"wordpress.add_audio",image:d+"/img/audio.gif",onclick:function(){tb_show("",tinymce.DOM.get("add_audio").href);tinymce.DOM.setStyle(["TB_overlay","TB_window","TB_load"],"z-index","999999")}});c.onBeforeExecCommand.add(function(p,m,s,l,j){var v=tinymce.DOM,k,i,r,u,t,q;if("mceFullScreen"==m){if("mce_fullscreen"!=p.id&&v.get("add_audio")&&v.get("add_video")&&v.get("add_image")&&v.get("add_media")){p.settings.theme_advanced_buttons1+=",|,add_image,add_video,add_audio,add_media"}}if("JustifyLeft"==m||"JustifyRight"==m||"JustifyCenter"==m){k=p.selection.getNode();if(k.nodeName=="IMG"){q=m.substr(7).toLowerCase();t="align"+q;i=p.dom.getParent(k,"dl.wp-caption");r=p.dom.getParent(k,"div.mceTemp");if(i&&r){u=p.dom.hasClass(i,t)?"alignnone":t;i.className=i.className.replace(/align[^ '"]+\s?/g,"");p.dom.addClass(i,u);if(u=="aligncenter"){p.dom.addClass(r,"mceIEcenter")}else{p.dom.removeClass(r,"mceIEcenter")}j.terminate=true;p.execCommand("mceRepaint")}else{if(p.dom.hasClass(k,t)){p.dom.addClass(k,"alignnone")}else{p.dom.removeClass(k,"alignnone")}}}}});c.onInit.add(function(i){i.onNodeChange.add(function(k,j,m){var l;if(m.nodeName=="IMG"){l=k.dom.getParent(m,"dl.wp-caption")}else{if(m.nodeName=="DIV"&&k.dom.hasClass(m,"mceTemp")){l=m.firstChild;if(!k.dom.hasClass(l,"wp-caption")){l=false}}}if(l){if(k.dom.hasClass(l,"alignleft")){j.setActive("justifyleft",1)}else{if(k.dom.hasClass(l,"alignright")){j.setActive("justifyright",1)}else{if(k.dom.hasClass(l,"aligncenter")){j.setActive("justifycenter",1)}}}}});i.onBeforeSetContent.add(function(j,k){if(k.content){k.content=k.content.replace(/

        \s*<(p|div|ul|ol|dl|table|blockquote|h[1-6]|fieldset|pre|address)( [^>]*)?>/gi,"<$1$2>");k.content=k.content.replace(/<\/(p|div|ul|ol|dl|table|blockquote|h[1-6]|fieldset|pre|address)>\s*<\/p>/gi,"")}})});if("undefined"!=typeof wpWordCount){c.onKeyUp.add(function(i,j){if(j.keyCode==g){return}if(13==j.keyCode||8==g||46==g){wpWordCount.wc(i.getContent({format:"raw"}))}g=j.keyCode})}c.onSaveContent.add(function(i,j){if(typeof(switchEditors)=="object"){if(i.isHidden()){j.content=j.element.value}else{j.content=switchEditors.pre_wpautop(j.content)}}});e._handleMoreBreak(c,d);c.addShortcut("alt+shift+c",c.getLang("justifycenter_desc"),"JustifyCenter");c.addShortcut("alt+shift+r",c.getLang("justifyright_desc"),"JustifyRight");c.addShortcut("alt+shift+l",c.getLang("justifyleft_desc"),"JustifyLeft");c.addShortcut("alt+shift+j",c.getLang("justifyfull_desc"),"JustifyFull");c.addShortcut("alt+shift+q",c.getLang("blockquote_desc"),"mceBlockQuote");c.addShortcut("alt+shift+u",c.getLang("bullist_desc"),"InsertUnorderedList");c.addShortcut("alt+shift+o",c.getLang("numlist_desc"),"InsertOrderedList");c.addShortcut("alt+shift+d",c.getLang("striketrough_desc"),"Strikethrough");c.addShortcut("alt+shift+n",c.getLang("spellchecker.desc"),"mceSpellCheck");c.addShortcut("alt+shift+a",c.getLang("link_desc"),"mceLink");c.addShortcut("alt+shift+s",c.getLang("unlink_desc"),"unlink");c.addShortcut("alt+shift+m",c.getLang("image_desc"),"mceImage");c.addShortcut("alt+shift+g",c.getLang("fullscreen.desc"),"mceFullScreen");c.addShortcut("alt+shift+z",c.getLang("wp_adv_desc"),"WP_Adv");c.addShortcut("alt+shift+h",c.getLang("help_desc"),"WP_Help");c.addShortcut("alt+shift+t",c.getLang("wp_more_desc"),"WP_More");c.addShortcut("alt+shift+p",c.getLang("wp_page_desc"),"WP_Page");c.addShortcut("ctrl+s",c.getLang("save_desc"),function(){if("function"==typeof autosave){autosave()}});if(tinymce.isWebKit){c.addShortcut("alt+shift+b",c.getLang("bold_desc"),"Bold");c.addShortcut("alt+shift+i",c.getLang("italic_desc"),"Italic")}c.onInit.add(function(i){tinymce.dom.Event.add(i.getWin(),"scroll",function(j){i.plugins.wordpress._hideButtons()});tinymce.dom.Event.add(i.getBody(),"dragstart",function(j){i.plugins.wordpress._hideButtons()})});c.onBeforeExecCommand.add(function(i,k,j,l){i.plugins.wordpress._hideButtons()});c.onSaveContent.add(function(i,j){i.plugins.wordpress._hideButtons()});c.onMouseDown.add(function(i,j){if(j.target.nodeName!="IMG"){i.plugins.wordpress._hideButtons()}})},getInfo:function(){return{longname:"WordPress Plugin",author:"WordPress",authorurl:"http://wordpress.org",infourl:"http://wordpress.org",version:"3.0"}},_setEmbed:function(b){return b.replace(/\[embed\]([\s\S]+?)\[\/embed\][\s\u00a0]*/g,function(d,c){return''+c+''})},_getEmbed:function(b){return b.replace(/]+>/g,function(c){if(c.indexOf('class="wp-oembed')!=-1){var d=c.match(/alt="([^\"]+)"/);if(d[1]){c="[embed]"+d[1]+"[/embed]"}}return c})},_showButtons:function(f,d){var g=tinyMCE.activeEditor,i,h,b,j=tinymce.DOM,e,c;b=g.dom.getViewPort(g.getWin());i=j.getPos(g.getContentAreaContainer());h=g.dom.getPos(f);e=Math.max(h.x-b.x,0)+i.x;c=Math.max(h.y-b.y,0)+i.y;j.setStyles(d,{top:c+5+"px",left:e+5+"px",display:"block"});if(this.mceTout){clearTimeout(this.mceTout)}this.mceTout=setTimeout(function(){g.plugins.wordpress._hideButtons()},5000)},_hideButtons:function(){if(!this.mceTout){return}if(document.getElementById("wp_editbtns")){tinymce.DOM.hide("wp_editbtns")}if(document.getElementById("wp_gallerybtns")){tinymce.DOM.hide("wp_gallerybtns")}clearTimeout(this.mceTout);this.mceTout=0},_resizeIframe:function(c,e,b){var d=c.getContentAreaContainer().firstChild;a.setStyle(d,"height",d.clientHeight+b);c.theme.deltaHeight+=b},_handleMoreBreak:function(c,d){var e,b;e='$1';b='';c.onInit.add(function(){c.dom.loadCSS(d+"/css/content.css")});c.onPostRender.add(function(){if(c.theme.onResolveName){c.theme.onResolveName.add(function(f,g){if(g.node.nodeName=="IMG"){if(c.dom.hasClass(g.node,"mceWPmore")){g.name="wpmore"}if(c.dom.hasClass(g.node,"mceWPnextpage")){g.name="wppage"}}})}});c.onBeforeSetContent.add(function(f,g){if(g.content){g.content=g.content.replace(//g,e);g.content=g.content.replace(//g,b)}});c.onPostProcess.add(function(f,g){if(g.get){g.content=g.content.replace(/]+>/g,function(i){if(i.indexOf('class="mceWPmore')!==-1){var h,j=(h=i.match(/alt="(.*?)"/))?h[1]:"";i=""}if(i.indexOf('class="mceWPnextpage')!==-1){i=""}return i})}});c.onNodeChange.add(function(g,f,h){f.setActive("wp_page",h.nodeName==="IMG"&&g.dom.hasClass(h,"mceWPnextpage"));f.setActive("wp_more",h.nodeName==="IMG"&&g.dom.hasClass(h,"mceWPmore"))})}});tinymce.PluginManager.add("wordpress",tinymce.plugins.WordPress)})(); \ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/wpdialogs/editor_plugin.dev.js b/wp-includes/js/tinymce/plugins/wpdialogs/editor_plugin.dev.js new file mode 100644 index 00000000..bdc63ddc --- /dev/null +++ b/wp-includes/js/tinymce/plugins/wpdialogs/editor_plugin.dev.js @@ -0,0 +1,97 @@ +/** + * editor_plugin_src.js + * + * Copyright 2009, Moxiecode Systems AB + * Released under LGPL License. + * + * License: http://tinymce.moxiecode.com/license + * Contributing: http://tinymce.moxiecode.com/contributing + */ + +(function($) { + var wpDialogFn = function( fn ) { + return function() { + if ( this.features.wpDialog ) + return fn.apply( this, arguments ); + else + return this.parent.apply( this, arguments ); + }; + }; + + tinymce.create('tinymce.plugins.WPDialogs', { + init : function(ed, url) { + // Replace window manager + ed.onBeforeRenderUI.add(function() { + ed.windowManager = new tinymce.WPWindowManager(ed); + }); + }, + + getInfo : function() { + return { + longname : 'WPDialogs', + author : 'WordPress', + authorurl : 'http://wordpress.org', + infourl : 'http://wordpress.org', + version : '0.1' + }; + } + }); + + $(document).ready(function() { + $.widget("wp.wpdialog", $.ui.dialog, { + open: function() { + // Initialize tinyMCEPopup if it exists. + if ( tinyMCEPopup ) + tinyMCEPopup.init(); + // Open the dialog. + $.ui.dialog.prototype.open.apply( this, arguments ); + // WebKit leaves focus in the TinyMCE editor unless we shift focus. + this.element.focus(); + this._trigger('refresh'); + } + }); + }); + + tinymce.create('tinymce.WPWindowManager:tinymce.InlineWindowManager', { + WPWindowManager : function(ed) { + this.parent(ed); + }, + + open : function(f, p) { + var t = this, element; + // Can't use wpDialogFn here; this.features isn't set yet. + if ( ! f.wpDialog ) + return this.parent( f, p ); + else if ( ! f.id ) + return; + + element = $('#' + f.id); + if ( ! element.length ) + return; + + t.features = f; + t.params = p; + t.onOpen.dispatch(t, f, p); + t.element = t.windows[ f.id ] = element; + + // Store selection + t.bookmark = t.editor.selection.getBookmark(1); + + element.wpdialog({ + title: f.title, + width: f.width, + height: f.height, + modal: true, + dialogClass: 'wp-dialog', + zIndex: 300000 + }); + }, + close : wpDialogFn(function() { + this.element.wpdialog('close'); + }) + }); + + // Register plugin + tinymce.PluginManager.add('wpdialogs', tinymce.plugins.WPDialogs); +})(jQuery); + diff --git a/wp-includes/js/tinymce/plugins/wpdialogs/editor_plugin.js b/wp-includes/js/tinymce/plugins/wpdialogs/editor_plugin.js new file mode 100644 index 00000000..fc621f13 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/wpdialogs/editor_plugin.js @@ -0,0 +1 @@ +(function(b){var a=function(c){return function(){if(this.features.wpDialog){return c.apply(this,arguments)}else{return this.parent.apply(this,arguments)}}};tinymce.create("tinymce.plugins.WPDialogs",{init:function(c,d){c.onBeforeRenderUI.add(function(){c.windowManager=new tinymce.WPWindowManager(c)})},getInfo:function(){return{longname:"WPDialogs",author:"WordPress",authorurl:"http://wordpress.org",infourl:"http://wordpress.org",version:"0.1"}}});b(document).ready(function(){b.widget("wp.wpdialog",b.ui.dialog,{open:function(){if(tinyMCEPopup){tinyMCEPopup.init()}b.ui.dialog.prototype.open.apply(this,arguments);this.element.focus();this._trigger("refresh")}})});tinymce.create("tinymce.WPWindowManager:tinymce.InlineWindowManager",{WPWindowManager:function(c){this.parent(c)},open:function(e,g){var d=this,c;if(!e.wpDialog){return this.parent(e,g)}else{if(!e.id){return}}c=b("#"+e.id);if(!c.length){return}d.features=e;d.params=g;d.onOpen.dispatch(d,e,g);d.element=d.windows[e.id]=c;d.bookmark=d.editor.selection.getBookmark(1);c.wpdialog({title:e.title,width:e.width,height:e.height,modal:true,dialogClass:"wp-dialog",zIndex:300000})},close:a(function(){this.element.wpdialog("close")})});tinymce.PluginManager.add("wpdialogs",tinymce.plugins.WPDialogs)})(jQuery); \ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/wpdialogs/js/popup.dev.js b/wp-includes/js/tinymce/plugins/wpdialogs/js/popup.dev.js new file mode 100644 index 00000000..3f79a257 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/wpdialogs/js/popup.dev.js @@ -0,0 +1,432 @@ +/** + * popup.js + * + * An altered version of tinyMCEPopup to work in the same window as tinymce. + * + * ------------------------------------------------------------------ + * + * Copyright 2009, Moxiecode Systems AB + * Released under LGPL License. + * + * License: http://tinymce.moxiecode.com/license + * Contributing: http://tinymce.moxiecode.com/contributing + */ + +// Some global instances + +/** + * TinyMCE popup/dialog helper class. This gives you easy access to the + * parent editor instance and a bunch of other things. It's higly recommended + * that you load this script into your dialogs. + * + * @static + * @class tinyMCEPopup + */ +var tinyMCEPopup = { + /** + * Initializes the popup this will be called automatically. + * + * @method init + */ + init : function() { + var t = this, w, ti; + + // Find window & API + w = t.getWin(); + tinymce = w.tinymce; + tinyMCE = w.tinyMCE; + t.editor = tinymce.EditorManager.activeEditor; + t.params = t.editor.windowManager.params; + t.features = t.editor.windowManager.features; + t.dom = tinymce.dom; + + // Setup on init listeners + t.listeners = []; + t.onInit = { + add : function(f, s) { + t.listeners.push({func : f, scope : s}); + } + }; + + t.isWindow = false; + t.id = t.features.id; + t.editor.windowManager.onOpen.dispatch(t.editor.windowManager, window); + }, + + /** + * Returns the reference to the parent window that opened the dialog. + * + * @method getWin + * @return {Window} Reference to the parent window that opened the dialog. + */ + getWin : function() { + return window; + }, + + /** + * Returns a window argument/parameter by name. + * + * @method getWindowArg + * @param {String} n Name of the window argument to retrive. + * @param {String} dv Optional default value to return. + * @return {String} Argument value or default value if it wasn't found. + */ + getWindowArg : function(n, dv) { + var v = this.params[n]; + + return tinymce.is(v) ? v : dv; + }, + + /** + * Returns a editor parameter/config option value. + * + * @method getParam + * @param {String} n Name of the editor config option to retrive. + * @param {String} dv Optional default value to return. + * @return {String} Parameter value or default value if it wasn't found. + */ + getParam : function(n, dv) { + return this.editor.getParam(n, dv); + }, + + /** + * Returns a language item by key. + * + * @method getLang + * @param {String} n Language item like mydialog.something. + * @param {String} dv Optional default value to return. + * @return {String} Language value for the item like "my string" or the default value if it wasn't found. + */ + getLang : function(n, dv) { + return this.editor.getLang(n, dv); + }, + + /** + * Executed a command on editor that opened the dialog/popup. + * + * @method execCommand + * @param {String} cmd Command to execute. + * @param {Boolean} ui Optional boolean value if the UI for the command should be presented or not. + * @param {Object} val Optional value to pass with the comman like an URL. + * @param {Object} a Optional arguments object. + */ + execCommand : function(cmd, ui, val, a) { + a = a || {}; + a.skip_focus = 1; + + this.restoreSelection(); + return this.editor.execCommand(cmd, ui, val, a); + }, + + /** + * Resizes the dialog to the inner size of the window. This is needed since various browsers + * have different border sizes on windows. + * + * @method resizeToInnerSize + */ + resizeToInnerSize : function() { + var t = this; + + // Detach it to workaround a Chrome specific bug + // https://sourceforge.net/tracker/?func=detail&atid=635682&aid=2926339&group_id=103281 + setTimeout(function() { + var vp = t.dom.getViewPort(window); + + t.editor.windowManager.resizeBy( + t.getWindowArg('mce_width') - vp.w, + t.getWindowArg('mce_height') - vp.h, + t.id || window + ); + }, 0); + }, + + /** + * Will executed the specified string when the page has been loaded. This function + * was added for compatibility with the 2.x branch. + * + * @method executeOnLoad + * @param {String} s String to evalutate on init. + */ + executeOnLoad : function(s) { + this.onInit.add(function() { + eval(s); + }); + }, + + /** + * Stores the current editor selection for later restoration. This can be useful since some browsers + * looses it's selection if a control element is selected/focused inside the dialogs. + * + * @method storeSelection + */ + storeSelection : function() { + this.editor.windowManager.bookmark = tinyMCEPopup.editor.selection.getBookmark(1); + }, + + /** + * Restores any stored selection. This can be useful since some browsers + * looses it's selection if a control element is selected/focused inside the dialogs. + * + * @method restoreSelection + */ + restoreSelection : function() { + var t = tinyMCEPopup; + + if (!t.isWindow && tinymce.isIE) + t.editor.selection.moveToBookmark(t.editor.windowManager.bookmark); + }, + + /** + * Loads a specific dialog language pack. If you pass in plugin_url as a arugment + * when you open the window it will load the /langs/_dlg.js lang pack file. + * + * @method requireLangPack + */ + requireLangPack : function() { + var t = this, u = t.getWindowArg('plugin_url') || t.getWindowArg('theme_url'); + + if (u && t.editor.settings.language && t.features.translate_i18n !== false) { + u += '/langs/' + t.editor.settings.language + '_dlg.js'; + + if (!tinymce.ScriptLoader.isDone(u)) { + document.write(''); + tinymce.ScriptLoader.markDone(u); + } + } + }, + + /** + * Executes a color picker on the specified element id. When the user + * then selects a color it will be set as the value of the specified element. + * + * @method pickColor + * @param {DOMEvent} e DOM event object. + * @param {string} element_id Element id to be filled with the color value from the picker. + */ + pickColor : function(e, element_id) { + this.execCommand('mceColorPicker', true, { + color : document.getElementById(element_id).value, + func : function(c) { + document.getElementById(element_id).value = c; + + try { + document.getElementById(element_id).onchange(); + } catch (ex) { + // Try fire event, ignore errors + } + } + }); + }, + + /** + * Opens a filebrowser/imagebrowser this will set the output value from + * the browser as a value on the specified element. + * + * @method openBrowser + * @param {string} element_id Id of the element to set value in. + * @param {string} type Type of browser to open image/file/flash. + * @param {string} option Option name to get the file_broswer_callback function name from. + */ + openBrowser : function(element_id, type, option) { + tinyMCEPopup.restoreSelection(); + this.editor.execCallback('file_browser_callback', element_id, document.getElementById(element_id).value, type, window); + }, + + /** + * Creates a confirm dialog. Please don't use the blocking behavior of this + * native version use the callback method instead then it can be extended. + * + * @method confirm + * @param {String} t Title for the new confirm dialog. + * @param {function} cb Callback function to be executed after the user has selected ok or cancel. + * @param {Object} s Optional scope to execute the callback in. + */ + confirm : function(t, cb, s) { + this.editor.windowManager.confirm(t, cb, s, window); + }, + + /** + * Creates a alert dialog. Please don't use the blocking behavior of this + * native version use the callback method instead then it can be extended. + * + * @method alert + * @param {String} t Title for the new alert dialog. + * @param {function} cb Callback function to be executed after the user has selected ok. + * @param {Object} s Optional scope to execute the callback in. + */ + alert : function(tx, cb, s) { + this.editor.windowManager.alert(tx, cb, s, window); + }, + + /** + * Closes the current window. + * + * @method close + */ + close : function() { + var t = this; + + // To avoid domain relaxing issue in Opera + function close() { + t.editor.windowManager.close(window); + t.editor = null; + }; + + if (tinymce.isOpera) + t.getWin().setTimeout(close, 0); + else + close(); + }, + + // Internal functions + + _restoreSelection : function() { + var e = window.event.srcElement; + + if (e.nodeName == 'INPUT' && (e.type == 'submit' || e.type == 'button')) + tinyMCEPopup.restoreSelection(); + }, + +/* _restoreSelection : function() { + var e = window.event.srcElement; + + // If user focus a non text input or textarea + if ((e.nodeName != 'INPUT' && e.nodeName != 'TEXTAREA') || e.type != 'text') + tinyMCEPopup.restoreSelection(); + },*/ + + _onDOMLoaded : function() { + var t = tinyMCEPopup, ti = document.title, bm, h, nv; + + if (t.domLoaded) + return; + + t.domLoaded = 1; + + tinyMCEPopup.init(); + + // Translate page + if (t.features.translate_i18n !== false) { + h = document.body.innerHTML; + + // Replace a=x with a="x" in IE + if (tinymce.isIE) + h = h.replace(/ (value|title|alt)=([^"][^\s>]+)/gi, ' $1="$2"') + + document.dir = t.editor.getParam('directionality',''); + + if ((nv = t.editor.translate(h)) && nv != h) + document.body.innerHTML = nv; + + if ((nv = t.editor.translate(ti)) && nv != ti) + document.title = ti = nv; + } + + document.body.style.display = ''; + + // Restore selection in IE when focus is placed on a non textarea or input element of the type text + if (tinymce.isIE) { + document.attachEvent('onmouseup', tinyMCEPopup._restoreSelection); + + // Add base target element for it since it would fail with modal dialogs + t.dom.add(t.dom.select('head')[0], 'base', {target : '_self'}); + } + + t.restoreSelection(); + + // Set inline title + if (!t.isWindow) + t.editor.windowManager.setTitle(window, ti); + else + window.focus(); + + if (!tinymce.isIE && !t.isWindow) { + tinymce.dom.Event._add(document, 'focus', function() { + t.editor.windowManager.focus(t.id); + }); + } + + // Patch for accessibility + tinymce.each(t.dom.select('select'), function(e) { + e.onkeydown = tinyMCEPopup._accessHandler; + }); + + // Call onInit + // Init must be called before focus so the selection won't get lost by the focus call + tinymce.each(t.listeners, function(o) { + o.func.call(o.scope, t.editor); + }); + + // Move focus to window + if (t.getWindowArg('mce_auto_focus', true)) { + window.focus(); + + // Focus element with mceFocus class + tinymce.each(document.forms, function(f) { + tinymce.each(f.elements, function(e) { + if (t.dom.hasClass(e, 'mceFocus') && !e.disabled) { + e.focus(); + return false; // Break loop + } + }); + }); + } + + document.onkeyup = tinyMCEPopup._closeWinKeyHandler; + }, + + _accessHandler : function(e) { + e = e || window.event; + + if (e.keyCode == 13 || e.keyCode == 32) { + e = e.target || e.srcElement; + + if (e.onchange) + e.onchange(); + + return tinymce.dom.Event.cancel(e); + } + }, + + _closeWinKeyHandler : function(e) { + e = e || window.event; + + if (e.keyCode == 27) + tinyMCEPopup.close(); + }, + + _wait : function() { + // Use IE method + if (document.attachEvent) { + document.attachEvent("onreadystatechange", function() { + if (document.readyState === "complete") { + document.detachEvent("onreadystatechange", arguments.callee); + tinyMCEPopup._onDOMLoaded(); + } + }); + + if (document.documentElement.doScroll && window == window.top) { + (function() { + if (tinyMCEPopup.domLoaded) + return; + + try { + // If IE is used, use the trick by Diego Perini + // http://javascript.nwbox.com/IEContentLoaded/ + document.documentElement.doScroll("left"); + } catch (ex) { + setTimeout(arguments.callee, 0); + return; + } + + tinyMCEPopup._onDOMLoaded(); + })(); + } + + document.attachEvent('onload', tinyMCEPopup._onDOMLoaded); + } else if (document.addEventListener) { + window.addEventListener('DOMContentLoaded', tinyMCEPopup._onDOMLoaded, false); + window.addEventListener('load', tinyMCEPopup._onDOMLoaded, false); + } + } +}; diff --git a/wp-includes/js/tinymce/plugins/wpdialogs/js/popup.js b/wp-includes/js/tinymce/plugins/wpdialogs/js/popup.js new file mode 100644 index 00000000..abacbd3a --- /dev/null +++ b/wp-includes/js/tinymce/plugins/wpdialogs/js/popup.js @@ -0,0 +1 @@ +var tinyMCEPopup={init:function(){var b=this,a,c;a=b.getWin();tinymce=a.tinymce;tinyMCE=a.tinyMCE;b.editor=tinymce.EditorManager.activeEditor;b.params=b.editor.windowManager.params;b.features=b.editor.windowManager.features;b.dom=tinymce.dom;b.listeners=[];b.onInit={add:function(e,d){b.listeners.push({func:e,scope:d})}};b.isWindow=false;b.id=b.features.id;b.editor.windowManager.onOpen.dispatch(b.editor.windowManager,window)},getWin:function(){return window},getWindowArg:function(c,b){var a=this.params[c];return tinymce.is(a)?a:b},getParam:function(b,a){return this.editor.getParam(b,a)},getLang:function(b,a){return this.editor.getLang(b,a)},execCommand:function(d,c,e,b){b=b||{};b.skip_focus=1;this.restoreSelection();return this.editor.execCommand(d,c,e,b)},resizeToInnerSize:function(){var a=this;setTimeout(function(){var b=a.dom.getViewPort(window);a.editor.windowManager.resizeBy(a.getWindowArg("mce_width")-b.w,a.getWindowArg("mce_height")-b.h,a.id||window)},0)},executeOnLoad:function(s){this.onInit.add(function(){eval(s)})},storeSelection:function(){this.editor.windowManager.bookmark=tinyMCEPopup.editor.selection.getBookmark(1)},restoreSelection:function(){var a=tinyMCEPopup;if(!a.isWindow&&tinymce.isIE){a.editor.selection.moveToBookmark(a.editor.windowManager.bookmark)}},requireLangPack:function(){var b=this,a=b.getWindowArg("plugin_url")||b.getWindowArg("theme_url");if(a&&b.editor.settings.language&&b.features.translate_i18n!==false){a+="/langs/"+b.editor.settings.language+"_dlg.js";if(!tinymce.ScriptLoader.isDone(a)){document.write(' - - + + +

        @@ -49,7 +49,7 @@
        - +
        diff --git a/wp-includes/js/tinymce/themes/advanced/anchor.htm b/wp-includes/js/tinymce/themes/advanced/anchor.htm index 820f9ab4..b7bbe95c 100644 --- a/wp-includes/js/tinymce/themes/advanced/anchor.htm +++ b/wp-includes/js/tinymce/themes/advanced/anchor.htm @@ -2,8 +2,8 @@ {#advanced_dlg.anchor_title} - - + + diff --git a/wp-includes/js/tinymce/themes/advanced/charmap.htm b/wp-includes/js/tinymce/themes/advanced/charmap.htm index 2e98030a..7a5ac7e1 100644 --- a/wp-includes/js/tinymce/themes/advanced/charmap.htm +++ b/wp-includes/js/tinymce/themes/advanced/charmap.htm @@ -2,9 +2,8 @@ {#advanced_dlg.charmap_title} - - - + + diff --git a/wp-includes/js/tinymce/themes/advanced/color_picker.htm b/wp-includes/js/tinymce/themes/advanced/color_picker.htm index 5a56e214..2d00cd5c 100644 --- a/wp-includes/js/tinymce/themes/advanced/color_picker.htm +++ b/wp-includes/js/tinymce/themes/advanced/color_picker.htm @@ -2,9 +2,9 @@ {#advanced_dlg.colorpicker_title} - - - + + + diff --git a/wp-includes/js/tinymce/themes/advanced/editor_template.js b/wp-includes/js/tinymce/themes/advanced/editor_template.js index 628c793c..c5a1719a 100644 --- a/wp-includes/js/tinymce/themes/advanced/editor_template.js +++ b/wp-includes/js/tinymce/themes/advanced/editor_template.js @@ -1 +1 @@ -(function(e){var d=e.DOM,b=e.dom.Event,h=e.extend,f=e.each,a=e.util.Cookie,g,c=e.explode;e.ThemeManager.requireLangPack("advanced");e.create("tinymce.themes.AdvancedTheme",{sizes:[8,10,12,14,18,24,36],controls:{bold:["bold_desc","Bold"],italic:["italic_desc","Italic"],underline:["underline_desc","Underline"],strikethrough:["striketrough_desc","Strikethrough"],justifyleft:["justifyleft_desc","JustifyLeft"],justifycenter:["justifycenter_desc","JustifyCenter"],justifyright:["justifyright_desc","JustifyRight"],justifyfull:["justifyfull_desc","JustifyFull"],bullist:["bullist_desc","InsertUnorderedList"],numlist:["numlist_desc","InsertOrderedList"],outdent:["outdent_desc","Outdent"],indent:["indent_desc","Indent"],cut:["cut_desc","Cut"],copy:["copy_desc","Copy"],paste:["paste_desc","Paste"],undo:["undo_desc","Undo"],redo:["redo_desc","Redo"],link:["link_desc","mceLink"],unlink:["unlink_desc","unlink"],image:["image_desc","mceImage"],cleanup:["cleanup_desc","mceCleanup"],help:["help_desc","mceHelp"],code:["code_desc","mceCodeEditor"],hr:["hr_desc","InsertHorizontalRule"],removeformat:["removeformat_desc","RemoveFormat"],sub:["sub_desc","subscript"],sup:["sup_desc","superscript"],forecolor:["forecolor_desc","ForeColor"],forecolorpicker:["forecolor_desc","mceForeColor"],backcolor:["backcolor_desc","HiliteColor"],backcolorpicker:["backcolor_desc","mceBackColor"],charmap:["charmap_desc","mceCharMap"],visualaid:["visualaid_desc","mceToggleVisualAid"],anchor:["anchor_desc","mceInsertAnchor"],newdocument:["newdocument_desc","mceNewDocument"],blockquote:["blockquote_desc","mceBlockQuote"]},stateControls:["bold","italic","underline","strikethrough","bullist","numlist","justifyleft","justifycenter","justifyright","justifyfull","sub","sup","blockquote"],init:function(j,k){var l=this,m,i,n;l.editor=j;l.url=k;l.onResolveName=new e.util.Dispatcher(this);l.settings=m=h({theme_advanced_path:true,theme_advanced_toolbar_location:"bottom",theme_advanced_buttons1:"bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect",theme_advanced_buttons2:"bullist,numlist,|,outdent,indent,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code",theme_advanced_buttons3:"hr,removeformat,visualaid,|,sub,sup,|,charmap",theme_advanced_blockformats:"p,address,pre,h1,h2,h3,h4,h5,h6",theme_advanced_toolbar_align:"center",theme_advanced_fonts:"Andale Mono=andale mono,times;Arial=arial,helvetica,sans-serif;Arial Black=arial black,avant garde;Book Antiqua=book antiqua,palatino;Comic Sans MS=comic sans ms,sans-serif;Courier New=courier new,courier;Georgia=georgia,palatino;Helvetica=helvetica;Impact=impact,chicago;Symbol=symbol;Tahoma=tahoma,arial,helvetica,sans-serif;Terminal=terminal,monaco;Times New Roman=times new roman,times;Trebuchet MS=trebuchet ms,geneva;Verdana=verdana,geneva;Webdings=webdings;Wingdings=wingdings,zapf dingbats",theme_advanced_more_colors:1,theme_advanced_row_height:23,theme_advanced_resize_horizontal:1,theme_advanced_resizing_use_cookie:1,theme_advanced_font_sizes:"1,2,3,4,5,6,7",readonly:j.settings.readonly},j.settings);if(!m.font_size_style_values){m.font_size_style_values="8pt,10pt,12pt,14pt,18pt,24pt,36pt"}if(e.is(m.theme_advanced_font_sizes,"string")){m.font_size_style_values=e.explode(m.font_size_style_values);m.font_size_classes=e.explode(m.font_size_classes||"");n={};j.settings.theme_advanced_font_sizes=m.theme_advanced_font_sizes;f(j.getParam("theme_advanced_font_sizes","","hash"),function(q,p){var o;if(p==q&&q>=1&&q<=7){p=q+" ("+l.sizes[q-1]+"pt)";if(j.settings.convert_fonts_to_spans){o=m.font_size_classes[q-1];q=m.font_size_style_values[q-1]||(l.sizes[q-1]+"pt")}}if(/^\s*\./.test(q)){o=q.replace(/\./g,"")}n[p]=o?{"class":o}:{fontSize:q}});m.theme_advanced_font_sizes=n}if((i=m.theme_advanced_path_location)&&i!="none"){m.theme_advanced_statusbar_location=m.theme_advanced_path_location}if(m.theme_advanced_statusbar_location=="none"){m.theme_advanced_statusbar_location=0}j.onInit.add(function(){j.onNodeChange.add(l._nodeChanged,l);if(j.settings.content_css!==false){j.dom.loadCSS(j.baseURI.toAbsolute("themes/advanced/skins/"+j.settings.skin+"/content.css"))}});j.onSetProgressState.add(function(q,o,r){var s,t=q.id,p;if(o){l.progressTimer=setTimeout(function(){s=q.getContainer();s=s.insertBefore(d.create("DIV",{style:"position:relative"}),s.firstChild);p=d.get(q.id+"_tbl");d.add(s,"div",{id:t+"_blocker","class":"mceBlocker",style:{width:p.clientWidth+2,height:p.clientHeight+2}});d.add(s,"div",{id:t+"_progress","class":"mceProgress",style:{left:p.clientWidth/2,top:p.clientHeight/2}})},r||0)}else{d.remove(t+"_blocker");d.remove(t+"_progress");clearTimeout(l.progressTimer)}});d.loadCSS(m.editor_css?j.documentBaseURI.toAbsolute(m.editor_css):k+"/skins/"+j.settings.skin+"/ui.css");if(m.skin_variant){d.loadCSS(k+"/skins/"+j.settings.skin+"/ui_"+m.skin_variant+".css")}},createControl:function(l,i){var j,k;if(k=i.createControl(l)){return k}switch(l){case"styleselect":return this._createStyleSelect();case"formatselect":return this._createBlockFormats();case"fontselect":return this._createFontSelect();case"fontsizeselect":return this._createFontSizeSelect();case"forecolor":return this._createForeColorMenu();case"backcolor":return this._createBackColorMenu()}if((j=this.controls[l])){return i.createButton(l,{title:"advanced."+j[0],cmd:j[1],ui:j[2],value:j[3]})}},execCommand:function(k,j,l){var i=this["_"+k];if(i){i.call(this,j,l);return true}return false},_importClasses:function(j){var i=this.editor,k=i.controlManager.get("styleselect");if(k.getLength()==0){f(i.dom.getClasses(),function(l){k.add(l["class"],l["class"])})}},_createStyleSelect:function(m){var j=this,i=j.editor,k=i.controlManager,l=k.createListBox("styleselect",{title:"advanced.style_select",onselect:function(n){if(l.selectedValue===n){i.execCommand("mceSetStyleInfo",0,{command:"removeformat"});l.select();return false}else{i.execCommand("mceSetCSSClass",0,n)}}});if(l){f(i.getParam("theme_advanced_styles","","hash"),function(o,n){if(o){l.add(j.editor.translate(n),o)}});l.onPostRender.add(function(o,p){if(!l.NativeListBox){b.add(p.id+"_text","focus",j._importClasses,j);b.add(p.id+"_text","mousedown",j._importClasses,j);b.add(p.id+"_open","focus",j._importClasses,j);b.add(p.id+"_open","mousedown",j._importClasses,j)}else{b.add(p.id,"focus",j._importClasses,j)}})}return l},_createFontSelect:function(){var k,j=this,i=j.editor;k=i.controlManager.createListBox("fontselect",{title:"advanced.fontdefault",cmd:"FontName"});if(k){f(i.getParam("theme_advanced_fonts",j.settings.theme_advanced_fonts,"hash"),function(m,l){k.add(i.translate(l),m,{style:m.indexOf("dings")==-1?"font-family:"+m:""})})}return k},_createFontSizeSelect:function(){var m=this,k=m.editor,n,l=0,j=[];n=k.controlManager.createListBox("fontsizeselect",{title:"advanced.font_size",onselect:function(i){if(i.fontSize){k.execCommand("FontSize",false,i.fontSize)}else{f(m.settings.theme_advanced_font_sizes,function(p,o){if(p["class"]){j.push(p["class"])}});k.editorCommands._applyInlineStyle("span",{"class":i["class"]},{check_classes:j})}}});if(n){f(m.settings.theme_advanced_font_sizes,function(o,i){var p=o.fontSize;if(p>=1&&p<=7){p=m.sizes[parseInt(p)-1]+"pt"}n.add(i,o,{style:"font-size:"+p,"class":"mceFontSize"+(l++)+(" "+(o["class"]||""))})})}return n},_createBlockFormats:function(){var k,i={p:"advanced.paragraph",address:"advanced.address",pre:"advanced.pre",h1:"advanced.h1",h2:"advanced.h2",h3:"advanced.h3",h4:"advanced.h4",h5:"advanced.h5",h6:"advanced.h6",div:"advanced.div",blockquote:"advanced.blockquote",code:"advanced.code",dt:"advanced.dt",dd:"advanced.dd",samp:"advanced.samp"},j=this;k=j.editor.controlManager.createListBox("formatselect",{title:"advanced.block",cmd:"FormatBlock"});if(k){f(j.editor.getParam("theme_advanced_blockformats",j.settings.theme_advanced_blockformats,"hash"),function(m,l){k.add(j.editor.translate(l!=m?l:i[m]),m,{"class":"mce_formatPreview mce_"+m})})}return k},_createForeColorMenu:function(){var m,j=this,k=j.settings,l={},i;if(k.theme_advanced_more_colors){l.more_colors_func=function(){j._mceColorPicker(0,{color:m.value,func:function(n){m.setColor(n)}})}}if(i=k.theme_advanced_text_colors){l.colors=i}if(k.theme_advanced_default_foreground_color){l.default_color=k.theme_advanced_default_foreground_color}l.title="advanced.forecolor_desc";l.cmd="ForeColor";l.scope=this;m=j.editor.controlManager.createColorSplitButton("forecolor",l);return m},_createBackColorMenu:function(){var m,j=this,k=j.settings,l={},i;if(k.theme_advanced_more_colors){l.more_colors_func=function(){j._mceColorPicker(0,{color:m.value,func:function(n){m.setColor(n)}})}}if(i=k.theme_advanced_background_colors){l.colors=i}if(k.theme_advanced_default_background_color){l.default_color=k.theme_advanced_default_background_color}l.title="advanced.backcolor_desc";l.cmd="HiliteColor";l.scope=this;m=j.editor.controlManager.createColorSplitButton("backcolor",l);return m},renderUI:function(k){var m,l,q,v=this,r=v.editor,w=v.settings,u,j,i;m=j=d.create("span",{id:r.id+"_parent","class":"mceEditor "+r.settings.skin+"Skin"+(w.skin_variant?" "+r.settings.skin+"Skin"+v._ufirst(w.skin_variant):"")});if(!d.boxModel){m=d.add(m,"div",{"class":"mceOldBoxModel"})}m=u=d.add(m,"table",{id:r.id+"_tbl","class":"mceLayout",cellSpacing:0,cellPadding:0});m=q=d.add(m,"tbody");switch((w.theme_advanced_layout_manager||"").toLowerCase()){case"rowlayout":l=v._rowLayout(w,q,k);break;case"customlayout":l=r.execCallback("theme_advanced_custom_layout",w,q,k,j);break;default:l=v._simpleLayout(w,q,k,j)}m=k.targetNode;i=d.stdMode?u.getElementsByTagName("tr"):u.rows;d.addClass(i[0],"mceFirst");d.addClass(i[i.length-1],"mceLast");f(d.select("tr",q),function(o){d.addClass(o.firstChild,"mceFirst");d.addClass(o.childNodes[o.childNodes.length-1],"mceLast")});if(d.get(w.theme_advanced_toolbar_container)){d.get(w.theme_advanced_toolbar_container).appendChild(j)}else{d.insertAfter(j,m)}b.add(r.id+"_path_row","click",function(n){n=n.target;if(n.nodeName=="A"){v._sel(n.className.replace(/^.*mcePath_([0-9]+).*$/,"$1"));return b.cancel(n)}});if(!r.getParam("accessibility_focus")){b.add(d.add(j,"a",{href:"#"},""),"focus",function(){tinyMCE.get(r.id).focus()})}if(w.theme_advanced_toolbar_location=="external"){k.deltaHeight=0}v.deltaHeight=k.deltaHeight;k.targetNode=null;return{iframeContainer:l,editorContainer:r.id+"_parent",sizeContainer:u,deltaHeight:k.deltaHeight}},getInfo:function(){return{longname:"Advanced theme",author:"Moxiecode Systems AB",authorurl:"http://tinymce.moxiecode.com",version:e.majorVersion+"."+e.minorVersion}},resizeBy:function(i,j){var k=d.get(this.editor.id+"_tbl");this.resizeTo(k.clientWidth+i,k.clientHeight+j)},resizeTo:function(i,l){var j=this.editor,k=j.settings,n=d.get(j.id+"_tbl"),o=d.get(j.id+"_ifr"),m;i=Math.max(k.theme_advanced_resizing_min_width||100,i);l=Math.max(k.theme_advanced_resizing_min_height||100,l);i=Math.min(k.theme_advanced_resizing_max_width||65535,i);l=Math.min(k.theme_advanced_resizing_max_height||65535,l);m=n.clientHeight-o.clientHeight;d.setStyle(o,"height",l-m);d.setStyles(n,{width:i,height:l})},destroy:function(){var i=this.editor.id;b.clear(i+"_resize");b.clear(i+"_path_row");b.clear(i+"_external_close")},_simpleLayout:function(y,r,k,i){var x=this,u=x.editor,v=y.theme_advanced_toolbar_location,m=y.theme_advanced_statusbar_location,l,j,q,w;if(y.readonly){l=d.add(r,"tr");l=j=d.add(l,"td",{"class":"mceIframeContainer"});return j}if(v=="top"){x._addToolbars(r,k)}if(v=="external"){l=w=d.create("div",{style:"position:relative"});l=d.add(l,"div",{id:u.id+"_external","class":"mceExternalToolbar"});d.add(l,"a",{id:u.id+"_external_close",href:"javascript:;","class":"mceExternalClose"});l=d.add(l,"table",{id:u.id+"_tblext",cellSpacing:0,cellPadding:0});q=d.add(l,"tbody");if(i.firstChild.className=="mceOldBoxModel"){i.firstChild.appendChild(w)}else{i.insertBefore(w,i.firstChild)}x._addToolbars(q,k);u.onMouseUp.add(function(){var o=d.get(u.id+"_external");d.show(o);d.hide(g);var n=b.add(u.id+"_external_close","click",function(){d.hide(u.id+"_external");b.remove(u.id+"_external_close","click",n)});d.show(o);d.setStyle(o,"top",0-d.getRect(u.id+"_tblext").h-1);d.hide(o);d.show(o);o.style.filter="";g=u.id+"_external";o=null})}if(m=="top"){x._addStatusBar(r,k)}if(!y.theme_advanced_toolbar_container){l=d.add(r,"tr");l=j=d.add(l,"td",{"class":"mceIframeContainer"})}if(v=="bottom"){x._addToolbars(r,k)}if(m=="bottom"){x._addStatusBar(r,k)}return j},_rowLayout:function(w,m,k){var v=this,p=v.editor,u,x,i=p.controlManager,l,j,r,q;u=w.theme_advanced_containers_default_class||"";x=w.theme_advanced_containers_default_align||"center";f(c(w.theme_advanced_containers||""),function(s,o){var n=w["theme_advanced_container_"+s]||"";switch(n.toLowerCase()){case"mceeditor":l=d.add(m,"tr");l=j=d.add(l,"td",{"class":"mceIframeContainer"});break;case"mceelementpath":v._addStatusBar(m,k);break;default:q=(w["theme_advanced_container_"+s+"_align"]||x).toLowerCase();q="mce"+v._ufirst(q);l=d.add(d.add(m,"tr"),"td",{"class":"mceToolbar "+(w["theme_advanced_container_"+s+"_class"]||u)+" "+q||x});r=i.createToolbar("toolbar"+o);v._addControls(n,r);d.setHTML(l,r.renderHTML());k.deltaHeight-=w.theme_advanced_row_height}});return j},_addControls:function(j,i){var k=this,l=k.settings,m,n=k.editor.controlManager;if(l.theme_advanced_disable&&!k._disabled){m={};f(c(l.theme_advanced_disable),function(o){m[o]=1});k._disabled=m}else{m=k._disabled}f(c(j),function(p){var o;if(m&&m[p]){return}if(p=="tablecontrols"){f(["table","|","row_props","cell_props","|","row_before","row_after","delete_row","|","col_before","col_after","delete_col","|","split_cells","merge_cells"],function(q){q=k.createControl(q,n);if(q){i.add(q)}});return}o=k.createControl(p,n);if(o){i.add(o)}})},_addToolbars:function(w,k){var z=this,p,m,r=z.editor,A=z.settings,y,j=r.controlManager,u,l,q=[],x;x=A.theme_advanced_toolbar_align.toLowerCase();x="mce"+z._ufirst(x);l=d.add(d.add(w,"tr"),"td",{"class":"mceToolbar "+x});if(!r.getParam("accessibility_focus")){q.push(d.createHTML("a",{href:"#",onfocus:"tinyMCE.get('"+r.id+"').focus();"},""))}q.push(d.createHTML("a",{href:"#",accesskey:"q",title:r.getLang("advanced.toolbar_focus")},""));for(p=1;(y=A["theme_advanced_buttons"+p]);p++){m=j.createToolbar("toolbar"+p,{"class":"mceToolbarRow"+p});if(A["theme_advanced_buttons"+p+"_add"]){y+=","+A["theme_advanced_buttons"+p+"_add"]}if(A["theme_advanced_buttons"+p+"_add_before"]){y=A["theme_advanced_buttons"+p+"_add_before"]+","+y}z._addControls(y,m);q.push(m.renderHTML());k.deltaHeight-=A.theme_advanced_row_height}q.push(d.createHTML("a",{href:"#",accesskey:"z",title:r.getLang("advanced.toolbar_focus"),onfocus:"tinyMCE.getInstanceById('"+r.id+"').focus();"},""));d.setHTML(l,q.join(""))},_addStatusBar:function(m,j){var k,v=this,p=v.editor,w=v.settings,i,q,u,l;k=d.add(m,"tr");k=l=d.add(k,"td",{"class":"mceStatusbar"});k=d.add(k,"div",{id:p.id+"_path_row"},w.theme_advanced_path?p.translate("advanced.path")+": ":" ");d.add(k,"a",{href:"#",accesskey:"x"});if(w.theme_advanced_resizing){d.add(l,"a",{id:p.id+"_resize",href:"javascript:;",onclick:"return false;","class":"mceResize"});if(w.theme_advanced_resizing_use_cookie){p.onPostRender.add(function(){var n=a.getHash("TinyMCE_"+p.id+"_size"),r=d.get(p.id+"_tbl");if(!n){return}if(w.theme_advanced_resize_horizontal){r.style.width=Math.max(10,n.cw)+"px"}r.style.height=Math.max(10,n.ch)+"px";d.get(p.id+"_ifr").style.height=Math.max(10,parseInt(n.ch)+v.deltaHeight)+"px"})}p.onPostRender.add(function(){b.add(p.id+"_resize","mousedown",function(x){var z,t,o,s,y,r;z=d.get(p.id+"_tbl");o=z.clientWidth;s=z.clientHeight;miw=w.theme_advanced_resizing_min_width||100;mih=w.theme_advanced_resizing_min_height||100;maw=w.theme_advanced_resizing_max_width||65535;mah=w.theme_advanced_resizing_max_height||65535;t=d.add(d.get(p.id+"_parent"),"div",{"class":"mcePlaceHolder"});d.setStyles(t,{width:o,height:s});d.hide(z);d.show(t);i={x:x.screenX,y:x.screenY,w:o,h:s,dx:null,dy:null};q=b.add(d.doc,"mousemove",function(B){var n,A;i.dx=B.screenX-i.x;i.dy=B.screenY-i.y;n=Math.max(miw,i.w+i.dx);A=Math.max(mih,i.h+i.dy);n=Math.min(maw,n);A=Math.min(mah,A);if(w.theme_advanced_resize_horizontal){t.style.width=n+"px"}t.style.height=A+"px";return b.cancel(B)});u=b.add(d.doc,"mouseup",function(n){var A;b.remove(d.doc,"mousemove",q);b.remove(d.doc,"mouseup",u);z.style.display="";d.remove(t);if(i.dx===null){return}A=d.get(p.id+"_ifr");if(w.theme_advanced_resize_horizontal){z.style.width=Math.max(10,i.w+i.dx)+"px"}z.style.height=Math.max(10,i.h+i.dy)+"px";A.style.height=Math.max(10,A.clientHeight+i.dy)+"px";if(w.theme_advanced_resizing_use_cookie){a.setHash("TinyMCE_"+p.id+"_size",{cw:i.w+i.dx,ch:i.h+i.dy})}});return b.cancel(x)})})}j.deltaHeight-=21;k=m=null},_nodeChanged:function(l,u,k,q){var y=this,i,r=0,x,m,z=y.settings,w,j,o;if(z.readonly){return}e.each(y.stateControls,function(n){u.setActive(n,l.queryCommandState(y.controls[n][1]))});u.setActive("visualaid",l.hasVisual);u.setDisabled("undo",!l.undoManager.hasUndo()&&!l.typing);u.setDisabled("redo",!l.undoManager.hasRedo());u.setDisabled("outdent",!l.queryCommandState("Outdent"));i=d.getParent(k,"A");if(m=u.get("link")){if(!i||!i.name){m.setDisabled(!i&&q);m.setActive(!!i)}}if(m=u.get("unlink")){m.setDisabled(!i&&q);m.setActive(!!i&&!i.name)}if(m=u.get("anchor")){m.setActive(!!i&&i.name);if(e.isWebKit){i=d.getParent(k,"IMG");m.setActive(!!i&&d.getAttrib(i,"mce_name")=="a")}}i=d.getParent(k,"IMG");if(m=u.get("image")){m.setActive(!!i&&k.className.indexOf("mceItem")==-1)}if(m=u.get("styleselect")){if(k.className){y._importClasses();m.select(k.className)}else{m.select()}}if(m=u.get("formatselect")){i=d.getParent(k,d.isBlock);if(i){m.select(i.nodeName.toLowerCase())}}if(l.settings.convert_fonts_to_spans){l.dom.getParent(k,function(p){if(p.nodeName==="SPAN"){if(!w&&p.className){w=p.className}if(!j&&p.style.fontSize){j=p.style.fontSize}if(!o&&p.style.fontFamily){o=p.style.fontFamily.replace(/[\"\']+/g,"").replace(/^([^,]+).*/,"$1").toLowerCase()}}return false});if(m=u.get("fontselect")){m.select(function(n){return n.replace(/^([^,]+).*/,"$1").toLowerCase()==o})}if(m=u.get("fontsizeselect")){m.select(function(n){if(n.fontSize&&n.fontSize===j){return true}if(n["class"]&&n["class"]===w){return true}})}}else{if(m=u.get("fontselect")){m.select(l.queryCommandValue("FontName"))}if(m=u.get("fontsizeselect")){x=l.queryCommandValue("FontSize");m.select(function(n){return n.fontSize==x})}}if(z.theme_advanced_path&&z.theme_advanced_statusbar_location){i=d.get(l.id+"_path")||d.add(l.id+"_path_row","span",{id:l.id+"_path"});d.setHTML(i,"");l.dom.getParent(k,function(A){var p=A.nodeName.toLowerCase(),s,v,t="";if(A.nodeType!=1||A.nodeName==="BR"||(d.hasClass(A,"mceItemHidden")||d.hasClass(A,"mceItemRemoved"))){return}if(x=d.getAttrib(A,"mce_name")){p=x}if(e.isIE&&A.scopeName!=="HTML"){p=A.scopeName+":"+p}p=p.replace(/mce\:/g,"");switch(p){case"b":p="strong";break;case"i":p="em";break;case"img":if(x=d.getAttrib(A,"src")){t+="src: "+x+" "}break;case"a":if(x=d.getAttrib(A,"name")){t+="name: "+x+" ";p+="#"+x}if(x=d.getAttrib(A,"href")){t+="href: "+x+" "}break;case"font":if(z.convert_fonts_to_spans){p="span"}if(x=d.getAttrib(A,"face")){t+="font: "+x+" "}if(x=d.getAttrib(A,"size")){t+="size: "+x+" "}if(x=d.getAttrib(A,"color")){t+="color: "+x+" "}break;case"span":if(x=d.getAttrib(A,"style")){t+="style: "+x+" "}break}if(x=d.getAttrib(A,"id")){t+="id: "+x+" "}if(x=A.className){x=x.replace(/(webkit-[\w\-]+|Apple-[\w\-]+|mceItem\w+|mceVisualAid)/g,"");if(x&&x.indexOf("mceItem")==-1){t+="class: "+x+" ";if(d.isBlock(A)||p=="img"||p=="span"){p+="."+x}}}p=p.replace(/(html:)/g,"");p={name:p,node:A,title:t};y.onResolveName.dispatch(y,p);t=p.title;p=p.name;v=d.create("a",{href:"javascript:;",onmousedown:"return false;",title:t,"class":"mcePath_"+(r++)},p);if(i.hasChildNodes()){i.insertBefore(d.doc.createTextNode(" \u00bb "),i.firstChild);i.insertBefore(v,i.firstChild)}else{i.appendChild(v)}},l.getBody())}},_sel:function(i){this.editor.execCommand("mceSelectNodeDepth",false,i)},_mceInsertAnchor:function(k,j){var i=this.editor;i.windowManager.open({url:e.baseURL+"/themes/advanced/anchor.htm",width:320+parseInt(i.getLang("advanced.anchor_delta_width",0)),height:90+parseInt(i.getLang("advanced.anchor_delta_height",0)),inline:true},{theme_url:this.url})},_mceCharMap:function(){var i=this.editor;i.windowManager.open({url:e.baseURL+"/themes/advanced/charmap.htm",width:550+parseInt(i.getLang("advanced.charmap_delta_width",0)),height:250+parseInt(i.getLang("advanced.charmap_delta_height",0)),inline:true},{theme_url:this.url})},_mceHelp:function(){var i=this.editor;i.windowManager.open({url:e.baseURL+"/themes/advanced/about.htm",width:480,height:380,inline:true},{theme_url:this.url})},_mceColorPicker:function(k,j){var i=this.editor;j=j||{};i.windowManager.open({url:e.baseURL+"/themes/advanced/color_picker.htm",width:375+parseInt(i.getLang("advanced.colorpicker_delta_width",0)),height:250+parseInt(i.getLang("advanced.colorpicker_delta_height",0)),close_previous:false,inline:true},{input_color:j.color,func:j.func,theme_url:this.url})},_mceCodeEditor:function(j,k){var i=this.editor;i.windowManager.open({url:e.baseURL+"/themes/advanced/source_editor.htm",width:parseInt(i.getParam("theme_advanced_source_editor_width",720)),height:parseInt(i.getParam("theme_advanced_source_editor_height",580)),inline:true,resizable:true,maximizable:true},{theme_url:this.url})},_mceImage:function(j,k){var i=this.editor;if(i.dom.getAttrib(i.selection.getNode(),"class").indexOf("mceItem")!=-1){return}i.windowManager.open({url:e.baseURL+"/themes/advanced/image.htm",width:355+parseInt(i.getLang("advanced.image_delta_width",0)),height:275+parseInt(i.getLang("advanced.image_delta_height",0)),inline:true},{theme_url:this.url})},_mceLink:function(j,k){var i=this.editor;i.windowManager.open({url:e.baseURL+"/themes/advanced/link.htm",width:310+parseInt(i.getLang("advanced.link_delta_width",0)),height:200+parseInt(i.getLang("advanced.link_delta_height",0)),inline:true},{theme_url:this.url})},_mceNewDocument:function(){var i=this.editor;i.windowManager.confirm("advanced.newdocument",function(j){if(j){i.execCommand("mceSetContent",false,"")}})},_mceForeColor:function(){var i=this;this._mceColorPicker(0,{color:i.fgColor,func:function(j){i.fgColor=j;i.editor.execCommand("ForeColor",false,j)}})},_mceBackColor:function(){var i=this;this._mceColorPicker(0,{color:i.bgColor,func:function(j){i.bgColor=j;i.editor.execCommand("HiliteColor",false,j)}})},_ufirst:function(i){return i.substring(0,1).toUpperCase()+i.substring(1)}});e.ThemeManager.add("advanced",e.themes.AdvancedTheme)}(tinymce)); \ No newline at end of file +(function(e){var d=e.DOM,b=e.dom.Event,h=e.extend,f=e.each,a=e.util.Cookie,g,c=e.explode;e.ThemeManager.requireLangPack("advanced");e.create("tinymce.themes.AdvancedTheme",{sizes:[8,10,12,14,18,24,36],controls:{bold:["bold_desc","Bold"],italic:["italic_desc","Italic"],underline:["underline_desc","Underline"],strikethrough:["striketrough_desc","Strikethrough"],justifyleft:["justifyleft_desc","JustifyLeft"],justifycenter:["justifycenter_desc","JustifyCenter"],justifyright:["justifyright_desc","JustifyRight"],justifyfull:["justifyfull_desc","JustifyFull"],bullist:["bullist_desc","InsertUnorderedList"],numlist:["numlist_desc","InsertOrderedList"],outdent:["outdent_desc","Outdent"],indent:["indent_desc","Indent"],cut:["cut_desc","Cut"],copy:["copy_desc","Copy"],paste:["paste_desc","Paste"],undo:["undo_desc","Undo"],redo:["redo_desc","Redo"],link:["link_desc","mceLink"],unlink:["unlink_desc","unlink"],image:["image_desc","mceImage"],cleanup:["cleanup_desc","mceCleanup"],help:["help_desc","mceHelp"],code:["code_desc","mceCodeEditor"],hr:["hr_desc","InsertHorizontalRule"],removeformat:["removeformat_desc","RemoveFormat"],sub:["sub_desc","subscript"],sup:["sup_desc","superscript"],forecolor:["forecolor_desc","ForeColor"],forecolorpicker:["forecolor_desc","mceForeColor"],backcolor:["backcolor_desc","HiliteColor"],backcolorpicker:["backcolor_desc","mceBackColor"],charmap:["charmap_desc","mceCharMap"],visualaid:["visualaid_desc","mceToggleVisualAid"],anchor:["anchor_desc","mceInsertAnchor"],newdocument:["newdocument_desc","mceNewDocument"],blockquote:["blockquote_desc","mceBlockQuote"]},stateControls:["bold","italic","underline","strikethrough","bullist","numlist","justifyleft","justifycenter","justifyright","justifyfull","sub","sup","blockquote"],init:function(j,k){var l=this,m,i,n;l.editor=j;l.url=k;l.onResolveName=new e.util.Dispatcher(this);l.settings=m=h({theme_advanced_path:true,theme_advanced_toolbar_location:"bottom",theme_advanced_buttons1:"bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect",theme_advanced_buttons2:"bullist,numlist,|,outdent,indent,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code",theme_advanced_buttons3:"hr,removeformat,visualaid,|,sub,sup,|,charmap",theme_advanced_blockformats:"p,address,pre,h1,h2,h3,h4,h5,h6",theme_advanced_toolbar_align:"center",theme_advanced_fonts:"Andale Mono=andale mono,times;Arial=arial,helvetica,sans-serif;Arial Black=arial black,avant garde;Book Antiqua=book antiqua,palatino;Comic Sans MS=comic sans ms,sans-serif;Courier New=courier new,courier;Georgia=georgia,palatino;Helvetica=helvetica;Impact=impact,chicago;Symbol=symbol;Tahoma=tahoma,arial,helvetica,sans-serif;Terminal=terminal,monaco;Times New Roman=times new roman,times;Trebuchet MS=trebuchet ms,geneva;Verdana=verdana,geneva;Webdings=webdings;Wingdings=wingdings,zapf dingbats",theme_advanced_more_colors:1,theme_advanced_row_height:23,theme_advanced_resize_horizontal:1,theme_advanced_resizing_use_cookie:1,theme_advanced_font_sizes:"1,2,3,4,5,6,7",readonly:j.settings.readonly},j.settings);if(!m.font_size_style_values){m.font_size_style_values="8pt,10pt,12pt,14pt,18pt,24pt,36pt"}if(e.is(m.theme_advanced_font_sizes,"string")){m.font_size_style_values=e.explode(m.font_size_style_values);m.font_size_classes=e.explode(m.font_size_classes||"");n={};j.settings.theme_advanced_font_sizes=m.theme_advanced_font_sizes;f(j.getParam("theme_advanced_font_sizes","","hash"),function(q,p){var o;if(p==q&&q>=1&&q<=7){p=q+" ("+l.sizes[q-1]+"pt)";o=m.font_size_classes[q-1];q=m.font_size_style_values[q-1]||(l.sizes[q-1]+"pt")}if(/^\s*\./.test(q)){o=q.replace(/\./g,"")}n[p]=o?{"class":o}:{fontSize:q}});m.theme_advanced_font_sizes=n}if((i=m.theme_advanced_path_location)&&i!="none"){m.theme_advanced_statusbar_location=m.theme_advanced_path_location}if(m.theme_advanced_statusbar_location=="none"){m.theme_advanced_statusbar_location=0}j.onInit.add(function(){if(!j.settings.readonly){j.onNodeChange.add(l._nodeChanged,l)}if(j.settings.content_css!==false){j.dom.loadCSS(j.baseURI.toAbsolute(k+"/skins/"+j.settings.skin+"/content.css"))}});j.onSetProgressState.add(function(q,o,r){var s,t=q.id,p;if(o){l.progressTimer=setTimeout(function(){s=q.getContainer();s=s.insertBefore(d.create("DIV",{style:"position:relative"}),s.firstChild);p=d.get(q.id+"_tbl");d.add(s,"div",{id:t+"_blocker","class":"mceBlocker",style:{width:p.clientWidth+2,height:p.clientHeight+2}});d.add(s,"div",{id:t+"_progress","class":"mceProgress",style:{left:p.clientWidth/2,top:p.clientHeight/2}})},r||0)}else{d.remove(t+"_blocker");d.remove(t+"_progress");clearTimeout(l.progressTimer)}});d.loadCSS(m.editor_css?j.documentBaseURI.toAbsolute(m.editor_css):k+"/skins/"+j.settings.skin+"/ui.css");if(m.skin_variant){d.loadCSS(k+"/skins/"+j.settings.skin+"/ui_"+m.skin_variant+".css")}},createControl:function(l,i){var j,k;if(k=i.createControl(l)){return k}switch(l){case"styleselect":return this._createStyleSelect();case"formatselect":return this._createBlockFormats();case"fontselect":return this._createFontSelect();case"fontsizeselect":return this._createFontSizeSelect();case"forecolor":return this._createForeColorMenu();case"backcolor":return this._createBackColorMenu()}if((j=this.controls[l])){return i.createButton(l,{title:"advanced."+j[0],cmd:j[1],ui:j[2],value:j[3]})}},execCommand:function(k,j,l){var i=this["_"+k];if(i){i.call(this,j,l);return true}return false},_importClasses:function(k){var i=this.editor,j=i.controlManager.get("styleselect");if(j.getLength()==0){f(i.dom.getClasses(),function(n,l){var m="style_"+l;i.formatter.register(m,{inline:"span",attributes:{"class":n["class"]},selector:"*"});j.add(n["class"],m)})}},_createStyleSelect:function(m){var k=this,i=k.editor,j=i.controlManager,l;l=j.createListBox("styleselect",{title:"advanced.style_select",onselect:function(o){var p,n=[];f(l.items,function(q){n.push(q.value)});i.focus();i.undoManager.add();p=i.formatter.matchAll(n);if(!o||p[0]==o){i.formatter.remove(p[0])}else{i.formatter.apply(o)}i.undoManager.add();i.nodeChanged();return false}});i.onInit.add(function(){var o=0,n=i.getParam("style_formats");if(n){f(n,function(p){var q,r=0;f(p,function(){r++});if(r>1){q=p.name=p.name||"style_"+(o++);i.formatter.register(q,p);l.add(p.title,q)}else{l.add(p.title)}})}else{f(i.getParam("theme_advanced_styles","","hash"),function(r,q){var p;if(r){p="style_"+(o++);i.formatter.register(p,{inline:"span",classes:r,selector:"*"});l.add(k.editor.translate(q),p)}})}});if(l.getLength()==0){l.onPostRender.add(function(o,p){if(!l.NativeListBox){b.add(p.id+"_text","focus",k._importClasses,k);b.add(p.id+"_text","mousedown",k._importClasses,k);b.add(p.id+"_open","focus",k._importClasses,k);b.add(p.id+"_open","mousedown",k._importClasses,k)}else{b.add(p.id,"focus",k._importClasses,k)}})}return l},_createFontSelect:function(){var k,j=this,i=j.editor;k=i.controlManager.createListBox("fontselect",{title:"advanced.fontdefault",onselect:function(l){var m=k.items[k.selectedIndex];if(!l&&m){i.execCommand("FontName",false,m.value);return}i.execCommand("FontName",false,l);k.select(function(n){return l==n});return false}});if(k){f(i.getParam("theme_advanced_fonts",j.settings.theme_advanced_fonts,"hash"),function(m,l){k.add(i.translate(l),m,{style:m.indexOf("dings")==-1?"font-family:"+m:""})})}return k},_createFontSizeSelect:function(){var m=this,k=m.editor,n,l=0,j=[];n=k.controlManager.createListBox("fontsizeselect",{title:"advanced.font_size",onselect:function(i){var o=n.items[n.selectedIndex];if(!i&&o){o=o.value;if(o["class"]){k.formatter.toggle("fontsize_class",{value:o["class"]});k.undoManager.add();k.nodeChanged()}else{k.execCommand("FontSize",false,o.fontSize)}return}if(i["class"]){k.focus();k.undoManager.add();k.formatter.toggle("fontsize_class",{value:i["class"]});k.undoManager.add();k.nodeChanged()}else{k.execCommand("FontSize",false,i.fontSize)}n.select(function(p){return i==p});return false}});if(n){f(m.settings.theme_advanced_font_sizes,function(o,i){var p=o.fontSize;if(p>=1&&p<=7){p=m.sizes[parseInt(p)-1]+"pt"}n.add(i,o,{style:"font-size:"+p,"class":"mceFontSize"+(l++)+(" "+(o["class"]||""))})})}return n},_createBlockFormats:function(){var k,i={p:"advanced.paragraph",address:"advanced.address",pre:"advanced.pre",h1:"advanced.h1",h2:"advanced.h2",h3:"advanced.h3",h4:"advanced.h4",h5:"advanced.h5",h6:"advanced.h6",div:"advanced.div",blockquote:"advanced.blockquote",code:"advanced.code",dt:"advanced.dt",dd:"advanced.dd",samp:"advanced.samp"},j=this;k=j.editor.controlManager.createListBox("formatselect",{title:"advanced.block",cmd:"FormatBlock"});if(k){f(j.editor.getParam("theme_advanced_blockformats",j.settings.theme_advanced_blockformats,"hash"),function(m,l){k.add(j.editor.translate(l!=m?l:i[m]),m,{"class":"mce_formatPreview mce_"+m})})}return k},_createForeColorMenu:function(){var m,j=this,k=j.settings,l={},i;if(k.theme_advanced_more_colors){l.more_colors_func=function(){j._mceColorPicker(0,{color:m.value,func:function(n){m.setColor(n)}})}}if(i=k.theme_advanced_text_colors){l.colors=i}if(k.theme_advanced_default_foreground_color){l.default_color=k.theme_advanced_default_foreground_color}l.title="advanced.forecolor_desc";l.cmd="ForeColor";l.scope=this;m=j.editor.controlManager.createColorSplitButton("forecolor",l);return m},_createBackColorMenu:function(){var m,j=this,k=j.settings,l={},i;if(k.theme_advanced_more_colors){l.more_colors_func=function(){j._mceColorPicker(0,{color:m.value,func:function(n){m.setColor(n)}})}}if(i=k.theme_advanced_background_colors){l.colors=i}if(k.theme_advanced_default_background_color){l.default_color=k.theme_advanced_default_background_color}l.title="advanced.backcolor_desc";l.cmd="HiliteColor";l.scope=this;m=j.editor.controlManager.createColorSplitButton("backcolor",l);return m},renderUI:function(k){var m,l,q,v=this,r=v.editor,w=v.settings,u,j,i;m=j=d.create("span",{id:r.id+"_parent","class":"mceEditor "+r.settings.skin+"Skin"+(w.skin_variant?" "+r.settings.skin+"Skin"+v._ufirst(w.skin_variant):"")});if(!d.boxModel){m=d.add(m,"div",{"class":"mceOldBoxModel"})}m=u=d.add(m,"table",{id:r.id+"_tbl","class":"mceLayout",cellSpacing:0,cellPadding:0});m=q=d.add(m,"tbody");switch((w.theme_advanced_layout_manager||"").toLowerCase()){case"rowlayout":l=v._rowLayout(w,q,k);break;case"customlayout":l=r.execCallback("theme_advanced_custom_layout",w,q,k,j);break;default:l=v._simpleLayout(w,q,k,j)}m=k.targetNode;i=d.stdMode?u.getElementsByTagName("tr"):u.rows;d.addClass(i[0],"mceFirst");d.addClass(i[i.length-1],"mceLast");f(d.select("tr",q),function(o){d.addClass(o.firstChild,"mceFirst");d.addClass(o.childNodes[o.childNodes.length-1],"mceLast")});if(d.get(w.theme_advanced_toolbar_container)){d.get(w.theme_advanced_toolbar_container).appendChild(j)}else{d.insertAfter(j,m)}b.add(r.id+"_path_row","click",function(n){n=n.target;if(n.nodeName=="A"){v._sel(n.className.replace(/^.*mcePath_([0-9]+).*$/,"$1"));return b.cancel(n)}});if(!r.getParam("accessibility_focus")){b.add(d.add(j,"a",{href:"#"},""),"focus",function(){tinyMCE.get(r.id).focus()})}if(w.theme_advanced_toolbar_location=="external"){k.deltaHeight=0}v.deltaHeight=k.deltaHeight;k.targetNode=null;return{iframeContainer:l,editorContainer:r.id+"_parent",sizeContainer:u,deltaHeight:k.deltaHeight}},getInfo:function(){return{longname:"Advanced theme",author:"Moxiecode Systems AB",authorurl:"http://tinymce.moxiecode.com",version:e.majorVersion+"."+e.minorVersion}},resizeBy:function(i,j){var k=d.get(this.editor.id+"_tbl");this.resizeTo(k.clientWidth+i,k.clientHeight+j)},resizeTo:function(i,m,k){var j=this.editor,l=this.settings,n=d.get(j.id+"_tbl"),o=d.get(j.id+"_ifr");i=Math.max(l.theme_advanced_resizing_min_width||100,i);m=Math.max(l.theme_advanced_resizing_min_height||100,m);i=Math.min(l.theme_advanced_resizing_max_width||65535,i);m=Math.min(l.theme_advanced_resizing_max_height||65535,m);d.setStyle(n,"height","");d.setStyle(o,"height",m);if(l.theme_advanced_resize_horizontal){d.setStyle(n,"width","");d.setStyle(o,"width",i);if(i"))}q.push(d.createHTML("a",{href:"#",accesskey:"q",title:r.getLang("advanced.toolbar_focus")},""));for(p=1;(y=A["theme_advanced_buttons"+p]);p++){m=j.createToolbar("toolbar"+p,{"class":"mceToolbarRow"+p});if(A["theme_advanced_buttons"+p+"_add"]){y+=","+A["theme_advanced_buttons"+p+"_add"]}if(A["theme_advanced_buttons"+p+"_add_before"]){y=A["theme_advanced_buttons"+p+"_add_before"]+","+y}z._addControls(y,m);q.push(m.renderHTML());k.deltaHeight-=A.theme_advanced_row_height}q.push(d.createHTML("a",{href:"#",accesskey:"z",title:r.getLang("advanced.toolbar_focus"),onfocus:"tinyMCE.getInstanceById('"+r.id+"').focus();"},""));d.setHTML(l,q.join(""))},_addStatusBar:function(m,j){var k,v=this,p=v.editor,w=v.settings,i,q,u,l;k=d.add(m,"tr");k=l=d.add(k,"td",{"class":"mceStatusbar"});k=d.add(k,"div",{id:p.id+"_path_row"},w.theme_advanced_path?p.translate("advanced.path")+": ":" ");d.add(k,"a",{href:"#",accesskey:"x"});if(w.theme_advanced_resizing){d.add(l,"a",{id:p.id+"_resize",href:"javascript:;",onclick:"return false;","class":"mceResize"});if(w.theme_advanced_resizing_use_cookie){p.onPostRender.add(function(){var n=a.getHash("TinyMCE_"+p.id+"_size"),r=d.get(p.id+"_tbl");if(!n){return}v.resizeTo(n.cw,n.ch)})}p.onPostRender.add(function(){b.add(p.id+"_resize","click",function(n){n.preventDefault()});b.add(p.id+"_resize","mousedown",function(D){var t,r,s,o,C,z,A,F,n,E,x;function y(G){G.preventDefault();n=A+(G.screenX-C);E=F+(G.screenY-z);v.resizeTo(n,E)}function B(G){b.remove(d.doc,"mousemove",t);b.remove(p.getDoc(),"mousemove",r);b.remove(d.doc,"mouseup",s);b.remove(p.getDoc(),"mouseup",o);n=A+(G.screenX-C);E=F+(G.screenY-z);v.resizeTo(n,E,true)}D.preventDefault();C=D.screenX;z=D.screenY;x=d.get(v.editor.id+"_ifr");A=n=x.clientWidth;F=E=x.clientHeight;t=b.add(d.doc,"mousemove",y);r=b.add(p.getDoc(),"mousemove",y);s=b.add(d.doc,"mouseup",B);o=b.add(p.getDoc(),"mouseup",B)})})}j.deltaHeight-=21;k=m=null},_nodeChanged:function(r,z,l,x,j){var C=this,i,y=0,B,u,D=C.settings,A,k,w,m,q;e.each(C.stateControls,function(n){z.setActive(n,r.queryCommandState(C.controls[n][1]))});function o(p){var s,n=j.parents,t=p;if(typeof(p)=="string"){t=function(v){return v.nodeName==p}}for(s=0;s {#advanced_dlg.image_title} - - - - + + + + diff --git a/wp-includes/js/tinymce/themes/advanced/img/icons.gif b/wp-includes/js/tinymce/themes/advanced/img/icons.gif index ccac36f54d983cc33a0a6e45134e3dabf1820367..e46de5333082869b9bdab2576a554a2f9d01a966 100644 GIT binary patch delta 556 zcmV+{0@MBRS(03^@+*J4nMj91K!6CCg;~%|ckg$9|95~7c!3}ITCag#i1+#^_l8J< zMz{hi-~mn`f&WkNUxKfAi@$h`&v=cmcm(hTgr^UBX9yQ4ge$;@S9v2sc!Q7Jc$RN@ zmw$PfkNI8?cZ4VRnMi^w;DBhrhc`+RN=Se=h;o@9dZI6Sqd$Lor0*6Nojs;s`lY}5 zD*y%?AcQ30fmnctx}x}`-+Hd^dawU_qECWAD1>z20BE=b8{mXb!1_C|f>=NVu#bDW zpL@Em`(u{{S@;LM$9uis`@ZLUzCVa0SOOTmgjL`H5`YKAhX)~m2gb8|$d7!eJ7C-QRuh-Zy%KS7+c?_=Av3*=JNnJy~rK`rcoD=5K!I_jd%qhmU`NkWb!Nz)#vo z{#n5N=kI>+|9GLPhphAZdEo$^A(xgh4GHvPh&Zm*sx;9k}YfYEZVec*RpNv_AT7Fa_7>mYxgeRym~JN1OPj2L>nUj delta 265 zcmV+k0rviqT=7}3@+*HkcdvJQzju7kcYWXYVXuK+i1+#^cYYsuf-iW3KX`;s`0DTl zfTs_7S9pkzc+QERc#5z1V-I(LCwGhAc#iLQkN#4PkEJJd6sW^ zmw$Pfk9nD&d1sdeS@;K=w|Sh;`JLB!ou_%A4|<^=dZI6Sqd$Loq)&RKPxg{;dXt~M zrH^{4pL(i?d4E@DtQYvI-+Hd^daoaN1i*)ee}ISodb2-!v`>3%$M|^Hc(s3fxQ~0e zA9i?eczh`PxzBsO-+R74bblXvt?zrmAAG_u{BA)2hHrShH+;r#e8+!$$d7! {#advanced_dlg.link_title} - - - - - + + + + + diff --git a/wp-includes/js/tinymce/themes/advanced/skins/default/content.css b/wp-includes/js/tinymce/themes/advanced/skins/default/content.css index cb7604e7..dd8fb95e 100644 --- a/wp-includes/js/tinymce/themes/advanced/skins/default/content.css +++ b/wp-includes/js/tinymce/themes/advanced/skins/default/content.css @@ -8,8 +8,9 @@ h4 {font-size: 1em} h5 {font-size: .83em} h6 {font-size: .75em} .mceItemTable, .mceItemTable td, .mceItemTable th, .mceItemTable caption, .mceItemVisualAid {border: 1px dashed #BBB;} -a.mceItemAnchor {width:12px; line-height:6px; overflow:hidden; padding-left:12px; background:url(img/items.gif) no-repeat bottom left;} -img.mceItemAnchor {width:12px; height:12px; background:url(img/items.gif) no-repeat;} +a.mceItemAnchor {display:inline-block; width:11px !important; height:11px !important; background:url(img/items.gif) no-repeat 0 0;} +span.mceItemNbsp {background: #DDD} +td.mceSelected, th.mceSelected {background-color:#3399ff !important} img {border:0;} table {cursor:default} table td, table th {cursor:text} @@ -17,7 +18,7 @@ ins {border-bottom:1px solid green; text-decoration: none; color:green} del {color:red; text-decoration:line-through} cite {border-bottom:1px dashed blue} acronym {border-bottom:1px dotted #CCC; cursor:help} -abbr, html\:abbr {border-bottom:1px dashed #CCC; cursor:help} +abbr {border-bottom:1px dashed #CCC; cursor:help} /* IE */ * html body { @@ -30,3 +31,6 @@ scrollbar-highlight-color:#F0F0EE; scrollbar-shadow-color:#F0F0EE; scrollbar-track-color:#F5F5F5; } + +img:-moz-broken {-moz-force-broken-image-icon:1; width:24px; height:24px} +font[face=mceinline] {font-family:inherit !important} diff --git a/wp-includes/js/tinymce/themes/advanced/skins/default/dialog.css b/wp-includes/js/tinymce/themes/advanced/skins/default/dialog.css index fa2df254..1f5598c6 100644 --- a/wp-includes/js/tinymce/themes/advanced/skins/default/dialog.css +++ b/wp-includes/js/tinymce/themes/advanced/skins/default/dialog.css @@ -42,10 +42,11 @@ width:94px; height:26px; background:url(img/buttons.png) 0 -26px; cursor:pointer; padding-bottom:2px; +float:left; } -#insert {background:url(img/buttons.png) 0 -52px;} -#cancel {background:url(img/buttons.png) 0 0;} +#insert {background:url(img/buttons.png) 0 -52px} +#cancel {background:url(img/buttons.png) 0 0; float:right} /* Browse */ a.pickcolor, a.browse {text-decoration:none} @@ -113,4 +114,4 @@ h3 {font-size:14px;} #colorpicker #namedcolors {width:150px;} #colorpicker #namedcolors a {display:block; float:left; width:10px; height:10px; margin:1px 1px 0 0; overflow:hidden;} #colorpicker #colornamecontainer {margin-top:5px;} -#colorpicker #picker_panel fieldset {margin:auto;width:325px;} \ No newline at end of file +#colorpicker #picker_panel fieldset {margin:auto;width:325px;} diff --git a/wp-includes/js/tinymce/themes/advanced/skins/default/ui.css b/wp-includes/js/tinymce/themes/advanced/skins/default/ui.css index 2c90d498..7f6cf5fd 100644 --- a/wp-includes/js/tinymce/themes/advanced/skins/default/ui.css +++ b/wp-includes/js/tinymce/themes/advanced/skins/default/ui.css @@ -4,7 +4,7 @@ .defaultSkin table td {vertical-align:middle} /* Containers */ -.defaultSkin table {background:#F0F0EE} +.defaultSkin table {direction:ltr; background:#F0F0EE} .defaultSkin iframe {display:block; background:#FFF} .defaultSkin .mceToolbar {height:26px} .defaultSkin .mceLeft {text-align:left} @@ -24,7 +24,7 @@ .defaultSkin .mceIframeContainer {border-top:1px solid #CCC; border-bottom:1px solid #CCC} .defaultSkin .mceStatusbar {font-family:'MS Sans Serif',sans-serif,Verdana,Arial; font-size:9pt; line-height:16px; overflow:visible; color:#000; display:block; height:20px} .defaultSkin .mceStatusbar div {float:left; margin:2px} -.defaultSkin .mceStatusbar a.mceResize {display:block; float:right; background:url(../../img/icons.gif) -800px 0; width:20px; height:20px; cursor:se-resize} +.defaultSkin .mceStatusbar a.mceResize {display:block; float:right; background:url(../../img/icons.gif) -800px 0; width:20px; height:20px; cursor:se-resize; outline:0} .defaultSkin .mceStatusbar a:hover {text-decoration:underline} .defaultSkin table.mceToolbar {margin-left:3px} .defaultSkin span.mceIcon, .defaultSkin img.mceIcon {display:block; width:20px; height:20px} @@ -47,7 +47,6 @@ .defaultSkin .mceSeparator {display:block; background:url(../../img/icons.gif) -180px 0; width:2px; height:20px; margin:2px 2px 0 4px} /* ListBox */ -.defaultSkin .mceListBox {direction:ltr} .defaultSkin .mceListBox, .defaultSkin .mceListBox a {display:block} .defaultSkin .mceListBox .mceText {padding-left:4px; width:70px; text-align:left; border:1px solid #CCC; border-right:0; background:#FFF; font-family:Tahoma,Verdana,Arial,Helvetica; font-size:11px; height:20px; line-height:20px; overflow:hidden} .defaultSkin .mceListBox .mceOpen {width:9px; height:20px; background:url(../../img/icons.gif) -741px 0; margin-right:2px; border:1px solid #CCC;} @@ -63,7 +62,7 @@ .defaultSkin .mceSplitButton {width:32px; height:20px; direction:ltr} .defaultSkin .mceSplitButton a, .defaultSkin .mceSplitButton span {height:20px; display:block} .defaultSkin .mceSplitButton a.mceAction {width:20px; border:1px solid #F0F0EE; border-right:0;} -.defaultSkin .mceSplitButton span.mceAction {width:20px; background:url(../../img/icons.gif) 20px 20px;} +.defaultSkin .mceSplitButton span.mceAction {width:20px; background-image:url(../../img/icons.gif);} .defaultSkin .mceSplitButton a.mceOpen {width:9px; background:url(../../img/icons.gif) -741px 0; border:1px solid #F0F0EE;} .defaultSkin .mceSplitButton span.mceOpen {display:none} .defaultSkin table.mceSplitButtonEnabled:hover a.mceAction, .defaultSkin .mceSplitButtonHover a.mceAction, .defaultSkin .mceSplitButtonSelected a.mceAction {border:1px solid #0A246A; border-right:0; background-color:#B2BBD0} @@ -108,7 +107,6 @@ /* Progress,Resize */ .defaultSkin .mceBlocker {position:absolute; left:0; top:0; z-index:1000; opacity:0.5; -ms-filter:'alpha(opacity=50)'; filter:alpha(opacity=50); background:#FFF} .defaultSkin .mceProgress {position:absolute; left:0; top:0; z-index:1001; background:url(img/progress.gif) no-repeat; width:32px; height:32px; margin:-16px 0 0 -16px} -.defaultSkin .mcePlaceHolder {border:1px dotted gray} /* Formats */ .defaultSkin .mce_formatPreview a {font-size:10px} @@ -211,4 +209,5 @@ .defaultSkin span.mce_del {background-position:-940px -20px} .defaultSkin span.mce_ins {background-position:-960px -20px} .defaultSkin span.mce_pagebreak {background-position:0 -40px} -.defaultSkin .mce_spellchecker span.mceAction {background-position:-540px -20px} +.defaultSkin span.mce_restoredraft {background-position:-20px -40px} +.defaultSkin span.mce_spellchecker {background-position:-540px -20px} diff --git a/wp-includes/js/tinymce/themes/advanced/skins/o2k7/content.css b/wp-includes/js/tinymce/themes/advanced/skins/o2k7/content.css index a4049317..500fa0de 100644 --- a/wp-includes/js/tinymce/themes/advanced/skins/o2k7/content.css +++ b/wp-includes/js/tinymce/themes/advanced/skins/o2k7/content.css @@ -8,8 +8,9 @@ h4 {font-size: 1em} h5 {font-size: .83em} h6 {font-size: .75em} .mceItemTable, .mceItemTable td, .mceItemTable th, .mceItemTable caption, .mceItemVisualAid {border: 1px dashed #BBB;} -a.mceItemAnchor {width:12px; line-height:6px; overflow:hidden; padding-left:12px; background:url(../default/img/items.gif) no-repeat bottom left;} -img.mceItemAnchor {width:12px; height:12px; background:url(../default/img/items.gif) no-repeat;} +a.mceItemAnchor {display:inline-block; width:11px !important; height:11px !important; background:url(../default/img/items.gif) no-repeat 0 0;} +span.mceItemNbsp {background: #DDD} +td.mceSelected, th.mceSelected {background-color:#3399ff !important} img {border:0;} table {cursor:default} table td, table th {cursor:text} @@ -17,7 +18,7 @@ ins {border-bottom:1px solid green; text-decoration: none; color:green} del {color:red; text-decoration:line-through} cite {border-bottom:1px dashed blue} acronym {border-bottom:1px dotted #CCC; cursor:help} -abbr, html\:abbr {border-bottom:1px dashed #CCC; cursor:help} +abbr {border-bottom:1px dashed #CCC; cursor:help} /* IE */ * html body { @@ -30,3 +31,6 @@ scrollbar-highlight-color:#F0F0EE; scrollbar-shadow-color:#F0F0EE; scrollbar-track-color:#F5F5F5; } + +img:-moz-broken {-moz-force-broken-image-icon:1; width:24px; height:24px} +font[face=mceinline] {font-family:inherit !important} diff --git a/wp-includes/js/tinymce/themes/advanced/skins/o2k7/dialog.css b/wp-includes/js/tinymce/themes/advanced/skins/o2k7/dialog.css index 6b278b64..3b0760a6 100644 --- a/wp-includes/js/tinymce/themes/advanced/skins/o2k7/dialog.css +++ b/wp-includes/js/tinymce/themes/advanced/skins/o2k7/dialog.css @@ -42,10 +42,11 @@ width:94px; height:26px; background:url(../default/img/buttons.png) 0 -26px; cursor:pointer; padding-bottom:2px; +float:left; } -#insert {background:url(../default/img/buttons.png) 0 -52px;} -#cancel {background:url(../default/img/buttons.png) 0 0;} +#insert {background:url(../default/img/buttons.png) 0 -52px} +#cancel {background:url(../default/img/buttons.png) 0 0; float:right} /* Browse */ a.pickcolor, a.browse {text-decoration:none} diff --git a/wp-includes/js/tinymce/themes/advanced/skins/o2k7/ui.css b/wp-includes/js/tinymce/themes/advanced/skins/o2k7/ui.css index 0f8d5c24..52f5760f 100644 --- a/wp-includes/js/tinymce/themes/advanced/skins/o2k7/ui.css +++ b/wp-includes/js/tinymce/themes/advanced/skins/o2k7/ui.css @@ -21,7 +21,7 @@ .o2k7Skin .mceIframeContainer {border-top:1px solid #ABC6DD; border-bottom:1px solid #ABC6DD} .o2k7Skin .mceStatusbar {display:block; font-family:'MS Sans Serif',sans-serif,Verdana,Arial; font-size:9pt; line-height:16px; overflow:visible; color:#000; height:20px} .o2k7Skin .mceStatusbar div {float:left; padding:2px} -.o2k7Skin .mceStatusbar a.mceResize {display:block; float:right; background:url(../../img/icons.gif) -800px 0; width:20px; height:20px; cursor:se-resize} +.o2k7Skin .mceStatusbar a.mceResize {display:block; float:right; background:url(../../img/icons.gif) -800px 0; width:20px; height:20px; cursor:se-resize; outline:0} .o2k7Skin .mceStatusbar a:hover {text-decoration:underline} .o2k7Skin table.mceToolbar {margin-left:3px} .o2k7Skin .mceToolbar .mceToolbarStart span {display:block; background:url(img/button_bg.png) -22px 0; width:1px; height:22px; margin-left:3px;} @@ -65,7 +65,7 @@ .o2k7Skin .mceSplitButton, .o2k7Skin .mceSplitButton a, .o2k7Skin .mceSplitButton span {display:block; height:22px} .o2k7Skin .mceSplitButton {background:url(img/button_bg.png)} .o2k7Skin .mceSplitButton a.mceAction {width:22px} -.o2k7Skin .mceSplitButton span.mceAction {width:22px; background:url(../../img/icons.gif) 20px 20px} +.o2k7Skin .mceSplitButton span.mceAction {width:22px; background-image:url(../../img/icons.gif)} .o2k7Skin .mceSplitButton a.mceOpen {width:10px; background:url(img/button_bg.png) -44px 0} .o2k7Skin .mceSplitButton span.mceOpen {display:none} .o2k7Skin table.mceSplitButtonEnabled:hover a.mceAction, .o2k7Skin .mceSplitButtonHover a.mceAction, .o2k7Skin .mceSplitButtonSelected {background:url(img/button_bg.png) 0 -22px} @@ -109,7 +109,6 @@ /* Progress,Resize */ .o2k7Skin .mceBlocker {position:absolute; left:0; top:0; z-index:1000; opacity:0.5; -ms-filter:'alpha(opacity=30)'; filter:alpha(opacity=50); background:#FFF} .o2k7Skin .mceProgress {position:absolute; left:0; top:0; z-index:1001; background:url(../default/img/progress.gif) no-repeat; width:32px; height:32px; margin:-16px 0 0 -16px} -.o2k7Skin .mcePlaceHolder {border:1px dotted gray} /* Formats */ .o2k7Skin .mce_formatPreview a {font-size:10px} @@ -212,4 +211,5 @@ .o2k7Skin span.mce_del {background-position:-940px -20px} .o2k7Skin span.mce_ins {background-position:-960px -20px} .o2k7Skin span.mce_pagebreak {background-position:0 -40px} -.o2k7Skin .mce_spellchecker span.mceAction {background-position:-540px -20px} +.o2k7Skin span.mce_restoredraft {background-position:-20px -40px} +.o2k7Skin span.mce_spellchecker {background-position:-540px -20px} diff --git a/wp-includes/js/tinymce/themes/advanced/skins/wp_theme/ui.css b/wp-includes/js/tinymce/themes/advanced/skins/wp_theme/ui.css index 1cd2771a..f4b1fe44 100644 --- a/wp-includes/js/tinymce/themes/advanced/skins/wp_theme/ui.css +++ b/wp-includes/js/tinymce/themes/advanced/skins/wp_theme/ui.css @@ -152,7 +152,9 @@ border:0; margin:0; padding:0; white-space:nowrap; text-decoration:none; font-we padding: 1px 2px; } .wp_themeSkin .mceSplitButton span.mceAction { - background: url(../../img/icons.gif) 20px 20px; + background-image: url(../../img/icons.gif); + background-repeat: no-repeat; + background-color: transparent; width:20px; } .wp_themeSkin .mceSplitButton a.mceOpen { @@ -346,7 +348,7 @@ border:0; margin:0; padding:0; white-space:nowrap; text-decoration:none; font-we .wp_themeSkin span.mce_del {background-position:-940px -20px} .wp_themeSkin span.mce_ins {background-position:-960px -20px} .wp_themeSkin span.mce_pagebreak {background-position:0 -40px} -.wp_themeSkin .mce_spellchecker span.mceAction {background-position:-540px -20px} +.wp_themeSkin span.mce_spellchecker {background-position:-540px -20px} /* border */ .wp_themeSkin .mceExternalToolbar, diff --git a/wp-includes/js/tinymce/themes/advanced/source_editor.htm b/wp-includes/js/tinymce/themes/advanced/source_editor.htm index 1c4225d8..b0db4ba6 100644 --- a/wp-includes/js/tinymce/themes/advanced/source_editor.htm +++ b/wp-includes/js/tinymce/themes/advanced/source_editor.htm @@ -1,9 +1,8 @@ - {#advanced_dlg.code_title} - - + + diff --git a/wp-includes/js/tinymce/tiny_mce.js b/wp-includes/js/tinymce/tiny_mce.js index 73ad8b89..2fee4a03 100644 --- a/wp-includes/js/tinymce/tiny_mce.js +++ b/wp-includes/js/tinymce/tiny_mce.js @@ -1 +1 @@ -var tinymce={majorVersion:"3",minorVersion:"2.7",releaseDate:"2009-09-22",_init:function(){var o=this,k=document,l=window,j=navigator,b=j.userAgent,h,a,g,f,e,m;o.isOpera=l.opera&&opera.buildNumber;o.isWebKit=/WebKit/.test(b);o.isIE=!o.isWebKit&&!o.isOpera&&(/MSIE/gi).test(b)&&(/Explorer/gi).test(j.appName);o.isIE6=o.isIE&&/MSIE [56]/.test(b);o.isGecko=!o.isWebKit&&/Gecko/.test(b);o.isMac=b.indexOf("Mac")!=-1;o.isAir=/adobeair/i.test(b);if(l.tinyMCEPreInit){o.suffix=tinyMCEPreInit.suffix;o.baseURL=tinyMCEPreInit.base;o.query=tinyMCEPreInit.query;return}o.suffix="";a=k.getElementsByTagName("base");for(h=0;h=c.length){for(e=0,b=g.length;e=c.length||g[e]!=c[e]){f=e+1;break}}}if(g.length=g.length||g[e]!=c[e]){f=e+1;break}}}if(f==1){return h}for(e=0,b=g.length-(f-1);e=0;c--){if(f[c].length==0||f[c]=="."){continue}if(f[c]==".."){b++;continue}if(b>0){b--;continue}h.push(f[c])}c=e.length-b;if(c<=0){g=h.reverse().join("/")}else{g=e.slice(0,c).join("/")+"/"+h.reverse().join("/")}if(g.indexOf("/")!==0){g="/"+g}if(d&&g.lastIndexOf("/")!==g.length-1){g+=d}return g},getURI:function(d){var c,b=this;if(!b.source||d){c="";if(!d){if(b.protocol){c+=b.protocol+"://"}if(b.userInfo){c+=b.userInfo+"@"}if(b.host){c+=b.host}if(b.port){c+=":"+b.port}}if(b.path){c+=b.path}if(b.query){c+="?"+b.query}if(b.anchor){c+="#"+b.anchor}b.source=c}return b.source}})})();(function(){var a=tinymce.each;tinymce.create("static tinymce.util.Cookie",{getHash:function(d){var b=this.get(d),c;if(b){a(b.split("&"),function(e){e=e.split("=");c=c||{};c[unescape(e[0])]=unescape(e[1])})}return c},setHash:function(j,b,g,f,i,c){var h="";a(b,function(e,d){h+=(!h?"":"&")+escape(d)+"="+escape(e)});this.set(j,h,g,f,i,c)},get:function(i){var h=document.cookie,g,f=i+"=",d;if(!h){return}d=h.indexOf("; "+f);if(d==-1){d=h.indexOf(f);if(d!=0){return null}}else{d+=2}g=h.indexOf(";",d);if(g==-1){g=h.length}return unescape(h.substring(d+f.length,g))},set:function(i,b,g,f,h,c){document.cookie=i+"="+escape(b)+((g)?"; expires="+g.toGMTString():"")+((f)?"; path="+escape(f):"")+((h)?"; domain="+h:"")+((c)?"; secure":"")},remove:function(e,b){var c=new Date();c.setTime(c.getTime()-1000);this.set(e,"",c,b,c)}})})();tinymce.create("static tinymce.util.JSON",{serialize:function(e){var c,a,d=tinymce.util.JSON.serialize,b;if(e==null){return"null"}b=typeof e;if(b=="string"){a="\bb\tt\nn\ff\rr\"\"''\\\\";return'"'+e.replace(/([\u0080-\uFFFF\x00-\x1f\"])/g,function(g,f){c=a.indexOf(f);if(c+1){return"\\"+a.charAt(c+1)}g=f.charCodeAt().toString(16);return"\\u"+"0000".substring(g.length)+g})+'"'}if(b=="object"){if(e.hasOwnProperty&&e instanceof Array){for(c=0,a="[";c0?",":"")+d(e[c])}return a+"]"}a="{";for(c in e){a+=typeof e[c]!="function"?(a.length>1?',"':'"')+c+'":'+d(e[c]):""}return a+"}"}return""+e},parse:function(s){try{return eval("("+s+")")}catch(ex){}}});tinymce.create("static tinymce.util.XHR",{send:function(g){var a,e,b=window,h=0;g.scope=g.scope||this;g.success_scope=g.success_scope||g.scope;g.error_scope=g.error_scope||g.scope;g.async=g.async===false?false:true;g.data=g.data||"";function d(i){a=0;try{a=new ActiveXObject(i)}catch(c){}return a}a=b.XMLHttpRequest?new XMLHttpRequest():d("Microsoft.XMLHTTP")||d("Msxml2.XMLHTTP");if(a){if(a.overrideMimeType){a.overrideMimeType(g.content_type)}a.open(g.type||(g.data?"POST":"GET"),g.url,g.async);if(g.content_type){a.setRequestHeader("Content-Type",g.content_type)}a.setRequestHeader("X-Requested-With","XMLHttpRequest");a.send(g.data);function f(){if(!g.async||a.readyState==4||h++>10000){if(g.success&&h<10000&&a.status==200){g.success.call(g.success_scope,""+a.responseText,a,g)}else{if(g.error){g.error.call(g.error_scope,h>10000?"TIMED_OUT":"GENERAL",a,g)}}a=null}else{b.setTimeout(f,10)}}if(!g.async){return f()}e=b.setTimeout(f,10)}}});(function(){var c=tinymce.extend,b=tinymce.util.JSON,a=tinymce.util.XHR;tinymce.create("tinymce.util.JSONRequest",{JSONRequest:function(d){this.settings=c({},d);this.count=0},send:function(f){var e=f.error,d=f.success;f=c(this.settings,f);f.success=function(h,g){h=b.parse(h);if(typeof(h)=="undefined"){h={error:"JSON Parse error."}}if(h.error){e.call(f.error_scope||f.scope,h.error,g)}else{d.call(f.success_scope||f.scope,h.result)}};f.error=function(h,g){e.call(f.error_scope||f.scope,h,g)};f.data=b.serialize({id:f.id||"c"+(this.count++),method:f.method,params:f.params});f.content_type="application/json";a.send(f)},"static":{sendRPC:function(d){return new tinymce.util.JSONRequest().send(d)}}})}());(function(c){var e=c.each,b=c.is;var d=c.isWebKit,a=c.isIE;c.create("tinymce.dom.DOMUtils",{doc:null,root:null,files:null,pixelStyles:/^(top|left|bottom|right|width|height|borderWidth)$/,props:{"for":"htmlFor","class":"className",className:"className",checked:"checked",disabled:"disabled",maxlength:"maxLength",readonly:"readOnly",selected:"selected",value:"value",id:"id",name:"name",type:"type"},DOMUtils:function(i,g){var f=this;f.doc=i;f.win=window;f.files={};f.cssFlicker=false;f.counter=0;f.boxModel=!c.isIE||i.compatMode=="CSS1Compat";f.stdMode=i.documentMode===8;f.settings=g=c.extend({keep_values:false,hex_colors:1,process_html:1},g);if(c.isIE6){try{i.execCommand("BackgroundImageCache",false,true)}catch(h){f.cssFlicker=true}}c.addUnload(f.destroy,f)},getRoot:function(){var f=this,g=f.settings;return(g&&f.get(g.root_element))||f.doc.body},getViewPort:function(g){var h,f;g=!g?this.win:g;h=g.document;f=this.boxModel?h.documentElement:h.body;return{x:g.pageXOffset||f.scrollLeft,y:g.pageYOffset||f.scrollTop,w:g.innerWidth||f.clientWidth,h:g.innerHeight||f.clientHeight}},getRect:function(i){var h,f=this,g;i=f.get(i);h=f.getPos(i);g=f.getSize(i);return{x:h.x,y:h.y,w:g.w,h:g.h}},getSize:function(j){var g=this,f,i;j=g.get(j);f=g.getStyle(j,"width");i=g.getStyle(j,"height");if(f.indexOf("px")===-1){f=0}if(i.indexOf("px")===-1){i=0}return{w:parseInt(f)||j.offsetWidth||j.clientWidth,h:parseInt(i)||j.offsetHeight||j.clientHeight}},getParent:function(i,h,g){return this.getParents(i,h,g,false)},getParents:function(p,k,i,m){var h=this,g,j=h.settings,l=[];p=h.get(p);m=m===undefined;if(j.strict_root){i=i||h.getRoot()}if(b(k,"string")){g=k;if(k==="*"){k=function(f){return f.nodeType==1}}else{k=function(f){return h.is(f,g)}}}while(p){if(p==i||!p.nodeType||p.nodeType===9){break}if(!k||k(p)){if(m){l.push(p)}else{return p}}p=p.parentNode}return m?l:null},get:function(f){var g;if(f&&this.doc&&typeof(f)=="string"){g=f;f=this.doc.getElementById(f);if(f&&f.id!==g){return this.doc.getElementsByName(g)[1]}}return f},getNext:function(g,f){return this._findSib(g,f,"nextSibling")},getPrev:function(g,f){return this._findSib(g,f,"previousSibling")},select:function(h,g){var f=this;return c.dom.Sizzle(h,f.get(g)||f.get(f.settings.root_element)||f.doc,[])},is:function(g,f){return c.dom.Sizzle.matches(f,g.nodeType?[g]:g).length>0},add:function(j,l,f,i,k){var g=this;return this.run(j,function(n){var m,h;m=b(l,"string")?g.doc.createElement(l):l;g.setAttribs(m,f);if(i){if(i.nodeType){m.appendChild(i)}else{g.setHTML(m,i)}}return !k?n.appendChild(m):m})},create:function(i,f,g){return this.add(this.doc.createElement(i),i,f,g,1)},createHTML:function(m,f,j){var l="",i=this,g;l+="<"+m;for(g in f){if(f.hasOwnProperty(g)){l+=" "+g+'="'+i.encode(f[g])+'"'}}if(c.is(j)){return l+">"+j+""}return l+" />"},remove:function(h,f){var g=this;return this.run(h,function(m){var l,k,j;l=m.parentNode;if(!l){return null}if(f){for(j=m.childNodes.length-1;j>=0;j--){g.insertAfter(m.childNodes[j],m)}}if(g.fixPsuedoLeaks){l=m.cloneNode(true);f="IELeakGarbageBin";k=g.get(f)||g.add(g.doc.body,"div",{id:f,style:"display:none"});k.appendChild(m);k.innerHTML="";return l}return l.removeChild(m)})},setStyle:function(i,f,g){var h=this;return h.run(i,function(l){var k,j;k=l.style;f=f.replace(/-(\D)/g,function(n,m){return m.toUpperCase()});if(h.pixelStyles.test(f)&&(c.is(g,"number")||/^[\-0-9\.]+$/.test(g))){g+="px"}switch(f){case"opacity":if(a){k.filter=g===""?"":"alpha(opacity="+(g*100)+")";if(!i.currentStyle||!i.currentStyle.hasLayout){k.display="inline-block"}}k[f]=k["-moz-opacity"]=k["-khtml-opacity"]=g||"";break;case"float":a?k.styleFloat=g:k.cssFloat=g;break;default:k[f]=g||""}if(h.settings.update_styles){h.setAttrib(l,"mce_style")}})},getStyle:function(i,f,h){i=this.get(i);if(!i){return false}if(this.doc.defaultView&&h){f=f.replace(/[A-Z]/g,function(j){return"-"+j});try{return this.doc.defaultView.getComputedStyle(i,null).getPropertyValue(f)}catch(g){return null}}f=f.replace(/-(\D)/g,function(k,j){return j.toUpperCase()});if(f=="float"){f=a?"styleFloat":"cssFloat"}if(i.currentStyle&&h){return i.currentStyle[f]}return i.style[f]},setStyles:function(i,j){var g=this,h=g.settings,f;f=h.update_styles;h.update_styles=0;e(j,function(k,l){g.setStyle(i,l,k)});h.update_styles=f;if(h.update_styles){g.setAttrib(i,h.cssText)}},setAttrib:function(h,i,f){var g=this;if(!h||!i){return}if(g.settings.strict){i=i.toLowerCase()}return this.run(h,function(k){var j=g.settings;switch(i){case"style":if(!b(f,"string")){e(f,function(l,m){g.setStyle(k,m,l)});return}if(j.keep_values){if(f&&!g._isRes(f)){k.setAttribute("mce_style",f,2)}else{k.removeAttribute("mce_style",2)}}k.style.cssText=f;break;case"class":k.className=f||"";break;case"src":case"href":if(j.keep_values){if(j.url_converter){f=j.url_converter.call(j.url_converter_scope||g,f,i,k)}g.setAttrib(k,"mce_"+i,f,2)}break;case"shape":k.setAttribute("mce_style",f);break}if(b(f)&&f!==null&&f.length!==0){k.setAttribute(i,""+f,2)}else{k.removeAttribute(i,2)}})},setAttribs:function(g,h){var f=this;return this.run(g,function(i){e(h,function(j,k){f.setAttrib(i,k,j)})})},getAttrib:function(i,j,h){var f,g=this;i=g.get(i);if(!i||i.nodeType!==1){return false}if(!b(h)){h=""}if(/^(src|href|style|coords|shape)$/.test(j)){f=i.getAttribute("mce_"+j);if(f){return f}}if(a&&g.props[j]){f=i[g.props[j]];f=f&&f.nodeValue?f.nodeValue:f}if(!f){f=i.getAttribute(j,2)}if(/^(checked|compact|declare|defer|disabled|ismap|multiple|nohref|noshade|nowrap|readonly|selected)$/.test(j)){if(i[g.props[j]]===true&&f===""){return j}return f?j:""}if(i.nodeName==="FORM"&&i.getAttributeNode(j)){return i.getAttributeNode(j).nodeValue}if(j==="style"){f=f||i.style.cssText;if(f){f=g.serializeStyle(g.parseStyle(f));if(g.settings.keep_values&&!g._isRes(f)){i.setAttribute("mce_style",f)}}}if(d&&j==="class"&&f){f=f.replace(/(apple|webkit)\-[a-z\-]+/gi,"")}if(a){switch(j){case"rowspan":case"colspan":if(f===1){f=""}break;case"size":if(f==="+0"||f===20||f===0){f=""}break;case"width":case"height":case"vspace":case"checked":case"disabled":case"readonly":if(f===0){f=""}break;case"hspace":if(f===-1){f=""}break;case"maxlength":case"tabindex":if(f===32768||f===2147483647||f==="32768"){f=""}break;case"multiple":case"compact":case"noshade":case"nowrap":if(f===65535){return j}return h;case"shape":f=f.toLowerCase();break;default:if(j.indexOf("on")===0&&f){f=(""+f).replace(/^function\s+\w+\(\)\s+\{\s+(.*)\s+\}$/,"$1")}}}return(f!==undefined&&f!==null&&f!=="")?""+f:h},getPos:function(m,i){var g=this,f=0,l=0,j,k=g.doc,h;m=g.get(m);i=i||k.body;if(m){if(a&&!g.stdMode){m=m.getBoundingClientRect();j=g.boxModel?k.documentElement:k.body;f=g.getStyle(g.select("html")[0],"borderWidth");f=(f=="medium"||g.boxModel&&!g.isIE6)&&2||f;m.top+=g.win.self!=g.win.top?2:0;return{x:m.left+j.scrollLeft-f,y:m.top+j.scrollTop-f}}h=m;while(h&&h!=i&&h.nodeType){f+=h.offsetLeft||0;l+=h.offsetTop||0;h=h.offsetParent}h=m.parentNode;while(h&&h!=i&&h.nodeType){f-=h.scrollLeft||0;l-=h.scrollTop||0;h=h.parentNode}}return{x:f,y:l}},parseStyle:function(h){var i=this,j=i.settings,k={};if(!h){return k}function f(w,q,v){var o,u,m,n;o=k[w+"-top"+q];if(!o){return}u=k[w+"-right"+q];if(o!=u){return}m=k[w+"-bottom"+q];if(u!=m){return}n=k[w+"-left"+q];if(m!=n){return}k[v]=n;delete k[w+"-top"+q];delete k[w+"-right"+q];delete k[w+"-bottom"+q];delete k[w+"-left"+q]}function g(n,m,l,p){var o;o=k[m];if(!o){return}o=k[l];if(!o){return}o=k[p];if(!o){return}k[n]=k[m]+" "+k[l]+" "+k[p];delete k[m];delete k[l];delete k[p]}h=h.replace(/&(#?[a-z0-9]+);/g,"&$1_MCE_SEMI_");e(h.split(";"),function(m){var l,n=[];if(m){m=m.replace(/_MCE_SEMI_/g,";");m=m.replace(/url\([^\)]+\)/g,function(o){n.push(o);return"url("+n.length+")"});m=m.split(":");l=c.trim(m[1]);l=l.replace(/url\(([^\)]+)\)/g,function(p,o){return n[parseInt(o)-1]});l=l.replace(/rgb\([^\)]+\)/g,function(o){return i.toHex(o)});if(j.url_converter){l=l.replace(/url\([\'\"]?([^\)\'\"]+)[\'\"]?\)/g,function(o,p){return"url("+j.url_converter.call(j.url_converter_scope||i,i.decode(p),"style",null)+")"})}k[c.trim(m[0]).toLowerCase()]=l}});f("border","","border");f("border","-width","border-width");f("border","-color","border-color");f("border","-style","border-style");f("padding","","padding");f("margin","","margin");g("border","border-width","border-style","border-color");if(a){if(k.border=="medium none"){k.border=""}}return k},serializeStyle:function(g){var f="";e(g,function(i,h){if(h&&i){if(c.isGecko&&h.indexOf("-moz-")===0){return}switch(h){case"color":case"background-color":i=i.toLowerCase();break}f+=(f?" ":"")+h+": "+i+";"}});return f},loadCSS:function(f){var h=this,i=h.doc,g;if(!f){f=""}g=h.select("head")[0];e(f.split(","),function(j){var k;if(h.files[j]){return}h.files[j]=true;k=h.create("link",{rel:"stylesheet",href:c._addVer(j)});if(a&&i.documentMode){k.onload=function(){i.recalc();k.onload=null}}g.appendChild(k)})},addClass:function(f,g){return this.run(f,function(h){var i;if(!g){return 0}if(this.hasClass(h,g)){return h.className}i=this.removeClass(h,g);return h.className=(i!=""?(i+" "):"")+g})},removeClass:function(h,i){var f=this,g;return f.run(h,function(k){var j;if(f.hasClass(k,i)){if(!g){g=new RegExp("(^|\\s+)"+i+"(\\s+|$)","g")}j=k.className.replace(g," ");return k.className=c.trim(j!=" "?j:"")}return k.className})},hasClass:function(g,f){g=this.get(g);if(!g||!f){return false}return(" "+g.className+" ").indexOf(" "+f+" ")!==-1},show:function(f){return this.setStyle(f,"display","block")},hide:function(f){return this.setStyle(f,"display","none")},isHidden:function(f){f=this.get(f);return !f||f.style.display=="none"||this.getStyle(f,"display")=="none"},uniqueId:function(f){return(!f?"mce_":f)+(this.counter++)},setHTML:function(i,g){var f=this;return this.run(i,function(m){var h,k,j,q,l,h;g=f.processHTML(g);if(a){function o(){try{m.innerHTML="
        "+g;m.removeChild(m.firstChild)}catch(n){while(m.firstChild){m.firstChild.removeNode()}h=f.create("div");h.innerHTML="
        "+g;e(h.childNodes,function(r,p){if(p){m.appendChild(r)}})}}if(f.settings.fix_ie_paragraphs){g=g.replace(/

        <\/p>|]+)><\/p>|/gi,' 

        ')}o();if(f.settings.fix_ie_paragraphs){j=m.getElementsByTagName("p");for(k=j.length-1,h=0;k>=0;k--){q=j[k];if(!q.hasChildNodes()){if(!q.mce_keep){h=1;break}q.removeAttribute("mce_keep")}}}if(h){g=g.replace(/

        ]+)>|

        /ig,'

        ');g=g.replace(/<\/p>/g,"
        ");o();if(f.settings.fix_ie_paragraphs){j=m.getElementsByTagName("DIV");for(k=j.length-1;k>=0;k--){q=j[k];if(q.mce_tmp){l=f.doc.createElement("p");q.cloneNode(false).outerHTML.replace(/([a-z0-9\-_]+)=/gi,function(p,n){var r;if(n!=="mce_tmp"){r=q.getAttribute(n);if(!r&&n==="class"){r=q.className}l.setAttribute(n,r)}});for(h=0;h|]+)>/gi,"<$1b$2>");j=j.replace(/<(\/?)em>|]+)>/gi,"<$1i$2>")}else{if(a){j=j.replace(/'/g,"'");j=j.replace(/\s+(disabled|checked|readonly|selected)\s*=\s*[\"\']?(false|0)[\"\']?/gi,"")}}j=j.replace(/]+)\/>|/gi,"");if(i.keep_values){if(/)/g,"\n");h=h.replace(/^[\r\n]*|[\r\n]*$/g,"");h=h.replace(/^\s*(\/\/\s*|\]\]>|-->|\]\]-->)\s*$/g,"");return h}j=j.replace(/]+|)>([\s\S]*?)<\/script>/gi,function(h,m,l){if(!m){m=' type="text/javascript"'}m=m.replace(/src=\"([^\"]+)\"?/i,function(n,o){if(i.url_converter){o=g.encode(i.url_converter.call(i.url_converter_scope||g,g.decode(o),"src","script"))}return'mce_src="'+o+'"'});if(c.trim(l)){k.push(f(l));l=""}return""+l+""});j=j.replace(/]+|)>([\s\S]*?)<\/style>/gi,function(h,m,l){if(l){k.push(f(l));l=""}return""+l+""});j=j.replace(/]+|)>([\s\S]*?)<\/noscript>/g,function(h,m,l){return""})}j=j.replace(//g,"");j=j.replace(/<([\w:]+) [^>]*(checked|compact|declare|defer|disabled|ismap|multiple|nohref|noshade|nowrap|readonly|selected)[^>]*>/gi,function(l){function h(o,m,n){if(n==="false"||n==="0"){return""}return" "+m+'="'+m+'"'}l=l.replace(/ (checked|compact|declare|defer|disabled|ismap|multiple|nohref|noshade|nowrap|readonly|selected)=[\"]([^\"]+)[\"]/gi,h);l=l.replace(/ (checked|compact|declare|defer|disabled|ismap|multiple|nohref|noshade|nowrap|readonly|selected)=[\']([^\']+)[\']/gi,h);l=l.replace(/ (checked|compact|declare|defer|disabled|ismap|multiple|nohref|noshade|nowrap|readonly|selected)=([^\s\"\'>]+)/gi,h);l=l.replace(/ (checked|compact|declare|defer|disabled|ismap|multiple|nohref|noshade|nowrap|readonly|selected)([\s>])/gi,' $1="$1"$2');return l});j=j.replace(/<([\w:]+) [^>]*(src|href|style|shape|coords)[^>]*>/gi,function(h,m){function l(o,n,q){var p=q;if(h.indexOf("mce_"+n)!=-1){return o}if(n=="style"){if(g._isRes(q)){return o}p=g.encode(g.serializeStyle(g.parseStyle(p)))}else{if(n!="coords"&&n!="shape"){if(i.url_converter){p=g.encode(i.url_converter.call(i.url_converter_scope||g,g.decode(q),n,m))}}}return" "+n+'="'+q+'" mce_'+n+'="'+p+'"'}h=h.replace(/ (src|href|style|coords|shape)=[\"]([^\"]+)[\"]/gi,l);h=h.replace(/ (src|href|style|coords|shape)=[\']([^\']+)[\']/gi,l);return h.replace(/ (src|href|style|coords|shape)=([^\s\"\'>]+)/gi,l)});j=j.replace(/MCE_SCRIPT:([0-9]+)/g,function(l,h){return k[h]})}return j},getOuterHTML:function(f){var g;f=this.get(f);if(!f){return null}if(f.outerHTML!==undefined){return f.outerHTML}g=(f.ownerDocument||this.doc).createElement("body");g.appendChild(f.cloneNode(true));return g.innerHTML},setOuterHTML:function(j,g,k){var f=this;function i(m,l,p){var q,o;o=p.createElement("body");o.innerHTML=l;q=o.lastChild;while(q){f.insertAfter(q.cloneNode(true),m);q=q.previousSibling}f.remove(m)}return this.run(j,function(l){l=f.get(l);if(l.nodeType==1){k=k||l.ownerDocument||f.doc;if(a){try{if(a&&l.nodeType==1){l.outerHTML=g}else{i(l,g,k)}}catch(h){i(l,g,k)}}else{i(l,g,k)}}})},decode:function(g){var h,i,f;if(/&[^;]+;/.test(g)){h=this.doc.createElement("div");h.innerHTML=g;i=h.firstChild;f="";if(i){do{f+=i.nodeValue}while(i.nextSibling)}return f||g}return g},encode:function(f){return f?(""+f).replace(/[<>&\"]/g,function(h,g){switch(h){case"&":return"&";case'"':return""";case"<":return"<";case">":return">"}return h}):f},insertAfter:function(h,g){var f=this;g=f.get(g);return this.run(h,function(k){var j,i;j=g.parentNode;i=g.nextSibling;if(i){j.insertBefore(k,i)}else{j.appendChild(k)}return k})},isBlock:function(f){if(f.nodeType&&f.nodeType!==1){return false}f=f.nodeName||f;return/^(H[1-6]|HR|P|DIV|ADDRESS|PRE|FORM|TABLE|LI|OL|UL|TH|TBODY|TR|TD|CAPTION|BLOCKQUOTE|CENTER|DL|DT|DD|DIR|FIELDSET|NOSCRIPT|NOFRAMES|MENU|ISINDEX|SAMP)$/.test(f)},replace:function(i,h,f){var g=this;if(b(h,"array")){i=i.cloneNode(true)}return g.run(h,function(j){if(f){e(j.childNodes,function(k){i.appendChild(k.cloneNode(true))})}if(g.fixPsuedoLeaks&&j.nodeType===1){j.parentNode.insertBefore(i,j);g.remove(j);return i}return j.parentNode.replaceChild(i,j)})},findCommonAncestor:function(h,f){var i=h,g;while(i){g=f;while(g&&i!=g){g=g.parentNode}if(i==g){break}i=i.parentNode}if(!i&&h.ownerDocument){return h.ownerDocument.documentElement}return i},toHex:function(f){var h=/^\s*rgb\s*?\(\s*?([0-9]+)\s*?,\s*?([0-9]+)\s*?,\s*?([0-9]+)\s*?\)\s*$/i.exec(f);function g(i){i=parseInt(i).toString(16);return i.length>1?i:"0"+i}if(h){f="#"+g(h[1])+g(h[2])+g(h[3]);return f}return f},getClasses:function(){var l=this,g=[],k,m={},n=l.settings.class_filter,j;if(l.classes){return l.classes}function o(f){e(f.imports,function(i){o(i)});e(f.cssRules||f.rules,function(i){switch(i.type||1){case 1:if(i.selectorText){e(i.selectorText.split(","),function(p){p=p.replace(/^\s*|\s*$|^\s\./g,"");if(/\.mce/.test(p)||!/\.[\w\-]+$/.test(p)){return}j=p;p=p.replace(/.*\.([a-z0-9_\-]+).*/i,"$1");if(n&&!(p=n(p,j))){return}if(!m[p]){g.push({"class":p});m[p]=1}})}break;case 3:o(i.styleSheet);break}})}try{e(l.doc.styleSheets,o)}catch(h){}if(g.length>0){l.classes=g}return g},run:function(j,i,h){var g=this,k;if(g.doc&&typeof(j)==="string"){j=g.get(j)}if(!j){return false}h=h||this;if(!j.nodeType&&(j.length||j.length===0)){k=[];e(j,function(l,f){if(l){if(typeof(l)=="string"){l=g.doc.getElementById(l)}k.push(i.call(h,l,f))}});return k}return i.call(h,j)},getAttribs:function(g){var f;g=this.get(g);if(!g){return[]}if(a){f=[];if(g.nodeName=="OBJECT"){return g.attributes}if(g.nodeName==="OPTION"&&this.getAttrib(g,"selected")){f.push({specified:1,nodeName:"selected"})}g.cloneNode(false).outerHTML.replace(/<\/?[\w:]+ ?|=[\"][^\"]+\"|=\'[^\']+\'|=\w+|>/gi,"").replace(/[\w:]+/gi,function(h){f.push({specified:1,nodeName:h})});return f}return g.attributes},destroy:function(g){var f=this;if(f.events){f.events.destroy()}f.win=f.doc=f.root=f.events=null;if(!g){c.removeUnload(f.destroy)}},createRng:function(){var f=this.doc;return f.createRange?f.createRange():new c.dom.Range(this)},split:function(l,k,o){var p=this,f=p.createRng(),m,j,n;function g(r,q){r=r[q];if(r&&r[q]&&r[q].nodeType==1&&i(r[q])){p.remove(r[q])}}function i(q){q=p.getOuterHTML(q);q=q.replace(/<(img|hr|table)/gi,"-");q=q.replace(/<[^>]+>/g,"");return q.replace(/[ \t\r\n]+| | /g,"")==""}function h(r){var q=0;while(r.previousSibling){q++;r=r.previousSibling}return q}if(l&&k){f.setStart(l.parentNode,h(l));f.setEnd(k.parentNode,h(k));m=f.extractContents();f=p.createRng();f.setStart(k.parentNode,h(k)+1);f.setEnd(l.parentNode,h(l)+1);j=f.extractContents();n=l.parentNode;g(m,"lastChild");if(!i(m)){n.insertBefore(m,l)}if(o){n.replaceChild(o,k)}else{n.insertBefore(k,l)}g(j,"firstChild");if(!i(j)){n.insertBefore(j,l)}p.remove(l);return o||k}},bind:function(j,f,i,h){var g=this;if(!g.events){g.events=new c.dom.EventUtils()}return g.events.add(j,f,i,h||this)},unbind:function(i,f,h){var g=this;if(!g.events){g.events=new c.dom.EventUtils()}return g.events.remove(i,f,h)},_findSib:function(j,g,h){var i=this,k=g;if(j){if(b(k,"string")){k=function(f){return i.is(f,g)}}for(j=j[h];j;j=j[h]){if(k(j)){return j}}}return null},_isRes:function(f){return/^(top|left|bottom|right|width|height)/i.test(f)||/;\s*(top|left|bottom|right|width|height)/i.test(f)}});c.DOM=new c.dom.DOMUtils(document,{process_html:0})})(tinymce);(function(f){var h=0,c=1,e=2,d=tinymce.extend;function g(m,k){var j,l;if(m.parentNode!=k){return -1}for(l=k.firstChild,j=0;l!=m;l=l.nextSibling){j++}return j}function b(k){var j=0;while(k.previousSibling){j++;k=k.previousSibling}return j}function i(j,k){var l;if(j.nodeType==3){return j}if(k<0){return j}l=j.firstChild;while(l!=null&&k>0){--k;l=l.nextSibling}if(l!=null){return l}return j}function a(k){var j=k.doc;d(this,{dom:k,startContainer:j,startOffset:0,endContainer:j,endOffset:0,collapsed:true,commonAncestorContainer:j,START_TO_START:0,START_TO_END:1,END_TO_END:2,END_TO_START:3})}d(a.prototype,{setStart:function(k,j){this._setEndPoint(true,k,j)},setEnd:function(k,j){this._setEndPoint(false,k,j)},setStartBefore:function(j){this.setStart(j.parentNode,b(j))},setStartAfter:function(j){this.setStart(j.parentNode,b(j)+1)},setEndBefore:function(j){this.setEnd(j.parentNode,b(j))},setEndAfter:function(j){this.setEnd(j.parentNode,b(j)+1)},collapse:function(k){var j=this;if(k){j.endContainer=j.startContainer;j.endOffset=j.startOffset}else{j.startContainer=j.endContainer;j.startOffset=j.endOffset}j.collapsed=true},selectNode:function(j){this.setStartBefore(j);this.setEndAfter(j)},selectNodeContents:function(j){this.setStart(j,0);this.setEnd(j,j.nodeType===1?j.childNodes.length:j.nodeValue.length)},compareBoundaryPoints:function(m,n){var l=this,p=l.startContainer,o=l.startOffset,k=l.endContainer,j=l.endOffset;if(m===0){return l._compareBoundaryPoints(p,o,p,o)}if(m===1){return l._compareBoundaryPoints(p,o,k,j)}if(m===2){return l._compareBoundaryPoints(k,j,k,j)}if(m===3){return l._compareBoundaryPoints(k,j,p,o)}},deleteContents:function(){this._traverse(e)},extractContents:function(){return this._traverse(h)},cloneContents:function(){return this._traverse(c)},insertNode:function(m){var j=this,l,k;if(m.nodeType===3||m.nodeType===4){l=j.startContainer.splitText(j.startOffset);j.startContainer.parentNode.insertBefore(m,l)}else{if(j.startContainer.childNodes.length>0){k=j.startContainer.childNodes[j.startOffset]}j.startContainer.insertBefore(m,k)}},surroundContents:function(l){var j=this,k=j.extractContents();j.insertNode(l);l.appendChild(k);j.selectNode(l)},cloneRange:function(){var j=this;return d(new a(j.dom),{startContainer:j.startContainer,startOffset:j.startOffset,endContainer:j.endContainer,endOffset:j.endOffset,collapsed:j.collapsed,commonAncestorContainer:j.commonAncestorContainer})},_isCollapsed:function(){return(this.startContainer==this.endContainer&&this.startOffset==this.endOffset)},_compareBoundaryPoints:function(m,p,k,o){var q,l,j,r,t,s;if(m==k){if(p==o){return 0}else{if(p0){l.collapse(k)}}l.collapsed=l._isCollapsed();l.commonAncestorContainer=l.dom.findCommonAncestor(l.startContainer,l.endContainer)},_traverse:function(r){var s=this,q,m=0,v=0,k,o,l,n,j,u;if(s.startContainer==s.endContainer){return s._traverseSameContainer(r)}for(q=s.endContainer,k=q.parentNode;k!=null;q=k,k=k.parentNode){if(k==s.startContainer){return s._traverseCommonStartContainer(q,r)}++m}for(q=s.startContainer,k=q.parentNode;k!=null;q=k,k=k.parentNode){if(k==s.endContainer){return s._traverseCommonEndContainer(q,r)}++v}o=v-m;l=s.startContainer;while(o>0){l=l.parentNode;o--}n=s.endContainer;while(o<0){n=n.parentNode;o++}for(j=l.parentNode,u=n.parentNode;j!=u;j=j.parentNode,u=u.parentNode){l=j;n=u}return s._traverseCommonAncestors(l,n,r)},_traverseSameContainer:function(o){var r=this,q,u,j,k,l,p,m;if(o!=e){q=r.dom.doc.createDocumentFragment()}if(r.startOffset==r.endOffset){return q}if(r.startContainer.nodeType==3){u=r.startContainer.nodeValue;j=u.substring(r.startOffset,r.endOffset);if(o!=c){r.startContainer.deleteData(r.startOffset,r.endOffset-r.startOffset);r.collapse(true)}if(o==e){return null}q.appendChild(r.dom.doc.createTextNode(j));return q}k=i(r.startContainer,r.startOffset);l=r.endOffset-r.startOffset;while(l>0){p=k.nextSibling;m=r._traverseFullySelected(k,o);if(q){q.appendChild(m)}--l;k=p}if(o!=c){r.collapse(true)}return q},_traverseCommonStartContainer:function(j,p){var s=this,r,k,l,m,q,o;if(p!=e){r=s.dom.doc.createDocumentFragment()}k=s._traverseRightBoundary(j,p);if(r){r.appendChild(k)}l=g(j,s.startContainer);m=l-s.startOffset;if(m<=0){if(p!=c){s.setEndBefore(j);s.collapse(false)}return r}k=j.previousSibling;while(m>0){q=k.previousSibling;o=s._traverseFullySelected(k,p);if(r){r.insertBefore(o,r.firstChild)}--m;k=q}if(p!=c){s.setEndBefore(j);s.collapse(false)}return r},_traverseCommonEndContainer:function(m,p){var s=this,r,o,j,k,q,l;if(p!=e){r=s.dom.doc.createDocumentFragment()}j=s._traverseLeftBoundary(m,p);if(r){r.appendChild(j)}o=g(m,s.endContainer);++o;k=s.endOffset-o;j=m.nextSibling;while(k>0){q=j.nextSibling;l=s._traverseFullySelected(j,p);if(r){r.appendChild(l)}--k;j=q}if(p!=c){s.setStartAfter(m);s.collapse(true)}return r},_traverseCommonAncestors:function(p,j,s){var w=this,l,v,o,q,r,k,u,m;if(s!=e){v=w.dom.doc.createDocumentFragment()}l=w._traverseLeftBoundary(p,s);if(v){v.appendChild(l)}o=p.parentNode;q=g(p,o);r=g(j,o);++q;k=r-q;u=p.nextSibling;while(k>0){m=u.nextSibling;l=w._traverseFullySelected(u,s);if(v){v.appendChild(l)}u=m;--k}l=w._traverseRightBoundary(j,s);if(v){v.appendChild(l)}if(s!=c){w.setStartAfter(p);w.collapse(true)}return v},_traverseRightBoundary:function(p,q){var s=this,l=i(s.endContainer,s.endOffset-1),r,o,n,j,k;var m=l!=s.endContainer;if(l==p){return s._traverseNode(l,m,false,q)}r=l.parentNode;o=s._traverseNode(r,false,false,q);while(r!=null){while(l!=null){n=l.previousSibling;j=s._traverseNode(l,m,false,q);if(q!=e){o.insertBefore(j,o.firstChild)}m=true;l=n}if(r==p){return o}l=r.previousSibling;r=r.parentNode;k=s._traverseNode(r,false,false,q);if(q!=e){k.appendChild(o)}o=k}return null},_traverseLeftBoundary:function(p,q){var s=this,m=i(s.startContainer,s.startOffset);var n=m!=s.startContainer,r,o,l,j,k;if(m==p){return s._traverseNode(m,n,true,q)}r=m.parentNode;o=s._traverseNode(r,false,true,q);while(r!=null){while(m!=null){l=m.nextSibling;j=s._traverseNode(m,n,true,q);if(q!=e){o.appendChild(j)}n=true;m=l}if(r==p){return o}m=r.nextSibling;r=r.parentNode;k=s._traverseNode(r,false,true,q);if(q!=e){k.appendChild(o)}o=k}return null},_traverseNode:function(j,o,r,s){var u=this,m,l,p,k,q;if(o){return u._traverseFullySelected(j,s)}if(j.nodeType==3){m=j.nodeValue;if(r){k=u.startOffset;l=m.substring(k);p=m.substring(0,k)}else{k=u.endOffset;l=m.substring(0,k);p=m.substring(k)}if(s!=c){j.nodeValue=p}if(s==e){return null}q=j.cloneNode(false);q.nodeValue=l;return q}if(s==e){return null}return j.cloneNode(false)},_traverseFullySelected:function(l,k){var j=this;if(k!=e){return k==c?l.cloneNode(true):l}l.parentNode.removeChild(l);return null}});f.Range=a})(tinymce.dom);(function(){function a(e){var d=this,h="\uFEFF",b,g;function c(j,i){if(j&&i){if(j.item&&i.item&&j.item(0)===i.item(0)){return 1}if(j.isEqual&&i.isEqual&&i.isEqual(j)){return 1}}return 0}function f(){var m=e.dom,j=e.getRng(),s=m.createRng(),p,k,n,q,o,l;function i(v){var t=v.parentNode.childNodes,u;for(u=t.length-1;u>=0;u--){if(t[u]==v){return u}}return -1}function r(v){var t=j.duplicate(),B,y,u,w,x=0,z=0,A,C;t.collapse(v);B=t.parentElement();t.pasteHTML(h);u=B.childNodes;for(y=0;y0&&(w.nodeType!==3||u[y-1].nodeType!==3)){z++}if(w.nodeType===3){A=w.nodeValue.indexOf(h);if(A!==-1){x+=A;break}x+=w.nodeValue.length}else{x=0}}t.moveStart("character",-1);t.text="";return{index:z,offset:x,parent:B}}n=j.item?j.item(0):j.parentElement();if(n.ownerDocument!=m.doc){return s}if(j.item||!n.hasChildNodes()){s.setStart(n.parentNode,i(n));s.setEnd(s.startContainer,s.startOffset+1);return s}l=e.isCollapsed();p=r(true);k=r(false);p.parent.normalize();k.parent.normalize();q=p.parent.childNodes[Math.min(p.index,p.parent.childNodes.length-1)];if(q.nodeType!=3){s.setStart(p.parent,p.index)}else{s.setStart(p.parent.childNodes[p.index],p.offset)}o=k.parent.childNodes[Math.min(k.index,k.parent.childNodes.length-1)];if(o.nodeType!=3){if(!l){k.index++}s.setEnd(k.parent,k.index)}else{s.setEnd(k.parent.childNodes[k.index],k.offset)}if(!l){q=s.startContainer;if(q.nodeType==1){s.setStart(q,Math.min(s.startOffset,q.childNodes.length))}o=s.endContainer;if(o.nodeType==1){s.setEnd(o,Math.min(s.endOffset,o.childNodes.length))}}d.addRange(s);return s}this.addRange=function(j){var o,m=e.dom.doc.body,p,k,q,l,n,i;q=j.startContainer;l=j.startOffset;n=j.endContainer;i=j.endOffset;o=m.createTextRange();q=q.nodeType==1?q.childNodes[Math.min(l,q.childNodes.length-1)]:q;n=n.nodeType==1?n.childNodes[Math.min(l==i?i:i-1,n.childNodes.length-1)]:n;if(q==n&&q.nodeType==1){if(/^(IMG|TABLE)$/.test(q.nodeName)&&l!=i){o=m.createControlRange();o.addElement(q)}else{o=m.createTextRange();if(!q.hasChildNodes()&&q.canHaveHTML){q.innerHTML=h}o.moveToElementText(q);if(q.innerHTML==h){o.collapse(true);q.removeChild(q.firstChild)}}if(l==i){o.collapse(i<=j.endContainer.childNodes.length-1)}o.select();return}function r(t,v){var u,s,w;if(t.nodeType!=3){return -1}u=t.nodeValue;s=m.createTextRange();t.nodeValue=u.substring(0,v)+h+u.substring(v);s.moveToElementText(t.parentNode);s.findText(h);w=Math.abs(s.moveStart("character",-1048575));t.nodeValue=u;return w}if(j.collapsed){pos=r(q,l);o=m.createTextRange();o.move("character",pos);o.select();return}else{if(q==n&&q.nodeType==3){p=r(q,l);o=m.createTextRange();o.move("character",p);o.moveEnd("character",i-l);o.select();return}p=r(q,l);k=r(n,i);o=m.createTextRange();if(p==-1){o.moveToElementText(q);p=0}else{o.move("character",p)}tmpRng=m.createTextRange();if(k==-1){tmpRng.moveToElementText(n)}else{tmpRng.move("character",k)}o.setEndPoint("EndToEnd",tmpRng);o.select();return}};this.getRangeAt=function(){if(!b||!c(g,e.getRng())){b=f();g=e.getRng()}return b};this.destroy=function(){g=b=null}}tinymce.dom.TridentSelection=a})();(function(){var p=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?/g,i=0,d=Object.prototype.toString,n=false;var b=function(D,t,A,v){A=A||[];var e=t=t||document;if(t.nodeType!==1&&t.nodeType!==9){return[]}if(!D||typeof D!=="string"){return A}var B=[],C,y,G,F,z,s,r=true,w=o(t);p.lastIndex=0;while((C=p.exec(D))!==null){B.push(C[1]);if(C[2]){s=RegExp.rightContext;break}}if(B.length>1&&j.exec(D)){if(B.length===2&&f.relative[B[0]]){y=g(B[0]+B[1],t)}else{y=f.relative[B[0]]?[t]:b(B.shift(),t);while(B.length){D=B.shift();if(f.relative[D]){D+=B.shift()}y=g(D,y)}}}else{if(!v&&B.length>1&&t.nodeType===9&&!w&&f.match.ID.test(B[0])&&!f.match.ID.test(B[B.length-1])){var H=b.find(B.shift(),t,w);t=H.expr?b.filter(H.expr,H.set)[0]:H.set[0]}if(t){var H=v?{expr:B.pop(),set:a(v)}:b.find(B.pop(),B.length===1&&(B[0]==="~"||B[0]==="+")&&t.parentNode?t.parentNode:t,w);y=H.expr?b.filter(H.expr,H.set):H.set;if(B.length>0){G=a(y)}else{r=false}while(B.length){var u=B.pop(),x=u;if(!f.relative[u]){u=""}else{x=B.pop()}if(x==null){x=t}f.relative[u](G,x,w)}}else{G=B=[]}}if(!G){G=y}if(!G){throw"Syntax error, unrecognized expression: "+(u||D)}if(d.call(G)==="[object Array]"){if(!r){A.push.apply(A,G)}else{if(t&&t.nodeType===1){for(var E=0;G[E]!=null;E++){if(G[E]&&(G[E]===true||G[E].nodeType===1&&h(t,G[E]))){A.push(y[E])}}}else{for(var E=0;G[E]!=null;E++){if(G[E]&&G[E].nodeType===1){A.push(y[E])}}}}}else{a(G,A)}if(s){b(s,e,A,v);b.uniqueSort(A)}return A};b.uniqueSort=function(r){if(c){n=false;r.sort(c);if(n){for(var e=1;e":function(w,r,x){var u=typeof r==="string";if(u&&!/\W/.test(r)){r=x?r:r.toUpperCase();for(var s=0,e=w.length;s=0)){if(!s){e.push(v)}}else{if(s){r[u]=false}}}}return false},ID:function(e){return e[1].replace(/\\/g,"")},TAG:function(r,e){for(var s=0;e[s]===false;s++){}return e[s]&&o(e[s])?r[1]:r[1].toUpperCase()},CHILD:function(e){if(e[1]=="nth"){var r=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(e[2]=="even"&&"2n"||e[2]=="odd"&&"2n+1"||!/\D/.test(e[2])&&"0n+"+e[2]||e[2]);e[2]=(r[1]+(r[2]||1))-0;e[3]=r[3]-0}e[0]=i++;return e},ATTR:function(u,r,s,e,v,w){var t=u[1].replace(/\\/g,"");if(!w&&f.attrMap[t]){u[1]=f.attrMap[t]}if(u[2]==="~="){u[4]=" "+u[4]+" "}return u},PSEUDO:function(u,r,s,e,v){if(u[1]==="not"){if(u[3].match(p).length>1||/^\w/.test(u[3])){u[3]=b(u[3],null,null,r)}else{var t=b.filter(u[3],r,s,true^v);if(!s){e.push.apply(e,t)}return false}}else{if(f.match.POS.test(u[0])||f.match.CHILD.test(u[0])){return true}}return u},POS:function(e){e.unshift(true);return e}},filters:{enabled:function(e){return e.disabled===false&&e.type!=="hidden"},disabled:function(e){return e.disabled===true},checked:function(e){return e.checked===true},selected:function(e){e.parentNode.selectedIndex;return e.selected===true},parent:function(e){return !!e.firstChild},empty:function(e){return !e.firstChild},has:function(s,r,e){return !!b(e[3],s).length},header:function(e){return/h\d/i.test(e.nodeName)},text:function(e){return"text"===e.type},radio:function(e){return"radio"===e.type},checkbox:function(e){return"checkbox"===e.type},file:function(e){return"file"===e.type},password:function(e){return"password"===e.type},submit:function(e){return"submit"===e.type},image:function(e){return"image"===e.type},reset:function(e){return"reset"===e.type},button:function(e){return"button"===e.type||e.nodeName.toUpperCase()==="BUTTON"},input:function(e){return/input|select|textarea|button/i.test(e.nodeName)}},setFilters:{first:function(r,e){return e===0},last:function(s,r,e,t){return r===t.length-1},even:function(r,e){return e%2===0},odd:function(r,e){return e%2===1},lt:function(s,r,e){return re[3]-0},nth:function(s,r,e){return e[3]-0==r},eq:function(s,r,e){return e[3]-0==r}},filter:{PSEUDO:function(w,s,t,x){var r=s[1],u=f.filters[r];if(u){return u(w,t,s,x)}else{if(r==="contains"){return(w.textContent||w.innerText||"").indexOf(s[3])>=0}else{if(r==="not"){var v=s[3];for(var t=0,e=v.length;t=0)}}},ID:function(r,e){return r.nodeType===1&&r.getAttribute("id")===e},TAG:function(r,e){return(e==="*"&&r.nodeType===1)||r.nodeName===e},CLASS:function(r,e){return(" "+(r.className||r.getAttribute("class"))+" ").indexOf(e)>-1},ATTR:function(v,t){var s=t[1],e=f.attrHandle[s]?f.attrHandle[s](v):v[s]!=null?v[s]:v.getAttribute(s),w=e+"",u=t[2],r=t[4];return e==null?u==="!=":u==="="?w===r:u==="*="?w.indexOf(r)>=0:u==="~="?(" "+w+" ").indexOf(r)>=0:!r?w&&e!==false:u==="!="?w!=r:u==="^="?w.indexOf(r)===0:u==="$="?w.substr(w.length-r.length)===r:u==="|="?w===r||w.substr(0,r.length+1)===r+"-":false},POS:function(u,r,s,v){var e=r[2],t=f.setFilters[e];if(t){return t(u,s,r,v)}}}};var j=f.match.POS;for(var l in f.match){f.match[l]=new RegExp(f.match[l].source+/(?![^\[]*\])(?![^\(]*\))/.source)}var a=function(r,e){r=Array.prototype.slice.call(r);if(e){e.push.apply(e,r);return e}return r};try{Array.prototype.slice.call(document.documentElement.childNodes)}catch(k){a=function(u,t){var r=t||[];if(d.call(u)==="[object Array]"){Array.prototype.push.apply(r,u)}else{if(typeof u.length==="number"){for(var s=0,e=u.length;s";var e=document.documentElement;e.insertBefore(r,e.firstChild);if(!!document.getElementById(s)){f.find.ID=function(u,v,w){if(typeof v.getElementById!=="undefined"&&!w){var t=v.getElementById(u[1]);return t?t.id===u[1]||typeof t.getAttributeNode!=="undefined"&&t.getAttributeNode("id").nodeValue===u[1]?[t]:undefined:[]}};f.filter.ID=function(v,t){var u=typeof v.getAttributeNode!=="undefined"&&v.getAttributeNode("id");return v.nodeType===1&&u&&u.nodeValue===t}}e.removeChild(r)})();(function(){var e=document.createElement("div");e.appendChild(document.createComment(""));if(e.getElementsByTagName("*").length>0){f.find.TAG=function(r,v){var u=v.getElementsByTagName(r[1]);if(r[1]==="*"){var t=[];for(var s=0;u[s];s++){if(u[s].nodeType===1){t.push(u[s])}}u=t}return u}}e.innerHTML="";if(e.firstChild&&typeof e.firstChild.getAttribute!=="undefined"&&e.firstChild.getAttribute("href")!=="#"){f.attrHandle.href=function(r){return r.getAttribute("href",2)}}})();if(document.querySelectorAll){(function(){var e=b,s=document.createElement("div");s.innerHTML="

        ";if(s.querySelectorAll&&s.querySelectorAll(".TEST").length===0){return}b=function(w,v,t,u){v=v||document;if(!u&&v.nodeType===9&&!o(v)){try{return a(v.querySelectorAll(w),t)}catch(x){}}return e(w,v,t,u)};for(var r in e){b[r]=e[r]}})()}if(document.getElementsByClassName&&document.documentElement.getElementsByClassName){(function(){var e=document.createElement("div");e.innerHTML="
        ";if(e.getElementsByClassName("e").length===0){return}e.lastChild.className="e";if(e.getElementsByClassName("e").length===1){return}f.order.splice(1,0,"CLASS");f.find.CLASS=function(r,s,t){if(typeof s.getElementsByClassName!=="undefined"&&!t){return s.getElementsByClassName(r[1])}}})()}function m(r,w,v,A,x,z){var y=r=="previousSibling"&&!z;for(var t=0,s=A.length;t0){u=e;break}}}e=e[r]}A[t]=u}}}var h=document.compareDocumentPosition?function(r,e){return r.compareDocumentPosition(e)&16}:function(r,e){return r!==e&&(r.contains?r.contains(e):true)};var o=function(e){return e.nodeType===9&&e.documentElement.nodeName!=="HTML"||!!e.ownerDocument&&e.ownerDocument.documentElement.nodeName!=="HTML"};var g=function(e,x){var t=[],u="",v,s=x.nodeType?[x]:x;while((v=f.match.PSEUDO.exec(e))){u+=v[0];e=e.replace(f.match.PSEUDO,"")}e=f.relative[e]?e+"*":e;for(var w=0,r=s.length;w=0;h--){k=g[h];if(k.obj===l){j._remove(k.obj,k.name,k.cfunc);k.obj=k.cfunc=null;g.splice(h,1)}}}},cancel:function(g){if(!g){return false}this.stop(g);return this.prevent(g)},stop:function(g){if(g.stopPropagation){g.stopPropagation()}else{g.cancelBubble=true}return false},prevent:function(g){if(g.preventDefault){g.preventDefault()}else{g.returnValue=false}return false},destroy:function(){var g=this;f(g.events,function(j,h){g._remove(j.obj,j.name,j.cfunc);j.obj=j.cfunc=null});g.events=[];g=null},_add:function(h,i,g){if(h.attachEvent){h.attachEvent("on"+i,g)}else{if(h.addEventListener){h.addEventListener(i,g,false)}else{h["on"+i]=g}}},_remove:function(i,j,h){if(i){try{if(i.detachEvent){i.detachEvent("on"+j,h)}else{if(i.removeEventListener){i.removeEventListener(j,h,false)}else{i["on"+j]=null}}}catch(g){}}},_pageInit:function(h){var g=this;if(g.domLoaded){return}g.domLoaded=true;f(g.inits,function(i){i()});g.inits=[]},_wait:function(i){var g=this,h=i.document;if(i.tinyMCE_GZ&&tinyMCE_GZ.loaded){g.domLoaded=1;return}if(h.attachEvent){h.attachEvent("onreadystatechange",function(){if(h.readyState==="complete"){h.detachEvent("onreadystatechange",arguments.callee);g._pageInit(i)}});if(h.documentElement.doScroll&&i==i.top){(function(){if(g.domLoaded){return}try{h.documentElement.doScroll("left")}catch(j){setTimeout(arguments.callee,0);return}g._pageInit(i)})()}}else{if(h.addEventListener){g._add(i,"DOMContentLoaded",function(){g._pageInit(i)})}}g._add(i,"load",function(){g._pageInit(i)})},_stoppers:{preventDefault:function(){this.returnValue=false},stopPropagation:function(){this.cancelBubble=true}}});a=d.dom.Event=new d.dom.EventUtils();a._wait(window);d.addUnload(function(){a.destroy()})})(tinymce);(function(a){var b=a.each;a.create("tinymce.dom.Element",{Element:function(g,e){var c=this,f,d;e=e||{};c.id=g;c.dom=f=e.dom||a.DOM;c.settings=e;if(!a.isIE){d=c.dom.get(c.id)}b(["getPos","getRect","getParent","add","setStyle","getStyle","setStyles","setAttrib","setAttribs","getAttrib","addClass","removeClass","hasClass","getOuterHTML","setOuterHTML","remove","show","hide","isHidden","setHTML","get"],function(h){c[h]=function(){var j=[g],k;for(k=0;k_';j.deleteContents();j.insertNode(f.getRng().createContextualFragment(i));l=f.dom.get("__caret");j=k.createRange();j.setStartBefore(l);j.setEndAfter(l);f.setRng(j);f.dom.remove("__caret")}else{if(j.item){k.execCommand("Delete",false,null);j=f.getRng()}j.pasteHTML(i)}f.onSetContent.dispatch(f,g)},getStart:function(){var f=this,g=f.getRng(),h;if(a){if(g.item){return g.item(0)}g=g.duplicate();g.collapse(1);h=g.parentElement();if(h&&h.nodeName=="BODY"){return h.firstChild}return h}else{h=g.startContainer;if(h.nodeName=="BODY"){return h.firstChild}return f.dom.getParent(h,"*")}},getEnd:function(){var f=this,g=f.getRng(),h;if(a){if(g.item){return g.item(0)}g=g.duplicate();g.collapse(0);h=g.parentElement();if(h&&h.nodeName=="BODY"){return h.lastChild}return h}else{h=g.endContainer;if(h.nodeName=="BODY"){return h.lastChild}return f.dom.getParent(h,"*")}},getBookmark:function(x){var j=this,m=j.getRng(),f,n,l,u=j.dom.getViewPort(j.win),v,p,z,o,w=-16777215,k,h=j.dom.getRoot(),g=0,i=0,y;n=u.x;l=u.y;if(x){return{rng:m,scrollX:n,scrollY:l}}if(a){if(m.item){v=m.item(0);d(j.dom.select(v.nodeName),function(s,r){if(v==s){p=r;return false}});return{tag:v.nodeName,index:p,scrollX:n,scrollY:l}}f=j.dom.doc.body.createTextRange();f.moveToElementText(h);f.collapse(true);z=Math.abs(f.move("character",w));f=m.duplicate();f.collapse(true);p=Math.abs(f.move("character",w));f=m.duplicate();f.collapse(false);o=Math.abs(f.move("character",w))-p;return{start:p-z,length:o,scrollX:n,scrollY:l}}v=j.getNode();k=j.getSel();if(!k){return null}if(v&&v.nodeName=="IMG"){return{scrollX:n,scrollY:l}}function q(A,D,t){var s=j.dom.doc.createTreeWalker(A,NodeFilter.SHOW_TEXT,null,false),E,B=0,C={};while((E=s.nextNode())!=null){if(E==D){C.start=B}if(E==t){C.end=B;return C}B+=e(E.nodeValue||"").length}return null}if(k.anchorNode==k.focusNode&&k.anchorOffset==k.focusOffset){v=q(h,k.anchorNode,k.focusNode);if(!v){return{scrollX:n,scrollY:l}}e(k.anchorNode.nodeValue||"").replace(/^\s+/,function(r){g=r.length});return{start:Math.max(v.start+k.anchorOffset-g,0),end:Math.max(v.end+k.focusOffset-g,0),scrollX:n,scrollY:l,beg:k.anchorOffset-g==0}}else{v=q(h,m.startContainer,m.endContainer);if(!v){return{scrollX:n,scrollY:l}}return{start:Math.max(v.start+m.startOffset-g,0),end:Math.max(v.end+m.endOffset-i,0),scrollX:n,scrollY:l,beg:m.startOffset-g==0}}},moveToBookmark:function(n){var o=this,g=o.getRng(),p=o.getSel(),j=o.dom.getRoot(),m,h,k;function i(q,t,D){var B=o.dom.doc.createTreeWalker(q,NodeFilter.SHOW_TEXT,null,false),x,s=0,A={},u,C,z,y;while((x=B.nextNode())!=null){z=y=0;k=x.nodeValue||"";h=e(k).length;s+=h;if(s>=t&&!A.startNode){u=t-(s-h);if(n.beg&&u>=h){continue}A.startNode=x;A.startOffset=u+y}if(s>=D){A.endNode=x;A.endOffset=D-(s-h)+y;return A}}return null}if(!n){return false}o.win.scrollTo(n.scrollX,n.scrollY);if(a){o.tridentSel.destroy();if(g=n.rng){try{g.select()}catch(l){}return true}o.win.focus();if(n.tag){g=j.createControlRange();d(o.dom.select(n.tag),function(r,q){if(q==n.index){g.addElement(r)}})}else{try{if(n.start<0){return true}g=p.createRange();g.moveToElementText(j);g.collapse(true);g.moveStart("character",n.start);g.moveEnd("character",n.length)}catch(f){return true}}try{g.select()}catch(l){}return true}if(!p){return false}if(n.rng){p.removeAllRanges();p.addRange(n.rng)}else{if(b(n.start)&&b(n.end)){try{m=i(j,n.start,n.end);if(m){g=o.dom.doc.createRange();g.setStart(m.startNode,m.startOffset);g.setEnd(m.endNode,m.endOffset);p.removeAllRanges();p.addRange(g)}if(!c.isOpera){o.win.focus()}}catch(l){}}}},select:function(g,l){var p=this,f=p.getRng(),q=p.getSel(),o,m,k,j=p.win.document;function h(u,t){var s,r;if(u){s=j.createTreeWalker(u,NodeFilter.SHOW_TEXT,null,false);while(u=s.nextNode()){r=u;if(c.trim(u.nodeValue).length!=0){if(t){return u}else{r=u}}}}return r}if(a){try{o=j.body;if(/^(IMG|TABLE)$/.test(g.nodeName)){f=o.createControlRange();f.addElement(g)}else{f=o.createTextRange();f.moveToElementText(g)}f.select()}catch(i){}}else{if(l){m=h(g,1)||p.dom.select("br:first",g)[0];k=h(g,0)||p.dom.select("br:last",g)[0];if(m&&k){f=j.createRange();if(m.nodeName=="BR"){f.setStartBefore(m)}else{f.setStart(m,0)}if(k.nodeName=="BR"){f.setEndBefore(k)}else{f.setEnd(k,k.nodeValue.length)}}else{f.selectNode(g)}}else{f.selectNode(g)}p.setRng(f)}return g},isCollapsed:function(){var f=this,h=f.getRng(),g=f.getSel();if(!h||h.item){return false}return !g||h.boundingWidth==0||h.collapsed},collapse:function(f){var g=this,h=g.getRng(),i;if(h.item){i=h.item(0);h=this.win.document.body.createTextRange();h.moveToElementText(i)}h.collapse(!!f);g.setRng(h)},getSel:function(){var g=this,f=this.win;return f.getSelection?f.getSelection():f.document.selection},getRng:function(j){var g=this,h,i;if(j&&g.tridentSel){return g.tridentSel.getRangeAt(0)}try{if(h=g.getSel()){i=h.rangeCount>0?h.getRangeAt(0):(h.createRange?h.createRange():g.win.document.createRange())}}catch(f){}if(!i){i=a?g.win.document.body.createTextRange():g.win.document.createRange()}return i},setRng:function(i){var h,g=this;if(!g.tridentSel){h=g.getSel();if(h){h.removeAllRanges();h.addRange(i)}}else{if(i.cloneRange){g.tridentSel.addRange(i);return}try{i.select()}catch(f){}}},setNode:function(g){var f=this;f.setContent(f.dom.getOuterHTML(g));return g},getNode:function(){var f=this,h=f.getRng(),g=f.getSel(),i;if(!a){if(!h){return f.dom.getRoot()}i=h.commonAncestorContainer;if(!h.collapsed){if(c.isWebKit&&g.anchorNode&&g.anchorNode.nodeType==1){return g.anchorNode.childNodes[g.anchorOffset]}if(h.startContainer==h.endContainer){if(h.startOffset-h.endOffset<2){if(h.startContainer.hasChildNodes()){i=h.startContainer.childNodes[h.startOffset]}}}}return f.dom.getParent(i,"*")}return h.item?h.item(0):h.parentElement()},getSelectedBlocks:function(g,f){var i=this,j=i.dom,m,h,l,k=[];m=j.getParent(g||i.getStart(),j.isBlock);h=j.getParent(f||i.getEnd(),j.isBlock);if(m){k.push(m)}if(m&&h&&m!=h){l=m;while((l=l.nextSibling)&&l!=h){if(j.isBlock(l)){k.push(l)}}}if(h&&m!=h){k.push(h)}return k},destroy:function(g){var f=this;f.win=null;if(f.tridentSel){f.tridentSel.destroy()}if(!g){c.removeUnload(f.destroy)}}})})(tinymce);(function(a){a.create("tinymce.dom.XMLWriter",{node:null,XMLWriter:function(c){function b(){var e=document.implementation;if(!e||!e.createDocument){try{return new ActiveXObject("MSXML2.DOMDocument")}catch(d){}try{return new ActiveXObject("Microsoft.XmlDom")}catch(d){}}else{return e.createDocument("","",null)}}this.doc=b();this.valid=a.isOpera||a.isWebKit;this.reset()},reset:function(){var b=this,c=b.doc;if(c.firstChild){c.removeChild(c.firstChild)}b.node=c.appendChild(c.createElement("html"))},writeStartElement:function(c){var b=this;b.node=b.node.appendChild(b.doc.createElement(c))},writeAttribute:function(c,b){if(this.valid){b=b.replace(/>/g,"%MCGT%")}this.node.setAttribute(c,b)},writeEndElement:function(){this.node=this.node.parentNode},writeFullEndElement:function(){var b=this,c=b.node;c.appendChild(b.doc.createTextNode(""));b.node=c.parentNode},writeText:function(b){if(this.valid){b=b.replace(/>/g,"%MCGT%")}this.node.appendChild(this.doc.createTextNode(b))},writeCDATA:function(b){this.node.appendChild(this.doc.createCDATASection(b))},writeComment:function(b){if(a.isIE){b=b.replace(/^\-|\-$/g," ")}this.node.appendChild(this.doc.createComment(b.replace(/\-\-/g," ")))},getContent:function(){var b;b=this.doc.xml||new XMLSerializer().serializeToString(this.doc);b=b.replace(/<\?[^?]+\?>||<\/html>||]+>/g,"");b=b.replace(/ ?\/>/g," />");if(this.valid){b=b.replace(/\%MCGT%/g,">")}return b}})})(tinymce);(function(a){a.create("tinymce.dom.StringWriter",{str:null,tags:null,count:0,settings:null,indent:null,StringWriter:function(b){this.settings=a.extend({indent_char:" ",indentation:0},b);this.reset()},reset:function(){this.indent="";this.str="";this.tags=[];this.count=0},writeStartElement:function(b){this._writeAttributesEnd();this.writeRaw("<"+b);this.tags.push(b);this.inAttr=true;this.count++;this.elementCount=this.count},writeAttribute:function(d,b){var c=this;c.writeRaw(" "+c.encode(d)+'="'+c.encode(b)+'"')},writeEndElement:function(){var b;if(this.tags.length>0){b=this.tags.pop();if(this._writeAttributesEnd(1)){this.writeRaw("")}if(this.settings.indentation>0){this.writeRaw("\n")}}},writeFullEndElement:function(){if(this.tags.length>0){this._writeAttributesEnd();this.writeRaw("");if(this.settings.indentation>0){this.writeRaw("\n")}}},writeText:function(b){this._writeAttributesEnd();this.writeRaw(this.encode(b));this.count++},writeCDATA:function(b){this._writeAttributesEnd();this.writeRaw("");this.count++},writeComment:function(b){this._writeAttributesEnd();this.writeRaw("");this.count++},writeRaw:function(b){this.str+=b},encode:function(b){return b.replace(/[<>&"]/g,function(c){switch(c){case"<":return"<";case">":return">";case"&":return"&";case'"':return"""}return c})},getContent:function(){return this.str},_writeAttributesEnd:function(b){if(!this.inAttr){return}this.inAttr=false;if(b&&this.elementCount==this.count){this.writeRaw(" />");return false}this.writeRaw(">");return true}})})(tinymce);(function(e){var g=e.extend,f=e.each,b=e.util.Dispatcher,d=e.isIE,a=e.isGecko;function c(h){return h.replace(/([?+*])/g,".$1")}e.create("tinymce.dom.Serializer",{Serializer:function(j){var i=this;i.key=0;i.onPreProcess=new b(i);i.onPostProcess=new b(i);try{i.writer=new e.dom.XMLWriter()}catch(h){i.writer=new e.dom.StringWriter()}i.settings=j=g({dom:e.DOM,valid_nodes:0,node_filter:0,attr_filter:0,invalid_attrs:/^(mce_|_moz_|sizset|sizcache)/,closed:/^(br|hr|input|meta|img|link|param|area)$/,entity_encoding:"named",entities:"160,nbsp,161,iexcl,162,cent,163,pound,164,curren,165,yen,166,brvbar,167,sect,168,uml,169,copy,170,ordf,171,laquo,172,not,173,shy,174,reg,175,macr,176,deg,177,plusmn,178,sup2,179,sup3,180,acute,181,micro,182,para,183,middot,184,cedil,185,sup1,186,ordm,187,raquo,188,frac14,189,frac12,190,frac34,191,iquest,192,Agrave,193,Aacute,194,Acirc,195,Atilde,196,Auml,197,Aring,198,AElig,199,Ccedil,200,Egrave,201,Eacute,202,Ecirc,203,Euml,204,Igrave,205,Iacute,206,Icirc,207,Iuml,208,ETH,209,Ntilde,210,Ograve,211,Oacute,212,Ocirc,213,Otilde,214,Ouml,215,times,216,Oslash,217,Ugrave,218,Uacute,219,Ucirc,220,Uuml,221,Yacute,222,THORN,223,szlig,224,agrave,225,aacute,226,acirc,227,atilde,228,auml,229,aring,230,aelig,231,ccedil,232,egrave,233,eacute,234,ecirc,235,euml,236,igrave,237,iacute,238,icirc,239,iuml,240,eth,241,ntilde,242,ograve,243,oacute,244,ocirc,245,otilde,246,ouml,247,divide,248,oslash,249,ugrave,250,uacute,251,ucirc,252,uuml,253,yacute,254,thorn,255,yuml,402,fnof,913,Alpha,914,Beta,915,Gamma,916,Delta,917,Epsilon,918,Zeta,919,Eta,920,Theta,921,Iota,922,Kappa,923,Lambda,924,Mu,925,Nu,926,Xi,927,Omicron,928,Pi,929,Rho,931,Sigma,932,Tau,933,Upsilon,934,Phi,935,Chi,936,Psi,937,Omega,945,alpha,946,beta,947,gamma,948,delta,949,epsilon,950,zeta,951,eta,952,theta,953,iota,954,kappa,955,lambda,956,mu,957,nu,958,xi,959,omicron,960,pi,961,rho,962,sigmaf,963,sigma,964,tau,965,upsilon,966,phi,967,chi,968,psi,969,omega,977,thetasym,978,upsih,982,piv,8226,bull,8230,hellip,8242,prime,8243,Prime,8254,oline,8260,frasl,8472,weierp,8465,image,8476,real,8482,trade,8501,alefsym,8592,larr,8593,uarr,8594,rarr,8595,darr,8596,harr,8629,crarr,8656,lArr,8657,uArr,8658,rArr,8659,dArr,8660,hArr,8704,forall,8706,part,8707,exist,8709,empty,8711,nabla,8712,isin,8713,notin,8715,ni,8719,prod,8721,sum,8722,minus,8727,lowast,8730,radic,8733,prop,8734,infin,8736,ang,8743,and,8744,or,8745,cap,8746,cup,8747,int,8756,there4,8764,sim,8773,cong,8776,asymp,8800,ne,8801,equiv,8804,le,8805,ge,8834,sub,8835,sup,8836,nsub,8838,sube,8839,supe,8853,oplus,8855,otimes,8869,perp,8901,sdot,8968,lceil,8969,rceil,8970,lfloor,8971,rfloor,9001,lang,9002,rang,9674,loz,9824,spades,9827,clubs,9829,hearts,9830,diams,338,OElig,339,oelig,352,Scaron,353,scaron,376,Yuml,710,circ,732,tilde,8194,ensp,8195,emsp,8201,thinsp,8204,zwnj,8205,zwj,8206,lrm,8207,rlm,8211,ndash,8212,mdash,8216,lsquo,8217,rsquo,8218,sbquo,8220,ldquo,8221,rdquo,8222,bdquo,8224,dagger,8225,Dagger,8240,permil,8249,lsaquo,8250,rsaquo,8364,euro",valid_elements:"*[*]",extended_valid_elements:0,valid_child_elements:0,invalid_elements:0,fix_table_elements:1,fix_list_elements:true,fix_content_duplication:true,convert_fonts_to_spans:false,font_size_classes:0,font_size_style_values:0,apply_source_formatting:0,indent_mode:"simple",indent_char:"\t",indent_levels:1,remove_linebreaks:1,remove_redundant_brs:1,element_format:"xhtml"},j);i.dom=j.dom;if(j.remove_redundant_brs){i.onPostProcess.add(function(k,l){l.content=l.content.replace(/(
        \s*)+<\/(p|h[1-6]|div|li)>/gi,function(n,m,o){if(/^
        \s*<\//.test(n)){return""}return n})})}if(j.element_format=="html"){i.onPostProcess.add(function(k,l){l.content=l.content.replace(/<([^>]+) \/>/g,"<$1>")})}if(j.fix_list_elements){i.onPreProcess.add(function(v,s){var l,y,w=["ol","ul"],u,t,q,k=/^(OL|UL)$/,z;function m(r,x){var o=x.split(","),p;while((r=r.previousSibling)!=null){for(p=0;p=1767){f(i.dom.select("p table",l.node).reverse(),function(p){var o=i.dom.getParent(p.parentNode,"table,p");if(o.nodeName!="TABLE"){try{i.dom.split(o,p)}catch(m){}}})}})}},setEntities:function(p){var n=this,j,m,h={},o="",k;if(n.entityLookup){return}j=p.split(",");for(m=0;m1){f(q[1].split("|"),function(u){var p={},t;k=k||[];u=u.replace(/::/g,"~");u=/^([!\-])?([\w*.?~_\-]+|)([=:<])?(.+)?$/.exec(u);u[2]=u[2].replace(/~/g,":");if(u[1]=="!"){r=r||[];r.push(u[2])}if(u[1]=="-"){for(t=0;t=1767)){p=j.createHTMLDocument("");f(r.nodeName=="BODY"?r.childNodes:[r],function(h){p.body.appendChild(p.importNode(h,true))});if(r.nodeName!="BODY"){r=p.body.firstChild}else{r=p.body}i=k.dom.doc;k.dom.doc=p}k.key=""+(parseInt(k.key)+1);if(!q.no_events){q.node=r;k.onPreProcess.dispatch(k,q)}k.writer.reset();k._serializeNode(r,q.getInner);q.content=k.writer.getContent();if(i){k.dom.doc=i}if(!q.no_events){k.onPostProcess.dispatch(k,q)}k._postProcess(q);q.node=null;return e.trim(q.content)},_postProcess:function(n){var i=this,k=i.settings,j=n.content,m=[],l;if(n.format=="html"){l=i._protect({content:j,patterns:[{pattern:/(]*>)(.*?)(<\/script>)/g},{pattern:/(]*>)(.*?)(<\/noscript>)/g},{pattern:/(]*>)(.*?)(<\/style>)/g},{pattern:/(]*>)(.*?)(<\/pre>)/g,encode:1},{pattern:/()/g}]});j=l.content;if(k.entity_encoding!=="raw"){j=i._encode(j)}if(!n.set){j=j.replace(/

        \s+<\/p>|]+)>\s+<\/p>/g,k.entity_encoding=="numeric"?" 

        ":" 

        ");if(k.remove_linebreaks){j=j.replace(/\r?\n|\r/g," ");j=j.replace(/(<[^>]+>)\s+/g,"$1 ");j=j.replace(/\s+(<\/[^>]+>)/g," $1");j=j.replace(/<(p|h[1-6]|blockquote|hr|div|table|tbody|tr|td|body|head|html|title|meta|style|pre|script|link|object) ([^>]+)>\s+/g,"<$1 $2>");j=j.replace(/<(p|h[1-6]|blockquote|hr|div|table|tbody|tr|td|body|head|html|title|meta|style|pre|script|link|object)>\s+/g,"<$1>");j=j.replace(/\s+<\/(p|h[1-6]|blockquote|hr|div|table|tbody|tr|td|body|head|html|title|meta|style|pre|script|link|object)>/g,"")}if(k.apply_source_formatting&&k.indent_mode=="simple"){j=j.replace(/<(\/?)(ul|hr|table|meta|link|tbody|tr|object|body|head|html|map)(|[^>]+)>\s*/g,"\n<$1$2$3>\n");j=j.replace(/\s*<(p|h[1-6]|blockquote|div|title|style|pre|script|td|li|area)(|[^>]+)>/g,"\n<$1$2>");j=j.replace(/<\/(p|h[1-6]|blockquote|div|title|style|pre|script|td|li)>\s*/g,"\n");j=j.replace(/\n\n/g,"\n")}}j=i._unprotect(j,l);j=j.replace(//g,"");if(k.entity_encoding=="raw"){j=j.replace(/

         <\/p>|]+)> <\/p>/g,"\u00a0

        ")}j=j.replace(/]+|)>([\s\S]*?)<\/noscript>/g,function(h,p,o){return""+i.dom.decode(o.replace(//g,""))+""})}n.content=j},_serializeNode:function(D,o){var z=this,A=z.settings,x=z.writer,q,j,u,F,E,G,B,h,y,k,r,C,p,m;if(!A.node_filter||A.node_filter(D)){switch(D.nodeType){case 1:if(D.hasAttribute?D.hasAttribute("mce_bogus"):D.getAttribute("mce_bogus")){return}p=false;q=D.hasChildNodes();k=D.getAttribute("mce_name")||D.nodeName.toLowerCase();if(d){if(D.scopeName!=="HTML"&&D.scopeName!=="html"){k=D.scopeName+":"+k}}if(k.indexOf("mce:")===0){k=k.substring(4)}if(!z.validElementsRE||!z.validElementsRE.test(k)||(z.invalidElementsRE&&z.invalidElementsRE.test(k))||o){p=true;break}if(d){if(A.fix_content_duplication){if(D.mce_serialized==z.key){return}D.mce_serialized=z.key}if(k.charAt(0)=="/"){k=k.substring(1)}}else{if(a){if(D.nodeName==="BR"&&D.getAttribute("type")=="_moz"){return}}}if(z.childRules){if(z.parentElementsRE.test(z.elementName)){if(!z.childRules[z.elementName].test(k)){p=true;break}}z.elementName=k}r=z.findRule(k);k=r.name||k;m=A.closed.test(k);if((!q&&r.noEmpty)||(d&&!k)){p=true;break}if(r.requiredAttribs){G=r.requiredAttribs;for(F=G.length-1;F>=0;F--){if(this.dom.getAttrib(D,G[F])!==""){break}}if(F==-1){p=true;break}}x.writeStartElement(k);if(r.attribs){for(F=0,B=r.attribs,E=B.length;F-1;F--){h=B[F];if(h.specified){G=h.nodeName.toLowerCase();if(A.invalid_attrs.test(G)||!r.validAttribsRE.test(G)){continue}C=z.findAttribRule(r,G);y=z._getAttrib(D,C,G);if(y!==null){x.writeAttribute(G,y)}}}}if(k==="script"&&e.trim(D.innerHTML)){x.writeText("// ");x.writeCDATA(D.innerHTML.replace(/|<\[CDATA\[|\]\]>/g,""));q=false;break}if(r.padd){if(q&&(u=D.firstChild)&&u.nodeType===1&&D.childNodes.length===1){if(u.hasAttribute?u.hasAttribute("mce_bogus"):u.getAttribute("mce_bogus")){x.writeText("\u00a0")}}else{if(!q){x.writeText("\u00a0")}}}break;case 3:if(z.childRules&&z.parentElementsRE.test(z.elementName)){if(!z.childRules[z.elementName].test(D.nodeName)){return}}return x.writeText(D.nodeValue);case 4:return x.writeCDATA(D.nodeValue);case 8:return x.writeComment(D.nodeValue)}}else{if(D.nodeType==1){q=D.hasChildNodes()}}if(q&&!m){u=D.firstChild;while(u){z._serializeNode(u);z.elementName=k;u=u.nextSibling}}if(!p){if(!m){x.writeFullEndElement()}else{x.writeEndElement()}}},_protect:function(j){var i=this;j.items=j.items||[];function h(l){return l.replace(/[\r\n\\]/g,function(m){if(m==="\n"){return"\\n"}else{if(m==="\\"){return"\\\\"}}return"\\r"})}function k(l){return l.replace(/\\[\\rn]/g,function(m){if(m==="\\n"){return"\n"}else{if(m==="\\\\"){return"\\"}}return"\r"})}f(j.patterns,function(l){j.content=k(h(j.content).replace(l.pattern,function(n,o,m,p){m=k(m);if(l.encode){m=i._encode(m)}j.items.push(m);return o+""+p}))});return j},_unprotect:function(i,j){i=i.replace(/\"))}if(a&&j.ListBox){if(a.Button||a.SplitButton){e+=b.createHTML("td",{"class":"mceToolbarEnd"},b.createHTML("span",null,""))}}if(b.stdMode){e+='
        "}else{e+=""}if(f&&j.ListBox){if(f.Button||f.SplitButton){e+=b.createHTML("td",{"class":"mceToolbarStart"},b.createHTML("span",null,""))}}}g="mceToolbarEnd";if(j.Button){g+=" mceToolbarEndButton"}else{if(j.SplitButton){g+=" mceToolbarEndSplitButton"}else{if(j.ListBox){g+=" mceToolbarEndListBox"}}}e+=b.createHTML("td",{"class":g},b.createHTML("span",null,""));return b.createHTML("table",{id:l.id,"class":"mceToolbar"+(m["class"]?" "+m["class"]:""),cellpadding:"0",cellspacing:"0",align:l.settings.align||""},""+e+"")}});(function(b){var a=b.util.Dispatcher,c=b.each;b.create("tinymce.AddOnManager",{items:[],urls:{},lookup:{},onAdd:new a(this),get:function(d){return this.lookup[d]},requireLangPack:function(f){var d,e=b.EditorManager.settings;if(e&&e.language){d=this.urls[f]+"/langs/"+e.language+".js";if(!b.dom.Event.domLoaded&&!e.strict_mode){b.ScriptLoader.load(d)}else{b.ScriptLoader.add(d)}}},add:function(e,d){this.items.push(d);this.lookup[e]=d;this.onAdd.dispatch(this,e,d);return d},load:function(h,e,d,g){var f=this;if(f.urls[h]){return}if(e.indexOf("/")!=0&&e.indexOf("://")==-1){e=b.baseURL+"/"+e}f.urls[h]=e.substring(0,e.lastIndexOf("/"));b.ScriptLoader.add(e,d,g)}});b.PluginManager=new b.AddOnManager();b.ThemeManager=new b.AddOnManager()}(tinymce));(function(f){var g=f.each,h=f.extend,e=f.DOM,a=f.dom.Event,c=f.ThemeManager,b=f.PluginManager,d=f.explode;f.create("static tinymce.EditorManager",{editors:{},i18n:{},activeEditor:null,preInit:function(){var i=this,j=window.location;f.documentBaseURL=j.href.replace(/[\?#].*$/,"").replace(/[\/\\][^\/]+$/,"");if(!/[\/\\]$/.test(f.documentBaseURL)){f.documentBaseURL+="/"}f.baseURL=new f.util.URI(f.documentBaseURL).toAbsolute(f.baseURL);f.EditorManager.baseURI=new f.util.URI(f.baseURL);i.onBeforeUnload=new f.util.Dispatcher(i);a.add(window,"beforeunload",function(k){i.onBeforeUnload.dispatch(i,k)})},init:function(q){var p=this,l,k=f.ScriptLoader,o,n,i=[],m;function j(u,v,r){var t=u[v];if(!t){return}if(f.is(t,"string")){r=t.replace(/\.\w+$/,"");r=r?f.resolve(r):0;t=f.resolve(t)}return t.apply(r||this,Array.prototype.slice.call(arguments,2))}q=h({theme:"simple",language:"en",strict_loading_mode:document.contentType=="application/xhtml+xml"},q);p.settings=q;if(!a.domLoaded&&!q.strict_loading_mode){if(q.language){k.add(f.baseURL+"/langs/"+q.language+".js")}if(q.theme&&q.theme.charAt(0)!="-"&&!c.urls[q.theme]){c.load(q.theme,"themes/"+q.theme+"/editor_template"+f.suffix+".js")}if(q.plugins){l=d(q.plugins);g(l,function(r){if(r&&r.charAt(0)!="-"&&!b.urls[r]){if(!f.isWebKit&&r=="safari"){return}b.load(r,"plugins/"+r+"/editor_plugin"+f.suffix+".js")}})}k.loadQueue()}a.add(document,"init",function(){var r,t;j(q,"onpageload");if(q.browsers){r=false;g(d(q.browsers),function(u){switch(u){case"ie":case"msie":if(f.isIE){r=true}break;case"gecko":if(f.isGecko){r=true}break;case"safari":case"webkit":if(f.isWebKit){r=true}break;case"opera":if(f.isOpera){r=true}break}});if(!r){return}}switch(q.mode){case"exact":r=q.elements||"";if(r.length>0){g(d(r),function(u){if(e.get(u)){m=new f.Editor(u,q);i.push(m);m.render(1)}else{o=0;g(document.forms,function(v){g(v.elements,function(w){if(w.name===u){u="mce_editor_"+o;e.setAttrib(w,"id",u);m=new f.Editor(u,q);i.push(m);m.render(1)}})})}})}break;case"textareas":case"specific_textareas":function s(v,u){return u.constructor===RegExp?u.test(v.className):e.hasClass(v,u)}g(e.select("textarea"),function(u){if(q.editor_deselector&&s(u,q.editor_deselector)){return}if(!q.editor_selector||s(u,q.editor_selector)){n=e.get(u.name);if(!u.id&&!n){u.id=u.name}if(!u.id||p.get(u.id)){u.id=e.uniqueId()}m=new f.Editor(u.id,q);i.push(m);m.render(1)}});break}if(q.oninit){r=t=0;g(i,function(u){t++;if(!u.initialized){u.onInit.add(function(){r++;if(r==t){j(q,"oninit")}})}else{r++}if(r==t){j(q,"oninit")}})}})},get:function(i){return this.editors[i]},getInstanceById:function(i){return this.get(i)},add:function(i){this.editors[i.id]=i;this._setActive(i);return i},remove:function(j){var i=this;if(!i.editors[j.id]){return null}delete i.editors[j.id];if(i.activeEditor==j){i._setActive(null);g(i.editors,function(k){i._setActive(k);return false})}j.destroy();return j},execCommand:function(o,m,l){var n=this,k=n.get(l),i;switch(o){case"mceFocus":k.focus();return true;case"mceAddEditor":case"mceAddControl":if(!n.get(l)){new f.Editor(l,n.settings).render()}return true;case"mceAddFrameControl":i=l.window;i.tinyMCE=tinyMCE;i.tinymce=f;f.DOM.doc=i.document;f.DOM.win=i;k=new f.Editor(l.element_id,l);k.render();if(f.isIE){function j(){k.destroy();i.detachEvent("onunload",j);i=i.tinyMCE=i.tinymce=null}i.attachEvent("onunload",j)}l.page_window=null;return true;case"mceRemoveEditor":case"mceRemoveControl":if(k){k.remove()}return true;case"mceToggleEditor":if(!k){n.execCommand("mceAddControl",0,l);return true}if(k.isHidden()){k.show()}else{k.hide()}return true}if(n.activeEditor){return n.activeEditor.execCommand(o,m,l)}return false},execInstanceCommand:function(m,l,k,j){var i=this.get(m);if(i){return i.execCommand(l,k,j)}return false},triggerSave:function(){g(this.editors,function(i){i.save()})},addI18n:function(k,l){var i,j=this.i18n;if(!f.is(k,"string")){g(k,function(n,m){g(n,function(q,p){g(q,function(s,r){if(p==="common"){j[m+"."+r]=s}else{j[m+"."+p+"."+r]=s}})})})}else{g(l,function(n,m){j[k+"."+m]=n})}},_setActive:function(i){this.selectedInstance=this.activeEditor=i}});f.EditorManager.preInit()})(tinymce);var tinyMCE=window.tinyMCE=tinymce.EditorManager;(function(n){var o=n.DOM,k=n.dom.Event,f=n.extend,l=n.util.Dispatcher;var j=n.each,a=n.isGecko,b=n.isIE,e=n.isWebKit;var d=n.is,h=n.ThemeManager,c=n.PluginManager,i=n.EditorManager;var p=n.inArray,m=n.grep,g=n.explode;n.create("tinymce.Editor",{Editor:function(u,r){var q=this;q.id=q.editorId=u;q.execCommands={};q.queryStateCommands={};q.queryValueCommands={};q.isNotDirty=false;q.plugins={};j(["onPreInit","onBeforeRenderUI","onPostRender","onInit","onRemove","onActivate","onDeactivate","onClick","onEvent","onMouseUp","onMouseDown","onDblClick","onKeyDown","onKeyUp","onKeyPress","onContextMenu","onSubmit","onReset","onPaste","onPreProcess","onPostProcess","onBeforeSetContent","onBeforeGetContent","onSetContent","onGetContent","onLoadContent","onSaveContent","onNodeChange","onChange","onBeforeExecCommand","onExecCommand","onUndo","onRedo","onVisualAid","onSetProgressState"],function(s){q[s]=new l(q)});q.settings=r=f({id:u,language:"en",docs_language:"en",theme:"simple",skin:"default",delta_width:0,delta_height:0,popup_css:"",plugins:"",document_base_url:n.documentBaseURL,add_form_submit_trigger:1,submit_patch:1,add_unload_trigger:1,convert_urls:1,relative_urls:1,remove_script_host:1,table_inline_editing:0,object_resizing:1,cleanup:1,accessibility_focus:1,custom_shortcuts:1,custom_undo_redo_keyboard_shortcuts:1,custom_undo_redo_restore_selection:1,custom_undo_redo:1,doctype:'',visual_table_class:"mceItemTable",visual:1,inline_styles:true,convert_fonts_to_spans:true,font_size_style_values:"xx-small,x-small,small,medium,large,x-large,xx-large",apply_source_formatting:1,directionality:"ltr",forced_root_block:"p",valid_elements:"@[id|class|style|title|dir';if(G.document_base_url!=n.documentBaseURL){F.iframeHTML+=''}F.iframeHTML+='';if(n.relaxedDomain){F.iframeHTML+=' + +

        + + + +update($wpdb->users, array('user_activation_key' => $key), array('user_login' => $user_login)); } - $message = __('Someone has asked to reset the password for the following site and username.') . "\r\n\r\n"; + $message = __('Someone requested that the password be reset for the following account:') . "\r\n\r\n"; $message .= network_site_url() . "\r\n\r\n"; $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n"; - $message .= __('To reset your password visit the following address, otherwise just ignore this email and nothing will happen.') . "\r\n\r\n"; - $message .= network_site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user_login), 'login') . "\r\n"; + $message .= __('If this was a mistake, just ignore this email and nothing will happen.') . "\r\n\r\n"; + $message .= __('To reset your password, visit the following address:') . "\r\n\r\n"; + $message .= '<' . network_site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user_login), 'login') . ">\r\n"; if ( is_multisite() ) $blogname = $GLOBALS['current_site']->site_name; @@ -211,14 +238,16 @@ function retrieve_password() { } /** - * Handles resetting the user's password. + * Retrieves a user row based on password reset key and login * * @uses $wpdb WordPress Database object * * @param string $key Hash to validate sending user's password - * @return bool|WP_Error + * @param string $login The user login + * + * @return object|WP_Error */ -function reset_password($key, $login) { +function check_password_reset_key($key, $login) { global $wpdb; $key = preg_replace('/[^a-z0-9]/i', '', $key); @@ -230,38 +259,26 @@ function reset_password($key, $login) { return new WP_Error('invalid_key', __('Invalid key')); $user = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->users WHERE user_activation_key = %s AND user_login = %s", $key, $login)); + if ( empty( $user ) ) return new WP_Error('invalid_key', __('Invalid key')); - // Generate something random for a password... - $new_pass = wp_generate_password(); + return $user; +} +/** + * Handles resetting the user's password. + * + * @uses $wpdb WordPress Database object + * + * @param string $key Hash to validate sending user's password + */ +function reset_password($user, $new_pass) { do_action('password_reset', $user, $new_pass); wp_set_password($new_pass, $user->ID); - update_user_option($user->ID, 'default_password_nag', true, true); //Set up the Password change nag. - $message = sprintf(__('Username: %s'), $user->user_login) . "\r\n"; - $message .= sprintf(__('Password: %s'), $new_pass) . "\r\n"; - $message .= site_url('wp-login.php', 'login') . "\r\n"; - - if ( is_multisite() ) - $blogname = $GLOBALS['current_site']->site_name; - else - // The blogname option is escaped with esc_html on the way into the database in sanitize_option - // we want to reverse this for the plain text arena of emails. - $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); - - $title = sprintf( __('[%s] Your new password'), $blogname ); - - $title = apply_filters('password_reset_title', $title); - $message = apply_filters('password_reset_message', $message, $new_pass); - - if ( $message && !wp_mail($user->user_email, $title, $message) ) - wp_die( __('The e-mail could not be sent.') . "
        \n" . __('Possible reason: your host may have disabled the mail() function...') ); wp_password_change_notification($user); - - return true; } /** @@ -304,7 +321,7 @@ function register_new_user( $user_login, $user_email ) { if ( $errors->get_error_code() ) return $errors; - $user_pass = wp_generate_password(); + $user_pass = wp_generate_password( 12, false); $user_id = wp_create_user( $sanitized_user_login, $user_pass, $user_email ); if ( ! $user_id ) { $errors->add( 'registerfail', sprintf( __( 'ERROR: Couldn’t register you... please contact the webmaster !' ), get_option( 'admin_email' ) ) ); @@ -368,6 +385,7 @@ break; case 'lostpassword' : case 'retrievepassword' : + if ( $http_post ) { $errors = retrieve_password(); if ( !is_wp_error($errors) ) { @@ -381,7 +399,7 @@ case 'retrievepassword' : $redirect_to = apply_filters( 'lostpassword_redirect', !empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '' ); do_action('lost_password'); - login_header(__('Lost Password'), '

        ' . __('Please enter your username or e-mail address. You will receive a new password via e-mail.') . '

        ', $errors); + login_header(__('Lost Password'), '

        ' . __('Please enter your username or email address. You will receive a link to create a new password via email.') . '

        ', $errors); $user_login = isset($_POST['user_login']) ? stripslashes($_POST['user_login']) : ''; @@ -398,58 +416,87 @@ case 'retrievepassword' : - - -

        - - - - ' . __('Your password has been reset.') . ' ' . __('Log in') . '

        '); + login_footer(); + exit; + } + wp_enqueue_script('utils'); + wp_enqueue_script('user-profile'); + + login_header(__('Reset Password'), '

        ' . __('Enter your new password below.') . '

        ', $errors ); + +?> +
        + + +

        + +

        +

        + +

        + +
        +

        + +
        +

        + + + + +" title="">

        - - -

        - - - - has_cap('edit_posts') && ( empty( $redirect_to ) || $redirect_to == 'wp-admin/' || $redirect_to == admin_url() ) ) - $redirect_to = admin_url('profile.php'); + + if ( ( empty( $redirect_to ) || $redirect_to == 'wp-admin/' || $redirect_to == admin_url() ) ) { + // If the user doesn't belong to a blog, send them to user admin. If the user can't edit posts, send them to their profile. + if ( is_multisite() && !get_active_blog_for_user($user->id) ) + $redirect_to = user_admin_url(); + elseif ( is_multisite() && !$user->has_cap('read') ) + $redirect_to = get_dashboard_url( $user->id ); + elseif ( !$user->has_cap('edit_posts') ) + $redirect_to = admin_url('profile.php'); + } wp_safe_redirect($redirect_to); exit(); } @@ -619,7 +664,7 @@ default:

        -

        +

        @@ -629,11 +674,17 @@ function wp_attempt_focus(){ setTimeout( function(){ try{ d = document.getElementById('user_pass'); +d.value = ''; d = document.getElementById('user_login'); - +get_error_code() ) { ?> +if( d.value != '' ) d.value = ''; + d.focus(); +d.select(); } catch(e){} }, 200); } @@ -643,6 +694,7 @@ wp_attempt_focus(); if(typeof wpOnload=='function')wpOnload(); + \ No newline at end of file +exit; +?> diff --git a/wp-rdf.php b/wp-rdf.php index 3c8f005f..cc94ad06 100644 --- a/wp-rdf.php +++ b/wp-rdf.php @@ -8,5 +8,5 @@ require( './wp-load.php' ); wp_redirect( get_bloginfo( 'rdf_url' ), 301 ); - -?> \ No newline at end of file +exit; +?> diff --git a/wp-register.php b/wp-register.php index caad4f2b..0b1a7697 100644 --- a/wp-register.php +++ b/wp-register.php @@ -10,6 +10,6 @@ */ require('./wp-load.php'); -wp_redirect('wp-login.php?action=register'); - -?> \ No newline at end of file +wp_redirect( site_url('wp-login.php?action=register') ); +exit; +?> diff --git a/wp-rss.php b/wp-rss.php index 0ae63a23..af2427ad 100644 --- a/wp-rss.php +++ b/wp-rss.php @@ -8,5 +8,5 @@ require( './wp-load.php' ); wp_redirect( get_bloginfo( 'rss_url' ), 301 ); - -?> \ No newline at end of file +exit; +?> diff --git a/wp-rss2.php b/wp-rss2.php index 78daa6d2..de75c239 100644 --- a/wp-rss2.php +++ b/wp-rss2.php @@ -8,5 +8,5 @@ require( './wp-load.php' ); wp_redirect( get_bloginfo( 'rss2_url' ), 301 ); - -?> \ No newline at end of file +exit; +?> diff --git a/wp-settings.php b/wp-settings.php index 473f2c6c..2cd12c1c 100644 --- a/wp-settings.php +++ b/wp-settings.php @@ -35,7 +35,7 @@ if ( function_exists( 'date_default_timezone_set' ) ) wp_unregister_GLOBALS(); // Ensure these global variables do not exist so they do not interfere with WordPress. -unset( $wp_filter, $cache_lastcommentmodified, $cache_lastpostdate ); +unset( $wp_filter, $cache_lastcommentmodified ); // Standardize $_SERVER variables across setups. wp_fix_server_vars(); @@ -65,9 +65,11 @@ wp_set_lang_dir(); // Load early WordPress files. require( ABSPATH . WPINC . '/compat.php' ); require( ABSPATH . WPINC . '/functions.php' ); -require( ABSPATH . WPINC . '/classes.php' ); +require( ABSPATH . WPINC . '/class-wp.php' ); +require( ABSPATH . WPINC . '/class-wp-error.php' ); +require( ABSPATH . WPINC . '/plugin.php' ); -// Include the wpdb class, or a db.php database drop-in if present. +// Include the wpdb class and, if present, a db.php database drop-in. require_wp_db(); // Set the database table prefix and the format specifiers for database table columns. @@ -77,7 +79,6 @@ wp_set_wpdb_vars(); wp_start_object_cache(); // Load early WordPress files. -require( ABSPATH . WPINC . '/plugin.php' ); require( ABSPATH . WPINC . '/default-filters.php' ); require( ABSPATH . WPINC . '/pomo/mo.php' ); @@ -100,6 +101,8 @@ require( ABSPATH . WPINC . '/l10n.php' ); wp_not_installed(); // Load most of WordPress. +require( ABSPATH . WPINC . '/class-wp-walker.php' ); +require( ABSPATH . WPINC . '/class-wp-ajax-response.php' ); require( ABSPATH . WPINC . '/formatting.php' ); require( ABSPATH . WPINC . '/capabilities.php' ); require( ABSPATH . WPINC . '/query.php' ); @@ -133,6 +136,7 @@ require( ABSPATH . WPINC . '/class-http.php' ); require( ABSPATH . WPINC . '/widgets.php' ); require( ABSPATH . WPINC . '/nav-menu.php' ); require( ABSPATH . WPINC . '/nav-menu-template.php' ); +require( ABSPATH . WPINC . '/admin-bar.php' ); // Load multisite-specific files. if ( is_multisite() ) { @@ -151,6 +155,14 @@ foreach ( wp_get_mu_plugins() as $mu_plugin ) { } unset( $mu_plugin ); +// Load network activated plugins. +if ( is_multisite() ) { + foreach( wp_get_active_network_plugins() as $network_plugin ) { + include_once( $network_plugin ); + } + unset( $network_plugin ); +} + do_action( 'muplugins_loaded' ); if ( is_multisite() ) @@ -170,6 +182,9 @@ require( ABSPATH . WPINC . '/vars.php' ); create_initial_taxonomies(); create_initial_post_types(); +// Register the default theme directory root +register_theme_directory( get_theme_root() ); + // Load active plugins. foreach ( wp_get_active_and_valid_plugins() as $plugin ) include_once( $plugin ); diff --git a/wp-signup.php b/wp-signup.php index 28b561a9..c2ab566b 100644 --- a/wp-signup.php +++ b/wp-signup.php @@ -6,7 +6,6 @@ require( dirname(__FILE__) . '/wp-load.php' ); add_action( 'wp_head', 'signuppageheaders' ) ; require( './wp-blog-header.php' ); -require_once( ABSPATH . WPINC . '/registration.php' ); if ( is_array( get_site_option( 'illegal_names' )) && isset( $_GET[ 'new' ] ) && in_array( $_GET[ 'new' ], get_site_option( 'illegal_names' ) ) == true ) { wp_redirect( network_home_url() ); @@ -23,7 +22,7 @@ function signuppageheaders() { } if ( !is_multisite() ) { - wp_redirect( get_option( 'siteurl' ) . "/wp-login.php?action=register" ); + wp_redirect( site_url('wp-login.php?action=register') ); die(); } @@ -81,12 +80,11 @@ function show_blog_form($blogname = '', $blog_title = '', $errors = '') { echo '.' . ( $site_domain = preg_replace( '|^www\.|', '', $current_site->domain ) ) . '
        '; if ( !is_user_logged_in() ) { - print '(' . __( 'Your address will be ' ); if ( !is_subdomain_install() ) - print $current_site->domain . $current_site->path . __( 'sitename' ); + $site = $current_site->domain . $current_site->path . __( 'sitename' ); else - print __( 'domain.' ) . $site_domain . $current_site->path; - echo '.) ' . __( 'Must be at least 4 characters, letters and numbers only. It cannot be changed, so choose carefully!' ) . '

        '; + $site = __( 'domain' ) . '.' . $site_domain . $current_site->path; + echo '

        (' . sprintf( __('Your address will be %s.'), $site ) . ') ' . __( 'Must be at least 4 characters, letters and numbers only. It cannot be changed, so choose carefully!' ) . '

        '; } // Blog Title @@ -393,7 +391,7 @@ $i18n_signup['blog'] = _x('blog', 'Multisite active signup type'); $i18n_signup['user'] = _x('user', 'Multisite active signup type'); if ( is_super_admin() ) - echo '
        ' . sprintf( __( 'Greetings Site Administrator! You are currently allowing “%s” registrations. To change or disable registration go to your Options page.' ), $i18n_signup[$active_signup], esc_url( network_admin_url( 'ms-options.php' ) ) ) . '
        '; + echo '
        ' . sprintf( __( 'Greetings Site Administrator! You are currently allowing “%s” registrations. To change or disable registration go to your Options page.' ), $i18n_signup[$active_signup], esc_url( network_admin_url( 'settings.php' ) ) ) . '
        '; $newblogname = isset($_GET['new']) ? strtolower(preg_replace('/^-|-$|[^-a-zA-Z0-9]/', '', $_GET['new'])) : null; diff --git a/xmlrpc.php b/xmlrpc.php index 5ec072b0..85171776 100644 --- a/xmlrpc.php +++ b/xmlrpc.php @@ -2,7 +2,6 @@ /** * XML-RPC protocol support for WordPress * - * @license GPL v2 <./license.txt> * @package WordPress */ @@ -53,6 +52,7 @@ exit; include_once(ABSPATH . 'wp-admin/includes/admin.php'); include_once(ABSPATH . WPINC . '/class-IXR.php'); +include_once(ABSPATH . WPINC . '/class-wp-xmlrpc-server.php'); // Turn off all warnings and errors. // error_reporting(0); @@ -98,3278 +98,10 @@ function logIO($io,$msg) { if ( isset($HTTP_RAW_POST_DATA) ) logIO("I", $HTTP_RAW_POST_DATA); -/** - * WordPress XMLRPC server implementation. - * - * Implements compatability for Blogger API, MetaWeblog API, MovableType, and - * pingback. Additional WordPress API for managing comments, pages, posts, - * options, etc. - * - * Since WordPress 2.6.0, WordPress XMLRPC server can be disabled in the - * administration panels. - * - * @package WordPress - * @subpackage Publishing - * @since 1.5.0 - */ -class wp_xmlrpc_server extends IXR_Server { - - /** - * Register all of the XMLRPC methods that XMLRPC server understands. - * - * PHP4 constructor and sets up server and method property. Passes XMLRPC - * methods through the 'xmlrpc_methods' filter to allow plugins to extend - * or replace XMLRPC methods. - * - * @since 1.5.0 - * - * @return wp_xmlrpc_server - */ - function wp_xmlrpc_server() { - $this->methods = array( - // WordPress API - 'wp.getUsersBlogs' => 'this:wp_getUsersBlogs', - 'wp.getPage' => 'this:wp_getPage', - 'wp.getPages' => 'this:wp_getPages', - 'wp.newPage' => 'this:wp_newPage', - 'wp.deletePage' => 'this:wp_deletePage', - 'wp.editPage' => 'this:wp_editPage', - 'wp.getPageList' => 'this:wp_getPageList', - 'wp.getAuthors' => 'this:wp_getAuthors', - 'wp.getCategories' => 'this:mw_getCategories', // Alias - 'wp.getTags' => 'this:wp_getTags', - 'wp.newCategory' => 'this:wp_newCategory', - 'wp.deleteCategory' => 'this:wp_deleteCategory', - 'wp.suggestCategories' => 'this:wp_suggestCategories', - 'wp.uploadFile' => 'this:mw_newMediaObject', // Alias - 'wp.getCommentCount' => 'this:wp_getCommentCount', - 'wp.getPostStatusList' => 'this:wp_getPostStatusList', - 'wp.getPageStatusList' => 'this:wp_getPageStatusList', - 'wp.getPageTemplates' => 'this:wp_getPageTemplates', - 'wp.getOptions' => 'this:wp_getOptions', - 'wp.setOptions' => 'this:wp_setOptions', - 'wp.getComment' => 'this:wp_getComment', - 'wp.getComments' => 'this:wp_getComments', - 'wp.deleteComment' => 'this:wp_deleteComment', - 'wp.editComment' => 'this:wp_editComment', - 'wp.newComment' => 'this:wp_newComment', - 'wp.getCommentStatusList' => 'this:wp_getCommentStatusList', - - // Blogger API - 'blogger.getUsersBlogs' => 'this:blogger_getUsersBlogs', - 'blogger.getUserInfo' => 'this:blogger_getUserInfo', - 'blogger.getPost' => 'this:blogger_getPost', - 'blogger.getRecentPosts' => 'this:blogger_getRecentPosts', - 'blogger.getTemplate' => 'this:blogger_getTemplate', - 'blogger.setTemplate' => 'this:blogger_setTemplate', - 'blogger.newPost' => 'this:blogger_newPost', - 'blogger.editPost' => 'this:blogger_editPost', - 'blogger.deletePost' => 'this:blogger_deletePost', - - // MetaWeblog API (with MT extensions to structs) - 'metaWeblog.newPost' => 'this:mw_newPost', - 'metaWeblog.editPost' => 'this:mw_editPost', - 'metaWeblog.getPost' => 'this:mw_getPost', - 'metaWeblog.getRecentPosts' => 'this:mw_getRecentPosts', - 'metaWeblog.getCategories' => 'this:mw_getCategories', - 'metaWeblog.newMediaObject' => 'this:mw_newMediaObject', - - // MetaWeblog API aliases for Blogger API - // see http://www.xmlrpc.com/stories/storyReader$2460 - 'metaWeblog.deletePost' => 'this:blogger_deletePost', - 'metaWeblog.getTemplate' => 'this:blogger_getTemplate', - 'metaWeblog.setTemplate' => 'this:blogger_setTemplate', - 'metaWeblog.getUsersBlogs' => 'this:blogger_getUsersBlogs', - - // MovableType API - 'mt.getCategoryList' => 'this:mt_getCategoryList', - 'mt.getRecentPostTitles' => 'this:mt_getRecentPostTitles', - 'mt.getPostCategories' => 'this:mt_getPostCategories', - 'mt.setPostCategories' => 'this:mt_setPostCategories', - 'mt.supportedMethods' => 'this:mt_supportedMethods', - 'mt.supportedTextFilters' => 'this:mt_supportedTextFilters', - 'mt.getTrackbackPings' => 'this:mt_getTrackbackPings', - 'mt.publishPost' => 'this:mt_publishPost', - - // PingBack - 'pingback.ping' => 'this:pingback_ping', - 'pingback.extensions.getPingbacks' => 'this:pingback_extensions_getPingbacks', - - 'demo.sayHello' => 'this:sayHello', - 'demo.addTwoNumbers' => 'this:addTwoNumbers' - ); - - $this->initialise_blog_option_info( ); - $this->methods = apply_filters('xmlrpc_methods', $this->methods); - } - - function serve_request() { - $this->IXR_Server($this->methods); - } - - /** - * Test XMLRPC API by saying, "Hello!" to client. - * - * @since 1.5.0 - * - * @param array $args Method Parameters. - * @return string - */ - function sayHello($args) { - return 'Hello!'; - } - - /** - * Test XMLRPC API by adding two numbers for client. - * - * @since 1.5.0 - * - * @param array $args Method Parameters. - * @return int - */ - function addTwoNumbers($args) { - $number1 = $args[0]; - $number2 = $args[1]; - return $number1 + $number2; - } - - /** - * Check user's credentials. - * - * @since 1.5.0 - * - * @param string $user_login User's username. - * @param string $user_pass User's password. - * @return bool Whether authentication passed. - * @deprecated use wp_xmlrpc_server::login - * @see wp_xmlrpc_server::login - */ - function login_pass_ok($user_login, $user_pass) { - if ( !get_option( 'enable_xmlrpc' ) ) { - $this->error = new IXR_Error( 405, sprintf( __( 'XML-RPC services are disabled on this site. An admin user can enable them at %s'), admin_url('options-writing.php') ) ); - return false; - } - - if (!user_pass_ok($user_login, $user_pass)) { - $this->error = new IXR_Error(403, __('Bad login/pass combination.')); - return false; - } - return true; - } - - /** - * Log user in. - * - * @since 2.8 - * - * @param string $username User's username. - * @param string $password User's password. - * @return mixed WP_User object if authentication passed, false otherwise - */ - function login($username, $password) { - if ( !get_option( 'enable_xmlrpc' ) ) { - $this->error = new IXR_Error( 405, sprintf( __( 'XML-RPC services are disabled on this site. An admin user can enable them at %s'), admin_url('options-writing.php') ) ); - return false; - } - - $user = wp_authenticate($username, $password); - - if (is_wp_error($user)) { - $this->error = new IXR_Error(403, __('Bad login/pass combination.')); - return false; - } - - wp_set_current_user( $user->ID ); - return $user; - } - - /** - * Sanitize string or array of strings for database. - * - * @since 1.5.2 - * - * @param string|array $array Sanitize single string or array of strings. - * @return string|array Type matches $array and sanitized for the database. - */ - function escape(&$array) { - global $wpdb; - - if (!is_array($array)) { - return($wpdb->escape($array)); - } else { - foreach ( (array) $array as $k => $v ) { - if ( is_array($v) ) { - $this->escape($array[$k]); - } else if ( is_object($v) ) { - //skip - } else { - $array[$k] = $wpdb->escape($v); - } - } - } - } - - /** - * Retrieve custom fields for post. - * - * @since 2.5.0 - * - * @param int $post_id Post ID. - * @return array Custom fields, if exist. - */ - function get_custom_fields($post_id) { - $post_id = (int) $post_id; - - $custom_fields = array(); - - foreach ( (array) has_meta($post_id) as $meta ) { - // Don't expose protected fields. - if ( strpos($meta['meta_key'], '_wp_') === 0 ) { - continue; - } - - $custom_fields[] = array( - "id" => $meta['meta_id'], - "key" => $meta['meta_key'], - "value" => $meta['meta_value'] - ); - } - - return $custom_fields; - } - - /** - * Set custom fields for post. - * - * @since 2.5.0 - * - * @param int $post_id Post ID. - * @param array $fields Custom fields. - */ - function set_custom_fields($post_id, $fields) { - $post_id = (int) $post_id; - - foreach ( (array) $fields as $meta ) { - if ( isset($meta['id']) ) { - $meta['id'] = (int) $meta['id']; - - if ( isset($meta['key']) ) { - update_meta($meta['id'], $meta['key'], $meta['value']); - } - else { - delete_meta($meta['id']); - } - } - else { - $_POST['metakeyinput'] = $meta['key']; - $_POST['metavalue'] = $meta['value']; - add_meta($post_id); - } - } - } - - /** - * Set up blog options property. - * - * Passes property through 'xmlrpc_blog_options' filter. - * - * @since 2.6.0 - */ - function initialise_blog_option_info( ) { - global $wp_version; - - $this->blog_options = array( - // Read only options - 'software_name' => array( - 'desc' => __( 'Software Name' ), - 'readonly' => true, - 'value' => 'WordPress' - ), - 'software_version' => array( - 'desc' => __( 'Software Version' ), - 'readonly' => true, - 'value' => $wp_version - ), - 'blog_url' => array( - 'desc' => __( 'Site URL' ), - 'readonly' => true, - 'option' => 'siteurl' - ), - - // Updatable options - 'time_zone' => array( - 'desc' => __( 'Time Zone' ), - 'readonly' => false, - 'option' => 'gmt_offset' - ), - 'blog_title' => array( - 'desc' => __( 'Site Title' ), - 'readonly' => false, - 'option' => 'blogname' - ), - 'blog_tagline' => array( - 'desc' => __( 'Site Tagline' ), - 'readonly' => false, - 'option' => 'blogdescription' - ), - 'date_format' => array( - 'desc' => __( 'Date Format' ), - 'readonly' => false, - 'option' => 'date_format' - ), - 'time_format' => array( - 'desc' => __( 'Time Format' ), - 'readonly' => false, - 'option' => 'time_format' - ), - 'users_can_register' => array( - 'desc' => __( 'Allow new users to sign up' ), - 'readonly' => false, - 'option' => 'users_can_register' - ) - ); - - $this->blog_options = apply_filters( 'xmlrpc_blog_options', $this->blog_options ); - } - - /** - * Retrieve the blogs of the user. - * - * @since 2.6.0 - * - * @param array $args Method parameters. - * @return array - */ - function wp_getUsersBlogs( $args ) { - global $current_site; - // If this isn't on WPMU then just use blogger_getUsersBlogs - if ( !is_multisite() ) { - array_unshift( $args, 1 ); - return $this->blogger_getUsersBlogs( $args ); - } - - $this->escape( $args ); - - $username = $args[0]; - $password = $args[1]; - - if ( !$user = $this->login($username, $password) ) - return $this->error; - - - do_action( 'xmlrpc_call', 'wp.getUsersBlogs' ); - - $blogs = (array) get_blogs_of_user( $user->ID ); - $struct = array( ); - - foreach ( $blogs as $blog ) { - // Don't include blogs that aren't hosted at this site - if ( $blog->site_id != $current_site->id ) - continue; - - $blog_id = $blog->userblog_id; - switch_to_blog($blog_id); - $is_admin = current_user_can('manage_options'); - - $struct[] = array( - 'isAdmin' => $is_admin, - 'url' => get_option( 'home' ) . '/', - 'blogid' => $blog_id, - 'blogName' => get_option( 'blogname' ), - 'xmlrpc' => site_url( 'xmlrpc.php' ) - ); - - restore_current_blog( ); - } - - return $struct; - } - - /** - * Retrieve page. - * - * @since 2.2.0 - * - * @param array $args Method parameters. - * @return array - */ - function wp_getPage($args) { - $this->escape($args); - - $blog_id = (int) $args[0]; - $page_id = (int) $args[1]; - $username = $args[2]; - $password = $args[3]; - - if ( !$user = $this->login($username, $password) ) { - return $this->error; - } - - if ( !current_user_can( 'edit_page', $page_id ) ) - return new IXR_Error( 401, __( 'Sorry, you cannot edit this page.' ) ); - - do_action('xmlrpc_call', 'wp.getPage'); - - // Lookup page info. - $page = get_page($page_id); - - // If we found the page then format the data. - if ( $page->ID && ($page->post_type == "page") ) { - // Get all of the page content and link. - $full_page = get_extended($page->post_content); - $link = post_permalink($page->ID); - - // Get info the page parent if there is one. - $parent_title = ""; - if ( !empty($page->post_parent) ) { - $parent = get_page($page->post_parent); - $parent_title = $parent->post_title; - } - - // Determine comment and ping settings. - $allow_comments = comments_open($page->ID) ? 1 : 0; - $allow_pings = pings_open($page->ID) ? 1 : 0; - - // Format page date. - $page_date = mysql2date("Ymd\TH:i:s", $page->post_date, false); - $page_date_gmt = mysql2date("Ymd\TH:i:s", $page->post_date_gmt, false); - - // For drafts use the GMT version of the date - if ( $page->post_status == 'draft' ) - $page_date_gmt = get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $page->post_date ), 'Ymd\TH:i:s' ); - - // Pull the categories info together. - $categories = array(); - foreach ( wp_get_post_categories($page->ID) as $cat_id ) { - $categories[] = get_cat_name($cat_id); - } - - // Get the author info. - $author = get_userdata($page->post_author); - - $page_template = get_post_meta( $page->ID, '_wp_page_template', true ); - if ( empty( $page_template ) ) - $page_template = 'default'; - - $page_struct = array( - "dateCreated" => new IXR_Date($page_date), - "userid" => $page->post_author, - "page_id" => $page->ID, - "page_status" => $page->post_status, - "description" => $full_page["main"], - "title" => $page->post_title, - "link" => $link, - "permaLink" => $link, - "categories" => $categories, - "excerpt" => $page->post_excerpt, - "text_more" => $full_page["extended"], - "mt_allow_comments" => $allow_comments, - "mt_allow_pings" => $allow_pings, - "wp_slug" => $page->post_name, - "wp_password" => $page->post_password, - "wp_author" => $author->display_name, - "wp_page_parent_id" => $page->post_parent, - "wp_page_parent_title" => $parent_title, - "wp_page_order" => $page->menu_order, - "wp_author_id" => $author->ID, - "wp_author_display_name" => $author->display_name, - "date_created_gmt" => new IXR_Date($page_date_gmt), - "custom_fields" => $this->get_custom_fields($page_id), - "wp_page_template" => $page_template - ); - - return($page_struct); - } - // If the page doesn't exist indicate that. - else { - return(new IXR_Error(404, __("Sorry, no such page."))); - } - } - - /** - * Retrieve Pages. - * - * @since 2.2.0 - * - * @param array $args Method parameters. - * @return array - */ - function wp_getPages($args) { - $this->escape($args); - - $blog_id = (int) $args[0]; - $username = $args[1]; - $password = $args[2]; - $num_pages = isset($args[3]) ? (int) $args[3] : 10; - - if ( !$user = $this->login($username, $password) ) - return $this->error; - - if ( !current_user_can( 'edit_pages' ) ) - return new IXR_Error( 401, __( 'Sorry, you cannot edit pages.' ) ); - - do_action('xmlrpc_call', 'wp.getPages'); - - $pages = get_posts( array('post_type' => 'page', 'post_status' => 'any', 'numberposts' => $num_pages) ); - $num_pages = count($pages); - - // If we have pages, put together their info. - if ( $num_pages >= 1 ) { - $pages_struct = array(); - - for ( $i = 0; $i < $num_pages; $i++ ) { - $page = wp_xmlrpc_server::wp_getPage(array( - $blog_id, $pages[$i]->ID, $username, $password - )); - $pages_struct[] = $page; - } - - return($pages_struct); - } - // If no pages were found return an error. - else { - return(array()); - } - } - - /** - * Create new page. - * - * @since 2.2.0 - * - * @param array $args Method parameters. - * @return unknown - */ - function wp_newPage($args) { - // Items not escaped here will be escaped in newPost. - $username = $this->escape($args[1]); - $password = $this->escape($args[2]); - $page = $args[3]; - $publish = $args[4]; - - if ( !$user = $this->login($username, $password) ) - return $this->error; - - do_action('xmlrpc_call', 'wp.newPage'); - - // Make sure the user is allowed to add new pages. - if ( !current_user_can("publish_pages") ) - return(new IXR_Error(401, __("Sorry, you cannot add new pages."))); - - // Mark this as content for a page. - $args[3]["post_type"] = "page"; - - // Let mw_newPost do all of the heavy lifting. - return($this->mw_newPost($args)); - } - - /** - * Delete page. - * - * @since 2.2.0 - * - * @param array $args Method parameters. - * @return bool True, if success. - */ - function wp_deletePage($args) { - $this->escape($args); - - $blog_id = (int) $args[0]; - $username = $args[1]; - $password = $args[2]; - $page_id = (int) $args[3]; - - if ( !$user = $this->login($username, $password) ) - return $this->error; - - do_action('xmlrpc_call', 'wp.deletePage'); - - // Get the current page based on the page_id and - // make sure it is a page and not a post. - $actual_page = wp_get_single_post($page_id, ARRAY_A); - if ( !$actual_page || ($actual_page["post_type"] != "page") ) - return(new IXR_Error(404, __("Sorry, no such page."))); - - // Make sure the user can delete pages. - if ( !current_user_can("delete_page", $page_id) ) - return(new IXR_Error(401, __("Sorry, you do not have the right to delete this page."))); - - // Attempt to delete the page. - $result = wp_delete_post($page_id); - if ( !$result ) - return(new IXR_Error(500, __("Failed to delete the page."))); - - return(true); - } - - /** - * Edit page. - * - * @since 2.2.0 - * - * @param array $args Method parameters. - * @return unknown - */ - function wp_editPage($args) { - // Items not escaped here will be escaped in editPost. - $blog_id = (int) $args[0]; - $page_id = (int) $this->escape($args[1]); - $username = $this->escape($args[2]); - $password = $this->escape($args[3]); - $content = $args[4]; - $publish = $args[5]; - - if ( !$user = $this->login($username, $password) ) - return $this->error; - - do_action('xmlrpc_call', 'wp.editPage'); - - // Get the page data and make sure it is a page. - $actual_page = wp_get_single_post($page_id, ARRAY_A); - if ( !$actual_page || ($actual_page["post_type"] != "page") ) - return(new IXR_Error(404, __("Sorry, no such page."))); - - // Make sure the user is allowed to edit pages. - if ( !current_user_can("edit_page", $page_id) ) - return(new IXR_Error(401, __("Sorry, you do not have the right to edit this page."))); - - // Mark this as content for a page. - $content["post_type"] = "page"; - - // Arrange args in the way mw_editPost understands. - $args = array( - $page_id, - $username, - $password, - $content, - $publish - ); - - // Let mw_editPost do all of the heavy lifting. - return($this->mw_editPost($args)); - } - - /** - * Retrieve page list. - * - * @since 2.2.0 - * - * @param array $args Method parameters. - * @return unknown - */ - function wp_getPageList($args) { - global $wpdb; - - $this->escape($args); - - $blog_id = (int) $args[0]; - $username = $args[1]; - $password = $args[2]; - - if ( !$user = $this->login($username, $password) ) - return $this->error; - - if ( !current_user_can( 'edit_pages' ) ) - return new IXR_Error( 401, __( 'Sorry, you cannot edit pages.' ) ); - - do_action('xmlrpc_call', 'wp.getPageList'); - - // Get list of pages ids and titles - $page_list = $wpdb->get_results(" - SELECT ID page_id, - post_title page_title, - post_parent page_parent_id, - post_date_gmt, - post_date, - post_status - FROM {$wpdb->posts} - WHERE post_type = 'page' - ORDER BY ID - "); - - // The date needs to be formated properly. - $num_pages = count($page_list); - for ( $i = 0; $i < $num_pages; $i++ ) { - $post_date = mysql2date("Ymd\TH:i:s", $page_list[$i]->post_date, false); - $post_date_gmt = mysql2date("Ymd\TH:i:s", $page_list[$i]->post_date_gmt, false); - - $page_list[$i]->dateCreated = new IXR_Date($post_date); - $page_list[$i]->date_created_gmt = new IXR_Date($post_date_gmt); - - // For drafts use the GMT version of the date - if ( $page_list[$i]->post_status == 'draft' ) { - $page_list[$i]->date_created_gmt = get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $page_list[$i]->post_date ), 'Ymd\TH:i:s' ); - $page_list[$i]->date_created_gmt = new IXR_Date( $page_list[$i]->date_created_gmt ); - } - - unset($page_list[$i]->post_date_gmt); - unset($page_list[$i]->post_date); - unset($page_list[$i]->post_status); - } - - return($page_list); - } - - /** - * Retrieve authors list. - * - * @since 2.2.0 - * - * @param array $args Method parameters. - * @return array - */ - function wp_getAuthors($args) { - - $this->escape($args); - - $blog_id = (int) $args[0]; - $username = $args[1]; - $password = $args[2]; - - if ( !$user = $this->login($username, $password) ) - return $this->error; - - if ( !current_user_can("edit_posts") ) - return(new IXR_Error(401, __("Sorry, you cannot edit posts on this site."))); - - do_action('xmlrpc_call', 'wp.getAuthors'); - - $authors = array(); - foreach ( (array) get_users_of_blog() as $row ) { - $authors[] = array( - "user_id" => $row->user_id, - "user_login" => $row->user_login, - "display_name" => $row->display_name - ); - } - - return($authors); - } - - /** - * Get list of all tags - * - * @since 2.7 - * - * @param array $args Method parameters. - * @return array - */ - function wp_getTags( $args ) { - $this->escape( $args ); - - $blog_id = (int) $args[0]; - $username = $args[1]; - $password = $args[2]; - - if ( !$user = $this->login($username, $password) ) - return $this->error; - - if ( !current_user_can( 'edit_posts' ) ) - return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view tags.' ) ); - - do_action( 'xmlrpc_call', 'wp.getKeywords' ); - - $tags = array( ); - - if ( $all_tags = get_tags() ) { - foreach( (array) $all_tags as $tag ) { - $struct['tag_id'] = $tag->term_id; - $struct['name'] = $tag->name; - $struct['count'] = $tag->count; - $struct['slug'] = $tag->slug; - $struct['html_url'] = esc_html( get_tag_link( $tag->term_id ) ); - $struct['rss_url'] = esc_html( get_tag_feed_link( $tag->term_id ) ); - - $tags[] = $struct; - } - } - - return $tags; - } - - /** - * Create new category. - * - * @since 2.2.0 - * - * @param array $args Method parameters. - * @return int Category ID. - */ - function wp_newCategory($args) { - $this->escape($args); - - $blog_id = (int) $args[0]; - $username = $args[1]; - $password = $args[2]; - $category = $args[3]; - - if ( !$user = $this->login($username, $password) ) - return $this->error; - - do_action('xmlrpc_call', 'wp.newCategory'); - - // Make sure the user is allowed to add a category. - if ( !current_user_can("manage_categories") ) - return(new IXR_Error(401, __("Sorry, you do not have the right to add a category."))); - - // If no slug was provided make it empty so that - // WordPress will generate one. - if ( empty($category["slug"]) ) - $category["slug"] = ""; - - // If no parent_id was provided make it empty - // so that it will be a top level page (no parent). - if ( !isset($category["parent_id"]) ) - $category["parent_id"] = ""; - - // If no description was provided make it empty. - if ( empty($category["description"]) ) - $category["description"] = ""; - - $new_category = array( - "cat_name" => $category["name"], - "category_nicename" => $category["slug"], - "category_parent" => $category["parent_id"], - "category_description" => $category["description"] - ); - - $cat_id = wp_insert_category($new_category, true); - if ( is_wp_error( $cat_id ) ) { - if ( 'term_exists' == $cat_id->get_error_code() ) - return (int) $cat_id->get_error_data(); - else - return(new IXR_Error(500, __("Sorry, the new category failed."))); - } elseif ( ! $cat_id ) { - return(new IXR_Error(500, __("Sorry, the new category failed."))); - } - - return($cat_id); - } - - /** - * Remove category. - * - * @since 2.5.0 - * - * @param array $args Method parameters. - * @return mixed See {@link wp_delete_category()} for return info. - */ - function wp_deleteCategory($args) { - $this->escape($args); - - $blog_id = (int) $args[0]; - $username = $args[1]; - $password = $args[2]; - $category_id = (int) $args[3]; - - if ( !$user = $this->login($username, $password) ) - return $this->error; - - do_action('xmlrpc_call', 'wp.deleteCategory'); - - if ( !current_user_can("manage_categories") ) - return new IXR_Error( 401, __( "Sorry, you do not have the right to delete a category." ) ); - - return wp_delete_category( $category_id ); - } - - /** - * Retrieve category list. - * - * @since 2.2.0 - * - * @param array $args Method parameters. - * @return array - */ - function wp_suggestCategories($args) { - $this->escape($args); - - $blog_id = (int) $args[0]; - $username = $args[1]; - $password = $args[2]; - $category = $args[3]; - $max_results = (int) $args[4]; - - if ( !$user = $this->login($username, $password) ) - return $this->error; - - if ( !current_user_can( 'edit_posts' ) ) - return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts to this site in order to view categories.' ) ); - - do_action('xmlrpc_call', 'wp.suggestCategories'); - - $category_suggestions = array(); - $args = array('get' => 'all', 'number' => $max_results, 'name__like' => $category); - foreach ( (array) get_categories($args) as $cat ) { - $category_suggestions[] = array( - "category_id" => $cat->cat_ID, - "category_name" => $cat->cat_name - ); - } - - return($category_suggestions); - } - - /** - * Retrieve comment. - * - * @since 2.7.0 - * - * @param array $args Method parameters. - * @return array - */ - function wp_getComment($args) { - $this->escape($args); - - $blog_id = (int) $args[0]; - $username = $args[1]; - $password = $args[2]; - $comment_id = (int) $args[3]; - - if ( !$user = $this->login($username, $password) ) - return $this->error; - - if ( !current_user_can( 'moderate_comments' ) ) - return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); - - do_action('xmlrpc_call', 'wp.getComment'); - - if ( ! $comment = get_comment($comment_id) ) - return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); - - // Format page date. - $comment_date = mysql2date("Ymd\TH:i:s", $comment->comment_date, false); - $comment_date_gmt = mysql2date("Ymd\TH:i:s", $comment->comment_date_gmt, false); - - if ( '0' == $comment->comment_approved ) - $comment_status = 'hold'; - else if ( 'spam' == $comment->comment_approved ) - $comment_status = 'spam'; - else if ( '1' == $comment->comment_approved ) - $comment_status = 'approve'; - else - $comment_status = $comment->comment_approved; - - $link = get_comment_link($comment); - - $comment_struct = array( - "date_created_gmt" => new IXR_Date($comment_date_gmt), - "user_id" => $comment->user_id, - "comment_id" => $comment->comment_ID, - "parent" => $comment->comment_parent, - "status" => $comment_status, - "content" => $comment->comment_content, - "link" => $link, - "post_id" => $comment->comment_post_ID, - "post_title" => get_the_title($comment->comment_post_ID), - "author" => $comment->comment_author, - "author_url" => $comment->comment_author_url, - "author_email" => $comment->comment_author_email, - "author_ip" => $comment->comment_author_IP, - "type" => $comment->comment_type, - ); - - return $comment_struct; - } - - /** - * Retrieve comments. - * - * @since 2.7.0 - * - * @param array $args Method parameters. - * @return array - */ - function wp_getComments($args) { - $raw_args = $args; - $this->escape($args); - - $blog_id = (int) $args[0]; - $username = $args[1]; - $password = $args[2]; - $struct = $args[3]; - - if ( !$user = $this->login($username, $password) ) - return $this->error; - - if ( !current_user_can( 'moderate_comments' ) ) - return new IXR_Error( 401, __( 'Sorry, you cannot edit comments.' ) ); - - do_action('xmlrpc_call', 'wp.getComments'); - - if ( isset($struct['status']) ) - $status = $struct['status']; - else - $status = ''; - - $post_id = ''; - if ( isset($struct['post_id']) ) - $post_id = absint($struct['post_id']); - - $offset = 0; - if ( isset($struct['offset']) ) - $offset = absint($struct['offset']); - - $number = 10; - if ( isset($struct['number']) ) - $number = absint($struct['number']); - - $comments = get_comments( array('status' => $status, 'post_id' => $post_id, 'offset' => $offset, 'number' => $number ) ); - $num_comments = count($comments); - - if ( ! $num_comments ) - return array(); - - $comments_struct = array(); - - for ( $i = 0; $i < $num_comments; $i++ ) { - $comment = wp_xmlrpc_server::wp_getComment(array( - $raw_args[0], $raw_args[1], $raw_args[2], $comments[$i]->comment_ID, - )); - $comments_struct[] = $comment; - } - - return $comments_struct; - } - - /** - * Remove comment. - * - * @since 2.7.0 - * - * @param array $args Method parameters. - * @return mixed {@link wp_delete_comment()} - */ - function wp_deleteComment($args) { - $this->escape($args); - - $blog_id = (int) $args[0]; - $username = $args[1]; - $password = $args[2]; - $comment_ID = (int) $args[3]; - - if ( !$user = $this->login($username, $password) ) - return $this->error; - - if ( !current_user_can( 'moderate_comments' ) ) - return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); - - do_action('xmlrpc_call', 'wp.deleteComment'); - - if ( !$comment = get_comment( $comment_ID ) ) - return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); - - if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) ) - return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); - - return wp_delete_comment($comment_ID); - } - - /** - * Edit comment. - * - * @since 2.7.0 - * - * @param array $args Method parameters. - * @return bool True, on success. - */ - function wp_editComment($args) { - $this->escape($args); - - $blog_id = (int) $args[0]; - $username = $args[1]; - $password = $args[2]; - $comment_ID = (int) $args[3]; - $content_struct = $args[4]; - - if ( !$user = $this->login($username, $password) ) - return $this->error; - - if ( !current_user_can( 'moderate_comments' ) ) - return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); - - if ( !$comment = get_comment( $comment_ID ) ) - return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); - - if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) ) - return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) ); - - do_action('xmlrpc_call', 'wp.editComment'); - - if ( isset($content_struct['status']) ) { - $statuses = get_comment_statuses(); - $statuses = array_keys($statuses); - - if ( ! in_array($content_struct['status'], $statuses) ) - return new IXR_Error( 401, __( 'Invalid comment status.' ) ); - $comment_approved = $content_struct['status']; - } - - // Do some timestamp voodoo - if ( !empty( $content_struct['date_created_gmt'] ) ) { - $dateCreated = str_replace( 'Z', '', $content_struct['date_created_gmt']->getIso() ) . 'Z'; // We know this is supposed to be GMT, so we're going to slap that Z on there by force - $comment_date = get_date_from_gmt(iso8601_to_datetime($dateCreated)); - $comment_date_gmt = iso8601_to_datetime($dateCreated, GMT); - } - - if ( isset($content_struct['content']) ) - $comment_content = $content_struct['content']; - - if ( isset($content_struct['author']) ) - $comment_author = $content_struct['author']; - - if ( isset($content_struct['author_url']) ) - $comment_author_url = $content_struct['author_url']; - - if ( isset($content_struct['author_email']) ) - $comment_author_email = $content_struct['author_email']; - - // We've got all the data -- post it: - $comment = compact('comment_ID', 'comment_content', 'comment_approved', 'comment_date', 'comment_date_gmt', 'comment_author', 'comment_author_email', 'comment_author_url'); - - $result = wp_update_comment($comment); - if ( is_wp_error( $result ) ) - return new IXR_Error(500, $result->get_error_message()); - - if ( !$result ) - return new IXR_Error(500, __('Sorry, the comment could not be edited. Something wrong happened.')); - - return true; - } - - /** - * Create new comment. - * - * @since 2.7.0 - * - * @param array $args Method parameters. - * @return mixed {@link wp_new_comment()} - */ - function wp_newComment($args) { - global $wpdb; - - $this->escape($args); - - $blog_id = (int) $args[0]; - $username = $args[1]; - $password = $args[2]; - $post = $args[3]; - $content_struct = $args[4]; - - $allow_anon = apply_filters('xmlrpc_allow_anonymous_comments', false); - - $user = $this->login($username, $password); - - if ( !$user ) { - $logged_in = false; - if ( $allow_anon && get_option('comment_registration') ) - return new IXR_Error( 403, __( 'You must be registered to comment' ) ); - else if ( !$allow_anon ) - return $this->error; - } else { - $logged_in = true; - } - - if ( is_numeric($post) ) - $post_id = absint($post); - else - $post_id = url_to_postid($post); - - if ( ! $post_id ) - return new IXR_Error( 404, __( 'Invalid post ID.' ) ); - - if ( ! get_post($post_id) ) - return new IXR_Error( 404, __( 'Invalid post ID.' ) ); - - $comment['comment_post_ID'] = $post_id; - - if ( $logged_in ) { - $comment['comment_author'] = $wpdb->escape( $user->display_name ); - $comment['comment_author_email'] = $wpdb->escape( $user->user_email ); - $comment['comment_author_url'] = $wpdb->escape( $user->user_url ); - $comment['user_ID'] = $user->ID; - } else { - $comment['comment_author'] = ''; - if ( isset($content_struct['author']) ) - $comment['comment_author'] = $content_struct['author']; - - $comment['comment_author_email'] = ''; - if ( isset($content_struct['author_email']) ) - $comment['comment_author_email'] = $content_struct['author_email']; - - $comment['comment_author_url'] = ''; - if ( isset($content_struct['author_url']) ) - $comment['comment_author_url'] = $content_struct['author_url']; - - $comment['user_ID'] = 0; - - if ( get_option('require_name_email') ) { - if ( 6 > strlen($comment['comment_author_email']) || '' == $comment['comment_author'] ) - return new IXR_Error( 403, __( 'Comment author name and email are required' ) ); - elseif ( !is_email($comment['comment_author_email']) ) - return new IXR_Error( 403, __( 'A valid email address is required' ) ); - } - } - - $comment['comment_parent'] = isset($content_struct['comment_parent']) ? absint($content_struct['comment_parent']) : 0; - - $comment['comment_content'] = $content_struct['content']; - - do_action('xmlrpc_call', 'wp.newComment'); - - return wp_new_comment($comment); - } - - /** - * Retrieve all of the comment status. - * - * @since 2.7.0 - * - * @param array $args Method parameters. - * @return array - */ - function wp_getCommentStatusList($args) { - $this->escape( $args ); - - $blog_id = (int) $args[0]; - $username = $args[1]; - $password = $args[2]; - - if ( !$user = $this->login($username, $password) ) - return $this->error; - - if ( !current_user_can( 'moderate_comments' ) ) - return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); - - do_action('xmlrpc_call', 'wp.getCommentStatusList'); - - return get_comment_statuses( ); - } - - /** - * Retrieve comment count. - * - * @since 2.5.0 - * - * @param array $args Method parameters. - * @return array - */ - function wp_getCommentCount( $args ) { - $this->escape($args); - - $blog_id = (int) $args[0]; - $username = $args[1]; - $password = $args[2]; - $post_id = (int) $args[3]; - - if ( !$user = $this->login($username, $password) ) - return $this->error; - - if ( !current_user_can( 'edit_posts' ) ) - return new IXR_Error( 403, __( 'You are not allowed access to details about comments.' ) ); - - do_action('xmlrpc_call', 'wp.getCommentCount'); - - $count = wp_count_comments( $post_id ); - return array( - "approved" => $count->approved, - "awaiting_moderation" => $count->moderated, - "spam" => $count->spam, - "total_comments" => $count->total_comments - ); - } - - /** - * Retrieve post statuses. - * - * @since 2.5.0 - * - * @param array $args Method parameters. - * @return array - */ - function wp_getPostStatusList( $args ) { - $this->escape( $args ); - - $blog_id = (int) $args[0]; - $username = $args[1]; - $password = $args[2]; - - if ( !$user = $this->login($username, $password) ) - return $this->error; - - if ( !current_user_can( 'edit_posts' ) ) - return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); - - do_action('xmlrpc_call', 'wp.getPostStatusList'); - - return get_post_statuses( ); - } - - /** - * Retrieve page statuses. - * - * @since 2.5.0 - * - * @param array $args Method parameters. - * @return array - */ - function wp_getPageStatusList( $args ) { - $this->escape( $args ); - - $blog_id = (int) $args[0]; - $username = $args[1]; - $password = $args[2]; - - if ( !$user = $this->login($username, $password) ) - return $this->error; - - if ( !current_user_can( 'edit_pages' ) ) - return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); - - do_action('xmlrpc_call', 'wp.getPageStatusList'); - - return get_page_statuses( ); - } - - /** - * Retrieve page templates. - * - * @since 2.6.0 - * - * @param array $args Method parameters. - * @return array - */ - function wp_getPageTemplates( $args ) { - $this->escape( $args ); - - $blog_id = (int) $args[0]; - $username = $args[1]; - $password = $args[2]; - - if ( !$user = $this->login($username, $password) ) - return $this->error; - - if ( !current_user_can( 'edit_pages' ) ) - return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) ); - - $templates = get_page_templates( ); - $templates['Default'] = 'default'; - - return $templates; - } - - /** - * Retrieve blog options. - * - * @since 2.6.0 - * - * @param array $args Method parameters. - * @return array - */ - function wp_getOptions( $args ) { - $this->escape( $args ); - - $blog_id = (int) $args[0]; - $username = $args[1]; - $password = $args[2]; - $options = (array) $args[3]; - - if ( !$user = $this->login($username, $password) ) - return $this->error; - - // If no specific options where asked for, return all of them - if ( count( $options ) == 0 ) - $options = array_keys($this->blog_options); - - return $this->_getOptions($options); - } - - /** - * Retrieve blog options value from list. - * - * @since 2.6.0 - * - * @param array $options Options to retrieve. - * @return array - */ - function _getOptions($options) { - $data = array( ); - foreach ( $options as $option ) { - if ( array_key_exists( $option, $this->blog_options ) ) { - $data[$option] = $this->blog_options[$option]; - //Is the value static or dynamic? - if ( isset( $data[$option]['option'] ) ) { - $data[$option]['value'] = get_option( $data[$option]['option'] ); - unset($data[$option]['option']); - } - } - } - - return $data; - } - - /** - * Update blog options. - * - * @since 2.6.0 - * - * @param array $args Method parameters. - * @return unknown - */ - function wp_setOptions( $args ) { - $this->escape( $args ); - - $blog_id = (int) $args[0]; - $username = $args[1]; - $password = $args[2]; - $options = (array) $args[3]; - - if ( !$user = $this->login($username, $password) ) - return $this->error; - - if ( !current_user_can( 'manage_options' ) ) - return new IXR_Error( 403, __( 'You are not allowed to update options.' ) ); - - foreach ( $options as $o_name => $o_value ) { - $option_names[] = $o_name; - if ( !array_key_exists( $o_name, $this->blog_options ) ) - continue; - - if ( $this->blog_options[$o_name]['readonly'] == true ) - continue; - - update_option( $this->blog_options[$o_name]['option'], $o_value ); - } - - //Now return the updated values - return $this->_getOptions($option_names); - } - - /* Blogger API functions. - * specs on http://plant.blogger.com/api and http://groups.yahoo.com/group/bloggerDev/ - */ - - /** - * Retrieve blogs that user owns. - * - * Will make more sense once we support multiple blogs. - * - * @since 1.5.0 - * - * @param array $args Method parameters. - * @return array - */ - function blogger_getUsersBlogs($args) { - if ( is_multisite() ) - return $this->_multisite_getUsersBlogs($args); - - $this->escape($args); - - $username = $args[1]; - $password = $args[2]; - - if ( !$user = $this->login($username, $password) ) - return $this->error; - - do_action('xmlrpc_call', 'blogger.getUsersBlogs'); - - $is_admin = current_user_can('manage_options'); - - $struct = array( - 'isAdmin' => $is_admin, - 'url' => get_option('home') . '/', - 'blogid' => '1', - 'blogName' => get_option('blogname'), - 'xmlrpc' => site_url( 'xmlrpc.php' ) - ); - - return array($struct); - } - - /** - * Private function for retrieving a users blogs for multisite setups - * - * @access protected - */ - function _multisite_getUsersBlogs($args) { - global $current_blog; - $domain = $current_blog->domain; - $path = $current_blog->path . 'xmlrpc.php'; - $protocol = is_ssl() ? 'https' : 'http'; - - $rpc = new IXR_Client("$protocol://{$domain}{$path}"); - $rpc->query('wp.getUsersBlogs', $args[1], $args[2]); - $blogs = $rpc->getResponse(); - - if ( isset($blogs['faultCode']) ) - return new IXR_Error($blogs['faultCode'], $blogs['faultString']); - - if ( $_SERVER['HTTP_HOST'] == $domain && $_SERVER['REQUEST_URI'] == $path ) { - return $blogs; - } else { - foreach ( (array) $blogs as $blog ) { - if ( strpos($blog['url'], $_SERVER['HTTP_HOST']) ) - return array($blog); - } - return array(); - } - } - - /** - * Retrieve user's data. - * - * Gives your client some info about you, so you don't have to. - * - * @since 1.5.0 - * - * @param array $args Method parameters. - * @return array - */ - function blogger_getUserInfo($args) { - - $this->escape($args); - - $username = $args[1]; - $password = $args[2]; - - if ( !$user = $this->login($username, $password) ) - return $this->error; - - if ( !current_user_can( 'edit_posts' ) ) - return new IXR_Error( 401, __( 'Sorry, you do not have access to user data on this site.' ) ); - - do_action('xmlrpc_call', 'blogger.getUserInfo'); - - $struct = array( - 'nickname' => $user->nickname, - 'userid' => $user->ID, - 'url' => $user->user_url, - 'lastname' => $user->last_name, - 'firstname' => $user->first_name - ); - - return $struct; - } - - /** - * Retrieve post. - * - * @since 1.5.0 - * - * @param array $args Method parameters. - * @return array - */ - function blogger_getPost($args) { - - $this->escape($args); - - $post_ID = (int) $args[1]; - $username = $args[2]; - $password = $args[3]; - - if ( !$user = $this->login($username, $password) ) - return $this->error; - - if ( !current_user_can( 'edit_post', $post_ID ) ) - return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) ); - - do_action('xmlrpc_call', 'blogger.getPost'); - - $post_data = wp_get_single_post($post_ID, ARRAY_A); - - $categories = implode(',', wp_get_post_categories($post_ID)); - - $content = ''.stripslashes($post_data['post_title']).''; - $content .= ''.$categories.''; - $content .= stripslashes($post_data['post_content']); - - $struct = array( - 'userid' => $post_data['post_author'], - 'dateCreated' => new IXR_Date(mysql2date('Ymd\TH:i:s', $post_data['post_date'], false)), - 'content' => $content, - 'postid' => $post_data['ID'] - ); - - return $struct; - } - - /** - * Retrieve list of recent posts. - * - * @since 1.5.0 - * - * @param array $args Method parameters. - * @return array - */ - function blogger_getRecentPosts($args) { - - $this->escape($args); - - $blog_ID = (int) $args[1]; /* though we don't use it yet */ - $username = $args[2]; - $password = $args[3]; - $num_posts = $args[4]; - - if ( !$user = $this->login($username, $password) ) - return $this->error; - - do_action('xmlrpc_call', 'blogger.getRecentPosts'); - - $posts_list = wp_get_recent_posts($num_posts); - - if ( !$posts_list ) { - $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); - return $this->error; - } - - foreach ($posts_list as $entry) { - if ( !current_user_can( 'edit_post', $entry['ID'] ) ) - continue; - - $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date'], false); - $categories = implode(',', wp_get_post_categories($entry['ID'])); - - $content = ''.stripslashes($entry['post_title']).''; - $content .= ''.$categories.''; - $content .= stripslashes($entry['post_content']); - - $struct[] = array( - 'userid' => $entry['post_author'], - 'dateCreated' => new IXR_Date($post_date), - 'content' => $content, - 'postid' => $entry['ID'], - ); - - } - - $recent_posts = array(); - for ( $j=0; $jescape($args); - - $blog_ID = (int) $args[1]; - $username = $args[2]; - $password = $args[3]; - $template = $args[4]; /* could be 'main' or 'archiveIndex', but we don't use it */ - - if ( !$user = $this->login($username, $password) ) - return $this->error; - - do_action('xmlrpc_call', 'blogger.getTemplate'); - - if ( !current_user_can('edit_themes') ) - return new IXR_Error(401, __('Sorry, this user can not edit the template.')); - - /* warning: here we make the assumption that the blog's URL is on the same server */ - $filename = get_option('home') . '/'; - $filename = preg_replace('#https?://.+?/#', $_SERVER['DOCUMENT_ROOT'].'/', $filename); - - $f = fopen($filename, 'r'); - $content = fread($f, filesize($filename)); - fclose($f); - - /* so it is actually editable with a windows/mac client */ - // FIXME: (or delete me) do we really want to cater to bad clients at the expense of good ones by BEEPing up their line breaks? commented. $content = str_replace("\n", "\r\n", $content); - - return $content; - } - - /** - * Updates the content of blog_filename. - * - * @since 1.5.0 - * - * @param array $args Method parameters. - * @return bool True when done. - */ - function blogger_setTemplate($args) { - - $this->escape($args); - - $blog_ID = (int) $args[1]; - $username = $args[2]; - $password = $args[3]; - $content = $args[4]; - $template = $args[5]; /* could be 'main' or 'archiveIndex', but we don't use it */ - - if ( !$user = $this->login($username, $password) ) - return $this->error; - - do_action('xmlrpc_call', 'blogger.setTemplate'); - - if ( !current_user_can('edit_themes') ) - return new IXR_Error(401, __('Sorry, this user cannot edit the template.')); - - /* warning: here we make the assumption that the blog's URL is on the same server */ - $filename = get_option('home') . '/'; - $filename = preg_replace('#https?://.+?/#', $_SERVER['DOCUMENT_ROOT'].'/', $filename); - - if ($f = fopen($filename, 'w+')) { - fwrite($f, $content); - fclose($f); - } else { - return new IXR_Error(500, __('Either the file is not writable, or something wrong happened. The file has not been updated.')); - } - - return true; - } - - /** - * Create new post. - * - * @since 1.5.0 - * - * @param array $args Method parameters. - * @return int - */ - function blogger_newPost($args) { - - $this->escape($args); - - $blog_ID = (int) $args[1]; /* though we don't use it yet */ - $username = $args[2]; - $password = $args[3]; - $content = $args[4]; - $publish = $args[5]; - - if ( !$user = $this->login($username, $password) ) - return $this->error; - - do_action('xmlrpc_call', 'blogger.newPost'); - - $cap = ($publish) ? 'publish_posts' : 'edit_posts'; - if ( !current_user_can($cap) ) - return new IXR_Error(401, __('Sorry, you are not allowed to post on this site.')); - - $post_status = ($publish) ? 'publish' : 'draft'; - - $post_author = $user->ID; - - $post_title = xmlrpc_getposttitle($content); - $post_category = xmlrpc_getpostcategory($content); - $post_content = xmlrpc_removepostdata($content); - - $post_date = current_time('mysql'); - $post_date_gmt = current_time('mysql', 1); - - $post_data = compact('blog_ID', 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_category', 'post_status'); - - $post_ID = wp_insert_post($post_data); - if ( is_wp_error( $post_ID ) ) - return new IXR_Error(500, $post_ID->get_error_message()); - - if ( !$post_ID ) - return new IXR_Error(500, __('Sorry, your entry could not be posted. Something wrong happened.')); - - $this->attach_uploads( $post_ID, $post_content ); - - logIO('O', "Posted ! ID: $post_ID"); - - return $post_ID; - } - - /** - * Edit a post. - * - * @since 1.5.0 - * - * @param array $args Method parameters. - * @return bool true when done. - */ - function blogger_editPost($args) { - - $this->escape($args); - - $post_ID = (int) $args[1]; - $username = $args[2]; - $password = $args[3]; - $content = $args[4]; - $publish = $args[5]; - - if ( !$user = $this->login($username, $password) ) - return $this->error; - - do_action('xmlrpc_call', 'blogger.editPost'); - - $actual_post = wp_get_single_post($post_ID,ARRAY_A); - - if ( !$actual_post || $actual_post['post_type'] != 'post' ) - return new IXR_Error(404, __('Sorry, no such post.')); - - $this->escape($actual_post); - - if ( !current_user_can('edit_post', $post_ID) ) - return new IXR_Error(401, __('Sorry, you do not have the right to edit this post.')); - - extract($actual_post, EXTR_SKIP); - - if ( ('publish' == $post_status) && !current_user_can('publish_posts') ) - return new IXR_Error(401, __('Sorry, you do not have the right to publish this post.')); - - $post_title = xmlrpc_getposttitle($content); - $post_category = xmlrpc_getpostcategory($content); - $post_content = xmlrpc_removepostdata($content); - - $postdata = compact('ID', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt'); - - $result = wp_update_post($postdata); - - if ( !$result ) - return new IXR_Error(500, __('For some strange yet very annoying reason, this post could not be edited.')); - - $this->attach_uploads( $ID, $post_content ); - - return true; - } - - /** - * Remove a post. - * - * @since 1.5.0 - * - * @param array $args Method parameters. - * @return bool True when post is deleted. - */ - function blogger_deletePost($args) { - $this->escape($args); - - $post_ID = (int) $args[1]; - $username = $args[2]; - $password = $args[3]; - $publish = $args[4]; - - if ( !$user = $this->login($username, $password) ) - return $this->error; - - do_action('xmlrpc_call', 'blogger.deletePost'); - - $actual_post = wp_get_single_post($post_ID,ARRAY_A); - - if ( !$actual_post || $actual_post['post_type'] != 'post' ) - return new IXR_Error(404, __('Sorry, no such post.')); - - if ( !current_user_can('delete_post', $post_ID) ) - return new IXR_Error(401, __('Sorry, you do not have the right to delete this post.')); - - $result = wp_delete_post($post_ID); - - if ( !$result ) - return new IXR_Error(500, __('For some strange yet very annoying reason, this post could not be deleted.')); - - return true; - } - - /* MetaWeblog API functions - * specs on wherever Dave Winer wants them to be - */ - - /** - * Create a new post. - * - * @since 1.5.0 - * - * @param array $args Method parameters. - * @return int - */ - function mw_newPost($args) { - $this->escape($args); - - $blog_ID = (int) $args[0]; // we will support this in the near future - $username = $args[1]; - $password = $args[2]; - $content_struct = $args[3]; - $publish = isset( $args[4] ) ? $args[4] : 0; - - if ( !$user = $this->login($username, $password) ) - return $this->error; - - do_action('xmlrpc_call', 'metaWeblog.newPost'); - - $page_template = ''; - if ( !empty( $content_struct['post_type'] ) ) { - if ( $content_struct['post_type'] == 'page' ) { - if ( $publish || 'publish' == $content_struct['page_status']) - $cap = 'publish_pages'; - else - $cap = 'edit_pages'; - $error_message = __( 'Sorry, you are not allowed to publish pages on this site.' ); - $post_type = 'page'; - if ( !empty( $content_struct['wp_page_template'] ) ) - $page_template = $content_struct['wp_page_template']; - } elseif ( $content_struct['post_type'] == 'post' ) { - if ( $publish || 'publish' == $content_struct['post_status']) - $cap = 'publish_posts'; - else - $cap = 'edit_posts'; - $error_message = __( 'Sorry, you are not allowed to publish posts on this site.' ); - $post_type = 'post'; - } else { - // No other post_type values are allowed here - return new IXR_Error( 401, __( 'Invalid post type.' ) ); - } - } else { - if ( $publish || 'publish' == $content_struct['post_status']) - $cap = 'publish_posts'; - else - $cap = 'edit_posts'; - $error_message = __( 'Sorry, you are not allowed to publish posts on this site.' ); - $post_type = 'post'; - } - - if ( !current_user_can( $cap ) ) - return new IXR_Error( 401, $error_message ); - - // Let WordPress generate the post_name (slug) unless - // one has been provided. - $post_name = ""; - if ( isset($content_struct["wp_slug"]) ) - $post_name = $content_struct["wp_slug"]; - - // Only use a password if one was given. - if ( isset($content_struct["wp_password"]) ) - $post_password = $content_struct["wp_password"]; - - // Only set a post parent if one was provided. - if ( isset($content_struct["wp_page_parent_id"]) ) - $post_parent = $content_struct["wp_page_parent_id"]; - - // Only set the menu_order if it was provided. - if ( isset($content_struct["wp_page_order"]) ) - $menu_order = $content_struct["wp_page_order"]; - - $post_author = $user->ID; - - // If an author id was provided then use it instead. - if ( isset($content_struct["wp_author_id"]) && ($user->ID != $content_struct["wp_author_id"]) ) { - switch ( $post_type ) { - case "post": - if ( !current_user_can("edit_others_posts") ) - return(new IXR_Error(401, __("You are not allowed to post as this user"))); - break; - case "page": - if ( !current_user_can("edit_others_pages") ) - return(new IXR_Error(401, __("You are not allowed to create pages as this user"))); - break; - default: - return(new IXR_Error(401, __("Invalid post type."))); - break; - } - $post_author = $content_struct["wp_author_id"]; - } - - $post_title = $content_struct['title']; - $post_content = $content_struct['description']; - - $post_status = $publish ? 'publish' : 'draft'; - - if ( isset( $content_struct["{$post_type}_status"] ) ) { - switch ( $content_struct["{$post_type}_status"] ) { - case 'draft': - case 'private': - case 'publish': - $post_status = $content_struct["{$post_type}_status"]; - break; - case 'pending': - // Pending is only valid for posts, not pages. - if ( $post_type === 'post' ) - $post_status = $content_struct["{$post_type}_status"]; - break; - default: - $post_status = $publish ? 'publish' : 'draft'; - break; - } - } - - $post_excerpt = $content_struct['mt_excerpt']; - $post_more = $content_struct['mt_text_more']; - - $tags_input = $content_struct['mt_keywords']; - - if ( isset($content_struct["mt_allow_comments"]) ) { - if ( !is_numeric($content_struct["mt_allow_comments"]) ) { - switch ( $content_struct["mt_allow_comments"] ) { - case "closed": - $comment_status = "closed"; - break; - case "open": - $comment_status = "open"; - break; - default: - $comment_status = get_option("default_comment_status"); - break; - } - } else { - switch ( (int) $content_struct["mt_allow_comments"] ) { - case 0: - case 2: - $comment_status = "closed"; - break; - case 1: - $comment_status = "open"; - break; - default: - $comment_status = get_option("default_comment_status"); - break; - } - } - } else { - $comment_status = get_option("default_comment_status"); - } - - if ( isset($content_struct["mt_allow_pings"]) ) { - if ( !is_numeric($content_struct["mt_allow_pings"]) ) { - switch ( $content_struct['mt_allow_pings'] ) { - case "closed": - $ping_status = "closed"; - break; - case "open": - $ping_status = "open"; - break; - default: - $ping_status = get_option("default_ping_status"); - break; - } - } else { - switch ( (int) $content_struct["mt_allow_pings"] ) { - case 0: - $ping_status = "closed"; - break; - case 1: - $ping_status = "open"; - break; - default: - $ping_status = get_option("default_ping_status"); - break; - } - } - } else { - $ping_status = get_option("default_ping_status"); - } - - if ( $post_more ) - $post_content = $post_content . "" . $post_more; - - $to_ping = $content_struct['mt_tb_ping_urls']; - if ( is_array($to_ping) ) - $to_ping = implode(' ', $to_ping); - - // Do some timestamp voodoo - if ( !empty( $content_struct['date_created_gmt'] ) ) - $dateCreated = str_replace( 'Z', '', $content_struct['date_created_gmt']->getIso() ) . 'Z'; // We know this is supposed to be GMT, so we're going to slap that Z on there by force - elseif ( !empty( $content_struct['dateCreated']) ) - $dateCreated = $content_struct['dateCreated']->getIso(); - - if ( !empty( $dateCreated ) ) { - $post_date = get_date_from_gmt(iso8601_to_datetime($dateCreated)); - $post_date_gmt = iso8601_to_datetime($dateCreated, GMT); - } else { - $post_date = current_time('mysql'); - $post_date_gmt = current_time('mysql', 1); - } - - $catnames = $content_struct['categories']; - logIO('O', 'Post cats: ' . var_export($catnames,true)); - $post_category = array(); - - if ( is_array($catnames) ) { - foreach ($catnames as $cat) { - $post_category[] = get_cat_ID($cat); - } - } - - // We've got all the data -- post it: - $postdata = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'comment_status', 'ping_status', 'to_ping', 'post_type', 'post_name', 'post_password', 'post_parent', 'menu_order', 'tags_input', 'page_template'); - - $post_ID = wp_insert_post($postdata, true); - if ( is_wp_error( $post_ID ) ) - return new IXR_Error(500, $post_ID->get_error_message()); - - if ( !$post_ID ) - return new IXR_Error(500, __('Sorry, your entry could not be posted. Something wrong happened.')); - - // Only posts can be sticky - if ( $post_type == 'post' && isset( $content_struct['sticky'] ) ) { - if ( $content_struct['sticky'] == true ) - stick_post( $post_ID ); - elseif ( $content_struct['sticky'] == false ) - unstick_post( $post_ID ); - } - - if ( isset($content_struct['custom_fields']) ) - $this->set_custom_fields($post_ID, $content_struct['custom_fields']); - - // Handle enclosures - $this->add_enclosure_if_new($post_ID, $content_struct['enclosure']); - - $this->attach_uploads( $post_ID, $post_content ); - - logIO('O', "Posted ! ID: $post_ID"); - - return strval($post_ID); - } - - function add_enclosure_if_new($post_ID, $enclosure) { - if ( is_array( $enclosure ) && isset( $enclosure['url'] ) && isset( $enclosure['length'] ) && isset( $enclosure['type'] ) ) { - - $encstring = $enclosure['url'] . "\n" . $enclosure['length'] . "\n" . $enclosure['type']; - $found = false; - foreach ( (array) get_post_custom($post_ID) as $key => $val) { - if ($key == 'enclosure') { - foreach ( (array) $val as $enc ) { - if ($enc == $encstring) { - $found = true; - break 2; - } - } - } - } - if (!$found) - add_post_meta( $post_ID, 'enclosure', $encstring ); - } - } - - /** - * Attach upload to a post. - * - * @since 2.1.0 - * - * @param int $post_ID Post ID. - * @param string $post_content Post Content for attachment. - */ - function attach_uploads( $post_ID, $post_content ) { - global $wpdb; - - // find any unattached files - $attachments = $wpdb->get_results( "SELECT ID, guid FROM {$wpdb->posts} WHERE post_parent = '0' AND post_type = 'attachment'" ); - if ( is_array( $attachments ) ) { - foreach ( $attachments as $file ) { - if ( strpos( $post_content, $file->guid ) !== false ) - $wpdb->update($wpdb->posts, array('post_parent' => $post_ID), array('ID' => $file->ID) ); - } - } - } - - /** - * Edit a post. - * - * @since 1.5.0 - * - * @param array $args Method parameters. - * @return bool True on success. - */ - function mw_editPost($args) { - - $this->escape($args); - - $post_ID = (int) $args[0]; - $username = $args[1]; - $password = $args[2]; - $content_struct = $args[3]; - $publish = $args[4]; - - if ( !$user = $this->login($username, $password) ) - return $this->error; - - do_action('xmlrpc_call', 'metaWeblog.editPost'); - - $cap = ( $publish ) ? 'publish_posts' : 'edit_posts'; - $error_message = __( 'Sorry, you are not allowed to publish posts on this site.' ); - $post_type = 'post'; - $page_template = ''; - if ( !empty( $content_struct['post_type'] ) ) { - if ( $content_struct['post_type'] == 'page' ) { - if ( $publish || 'publish' == $content_struct['page_status'] ) - $cap = 'publish_pages'; - else - $cap = 'edit_pages'; - $error_message = __( 'Sorry, you are not allowed to publish pages on this site.' ); - $post_type = 'page'; - if ( !empty( $content_struct['wp_page_template'] ) ) - $page_template = $content_struct['wp_page_template']; - } elseif ( $content_struct['post_type'] == 'post' ) { - if ( $publish || 'publish' == $content_struct['post_status'] ) - $cap = 'publish_posts'; - else - $cap = 'edit_posts'; - $error_message = __( 'Sorry, you are not allowed to publish posts on this site.' ); - $post_type = 'post'; - } else { - // No other post_type values are allowed here - return new IXR_Error( 401, __( 'Invalid post type.' ) ); - } - } else { - if ( $publish || 'publish' == $content_struct['post_status'] ) - $cap = 'publish_posts'; - else - $cap = 'edit_posts'; - $error_message = __( 'Sorry, you are not allowed to publish posts on this site.' ); - $post_type = 'post'; - } - - if ( !current_user_can( $cap ) ) - return new IXR_Error( 401, $error_message ); - - $postdata = wp_get_single_post($post_ID, ARRAY_A); - - // If there is no post data for the give post id, stop - // now and return an error. Other wise a new post will be - // created (which was the old behavior). - if ( empty($postdata["ID"]) ) - return(new IXR_Error(404, __("Invalid post ID."))); - - $this->escape($postdata); - extract($postdata, EXTR_SKIP); - - // Let WordPress manage slug if none was provided. - $post_name = ""; - if ( isset($content_struct["wp_slug"]) ) - $post_name = $content_struct["wp_slug"]; - - // Only use a password if one was given. - if ( isset($content_struct["wp_password"]) ) - $post_password = $content_struct["wp_password"]; - - // Only set a post parent if one was given. - if ( isset($content_struct["wp_page_parent_id"]) ) - $post_parent = $content_struct["wp_page_parent_id"]; - - // Only set the menu_order if it was given. - if ( isset($content_struct["wp_page_order"]) ) - $menu_order = $content_struct["wp_page_order"]; - - $post_author = $postdata["post_author"]; - - // Only set the post_author if one is set. - if ( isset($content_struct["wp_author_id"]) && ($user->ID != $content_struct["wp_author_id"]) ) { - switch ( $post_type ) { - case "post": - if ( !current_user_can("edit_others_posts") ) - return(new IXR_Error(401, __("You are not allowed to change the post author as this user."))); - break; - case "page": - if ( !current_user_can("edit_others_pages") ) - return(new IXR_Error(401, __("You are not allowed to change the page author as this user."))); - break; - default: - return(new IXR_Error(401, __("Invalid post type."))); - break; - } - $post_author = $content_struct["wp_author_id"]; - } - - if ( isset($content_struct["mt_allow_comments"]) ) { - if ( !is_numeric($content_struct["mt_allow_comments"]) ) { - switch ( $content_struct["mt_allow_comments"] ) { - case "closed": - $comment_status = "closed"; - break; - case "open": - $comment_status = "open"; - break; - default: - $comment_status = get_option("default_comment_status"); - break; - } - } else { - switch ( (int) $content_struct["mt_allow_comments"] ) { - case 0: - case 2: - $comment_status = "closed"; - break; - case 1: - $comment_status = "open"; - break; - default: - $comment_status = get_option("default_comment_status"); - break; - } - } - } - - if ( isset($content_struct["mt_allow_pings"]) ) { - if ( !is_numeric($content_struct["mt_allow_pings"]) ) { - switch ( $content_struct["mt_allow_pings"] ) { - case "closed": - $ping_status = "closed"; - break; - case "open": - $ping_status = "open"; - break; - default: - $ping_status = get_option("default_ping_status"); - break; - } - } else { - switch ( (int) $content_struct["mt_allow_pings"] ) { - case 0: - $ping_status = "closed"; - break; - case 1: - $ping_status = "open"; - break; - default: - $ping_status = get_option("default_ping_status"); - break; - } - } - } - - $post_title = $content_struct['title']; - $post_content = $content_struct['description']; - $catnames = $content_struct['categories']; - - $post_category = array(); - - if ( is_array($catnames) ) { - foreach ($catnames as $cat) { - $post_category[] = get_cat_ID($cat); - } - } - - $post_excerpt = $content_struct['mt_excerpt']; - $post_more = $content_struct['mt_text_more']; - - $post_status = $publish ? 'publish' : 'draft'; - if ( isset( $content_struct["{$post_type}_status"] ) ) { - switch( $content_struct["{$post_type}_status"] ) { - case 'draft': - case 'private': - case 'publish': - $post_status = $content_struct["{$post_type}_status"]; - break; - case 'pending': - // Pending is only valid for posts, not pages. - if ( $post_type === 'post' ) - $post_status = $content_struct["{$post_type}_status"]; - break; - default: - $post_status = $publish ? 'publish' : 'draft'; - break; - } - } - - $tags_input = $content_struct['mt_keywords']; - - if ( ('publish' == $post_status) ) { - if ( ( 'page' == $post_type ) && !current_user_can('publish_pages') ) - return new IXR_Error(401, __('Sorry, you do not have the right to publish this page.')); - else if ( !current_user_can('publish_posts') ) - return new IXR_Error(401, __('Sorry, you do not have the right to publish this post.')); - } - - if ( $post_more ) - $post_content = $post_content . "" . $post_more; - - $to_ping = $content_struct['mt_tb_ping_urls']; - if ( is_array($to_ping) ) - $to_ping = implode(' ', $to_ping); - - // Do some timestamp voodoo - if ( !empty( $content_struct['date_created_gmt'] ) ) - $dateCreated = str_replace( 'Z', '', $content_struct['date_created_gmt']->getIso() ) . 'Z'; // We know this is supposed to be GMT, so we're going to slap that Z on there by force - elseif ( !empty( $content_struct['dateCreated']) ) - $dateCreated = $content_struct['dateCreated']->getIso(); - - if ( !empty( $dateCreated ) ) { - $post_date = get_date_from_gmt(iso8601_to_datetime($dateCreated)); - $post_date_gmt = iso8601_to_datetime($dateCreated, GMT); - } else { - $post_date = $postdata['post_date']; - $post_date_gmt = $postdata['post_date_gmt']; - } - - // We've got all the data -- post it: - $newpost = compact('ID', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'comment_status', 'ping_status', 'post_date', 'post_date_gmt', 'to_ping', 'post_name', 'post_password', 'post_parent', 'menu_order', 'post_author', 'tags_input', 'page_template'); - - $result = wp_update_post($newpost, true); - if ( is_wp_error( $result ) ) - return new IXR_Error(500, $result->get_error_message()); - - if ( !$result ) - return new IXR_Error(500, __('Sorry, your entry could not be edited. Something wrong happened.')); - - // Only posts can be sticky - if ( $post_type == 'post' && isset( $content_struct['sticky'] ) ) { - if ( $content_struct['sticky'] == true ) - stick_post( $post_ID ); - elseif ( $content_struct['sticky'] == false ) - unstick_post( $post_ID ); - } - - if ( isset($content_struct['custom_fields']) ) - $this->set_custom_fields($post_ID, $content_struct['custom_fields']); - - // Handle enclosures - $this->add_enclosure_if_new($post_ID, $content_struct['enclosure']); - - $this->attach_uploads( $ID, $post_content ); - - logIO('O',"(MW) Edited ! ID: $post_ID"); - - return true; - } - - /** - * Retrieve post. - * - * @since 1.5.0 - * - * @param array $args Method parameters. - * @return array - */ - function mw_getPost($args) { - - $this->escape($args); - - $post_ID = (int) $args[0]; - $username = $args[1]; - $password = $args[2]; - - if ( !$user = $this->login($username, $password) ) - return $this->error; - - if ( !current_user_can( 'edit_post', $post_ID ) ) - return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) ); - - do_action('xmlrpc_call', 'metaWeblog.getPost'); - - $postdata = wp_get_single_post($post_ID, ARRAY_A); - - if ($postdata['post_date'] != '') { - $post_date = mysql2date('Ymd\TH:i:s', $postdata['post_date'], false); - $post_date_gmt = mysql2date('Ymd\TH:i:s', $postdata['post_date_gmt'], false); - - // For drafts use the GMT version of the post date - if ( $postdata['post_status'] == 'draft' ) - $post_date_gmt = get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $postdata['post_date'] ), 'Ymd\TH:i:s' ); - - $categories = array(); - $catids = wp_get_post_categories($post_ID); - foreach($catids as $catid) - $categories[] = get_cat_name($catid); - - $tagnames = array(); - $tags = wp_get_post_tags( $post_ID ); - if ( !empty( $tags ) ) { - foreach ( $tags as $tag ) - $tagnames[] = $tag->name; - $tagnames = implode( ', ', $tagnames ); - } else { - $tagnames = ''; - } - - $post = get_extended($postdata['post_content']); - $link = post_permalink($postdata['ID']); - - // Get the author info. - $author = get_userdata($postdata['post_author']); - - $allow_comments = ('open' == $postdata['comment_status']) ? 1 : 0; - $allow_pings = ('open' == $postdata['ping_status']) ? 1 : 0; - - // Consider future posts as published - if ( $postdata['post_status'] === 'future' ) - $postdata['post_status'] = 'publish'; - - $sticky = false; - if ( is_sticky( $post_ID ) ) - $sticky = true; - - $enclosure = array(); - foreach ( (array) get_post_custom($post_ID) as $key => $val) { - if ($key == 'enclosure') { - foreach ( (array) $val as $enc ) { - $encdata = split("\n", $enc); - $enclosure['url'] = trim(htmlspecialchars($encdata[0])); - $enclosure['length'] = (int) trim($encdata[1]); - $enclosure['type'] = trim($encdata[2]); - break 2; - } - } - } - - $resp = array( - 'dateCreated' => new IXR_Date($post_date), - 'userid' => $postdata['post_author'], - 'postid' => $postdata['ID'], - 'description' => $post['main'], - 'title' => $postdata['post_title'], - 'link' => $link, - 'permaLink' => $link, - // commented out because no other tool seems to use this - // 'content' => $entry['post_content'], - 'categories' => $categories, - 'mt_excerpt' => $postdata['post_excerpt'], - 'mt_text_more' => $post['extended'], - 'mt_allow_comments' => $allow_comments, - 'mt_allow_pings' => $allow_pings, - 'mt_keywords' => $tagnames, - 'wp_slug' => $postdata['post_name'], - 'wp_password' => $postdata['post_password'], - 'wp_author_id' => $author->ID, - 'wp_author_display_name' => $author->display_name, - 'date_created_gmt' => new IXR_Date($post_date_gmt), - 'post_status' => $postdata['post_status'], - 'custom_fields' => $this->get_custom_fields($post_ID), - 'sticky' => $sticky - ); - - if ( !empty($enclosure) ) $resp['enclosure'] = $enclosure; - - return $resp; - } else { - return new IXR_Error(404, __('Sorry, no such post.')); - } - } - - /** - * Retrieve list of recent posts. - * - * @since 1.5.0 - * - * @param array $args Method parameters. - * @return array - */ - function mw_getRecentPosts($args) { - - $this->escape($args); - - $blog_ID = (int) $args[0]; - $username = $args[1]; - $password = $args[2]; - $num_posts = (int) $args[3]; - - if ( !$user = $this->login($username, $password) ) - return $this->error; - - do_action('xmlrpc_call', 'metaWeblog.getRecentPosts'); - - $posts_list = wp_get_recent_posts($num_posts); - - if ( !$posts_list ) - return array( ); - - foreach ($posts_list as $entry) { - if ( !current_user_can( 'edit_post', $entry['ID'] ) ) - continue; - - $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date'], false); - $post_date_gmt = mysql2date('Ymd\TH:i:s', $entry['post_date_gmt'], false); - - // For drafts use the GMT version of the date - if ( $entry['post_status'] == 'draft' ) - $post_date_gmt = get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $entry['post_date'] ), 'Ymd\TH:i:s' ); - - $categories = array(); - $catids = wp_get_post_categories($entry['ID']); - foreach( $catids as $catid ) - $categories[] = get_cat_name($catid); - - $tagnames = array(); - $tags = wp_get_post_tags( $entry['ID'] ); - if ( !empty( $tags ) ) { - foreach ( $tags as $tag ) { - $tagnames[] = $tag->name; - } - $tagnames = implode( ', ', $tagnames ); - } else { - $tagnames = ''; - } - - $post = get_extended($entry['post_content']); - $link = post_permalink($entry['ID']); - - // Get the post author info. - $author = get_userdata($entry['post_author']); - - $allow_comments = ('open' == $entry['comment_status']) ? 1 : 0; - $allow_pings = ('open' == $entry['ping_status']) ? 1 : 0; - - // Consider future posts as published - if ( $entry['post_status'] === 'future' ) - $entry['post_status'] = 'publish'; - - $struct[] = array( - 'dateCreated' => new IXR_Date($post_date), - 'userid' => $entry['post_author'], - 'postid' => $entry['ID'], - 'description' => $post['main'], - 'title' => $entry['post_title'], - 'link' => $link, - 'permaLink' => $link, - // commented out because no other tool seems to use this - // 'content' => $entry['post_content'], - 'categories' => $categories, - 'mt_excerpt' => $entry['post_excerpt'], - 'mt_text_more' => $post['extended'], - 'mt_allow_comments' => $allow_comments, - 'mt_allow_pings' => $allow_pings, - 'mt_keywords' => $tagnames, - 'wp_slug' => $entry['post_name'], - 'wp_password' => $entry['post_password'], - 'wp_author_id' => $author->ID, - 'wp_author_display_name' => $author->display_name, - 'date_created_gmt' => new IXR_Date($post_date_gmt), - 'post_status' => $entry['post_status'], - 'custom_fields' => $this->get_custom_fields($entry['ID']) - ); - - } - - $recent_posts = array(); - for ( $j=0; $jescape($args); - - $blog_ID = (int) $args[0]; - $username = $args[1]; - $password = $args[2]; - - if ( !$user = $this->login($username, $password) ) - return $this->error; - - if ( !current_user_can( 'edit_posts' ) ) - return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); - - do_action('xmlrpc_call', 'metaWeblog.getCategories'); - - $categories_struct = array(); - - if ( $cats = get_categories(array('get' => 'all')) ) { - foreach ( $cats as $cat ) { - $struct['categoryId'] = $cat->term_id; - $struct['parentId'] = $cat->parent; - $struct['description'] = $cat->name; - $struct['categoryDescription'] = $cat->description; - $struct['categoryName'] = $cat->name; - $struct['htmlUrl'] = esc_html(get_category_link($cat->term_id)); - $struct['rssUrl'] = esc_html(get_category_feed_link($cat->term_id, 'rss2')); - - $categories_struct[] = $struct; - } - } - - return $categories_struct; - } - - /** - * Uploads a file, following your settings. - * - * Adapted from a patch by Johann Richard. - * - * @link http://mycvs.org/archives/2004/06/30/file-upload-to-wordpress-in-ecto/ - * - * @since 1.5.0 - * - * @param array $args Method parameters. - * @return array - */ - function mw_newMediaObject($args) { - global $wpdb; - - $blog_ID = (int) $args[0]; - $username = $wpdb->escape($args[1]); - $password = $wpdb->escape($args[2]); - $data = $args[3]; - - $name = sanitize_file_name( $data['name'] ); - $type = $data['type']; - $bits = $data['bits']; - - logIO('O', '(MW) Received '.strlen($bits).' bytes'); - - if ( !$user = $this->login($username, $password) ) - return $this->error; - - do_action('xmlrpc_call', 'metaWeblog.newMediaObject'); - - if ( !current_user_can('upload_files') ) { - logIO('O', '(MW) User does not have upload_files capability'); - $this->error = new IXR_Error(401, __('You are not allowed to upload files to this site.')); - return $this->error; - } - - if ( $upload_err = apply_filters( "pre_upload_error", false ) ) - return new IXR_Error(500, $upload_err); - - if ( !empty($data["overwrite"]) && ($data["overwrite"] == true) ) { - // Get postmeta info on the object. - $old_file = $wpdb->get_row(" - SELECT ID - FROM {$wpdb->posts} - WHERE post_title = '{$name}' - AND post_type = 'attachment' - "); - - // Delete previous file. - wp_delete_attachment($old_file->ID); - - // Make sure the new name is different by pre-pending the - // previous post id. - $filename = preg_replace("/^wpid\d+-/", "", $name); - $name = "wpid{$old_file->ID}-{$filename}"; - } - - $upload = wp_upload_bits($name, $type, $bits); - if ( ! empty($upload['error']) ) { - $errorString = sprintf(__('Could not write file %1$s (%2$s)'), $name, $upload['error']); - logIO('O', '(MW) ' . $errorString); - return new IXR_Error(500, $errorString); - } - // Construct the attachment array - // attach to post_id 0 - $post_id = 0; - $attachment = array( - 'post_title' => $name, - 'post_content' => '', - 'post_type' => 'attachment', - 'post_parent' => $post_id, - 'post_mime_type' => $type, - 'guid' => $upload[ 'url' ] - ); - - // Save the data - $id = wp_insert_attachment( $attachment, $upload[ 'file' ], $post_id ); - wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $upload['file'] ) ); - - return apply_filters( 'wp_handle_upload', array( 'file' => $name, 'url' => $upload[ 'url' ], 'type' => $type ), 'upload' ); - } - - /* MovableType API functions - * specs on http://www.movabletype.org/docs/mtmanual_programmatic.html - */ - - /** - * Retrieve the post titles of recent posts. - * - * @since 1.5.0 - * - * @param array $args Method parameters. - * @return array - */ - function mt_getRecentPostTitles($args) { - - $this->escape($args); - - $blog_ID = (int) $args[0]; - $username = $args[1]; - $password = $args[2]; - $num_posts = (int) $args[3]; - - if ( !$user = $this->login($username, $password) ) - return $this->error; - - do_action('xmlrpc_call', 'mt.getRecentPostTitles'); - - $posts_list = wp_get_recent_posts($num_posts); - - if ( !$posts_list ) { - $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); - return $this->error; - } - - foreach ($posts_list as $entry) { - if ( !current_user_can( 'edit_post', $entry['ID'] ) ) - continue; - - $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date'], false); - $post_date_gmt = mysql2date('Ymd\TH:i:s', $entry['post_date_gmt'], false); - - // For drafts use the GMT version of the date - if ( $entry['post_status'] == 'draft' ) - $post_date_gmt = get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $entry['post_date'] ), 'Ymd\TH:i:s' ); - - $struct[] = array( - 'dateCreated' => new IXR_Date($post_date), - 'userid' => $entry['post_author'], - 'postid' => $entry['ID'], - 'title' => $entry['post_title'], - 'date_created_gmt' => new IXR_Date($post_date_gmt) - ); - - } - - $recent_posts = array(); - for ( $j=0; $jescape($args); - - $blog_ID = (int) $args[0]; - $username = $args[1]; - $password = $args[2]; - - if ( !$user = $this->login($username, $password) ) - return $this->error; - - if ( !current_user_can( 'edit_posts' ) ) - return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); - - do_action('xmlrpc_call', 'mt.getCategoryList'); - - $categories_struct = array(); - - if ( $cats = get_categories(array('hide_empty' => 0, 'hierarchical' => 0)) ) { - foreach ( $cats as $cat ) { - $struct['categoryId'] = $cat->term_id; - $struct['categoryName'] = $cat->name; - - $categories_struct[] = $struct; - } - } - - return $categories_struct; - } - - /** - * Retrieve post categories. - * - * @since 1.5.0 - * - * @param array $args Method parameters. - * @return array - */ - function mt_getPostCategories($args) { - - $this->escape($args); - - $post_ID = (int) $args[0]; - $username = $args[1]; - $password = $args[2]; - - if ( !$user = $this->login($username, $password) ) - return $this->error; - - if ( !current_user_can( 'edit_post', $post_ID ) ) - return new IXR_Error( 401, __( 'Sorry, you can not edit this post.' ) ); - - do_action('xmlrpc_call', 'mt.getPostCategories'); - - $categories = array(); - $catids = wp_get_post_categories(intval($post_ID)); - // first listed category will be the primary category - $isPrimary = true; - foreach ( $catids as $catid ) { - $categories[] = array( - 'categoryName' => get_cat_name($catid), - 'categoryId' => (string) $catid, - 'isPrimary' => $isPrimary - ); - $isPrimary = false; - } - - return $categories; - } - - /** - * Sets categories for a post. - * - * @since 1.5.0 - * - * @param array $args Method parameters. - * @return bool True on success. - */ - function mt_setPostCategories($args) { - - $this->escape($args); - - $post_ID = (int) $args[0]; - $username = $args[1]; - $password = $args[2]; - $categories = $args[3]; - - if ( !$user = $this->login($username, $password) ) - return $this->error; - - do_action('xmlrpc_call', 'mt.setPostCategories'); - - if ( !current_user_can('edit_post', $post_ID) ) - return new IXR_Error(401, __('Sorry, you cannot edit this post.')); - - foreach ( $categories as $cat ) { - $catids[] = $cat['categoryId']; - } - - wp_set_post_categories($post_ID, $catids); - - return true; - } - - /** - * Retrieve an array of methods supported by this server. - * - * @since 1.5.0 - * - * @param array $args Method parameters. - * @return array - */ - function mt_supportedMethods($args) { - - do_action('xmlrpc_call', 'mt.supportedMethods'); - - $supported_methods = array(); - foreach ( $this->methods as $key => $value ) { - $supported_methods[] = $key; - } - - return $supported_methods; - } - - /** - * Retrieve an empty array because we don't support per-post text filters. - * - * @since 1.5.0 - * - * @param array $args Method parameters. - */ - function mt_supportedTextFilters($args) { - do_action('xmlrpc_call', 'mt.supportedTextFilters'); - return apply_filters('xmlrpc_text_filters', array()); - } - - /** - * Retrieve trackbacks sent to a given post. - * - * @since 1.5.0 - * - * @param array $args Method parameters. - * @return mixed - */ - function mt_getTrackbackPings($args) { - - global $wpdb; - - $post_ID = intval($args); - - do_action('xmlrpc_call', 'mt.getTrackbackPings'); - - $actual_post = wp_get_single_post($post_ID, ARRAY_A); - - if ( !$actual_post ) - return new IXR_Error(404, __('Sorry, no such post.')); - - $comments = $wpdb->get_results( $wpdb->prepare("SELECT comment_author_url, comment_content, comment_author_IP, comment_type FROM $wpdb->comments WHERE comment_post_ID = %d", $post_ID) ); - - if ( !$comments ) - return array(); - - $trackback_pings = array(); - foreach ( $comments as $comment ) { - if ( 'trackback' == $comment->comment_type ) { - $content = $comment->comment_content; - $title = substr($content, 8, (strpos($content, '') - 8)); - $trackback_pings[] = array( - 'pingTitle' => $title, - 'pingURL' => $comment->comment_author_url, - 'pingIP' => $comment->comment_author_IP - ); - } - } - - return $trackback_pings; - } - - /** - * Sets a post's publish status to 'publish'. - * - * @since 1.5.0 - * - * @param array $args Method parameters. - * @return int - */ - function mt_publishPost($args) { - - $this->escape($args); - - $post_ID = (int) $args[0]; - $username = $args[1]; - $password = $args[2]; - - if ( !$user = $this->login($username, $password) ) - return $this->error; - - do_action('xmlrpc_call', 'mt.publishPost'); - - if ( !current_user_can('publish_posts') || !current_user_can('edit_post', $post_ID) ) - return new IXR_Error(401, __('Sorry, you cannot edit this post.')); - - $postdata = wp_get_single_post($post_ID,ARRAY_A); - - $postdata['post_status'] = 'publish'; - - // retain old cats - $cats = wp_get_post_categories($post_ID); - $postdata['post_category'] = $cats; - $this->escape($postdata); - - $result = wp_update_post($postdata); - - return $result; - } - - /* PingBack functions - * specs on www.hixie.ch/specs/pingback/pingback - */ - - /** - * Retrieves a pingback and registers it. - * - * @since 1.5.0 - * - * @param array $args Method parameters. - * @return array - */ - function pingback_ping($args) { - global $wpdb; - - do_action('xmlrpc_call', 'pingback.ping'); - - $this->escape($args); - - $pagelinkedfrom = $args[0]; - $pagelinkedto = $args[1]; - - $title = ''; - - $pagelinkedfrom = str_replace('&', '&', $pagelinkedfrom); - $pagelinkedto = str_replace('&', '&', $pagelinkedto); - $pagelinkedto = str_replace('&', '&', $pagelinkedto); - - // Check if the page linked to is in our site - $pos1 = strpos($pagelinkedto, str_replace(array('http://www.','http://','https://www.','https://'), '', get_option('home'))); - if ( !$pos1 ) - return new IXR_Error(0, __('Is there no link to us?')); - - // let's find which post is linked to - // FIXME: does url_to_postid() cover all these cases already? - // if so, then let's use it and drop the old code. - $urltest = parse_url($pagelinkedto); - if ( $post_ID = url_to_postid($pagelinkedto) ) { - $way = 'url_to_postid()'; - } elseif ( preg_match('#p/[0-9]{1,}#', $urltest['path'], $match) ) { - // the path defines the post_ID (archives/p/XXXX) - $blah = explode('/', $match[0]); - $post_ID = (int) $blah[1]; - $way = 'from the path'; - } elseif ( preg_match('#p=[0-9]{1,}#', $urltest['query'], $match) ) { - // the querystring defines the post_ID (?p=XXXX) - $blah = explode('=', $match[0]); - $post_ID = (int) $blah[1]; - $way = 'from the querystring'; - } elseif ( isset($urltest['fragment']) ) { - // an #anchor is there, it's either... - if ( intval($urltest['fragment']) ) { - // ...an integer #XXXX (simpliest case) - $post_ID = (int) $urltest['fragment']; - $way = 'from the fragment (numeric)'; - } elseif ( preg_match('/post-[0-9]+/',$urltest['fragment']) ) { - // ...a post id in the form 'post-###' - $post_ID = preg_replace('/[^0-9]+/', '', $urltest['fragment']); - $way = 'from the fragment (post-###)'; - } elseif ( is_string($urltest['fragment']) ) { - // ...or a string #title, a little more complicated - $title = preg_replace('/[^a-z0-9]/i', '.', $urltest['fragment']); - $sql = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_title RLIKE %s", $title); - if (! ($post_ID = $wpdb->get_var($sql)) ) { - // returning unknown error '0' is better than die()ing - return new IXR_Error(0, ''); - } - $way = 'from the fragment (title)'; - } - } else { - // TODO: Attempt to extract a post ID from the given URL - return new IXR_Error(33, __('The specified target URL cannot be used as a target. It either doesn’t exist, or it is not a pingback-enabled resource.')); - } - $post_ID = (int) $post_ID; - - - logIO("O","(PB) URL='$pagelinkedto' ID='$post_ID' Found='$way'"); - - $post = get_post($post_ID); - - if ( !$post ) // Post_ID not found - return new IXR_Error(33, __('The specified target URL cannot be used as a target. It either doesn’t exist, or it is not a pingback-enabled resource.')); - - if ( $post_ID == url_to_postid($pagelinkedfrom) ) - return new IXR_Error(0, __('The source URL and the target URL cannot both point to the same resource.')); - - // Check if pings are on - if ( !pings_open($post) ) - return new IXR_Error(33, __('The specified target URL cannot be used as a target. It either doesn’t exist, or it is not a pingback-enabled resource.')); - - // Let's check that the remote site didn't already pingback this entry - if ( $wpdb->get_results( $wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_author_url = %s", $post_ID, $pagelinkedfrom) ) ) - return new IXR_Error( 48, __( 'The pingback has already been registered.' ) ); - - // very stupid, but gives time to the 'from' server to publish ! - sleep(1); - - // Let's check the remote site - $linea = wp_remote_fopen( $pagelinkedfrom ); - if ( !$linea ) - return new IXR_Error(16, __('The source URL does not exist.')); - - $linea = apply_filters('pre_remote_source', $linea, $pagelinkedto); - - // Work around bug in strip_tags(): - $linea = str_replace(']*>/", "\n\n", $linea ); - - preg_match('|([^<]*?)|is', $linea, $matchtitle); - $title = $matchtitle[1]; - if ( empty( $title ) ) - return new IXR_Error(32, __('We cannot find a title on that page.')); - - $linea = strip_tags( $linea, '' ); // just keep the tag we need - - $p = explode( "\n\n", $linea ); - - $preg_target = preg_quote($pagelinkedto, '|'); - - foreach ( $p as $para ) { - if ( strpos($para, $pagelinkedto) !== false ) { // it exists, but is it a link? - preg_match("|]+?".$preg_target."[^>]*>([^>]+?)|", $para, $context); - - // If the URL isn't in a link context, keep looking - if ( empty($context) ) - continue; - - // We're going to use this fake tag to mark the context in a bit - // the marker is needed in case the link text appears more than once in the paragraph - $excerpt = preg_replace('|\|', '', $para); - - // prevent really long link text - if ( strlen($context[1]) > 100 ) - $context[1] = substr($context[1], 0, 100) . '...'; - - $marker = ''.$context[1].''; // set up our marker - $excerpt= str_replace($context[0], $marker, $excerpt); // swap out the link for our marker - $excerpt = strip_tags($excerpt, ''); // strip all tags but our context marker - $excerpt = trim($excerpt); - $preg_marker = preg_quote($marker, '|'); - $excerpt = preg_replace("|.*?\s(.{0,100}$preg_marker.{0,100})\s.*|s", '$1', $excerpt); - $excerpt = strip_tags($excerpt); // YES, again, to remove the marker wrapper - break; - } - } - - if ( empty($context) ) // Link to target not found - return new IXR_Error(17, __('The source URL does not contain a link to the target URL, and so cannot be used as a source.')); - - $pagelinkedfrom = str_replace('&', '&', $pagelinkedfrom); - - $context = '[...] ' . esc_html( $excerpt ) . ' [...]'; - $pagelinkedfrom = $wpdb->escape( $pagelinkedfrom ); - - $comment_post_ID = (int) $post_ID; - $comment_author = $title; - $this->escape($comment_author); - $comment_author_url = $pagelinkedfrom; - $comment_content = $context; - $this->escape($comment_content); - $comment_type = 'pingback'; - - $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_content', 'comment_type'); - - $comment_ID = wp_new_comment($commentdata); - do_action('pingback_post', $comment_ID); - - return sprintf(__('Pingback from %1$s to %2$s registered. Keep the web talking! :-)'), $pagelinkedfrom, $pagelinkedto); - } - - /** - * Retrieve array of URLs that pingbacked the given URL. - * - * Specs on http://www.aquarionics.com/misc/archives/blogite/0198.html - * - * @since 1.5.0 - * - * @param array $args Method parameters. - * @return array - */ - function pingback_extensions_getPingbacks($args) { - - global $wpdb; - - do_action('xmlrpc_call', 'pingback.extensions.getPingbacks'); - - $this->escape($args); - - $url = $args; - - $post_ID = url_to_postid($url); - if ( !$post_ID ) { - // We aren't sure that the resource is available and/or pingback enabled - return new IXR_Error(33, __('The specified target URL cannot be used as a target. It either doesn’t exist, or it is not a pingback-enabled resource.')); - } - - $actual_post = wp_get_single_post($post_ID, ARRAY_A); - - if ( !$actual_post ) { - // No such post = resource not found - return new IXR_Error(32, __('The specified target URL does not exist.')); - } - - $comments = $wpdb->get_results( $wpdb->prepare("SELECT comment_author_url, comment_content, comment_author_IP, comment_type FROM $wpdb->comments WHERE comment_post_ID = %d", $post_ID) ); - - if ( !$comments ) - return array(); - - $pingbacks = array(); - foreach ( $comments as $comment ) { - if ( 'pingback' == $comment->comment_type ) - $pingbacks[] = $comment->comment_author_url; - } - - return $pingbacks; - } -} +// Allow for a plugin to insert a different class to handle requests. +$wp_xmlrpc_server_class = apply_filters('wp_xmlrpc_server_class', 'wp_xmlrpc_server'); +$wp_xmlrpc_server = new $wp_xmlrpc_server_class; -$wp_xmlrpc_server = new wp_xmlrpc_server(); +// Fire off the request $wp_xmlrpc_server->serve_request(); ?> \ No newline at end of file -- 2.44.0
        '+j.renderHTML()+""+j.renderHTML()+"