code stringlengths 1 2.01M | repo_name stringlengths 3 62 | path stringlengths 1 267 | language stringclasses 231
values | license stringclasses 13
values | size int64 1 2.01M |
|---|---|---|---|---|---|
// assign default value to all undefined variables
// core variables
$text-color: #fff !default;
$base-color: #222 !default;
$icon-color: hsl( hue( $base-color ), 7%, 95% ) !default;
$highlight-color: #0074a2 !default;
$notification-color: #d54e21 !default;
// global
$body-background: #f1f1f1 !default;
$link: #0074a2 !default;
$link-focus: lighten( $link, 10% ) !default;
$button-color: $highlight-color !default;
$form-checked: $highlight-color !default;
// admin menu & admin-bar
$menu-text: $text-color !default;
$menu-icon: $icon-color !default;
$menu-background: $base-color !default;
$menu-highlight-text: $text-color !default;
$menu-highlight-icon: $text-color !default;
$menu-highlight-background: $highlight-color !default;
$menu-current-text: $menu-highlight-text !default;
$menu-current-icon: $menu-highlight-icon !default;
$menu-current-background: $menu-highlight-background !default;
$menu-submenu-text: mix( $base-color, $text-color, 30% ) !default;
$menu-submenu-background: darken( $base-color, 7% ) !default;
$menu-submenu-background-alt: desaturate( lighten( $menu-background, 7% ), 7% ) !default;
$menu-submenu-focus-text: $highlight-color !default;
$menu-submenu-current-text: $text-color !default;
$menu-bubble-text: $text-color !default;
$menu-bubble-background: $notification-color !default;
$menu-bubble-current-text: $text-color !default;
$menu-bubble-current-background: $menu-submenu-background !default;
$menu-collapse-text: $menu-icon !default;
$menu-collapse-icon: $menu-icon !default;
$menu-collapse-focus-text: $text-color !default;
$menu-collapse-focus-icon: $menu-highlight-icon !default;
$adminbar-avatar-frame: lighten( $menu-background, 7% ) !default;
$adminbar-input-background: lighten( $menu-background, 7% ) !default;
$menu-customizer-text: mix( $base-color, $text-color, 40% ) !default;
| 01-wordpress-paypal | trunk/wp-admin/css/colors/_variables.scss | SCSS | gpl3 | 1,851 |
/*
* Button mixin- creates 3d-ish button effect with correct
* highlights/shadows, based on a base color.
*/
html {
background: #f5f5f5; }
/* Links */
a {
color: #0074a2; }
a:hover, a:active, a:focus {
color: #0099d5; }
#media-upload a.del-link:hover, div.dashboard-widget-submit input:hover, .subsubsub a:hover, .subsubsub a.current:hover {
color: #0099d5; }
/* Forms */
input[type=checkbox]:checked:before {
color: #04a4cc; }
input[type=radio]:checked:before {
background: #04a4cc; }
.wp-core-ui input[type="reset"]:hover, .wp-core-ui input[type="reset"]:active {
color: #0099d5; }
/* Core UI */
.wp-core-ui .button-primary {
background: #04a4cc;
border-color: #037c9a;
color: white;
-webkit-box-shadow: inset 0 1px 0 #22cffb, 0 1px 0 rgba(0, 0, 0, 0.15);
box-shadow: inset 0 1px 0 #22cffb, 0 1px 0 rgba(0, 0, 0, 0.15); }
.wp-core-ui .button-primary:hover, .wp-core-ui .button-primary:focus {
background: #0490b3;
border-color: #036881;
color: white;
-webkit-box-shadow: inset 0 1px 0 #09cafa, 0 1px 0 rgba(0, 0, 0, 0.15);
box-shadow: inset 0 1px 0 #09cafa, 0 1px 0 rgba(0, 0, 0, 0.15); }
.wp-core-ui .button-primary:active {
background: #037c9a;
border-color: #036881;
color: white;
-webkit-box-shadow: inset 0 2px 5px -3px rgba(0, 0, 0, 0.5);
box-shadow: inset 0 2px 5px -3px rgba(0, 0, 0, 0.5); }
.wp-core-ui .button-primary[disabled], .wp-core-ui .button-primary:disabled, .wp-core-ui .button-primary.button-primary-disabled, .wp-core-ui .button-primary.disabled {
color: #c7cfd1 !important;
background: #0384a4 !important;
border-color: #036881 !important;
text-shadow: none !important; }
.wp-core-ui .wp-ui-primary {
color: #333;
background-color: #e5e5e5; }
.wp-core-ui .wp-ui-text-primary {
color: #e5e5e5; }
.wp-core-ui .wp-ui-highlight {
color: #fff;
background-color: #888; }
.wp-core-ui .wp-ui-text-highlight {
color: #888; }
.wp-core-ui .wp-ui-notification {
color: #fff;
background-color: #d64e07; }
.wp-core-ui .wp-ui-text-notification {
color: #d64e07; }
.wp-core-ui .wp-ui-text-icon {
color: #999; }
/* List tables */
.wrap .add-new-h2:hover, #add-new-comment a:hover, .tablenav .tablenav-pages a:hover, .tablenav .tablenav-pages a:focus {
color: #333;
background-color: #e5e5e5; }
.view-switch a.current:before {
color: #e5e5e5; }
.view-switch a:hover:before {
color: #d64e07; }
.post-com-count:hover:after {
border-top-color: #e5e5e5; }
.post-com-count:hover span {
color: #333;
background-color: #e5e5e5; }
strong .post-com-count:after {
border-top-color: #d64e07; }
strong .post-com-count span {
background-color: #d64e07; }
/* Admin Menu */
#adminmenuback, #adminmenuwrap, #adminmenu {
background: #e5e5e5; }
#adminmenu a {
color: #333; }
#adminmenu div.wp-menu-image:before {
color: #999; }
#adminmenu a:hover, #adminmenu li.menu-top:hover, #adminmenu li.opensub > a.menu-top, #adminmenu li > a.menu-top:focus {
color: #fff;
background-color: #888; }
#adminmenu li.menu-top:hover div.wp-menu-image:before, #adminmenu li.opensub > a.menu-top div.wp-menu-image:before {
color: #ccc; }
/* Active tabs use a bottom border color that matches the page background color. */
.about-wrap h2 .nav-tab-active, .nav-tab-active, .nav-tab-active:hover {
background-color: #f5f5f5;
border-bottom-color: #f5f5f5; }
/* Admin Menu: submenu */
#adminmenu .wp-submenu, #adminmenu .wp-has-current-submenu .wp-submenu, #adminmenu .wp-has-current-submenu.opensub .wp-submenu, .folded #adminmenu .wp-has-current-submenu .wp-submenu, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu {
background: #fff; }
#adminmenu li.wp-has-submenu.wp-not-current-submenu.opensub:hover:after {
border-right-color: #fff; }
#adminmenu .wp-submenu .wp-submenu-head {
color: #686868; }
#adminmenu .wp-submenu a, #adminmenu .wp-has-current-submenu .wp-submenu a, .folded #adminmenu .wp-has-current-submenu .wp-submenu a, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu a, #adminmenu .wp-has-current-submenu.opensub .wp-submenu a {
color: #686868; }
#adminmenu .wp-submenu a:focus, #adminmenu .wp-submenu a:hover, #adminmenu .wp-has-current-submenu .wp-submenu a:focus, #adminmenu .wp-has-current-submenu .wp-submenu a:hover, .folded #adminmenu .wp-has-current-submenu .wp-submenu a:focus, .folded #adminmenu .wp-has-current-submenu .wp-submenu a:hover, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu a:focus, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu a:hover, #adminmenu .wp-has-current-submenu.opensub .wp-submenu a:focus, #adminmenu .wp-has-current-submenu.opensub .wp-submenu a:hover {
color: #04a4cc; }
/* Admin Menu: current */
#adminmenu .wp-submenu li.current a, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a, #adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a {
color: #333; }
#adminmenu .wp-submenu li.current a:hover, #adminmenu .wp-submenu li.current a:focus, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a:hover, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a:focus, #adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:hover, #adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:focus {
color: #04a4cc; }
ul#adminmenu a.wp-has-current-submenu:after, ul#adminmenu > li.current > a.current:after {
border-right-color: #f5f5f5; }
#adminmenu li.current a.menu-top, #adminmenu li.wp-has-current-submenu a.wp-has-current-submenu, #adminmenu li.wp-has-current-submenu .wp-submenu .wp-submenu-head, .folded #adminmenu li.current.menu-top {
color: #fff;
background: #888; }
#adminmenu li.wp-has-current-submenu div.wp-menu-image:before {
color: #ccc; }
/* Admin Menu: bubble */
#adminmenu .awaiting-mod, #adminmenu .update-plugins {
color: #fff;
background: #d64e07; }
#adminmenu li.current a .awaiting-mod, #adminmenu li a.wp-has-current-submenu .update-plugins, #adminmenu li:hover a .awaiting-mod, #adminmenu li.menu-top:hover > a .update-plugins {
color: #333;
background: #fff; }
/* Admin Menu: collapse button */
#collapse-menu {
color: #777; }
#collapse-menu:hover {
color: #333; }
#collapse-button div:after {
color: #999; }
#collapse-menu:hover #collapse-button div:after {
color: #555; }
/* Admin Bar */
#wpadminbar {
color: #333;
background: #e5e5e5; }
#wpadminbar .ab-item, #wpadminbar a.ab-item, #wpadminbar > #wp-toolbar span.ab-label, #wpadminbar > #wp-toolbar span.noticon {
color: #333; }
#wpadminbar .ab-icon, #wpadminbar .ab-icon:before, #wpadminbar .ab-item:before, #wpadminbar .ab-item:after {
color: #999; }
#wpadminbar .ab-top-menu > li:hover > .ab-item, #wpadminbar .ab-top-menu > li.hover > .ab-item, #wpadminbar .ab-top-menu > li > .ab-item:focus, #wpadminbar.nojq .quicklinks .ab-top-menu > li > .ab-item:focus, #wpadminbar-nojs .ab-top-menu > li.menupop:hover > .ab-item, #wpadminbar .ab-top-menu > li.menupop.hover > .ab-item {
color: #04a4cc;
background: #fff; }
#wpadminbar > #wp-toolbar li:hover span.ab-label, #wpadminbar > #wp-toolbar li.hover span.ab-label, #wpadminbar > #wp-toolbar a:focus span.ab-label {
color: #04a4cc; }
#wpadminbar li:hover .ab-icon:before, #wpadminbar li:hover .ab-item:before, #wpadminbar li:hover .ab-item:after, #wpadminbar li:hover #adminbarsearch:before {
color: #ccc; }
/* Admin Bar: submenu */
#wpadminbar .menupop .ab-sub-wrapper {
background: #fff; }
#wpadminbar .quicklinks .menupop ul.ab-sub-secondary, #wpadminbar .quicklinks .menupop ul.ab-sub-secondary .ab-submenu {
background: #f6f7f7; }
#wpadminbar .ab-submenu .ab-item, #wpadminbar .quicklinks .menupop ul li a, #wpadminbar .quicklinks .menupop.hover ul li a, #wpadminbar-nojs .quicklinks .menupop:hover ul li a {
color: #686868; }
#wpadminbar .quicklinks li .blavatar, #wpadminbar .menupop .menupop > .ab-item:before {
color: #999; }
#wpadminbar .quicklinks .menupop ul li a:hover, #wpadminbar .quicklinks .menupop ul li a:focus, #wpadminbar .quicklinks .menupop ul li a:hover strong, #wpadminbar .quicklinks .menupop ul li a:focus strong, #wpadminbar .quicklinks .menupop.hover ul li a:hover, #wpadminbar .quicklinks .menupop.hover ul li a:focus, #wpadminbar.nojs .quicklinks .menupop:hover ul li a:hover, #wpadminbar.nojs .quicklinks .menupop:hover ul li a:focus, #wpadminbar li:hover .ab-icon:before, #wpadminbar li:hover .ab-item:before, #wpadminbar li a:focus .ab-icon:before, #wpadminbar li .ab-item:focus:before, #wpadminbar li.hover .ab-icon:before, #wpadminbar li.hover .ab-item:before, #wpadminbar li:hover .ab-item:after, #wpadminbar li.hover .ab-item:after, #wpadminbar li:hover #adminbarsearch:before {
color: #04a4cc; }
#wpadminbar .quicklinks li a:hover .blavatar, #wpadminbar .menupop .menupop > .ab-item:hover:before {
color: #04a4cc; }
/* Admin Bar: search */
#wpadminbar #adminbarsearch:before {
color: #999; }
#wpadminbar > #wp-toolbar > #wp-admin-bar-top-secondary > #wp-admin-bar-search #adminbarsearch input.adminbar-input:focus {
color: #333;
background: #f7f7f7; }
#wpadminbar #adminbarsearch .adminbar-input::-webkit-input-placeholder {
color: #333;
opacity: 0.7; }
#wpadminbar #adminbarsearch .adminbar-input:-moz-placeholder {
color: #333;
opacity: 0.7; }
#wpadminbar #adminbarsearch .adminbar-input::-moz-placeholder {
color: #333;
opacity: 0.7; }
#wpadminbar #adminbarsearch .adminbar-input:-ms-input-placeholder {
color: #333;
opacity: 0.7; }
/* Admin Bar: my account */
#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar > a img {
border-color: #f7f7f7;
background-color: #f7f7f7; }
#wpadminbar #wp-admin-bar-user-info .display-name {
color: #333; }
#wpadminbar #wp-admin-bar-user-info a:hover .display-name {
color: #04a4cc; }
#wpadminbar #wp-admin-bar-user-info .username {
color: #686868; }
/* Pointers */
.wp-pointer .wp-pointer-content h3 {
background-color: #04a4cc;
border-color: #0490b3; }
.wp-pointer .wp-pointer-content h3:before {
color: #04a4cc; }
.wp-pointer.wp-pointer-top .wp-pointer-arrow, .wp-pointer.wp-pointer-undefined .wp-pointer-arrow {
border-bottom-color: #04a4cc; }
/* Media Uploader */
.media-item .bar, .media-progress-bar div {
background-color: #04a4cc; }
.details.attachment {
-webkit-box-shadow: 0 0 0 1px #fff, 0 0 0 5px #04a4cc;
box-shadow: 0 0 0 1px #fff, 0 0 0 5px #04a4cc; }
.attachment.details .check {
background-color: #04a4cc;
-webkit-box-shadow: 0 0 0 1px #fff, 0 0 0 2px #04a4cc;
box-shadow: 0 0 0 1px #fff, 0 0 0 2px #04a4cc; }
/* Themes */
.theme-browser .theme.active .theme-name, .theme-browser .theme.add-new-theme:hover:after {
background: #04a4cc; }
.theme-browser .theme.add-new-theme:hover span:after {
color: #04a4cc; }
.theme-overlay .theme-header .close:hover, .theme-overlay .theme-header .right:hover, .theme-overlay .theme-header .left:hover {
background: #04a4cc; }
.theme-section.current, .theme-filter.current {
border-bottom-color: #e5e5e5; }
body.more-filters-opened .more-filters, body.more-filters-opened .more-filters:before {
color: #333;
background-color: #e5e5e5; }
body.more-filters-opened .more-filters:hover, body.more-filters-opened .more-filters:focus, body.more-filters-opened .more-filters:hover:before, body.more-filters-opened .more-filters:focus:before {
background-color: #888;
color: #fff; }
/* Widgets */
.widgets-chooser li.widgets-chooser-selected {
background-color: #888;
color: #fff; }
.widgets-chooser li.widgets-chooser-selected:before, .widgets-chooser li.widgets-chooser-selected:focus:before {
color: #fff; }
/* Customize */
#customize-theme-controls .widget-area-select .selected {
background-color: #888;
color: #fff; }
/* jQuery UI Slider */
.wp-slider .ui-slider-handle, .wp-slider .ui-slider-handle.ui-state-hover, .wp-slider .ui-slider-handle.focus {
background: #04a4cc;
border-color: #037c9a;
-webkit-box-shadow: inset 0 1px 0 #22cffb, 0 1px 0 rgba(0, 0, 0, 0.15);
box-shadow: inset 0 1px 0 #22cffb, 0 1px 0 rgba(0, 0, 0, 0.15); }
/* Thickbox: Plugin information */
#sidemenu a.current {
background: #f5f5f5;
border-bottom-color: #f5f5f5; }
#plugin-information .action-button {
background: #04a4cc; }
/* Responsive Component */
div#wp-responsive-toggle a:before {
color: #999; }
.wp-responsive-open div#wp-responsive-toggle a {
border-color: transparent;
background: #888; }
.star-rating .star {
color: #04a4cc; }
.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle a {
background: #fff; }
/* temporary fix for admin-bar hover color */
#wpadminbar .ab-top-menu > li:hover > .ab-item, #wpadminbar .ab-top-menu > li.hover > .ab-item, #wpadminbar > #wp-toolbar > #wp-admin-bar-root-default li:hover span.ab-label, #wpadminbar > #wp-toolbar > #wp-admin-bar-top-secondary li.hover span.ab-label, #wpadminbar .ab-top-menu > li > .ab-item:focus, #wpadminbar.nojq .quicklinks .ab-top-menu > li > .ab-item:focus, #wpadminbar-nojs .ab-top-menu > li.menupop:hover > .ab-item, #wpadminbar .ab-top-menu > li.menupop.hover > .ab-item {
color: #333; }
/* Override the theme filter highlight color for this scheme */
.theme-section.current, .theme-filter.current {
border-bottom-color: #04a4cc; }
| 01-wordpress-paypal | trunk/wp-admin/css/colors/light/colors.css | CSS | gpl3 | 13,300 |
$base-color: #e5e5e5;
$icon-color: #999;
$text-color: #333;
$highlight-color: #04a4cc;
$notification-color: #d64e07;
$body-background: #f5f5f5;
$menu-highlight-text: #fff;
$menu-highlight-icon: #ccc;
$menu-highlight-background: #888;
$menu-bubble-text: #fff;
$menu-avatar-frame: #aaa;
$menu-submenu-background: #fff;
$menu-collapse-text: #777;
$menu-collapse-focus-icon: #555;
@import "../_admin.scss";
/* temporary fix for admin-bar hover color */
#wpadminbar .ab-top-menu > li:hover > .ab-item,
#wpadminbar .ab-top-menu > li.hover > .ab-item,
#wpadminbar > #wp-toolbar > #wp-admin-bar-root-default li:hover span.ab-label,
#wpadminbar > #wp-toolbar > #wp-admin-bar-top-secondary li.hover span.ab-label,
#wpadminbar .ab-top-menu > li > .ab-item:focus,
#wpadminbar.nojq .quicklinks .ab-top-menu > li > .ab-item:focus,
#wpadminbar-nojs .ab-top-menu > li.menupop:hover > .ab-item,
#wpadminbar .ab-top-menu > li.menupop.hover > .ab-item {
color: $text-color;
}
/* Override the theme filter highlight color for this scheme */
.theme-section.current,
.theme-filter.current {
border-bottom-color: $highlight-color;
}
| 01-wordpress-paypal | trunk/wp-admin/css/colors/light/colors.scss | SCSS | gpl3 | 1,119 |
/*
* Button mixin- creates 3d-ish button effect with correct
* highlights/shadows, based on a base color.
*/
html {
background: #f5f5f5; }
/* Links */
a {
color: #0074a2; }
a:hover, a:active, a:focus {
color: #0099d5; }
#media-upload a.del-link:hover, div.dashboard-widget-submit input:hover, .subsubsub a:hover, .subsubsub a.current:hover {
color: #0099d5; }
/* Forms */
input[type=checkbox]:checked:before {
color: #04a4cc; }
input[type=radio]:checked:before {
background: #04a4cc; }
.wp-core-ui input[type="reset"]:hover, .wp-core-ui input[type="reset"]:active {
color: #0099d5; }
/* Core UI */
.wp-core-ui .button-primary {
background: #04a4cc;
border-color: #037c9a;
color: white;
-webkit-box-shadow: inset 0 1px 0 #22cffb, 0 1px 0 rgba(0, 0, 0, 0.15);
box-shadow: inset 0 1px 0 #22cffb, 0 1px 0 rgba(0, 0, 0, 0.15); }
.wp-core-ui .button-primary:hover, .wp-core-ui .button-primary:focus {
background: #0490b3;
border-color: #036881;
color: white;
-webkit-box-shadow: inset 0 1px 0 #09cafa, 0 1px 0 rgba(0, 0, 0, 0.15);
box-shadow: inset 0 1px 0 #09cafa, 0 1px 0 rgba(0, 0, 0, 0.15); }
.wp-core-ui .button-primary:active {
background: #037c9a;
border-color: #036881;
color: white;
-webkit-box-shadow: inset 0 2px 5px -3px rgba(0, 0, 0, 0.5);
box-shadow: inset 0 2px 5px -3px rgba(0, 0, 0, 0.5); }
.wp-core-ui .button-primary[disabled], .wp-core-ui .button-primary:disabled, .wp-core-ui .button-primary.button-primary-disabled, .wp-core-ui .button-primary.disabled {
color: #c7cfd1 !important;
background: #0384a4 !important;
border-color: #036881 !important;
text-shadow: none !important; }
.wp-core-ui .wp-ui-primary {
color: #333;
background-color: #e5e5e5; }
.wp-core-ui .wp-ui-text-primary {
color: #e5e5e5; }
.wp-core-ui .wp-ui-highlight {
color: #fff;
background-color: #888; }
.wp-core-ui .wp-ui-text-highlight {
color: #888; }
.wp-core-ui .wp-ui-notification {
color: #fff;
background-color: #d64e07; }
.wp-core-ui .wp-ui-text-notification {
color: #d64e07; }
.wp-core-ui .wp-ui-text-icon {
color: #999; }
/* List tables */
.wrap .add-new-h2:hover, #add-new-comment a:hover, .tablenav .tablenav-pages a:hover, .tablenav .tablenav-pages a:focus {
color: #333;
background-color: #e5e5e5; }
.view-switch a.current:before {
color: #e5e5e5; }
.view-switch a:hover:before {
color: #d64e07; }
.post-com-count:hover:after {
border-top-color: #e5e5e5; }
.post-com-count:hover span {
color: #333;
background-color: #e5e5e5; }
strong .post-com-count:after {
border-top-color: #d64e07; }
strong .post-com-count span {
background-color: #d64e07; }
/* Admin Menu */
#adminmenuback, #adminmenuwrap, #adminmenu {
background: #e5e5e5; }
#adminmenu a {
color: #333; }
#adminmenu div.wp-menu-image:before {
color: #999; }
#adminmenu a:hover, #adminmenu li.menu-top:hover, #adminmenu li.opensub > a.menu-top, #adminmenu li > a.menu-top:focus {
color: #fff;
background-color: #888; }
#adminmenu li.menu-top:hover div.wp-menu-image:before, #adminmenu li.opensub > a.menu-top div.wp-menu-image:before {
color: #ccc; }
/* Active tabs use a bottom border color that matches the page background color. */
.about-wrap h2 .nav-tab-active, .nav-tab-active, .nav-tab-active:hover {
background-color: #f5f5f5;
border-bottom-color: #f5f5f5; }
/* Admin Menu: submenu */
#adminmenu .wp-submenu, #adminmenu .wp-has-current-submenu .wp-submenu, #adminmenu .wp-has-current-submenu.opensub .wp-submenu, .folded #adminmenu .wp-has-current-submenu .wp-submenu, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu {
background: #fff; }
#adminmenu li.wp-has-submenu.wp-not-current-submenu.opensub:hover:after {
border-left-color: #fff; }
#adminmenu .wp-submenu .wp-submenu-head {
color: #686868; }
#adminmenu .wp-submenu a, #adminmenu .wp-has-current-submenu .wp-submenu a, .folded #adminmenu .wp-has-current-submenu .wp-submenu a, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu a, #adminmenu .wp-has-current-submenu.opensub .wp-submenu a {
color: #686868; }
#adminmenu .wp-submenu a:focus, #adminmenu .wp-submenu a:hover, #adminmenu .wp-has-current-submenu .wp-submenu a:focus, #adminmenu .wp-has-current-submenu .wp-submenu a:hover, .folded #adminmenu .wp-has-current-submenu .wp-submenu a:focus, .folded #adminmenu .wp-has-current-submenu .wp-submenu a:hover, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu a:focus, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu a:hover, #adminmenu .wp-has-current-submenu.opensub .wp-submenu a:focus, #adminmenu .wp-has-current-submenu.opensub .wp-submenu a:hover {
color: #04a4cc; }
/* Admin Menu: current */
#adminmenu .wp-submenu li.current a, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a, #adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a {
color: #333; }
#adminmenu .wp-submenu li.current a:hover, #adminmenu .wp-submenu li.current a:focus, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a:hover, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a:focus, #adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:hover, #adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:focus {
color: #04a4cc; }
ul#adminmenu a.wp-has-current-submenu:after, ul#adminmenu > li.current > a.current:after {
border-left-color: #f5f5f5; }
#adminmenu li.current a.menu-top, #adminmenu li.wp-has-current-submenu a.wp-has-current-submenu, #adminmenu li.wp-has-current-submenu .wp-submenu .wp-submenu-head, .folded #adminmenu li.current.menu-top {
color: #fff;
background: #888; }
#adminmenu li.wp-has-current-submenu div.wp-menu-image:before {
color: #ccc; }
/* Admin Menu: bubble */
#adminmenu .awaiting-mod, #adminmenu .update-plugins {
color: #fff;
background: #d64e07; }
#adminmenu li.current a .awaiting-mod, #adminmenu li a.wp-has-current-submenu .update-plugins, #adminmenu li:hover a .awaiting-mod, #adminmenu li.menu-top:hover > a .update-plugins {
color: #333;
background: #fff; }
/* Admin Menu: collapse button */
#collapse-menu {
color: #777; }
#collapse-menu:hover {
color: #333; }
#collapse-button div:after {
color: #999; }
#collapse-menu:hover #collapse-button div:after {
color: #555; }
/* Admin Bar */
#wpadminbar {
color: #333;
background: #e5e5e5; }
#wpadminbar .ab-item, #wpadminbar a.ab-item, #wpadminbar > #wp-toolbar span.ab-label, #wpadminbar > #wp-toolbar span.noticon {
color: #333; }
#wpadminbar .ab-icon, #wpadminbar .ab-icon:before, #wpadminbar .ab-item:before, #wpadminbar .ab-item:after {
color: #999; }
#wpadminbar .ab-top-menu > li:hover > .ab-item, #wpadminbar .ab-top-menu > li.hover > .ab-item, #wpadminbar .ab-top-menu > li > .ab-item:focus, #wpadminbar.nojq .quicklinks .ab-top-menu > li > .ab-item:focus, #wpadminbar-nojs .ab-top-menu > li.menupop:hover > .ab-item, #wpadminbar .ab-top-menu > li.menupop.hover > .ab-item {
color: #04a4cc;
background: #fff; }
#wpadminbar > #wp-toolbar li:hover span.ab-label, #wpadminbar > #wp-toolbar li.hover span.ab-label, #wpadminbar > #wp-toolbar a:focus span.ab-label {
color: #04a4cc; }
#wpadminbar li:hover .ab-icon:before, #wpadminbar li:hover .ab-item:before, #wpadminbar li:hover .ab-item:after, #wpadminbar li:hover #adminbarsearch:before {
color: #ccc; }
/* Admin Bar: submenu */
#wpadminbar .menupop .ab-sub-wrapper {
background: #fff; }
#wpadminbar .quicklinks .menupop ul.ab-sub-secondary, #wpadminbar .quicklinks .menupop ul.ab-sub-secondary .ab-submenu {
background: #f6f7f7; }
#wpadminbar .ab-submenu .ab-item, #wpadminbar .quicklinks .menupop ul li a, #wpadminbar .quicklinks .menupop.hover ul li a, #wpadminbar-nojs .quicklinks .menupop:hover ul li a {
color: #686868; }
#wpadminbar .quicklinks li .blavatar, #wpadminbar .menupop .menupop > .ab-item:before {
color: #999; }
#wpadminbar .quicklinks .menupop ul li a:hover, #wpadminbar .quicklinks .menupop ul li a:focus, #wpadminbar .quicklinks .menupop ul li a:hover strong, #wpadminbar .quicklinks .menupop ul li a:focus strong, #wpadminbar .quicklinks .menupop.hover ul li a:hover, #wpadminbar .quicklinks .menupop.hover ul li a:focus, #wpadminbar.nojs .quicklinks .menupop:hover ul li a:hover, #wpadminbar.nojs .quicklinks .menupop:hover ul li a:focus, #wpadminbar li:hover .ab-icon:before, #wpadminbar li:hover .ab-item:before, #wpadminbar li a:focus .ab-icon:before, #wpadminbar li .ab-item:focus:before, #wpadminbar li.hover .ab-icon:before, #wpadminbar li.hover .ab-item:before, #wpadminbar li:hover .ab-item:after, #wpadminbar li.hover .ab-item:after, #wpadminbar li:hover #adminbarsearch:before {
color: #04a4cc; }
#wpadminbar .quicklinks li a:hover .blavatar, #wpadminbar .menupop .menupop > .ab-item:hover:before {
color: #04a4cc; }
/* Admin Bar: search */
#wpadminbar #adminbarsearch:before {
color: #999; }
#wpadminbar > #wp-toolbar > #wp-admin-bar-top-secondary > #wp-admin-bar-search #adminbarsearch input.adminbar-input:focus {
color: #333;
background: #f7f7f7; }
#wpadminbar #adminbarsearch .adminbar-input::-webkit-input-placeholder {
color: #333;
opacity: 0.7; }
#wpadminbar #adminbarsearch .adminbar-input:-moz-placeholder {
color: #333;
opacity: 0.7; }
#wpadminbar #adminbarsearch .adminbar-input::-moz-placeholder {
color: #333;
opacity: 0.7; }
#wpadminbar #adminbarsearch .adminbar-input:-ms-input-placeholder {
color: #333;
opacity: 0.7; }
/* Admin Bar: my account */
#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar > a img {
border-color: #f7f7f7;
background-color: #f7f7f7; }
#wpadminbar #wp-admin-bar-user-info .display-name {
color: #333; }
#wpadminbar #wp-admin-bar-user-info a:hover .display-name {
color: #04a4cc; }
#wpadminbar #wp-admin-bar-user-info .username {
color: #686868; }
/* Pointers */
.wp-pointer .wp-pointer-content h3 {
background-color: #04a4cc;
border-color: #0490b3; }
.wp-pointer .wp-pointer-content h3:before {
color: #04a4cc; }
.wp-pointer.wp-pointer-top .wp-pointer-arrow, .wp-pointer.wp-pointer-undefined .wp-pointer-arrow {
border-bottom-color: #04a4cc; }
/* Media Uploader */
.media-item .bar, .media-progress-bar div {
background-color: #04a4cc; }
.details.attachment {
-webkit-box-shadow: 0 0 0 1px #fff, 0 0 0 5px #04a4cc;
box-shadow: 0 0 0 1px #fff, 0 0 0 5px #04a4cc; }
.attachment.details .check {
background-color: #04a4cc;
-webkit-box-shadow: 0 0 0 1px #fff, 0 0 0 2px #04a4cc;
box-shadow: 0 0 0 1px #fff, 0 0 0 2px #04a4cc; }
/* Themes */
.theme-browser .theme.active .theme-name, .theme-browser .theme.add-new-theme:hover:after {
background: #04a4cc; }
.theme-browser .theme.add-new-theme:hover span:after {
color: #04a4cc; }
.theme-overlay .theme-header .close:hover, .theme-overlay .theme-header .right:hover, .theme-overlay .theme-header .left:hover {
background: #04a4cc; }
.theme-section.current, .theme-filter.current {
border-bottom-color: #e5e5e5; }
body.more-filters-opened .more-filters, body.more-filters-opened .more-filters:before {
color: #333;
background-color: #e5e5e5; }
body.more-filters-opened .more-filters:hover, body.more-filters-opened .more-filters:focus, body.more-filters-opened .more-filters:hover:before, body.more-filters-opened .more-filters:focus:before {
background-color: #888;
color: #fff; }
/* Widgets */
.widgets-chooser li.widgets-chooser-selected {
background-color: #888;
color: #fff; }
.widgets-chooser li.widgets-chooser-selected:before, .widgets-chooser li.widgets-chooser-selected:focus:before {
color: #fff; }
/* Customize */
#customize-theme-controls .widget-area-select .selected {
background-color: #888;
color: #fff; }
/* jQuery UI Slider */
.wp-slider .ui-slider-handle, .wp-slider .ui-slider-handle.ui-state-hover, .wp-slider .ui-slider-handle.focus {
background: #04a4cc;
border-color: #037c9a;
-webkit-box-shadow: inset 0 1px 0 #22cffb, 0 1px 0 rgba(0, 0, 0, 0.15);
box-shadow: inset 0 1px 0 #22cffb, 0 1px 0 rgba(0, 0, 0, 0.15); }
/* Thickbox: Plugin information */
#sidemenu a.current {
background: #f5f5f5;
border-bottom-color: #f5f5f5; }
#plugin-information .action-button {
background: #04a4cc; }
/* Responsive Component */
div#wp-responsive-toggle a:before {
color: #999; }
.wp-responsive-open div#wp-responsive-toggle a {
border-color: transparent;
background: #888; }
.star-rating .star {
color: #04a4cc; }
.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle a {
background: #fff; }
/* temporary fix for admin-bar hover color */
#wpadminbar .ab-top-menu > li:hover > .ab-item, #wpadminbar .ab-top-menu > li.hover > .ab-item, #wpadminbar > #wp-toolbar > #wp-admin-bar-root-default li:hover span.ab-label, #wpadminbar > #wp-toolbar > #wp-admin-bar-top-secondary li.hover span.ab-label, #wpadminbar .ab-top-menu > li > .ab-item:focus, #wpadminbar.nojq .quicklinks .ab-top-menu > li > .ab-item:focus, #wpadminbar-nojs .ab-top-menu > li.menupop:hover > .ab-item, #wpadminbar .ab-top-menu > li.menupop.hover > .ab-item {
color: #333; }
/* Override the theme filter highlight color for this scheme */
.theme-section.current, .theme-filter.current {
border-bottom-color: #04a4cc; }
| 01-wordpress-paypal | trunk/wp-admin/css/colors/light/colors-rtl.css | CSS | gpl3 | 13,298 |
@import 'variables';
@import 'mixins';
html {
background: $body-background;
}
/* Links */
a {
color: $link;
&:hover,
&:active,
&:focus {
color: $link-focus;
}
}
#media-upload a.del-link:hover,
div.dashboard-widget-submit input:hover,
.subsubsub a:hover,
.subsubsub a.current:hover {
color: $link-focus;
}
/* Forms */
input[type=checkbox]:checked:before {
color: $form-checked;
}
input[type=radio]:checked:before {
background: $form-checked;
}
.wp-core-ui input[type="reset"]:hover,
.wp-core-ui input[type="reset"]:active {
color: $link-focus;
}
/* Core UI */
.wp-core-ui {
.button-primary {
@include button( $button-color );
}
.wp-ui-primary {
color: $text-color;
background-color: $base-color;
}
.wp-ui-text-primary {
color: $base-color;
}
.wp-ui-highlight {
color: $menu-highlight-text;
background-color: $menu-highlight-background;
}
.wp-ui-text-highlight {
color: $menu-highlight-background;
}
.wp-ui-notification {
color: $menu-bubble-text;
background-color: $menu-bubble-background;
}
.wp-ui-text-notification {
color: $menu-bubble-background;
}
.wp-ui-text-icon {
color: $menu-icon;
}
}
/* List tables */
.wrap .add-new-h2:hover,
#add-new-comment a:hover,
.tablenav .tablenav-pages a:hover,
.tablenav .tablenav-pages a:focus {
color: $menu-text;
background-color: $menu-background;
}
.view-switch a.current:before {
color: $menu-background;
}
.view-switch a:hover:before {
color: $menu-bubble-background;
}
.post-com-count:hover:after {
border-top-color: $menu-background;
}
.post-com-count:hover span {
color: $menu-text;
background-color: $menu-background;
}
strong .post-com-count:after {
border-top-color: $menu-bubble-background;
}
strong .post-com-count span {
background-color: $menu-bubble-background;
}
/* Admin Menu */
#adminmenuback,
#adminmenuwrap,
#adminmenu {
background: $menu-background;
}
#adminmenu a {
color: $menu-text;
}
#adminmenu div.wp-menu-image:before {
color: $menu-icon;
}
#adminmenu a:hover,
#adminmenu li.menu-top:hover,
#adminmenu li.opensub > a.menu-top,
#adminmenu li > a.menu-top:focus {
color: $menu-highlight-text;
background-color: $menu-highlight-background;
}
#adminmenu li.menu-top:hover div.wp-menu-image:before,
#adminmenu li.opensub > a.menu-top div.wp-menu-image:before {
color: $menu-highlight-icon;
}
/* Active tabs use a bottom border color that matches the page background color. */
.about-wrap h2 .nav-tab-active,
.nav-tab-active,
.nav-tab-active:hover {
background-color: $body-background;
border-bottom-color: $body-background;
}
/* Admin Menu: submenu */
#adminmenu .wp-submenu,
#adminmenu .wp-has-current-submenu .wp-submenu,
#adminmenu .wp-has-current-submenu.opensub .wp-submenu,
.folded #adminmenu .wp-has-current-submenu .wp-submenu,
#adminmenu a.wp-has-current-submenu:focus + .wp-submenu {
background: $menu-submenu-background;
}
#adminmenu li.wp-has-submenu.wp-not-current-submenu.opensub:hover:after {
border-right-color: $menu-submenu-background;
}
#adminmenu .wp-submenu .wp-submenu-head {
color: $menu-submenu-text;
}
#adminmenu .wp-submenu a,
#adminmenu .wp-has-current-submenu .wp-submenu a,
.folded #adminmenu .wp-has-current-submenu .wp-submenu a,
#adminmenu a.wp-has-current-submenu:focus + .wp-submenu a,
#adminmenu .wp-has-current-submenu.opensub .wp-submenu a {
color: $menu-submenu-text;
&:focus, &:hover {
color: $menu-submenu-focus-text;
}
}
/* Admin Menu: current */
#adminmenu .wp-submenu li.current a,
#adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a,
#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a {
color: $menu-submenu-current-text;
&:hover, &:focus {
color: $menu-submenu-focus-text;
}
}
ul#adminmenu a.wp-has-current-submenu:after,
ul#adminmenu > li.current > a.current:after {
border-right-color: $body-background;
}
#adminmenu li.current a.menu-top,
#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu,
#adminmenu li.wp-has-current-submenu .wp-submenu .wp-submenu-head,
.folded #adminmenu li.current.menu-top {
color: $menu-current-text;
background: $menu-current-background;
}
#adminmenu li.wp-has-current-submenu div.wp-menu-image:before {
color: $menu-current-icon;
}
/* Admin Menu: bubble */
#adminmenu .awaiting-mod,
#adminmenu .update-plugins {
color: $menu-bubble-text;
background: $menu-bubble-background;
}
#adminmenu li.current a .awaiting-mod,
#adminmenu li a.wp-has-current-submenu .update-plugins,
#adminmenu li:hover a .awaiting-mod,
#adminmenu li.menu-top:hover > a .update-plugins {
color: $menu-bubble-current-text;
background: $menu-bubble-current-background;
}
/* Admin Menu: collapse button */
#collapse-menu {
color: $menu-collapse-text;
}
#collapse-menu:hover {
color: $menu-collapse-focus-text;
}
#collapse-button div:after {
color: $menu-collapse-icon;
}
#collapse-menu:hover #collapse-button div:after {
color: $menu-collapse-focus-icon;
}
/* Admin Bar */
#wpadminbar {
color: $menu-text;
background: $menu-background;
}
#wpadminbar .ab-item,
#wpadminbar a.ab-item,
#wpadminbar > #wp-toolbar span.ab-label,
#wpadminbar > #wp-toolbar span.noticon {
color: $menu-text;
}
#wpadminbar .ab-icon,
#wpadminbar .ab-icon:before,
#wpadminbar .ab-item:before,
#wpadminbar .ab-item:after {
color: $menu-icon;
}
#wpadminbar .ab-top-menu > li:hover > .ab-item,
#wpadminbar .ab-top-menu > li.hover > .ab-item,
#wpadminbar .ab-top-menu > li > .ab-item:focus,
#wpadminbar.nojq .quicklinks .ab-top-menu > li > .ab-item:focus,
#wpadminbar-nojs .ab-top-menu > li.menupop:hover > .ab-item,
#wpadminbar .ab-top-menu > li.menupop.hover > .ab-item {
color: $menu-submenu-focus-text;
background: $menu-submenu-background;
}
#wpadminbar > #wp-toolbar li:hover span.ab-label,
#wpadminbar > #wp-toolbar li.hover span.ab-label,
#wpadminbar > #wp-toolbar a:focus span.ab-label {
color: $menu-submenu-focus-text;
}
#wpadminbar li:hover .ab-icon:before,
#wpadminbar li:hover .ab-item:before,
#wpadminbar li:hover .ab-item:after,
#wpadminbar li:hover #adminbarsearch:before {
color: $menu-highlight-icon;
}
/* Admin Bar: submenu */
#wpadminbar .menupop .ab-sub-wrapper {
background: $menu-submenu-background;
}
#wpadminbar .quicklinks .menupop ul.ab-sub-secondary,
#wpadminbar .quicklinks .menupop ul.ab-sub-secondary .ab-submenu {
background: $menu-submenu-background-alt;
}
#wpadminbar .ab-submenu .ab-item,
#wpadminbar .quicklinks .menupop ul li a,
#wpadminbar .quicklinks .menupop.hover ul li a,
#wpadminbar-nojs .quicklinks .menupop:hover ul li a {
color: $menu-submenu-text;
}
#wpadminbar .quicklinks li .blavatar,
#wpadminbar .menupop .menupop > .ab-item:before {
color: $menu-icon;
}
#wpadminbar .quicklinks .menupop ul li a:hover,
#wpadminbar .quicklinks .menupop ul li a:focus,
#wpadminbar .quicklinks .menupop ul li a:hover strong,
#wpadminbar .quicklinks .menupop ul li a:focus strong,
#wpadminbar .quicklinks .menupop.hover ul li a:hover,
#wpadminbar .quicklinks .menupop.hover ul li a:focus,
#wpadminbar.nojs .quicklinks .menupop:hover ul li a:hover,
#wpadminbar.nojs .quicklinks .menupop:hover ul li a:focus,
#wpadminbar li:hover .ab-icon:before,
#wpadminbar li:hover .ab-item:before,
#wpadminbar li a:focus .ab-icon:before,
#wpadminbar li .ab-item:focus:before,
#wpadminbar li.hover .ab-icon:before,
#wpadminbar li.hover .ab-item:before,
#wpadminbar li:hover .ab-item:after,
#wpadminbar li.hover .ab-item:after,
#wpadminbar li:hover #adminbarsearch:before {
color: $menu-submenu-focus-text;
}
#wpadminbar .quicklinks li a:hover .blavatar,
#wpadminbar .menupop .menupop > .ab-item:hover:before {
color: $menu-submenu-focus-text;
}
/* Admin Bar: search */
#wpadminbar #adminbarsearch:before {
color: $menu-icon;
}
#wpadminbar > #wp-toolbar > #wp-admin-bar-top-secondary > #wp-admin-bar-search #adminbarsearch input.adminbar-input:focus {
color: $menu-text;
background: $adminbar-input-background;
}
#wpadminbar #adminbarsearch .adminbar-input::-webkit-input-placeholder { color: $menu-text; opacity: .7; }
#wpadminbar #adminbarsearch .adminbar-input:-moz-placeholder { color: $menu-text; opacity: .7; }
#wpadminbar #adminbarsearch .adminbar-input::-moz-placeholder { color: $menu-text; opacity: .7; }
#wpadminbar #adminbarsearch .adminbar-input:-ms-input-placeholder { color: $menu-text; opacity: .7; }
/* Admin Bar: my account */
#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar > a img {
border-color: $adminbar-avatar-frame;
background-color: $adminbar-avatar-frame;
}
#wpadminbar #wp-admin-bar-user-info .display-name {
color: $menu-text;
}
#wpadminbar #wp-admin-bar-user-info a:hover .display-name {
color: $menu-submenu-focus-text;
}
#wpadminbar #wp-admin-bar-user-info .username {
color: $menu-submenu-text;
}
/* Pointers */
.wp-pointer .wp-pointer-content h3 {
background-color: $highlight-color;
border-color: darken( $highlight-color, 5% );
}
.wp-pointer .wp-pointer-content h3:before {
color: $highlight-color;
}
.wp-pointer.wp-pointer-top .wp-pointer-arrow,
.wp-pointer.wp-pointer-undefined .wp-pointer-arrow {
border-bottom-color: $highlight-color;
}
/* Media Uploader */
.media-item .bar,
.media-progress-bar div {
background-color: $highlight-color;
}
.details.attachment {
box-shadow: 0 0 0 1px #fff, 0 0 0 5px $highlight-color;
}
.attachment.details .check {
background-color: $highlight-color;
box-shadow: 0 0 0 1px #fff, 0 0 0 2px $highlight-color;
}
/* Themes */
.theme-browser .theme.active .theme-name,
.theme-browser .theme.add-new-theme:hover:after {
background: $highlight-color;
}
.theme-browser .theme.add-new-theme:hover span:after {
color: $highlight-color;
}
.theme-overlay .theme-header .close:hover,
.theme-overlay .theme-header .right:hover,
.theme-overlay .theme-header .left:hover {
background: $highlight-color;
}
.theme-section.current,
.theme-filter.current {
border-bottom-color: $menu-background;
}
body.more-filters-opened .more-filters,
body.more-filters-opened .more-filters:before {
color: $menu-text;
background-color: $menu-background;
}
body.more-filters-opened .more-filters:hover,
body.more-filters-opened .more-filters:focus,
body.more-filters-opened .more-filters:hover:before,
body.more-filters-opened .more-filters:focus:before {
background-color: $menu-highlight-background;
color: $menu-highlight-text;
}
/* Widgets */
.widgets-chooser li.widgets-chooser-selected {
background-color: $menu-highlight-background;
color: $menu-highlight-text;
}
.widgets-chooser li.widgets-chooser-selected:before,
.widgets-chooser li.widgets-chooser-selected:focus:before {
color: $menu-highlight-text;
}
/* Customize */
#customize-theme-controls .widget-area-select .selected {
background-color: $menu-highlight-background;
color: $menu-highlight-text;
}
/* jQuery UI Slider */
.wp-slider .ui-slider-handle,
.wp-slider .ui-slider-handle.ui-state-hover,
.wp-slider .ui-slider-handle.focus {
background: $button-color;
border-color: darken( $button-color, 10% );
box-shadow: inset 0 1px 0 lighten( $button-color, 15% ), 0 1px 0 rgba(0,0,0,.15);
}
/* Thickbox: Plugin information */
#sidemenu a.current {
background: $body-background;
border-bottom-color: $body-background;
}
#plugin-information .action-button {
background: $button-color;
}
/* Responsive Component */
div#wp-responsive-toggle a:before {
color: $menu-icon;
}
.wp-responsive-open div#wp-responsive-toggle a {
// ToDo: make inset border
border-color: transparent;
background: $menu-highlight-background;
}
.star-rating .star {
color: $highlight-color;
}
.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle a {
background: $menu-submenu-background;
}
| 01-wordpress-paypal | trunk/wp-admin/css/colors/_admin.scss | SCSS | gpl3 | 11,703 |
/*
* Button mixin- creates 3d-ish button effect with correct
* highlights/shadows, based on a base color.
*/
html {
background: #f1f1f1; }
/* Links */
a {
color: #0074a2; }
a:hover, a:active, a:focus {
color: #0099d5; }
#media-upload a.del-link:hover, div.dashboard-widget-submit input:hover, .subsubsub a:hover, .subsubsub a.current:hover {
color: #0099d5; }
/* Forms */
input[type=checkbox]:checked:before {
color: #523f6d; }
input[type=radio]:checked:before {
background: #523f6d; }
.wp-core-ui input[type="reset"]:hover, .wp-core-ui input[type="reset"]:active {
color: #0099d5; }
/* Core UI */
.wp-core-ui .button-primary {
background: #a3b745;
border-color: #839237;
color: white;
-webkit-box-shadow: inset 0 1px 0 #c0cd7b, 0 1px 0 rgba(0, 0, 0, 0.15);
box-shadow: inset 0 1px 0 #c0cd7b, 0 1px 0 rgba(0, 0, 0, 0.15); }
.wp-core-ui .button-primary:hover, .wp-core-ui .button-primary:focus {
background: #93a43e;
border-color: #727f30;
color: white;
-webkit-box-shadow: inset 0 1px 0 #b7c669, 0 1px 0 rgba(0, 0, 0, 0.15);
box-shadow: inset 0 1px 0 #b7c669, 0 1px 0 rgba(0, 0, 0, 0.15); }
.wp-core-ui .button-primary:active {
background: #839237;
border-color: #727f30;
color: white;
-webkit-box-shadow: inset 0 2px 5px -3px rgba(0, 0, 0, 0.5);
box-shadow: inset 0 2px 5px -3px rgba(0, 0, 0, 0.5); }
.wp-core-ui .button-primary[disabled], .wp-core-ui .button-primary:disabled, .wp-core-ui .button-primary.button-primary-disabled, .wp-core-ui .button-primary.disabled {
color: #cfd1c7 !important;
background: #89993a !important;
border-color: #727f30 !important;
text-shadow: none !important; }
.wp-core-ui .wp-ui-primary {
color: #fff;
background-color: #523f6d; }
.wp-core-ui .wp-ui-text-primary {
color: #523f6d; }
.wp-core-ui .wp-ui-highlight {
color: #fff;
background-color: #a3b745; }
.wp-core-ui .wp-ui-text-highlight {
color: #a3b745; }
.wp-core-ui .wp-ui-notification {
color: #fff;
background-color: #d46f15; }
.wp-core-ui .wp-ui-text-notification {
color: #d46f15; }
.wp-core-ui .wp-ui-text-icon {
color: #ece6f6; }
/* List tables */
.wrap .add-new-h2:hover, #add-new-comment a:hover, .tablenav .tablenav-pages a:hover, .tablenav .tablenav-pages a:focus {
color: #fff;
background-color: #523f6d; }
.view-switch a.current:before {
color: #523f6d; }
.view-switch a:hover:before {
color: #d46f15; }
.post-com-count:hover:after {
border-top-color: #523f6d; }
.post-com-count:hover span {
color: #fff;
background-color: #523f6d; }
strong .post-com-count:after {
border-top-color: #d46f15; }
strong .post-com-count span {
background-color: #d46f15; }
/* Admin Menu */
#adminmenuback, #adminmenuwrap, #adminmenu {
background: #523f6d; }
#adminmenu a {
color: #fff; }
#adminmenu div.wp-menu-image:before {
color: #ece6f6; }
#adminmenu a:hover, #adminmenu li.menu-top:hover, #adminmenu li.opensub > a.menu-top, #adminmenu li > a.menu-top:focus {
color: #fff;
background-color: #a3b745; }
#adminmenu li.menu-top:hover div.wp-menu-image:before, #adminmenu li.opensub > a.menu-top div.wp-menu-image:before {
color: #fff; }
/* Active tabs use a bottom border color that matches the page background color. */
.about-wrap h2 .nav-tab-active, .nav-tab-active, .nav-tab-active:hover {
background-color: #f1f1f1;
border-bottom-color: #f1f1f1; }
/* Admin Menu: submenu */
#adminmenu .wp-submenu, #adminmenu .wp-has-current-submenu .wp-submenu, #adminmenu .wp-has-current-submenu.opensub .wp-submenu, .folded #adminmenu .wp-has-current-submenu .wp-submenu, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu {
background: #413256; }
#adminmenu li.wp-has-submenu.wp-not-current-submenu.opensub:hover:after {
border-right-color: #413256; }
#adminmenu .wp-submenu .wp-submenu-head {
color: #cbc5d3; }
#adminmenu .wp-submenu a, #adminmenu .wp-has-current-submenu .wp-submenu a, .folded #adminmenu .wp-has-current-submenu .wp-submenu a, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu a, #adminmenu .wp-has-current-submenu.opensub .wp-submenu a {
color: #cbc5d3; }
#adminmenu .wp-submenu a:focus, #adminmenu .wp-submenu a:hover, #adminmenu .wp-has-current-submenu .wp-submenu a:focus, #adminmenu .wp-has-current-submenu .wp-submenu a:hover, .folded #adminmenu .wp-has-current-submenu .wp-submenu a:focus, .folded #adminmenu .wp-has-current-submenu .wp-submenu a:hover, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu a:focus, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu a:hover, #adminmenu .wp-has-current-submenu.opensub .wp-submenu a:focus, #adminmenu .wp-has-current-submenu.opensub .wp-submenu a:hover {
color: #a3b745; }
/* Admin Menu: current */
#adminmenu .wp-submenu li.current a, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a, #adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a {
color: #fff; }
#adminmenu .wp-submenu li.current a:hover, #adminmenu .wp-submenu li.current a:focus, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a:hover, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a:focus, #adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:hover, #adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:focus {
color: #a3b745; }
ul#adminmenu a.wp-has-current-submenu:after, ul#adminmenu > li.current > a.current:after {
border-right-color: #f1f1f1; }
#adminmenu li.current a.menu-top, #adminmenu li.wp-has-current-submenu a.wp-has-current-submenu, #adminmenu li.wp-has-current-submenu .wp-submenu .wp-submenu-head, .folded #adminmenu li.current.menu-top {
color: #fff;
background: #a3b745; }
#adminmenu li.wp-has-current-submenu div.wp-menu-image:before {
color: #fff; }
/* Admin Menu: bubble */
#adminmenu .awaiting-mod, #adminmenu .update-plugins {
color: #fff;
background: #d46f15; }
#adminmenu li.current a .awaiting-mod, #adminmenu li a.wp-has-current-submenu .update-plugins, #adminmenu li:hover a .awaiting-mod, #adminmenu li.menu-top:hover > a .update-plugins {
color: #fff;
background: #413256; }
/* Admin Menu: collapse button */
#collapse-menu {
color: #ece6f6; }
#collapse-menu:hover {
color: #fff; }
#collapse-button div:after {
color: #ece6f6; }
#collapse-menu:hover #collapse-button div:after {
color: #fff; }
/* Admin Bar */
#wpadminbar {
color: #fff;
background: #523f6d; }
#wpadminbar .ab-item, #wpadminbar a.ab-item, #wpadminbar > #wp-toolbar span.ab-label, #wpadminbar > #wp-toolbar span.noticon {
color: #fff; }
#wpadminbar .ab-icon, #wpadminbar .ab-icon:before, #wpadminbar .ab-item:before, #wpadminbar .ab-item:after {
color: #ece6f6; }
#wpadminbar .ab-top-menu > li:hover > .ab-item, #wpadminbar .ab-top-menu > li.hover > .ab-item, #wpadminbar .ab-top-menu > li > .ab-item:focus, #wpadminbar.nojq .quicklinks .ab-top-menu > li > .ab-item:focus, #wpadminbar-nojs .ab-top-menu > li.menupop:hover > .ab-item, #wpadminbar .ab-top-menu > li.menupop.hover > .ab-item {
color: #a3b745;
background: #413256; }
#wpadminbar > #wp-toolbar li:hover span.ab-label, #wpadminbar > #wp-toolbar li.hover span.ab-label, #wpadminbar > #wp-toolbar a:focus span.ab-label {
color: #a3b745; }
#wpadminbar li:hover .ab-icon:before, #wpadminbar li:hover .ab-item:before, #wpadminbar li:hover .ab-item:after, #wpadminbar li:hover #adminbarsearch:before {
color: #fff; }
/* Admin Bar: submenu */
#wpadminbar .menupop .ab-sub-wrapper {
background: #413256; }
#wpadminbar .quicklinks .menupop ul.ab-sub-secondary, #wpadminbar .quicklinks .menupop ul.ab-sub-secondary .ab-submenu {
background: #64537c; }
#wpadminbar .ab-submenu .ab-item, #wpadminbar .quicklinks .menupop ul li a, #wpadminbar .quicklinks .menupop.hover ul li a, #wpadminbar-nojs .quicklinks .menupop:hover ul li a {
color: #cbc5d3; }
#wpadminbar .quicklinks li .blavatar, #wpadminbar .menupop .menupop > .ab-item:before {
color: #ece6f6; }
#wpadminbar .quicklinks .menupop ul li a:hover, #wpadminbar .quicklinks .menupop ul li a:focus, #wpadminbar .quicklinks .menupop ul li a:hover strong, #wpadminbar .quicklinks .menupop ul li a:focus strong, #wpadminbar .quicklinks .menupop.hover ul li a:hover, #wpadminbar .quicklinks .menupop.hover ul li a:focus, #wpadminbar.nojs .quicklinks .menupop:hover ul li a:hover, #wpadminbar.nojs .quicklinks .menupop:hover ul li a:focus, #wpadminbar li:hover .ab-icon:before, #wpadminbar li:hover .ab-item:before, #wpadminbar li a:focus .ab-icon:before, #wpadminbar li .ab-item:focus:before, #wpadminbar li.hover .ab-icon:before, #wpadminbar li.hover .ab-item:before, #wpadminbar li:hover .ab-item:after, #wpadminbar li.hover .ab-item:after, #wpadminbar li:hover #adminbarsearch:before {
color: #a3b745; }
#wpadminbar .quicklinks li a:hover .blavatar, #wpadminbar .menupop .menupop > .ab-item:hover:before {
color: #a3b745; }
/* Admin Bar: search */
#wpadminbar #adminbarsearch:before {
color: #ece6f6; }
#wpadminbar > #wp-toolbar > #wp-admin-bar-top-secondary > #wp-admin-bar-search #adminbarsearch input.adminbar-input:focus {
color: #fff;
background: #624c84; }
#wpadminbar #adminbarsearch .adminbar-input::-webkit-input-placeholder {
color: #fff;
opacity: 0.7; }
#wpadminbar #adminbarsearch .adminbar-input:-moz-placeholder {
color: #fff;
opacity: 0.7; }
#wpadminbar #adminbarsearch .adminbar-input::-moz-placeholder {
color: #fff;
opacity: 0.7; }
#wpadminbar #adminbarsearch .adminbar-input:-ms-input-placeholder {
color: #fff;
opacity: 0.7; }
/* Admin Bar: my account */
#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar > a img {
border-color: #624c84;
background-color: #624c84; }
#wpadminbar #wp-admin-bar-user-info .display-name {
color: #fff; }
#wpadminbar #wp-admin-bar-user-info a:hover .display-name {
color: #a3b745; }
#wpadminbar #wp-admin-bar-user-info .username {
color: #cbc5d3; }
/* Pointers */
.wp-pointer .wp-pointer-content h3 {
background-color: #a3b745;
border-color: #93a43e; }
.wp-pointer .wp-pointer-content h3:before {
color: #a3b745; }
.wp-pointer.wp-pointer-top .wp-pointer-arrow, .wp-pointer.wp-pointer-undefined .wp-pointer-arrow {
border-bottom-color: #a3b745; }
/* Media Uploader */
.media-item .bar, .media-progress-bar div {
background-color: #a3b745; }
.details.attachment {
-webkit-box-shadow: 0 0 0 1px #fff, 0 0 0 5px #a3b745;
box-shadow: 0 0 0 1px #fff, 0 0 0 5px #a3b745; }
.attachment.details .check {
background-color: #a3b745;
-webkit-box-shadow: 0 0 0 1px #fff, 0 0 0 2px #a3b745;
box-shadow: 0 0 0 1px #fff, 0 0 0 2px #a3b745; }
/* Themes */
.theme-browser .theme.active .theme-name, .theme-browser .theme.add-new-theme:hover:after {
background: #a3b745; }
.theme-browser .theme.add-new-theme:hover span:after {
color: #a3b745; }
.theme-overlay .theme-header .close:hover, .theme-overlay .theme-header .right:hover, .theme-overlay .theme-header .left:hover {
background: #a3b745; }
.theme-section.current, .theme-filter.current {
border-bottom-color: #523f6d; }
body.more-filters-opened .more-filters, body.more-filters-opened .more-filters:before {
color: #fff;
background-color: #523f6d; }
body.more-filters-opened .more-filters:hover, body.more-filters-opened .more-filters:focus, body.more-filters-opened .more-filters:hover:before, body.more-filters-opened .more-filters:focus:before {
background-color: #a3b745;
color: #fff; }
/* Widgets */
.widgets-chooser li.widgets-chooser-selected {
background-color: #a3b745;
color: #fff; }
.widgets-chooser li.widgets-chooser-selected:before, .widgets-chooser li.widgets-chooser-selected:focus:before {
color: #fff; }
/* Customize */
#customize-theme-controls .widget-area-select .selected {
background-color: #a3b745;
color: #fff; }
/* jQuery UI Slider */
.wp-slider .ui-slider-handle, .wp-slider .ui-slider-handle.ui-state-hover, .wp-slider .ui-slider-handle.focus {
background: #a3b745;
border-color: #839237;
-webkit-box-shadow: inset 0 1px 0 #c0cd7b, 0 1px 0 rgba(0, 0, 0, 0.15);
box-shadow: inset 0 1px 0 #c0cd7b, 0 1px 0 rgba(0, 0, 0, 0.15); }
/* Thickbox: Plugin information */
#sidemenu a.current {
background: #f1f1f1;
border-bottom-color: #f1f1f1; }
#plugin-information .action-button {
background: #a3b745; }
/* Responsive Component */
div#wp-responsive-toggle a:before {
color: #ece6f6; }
.wp-responsive-open div#wp-responsive-toggle a {
border-color: transparent;
background: #a3b745; }
.star-rating .star {
color: #a3b745; }
.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle a {
background: #413256; }
| 01-wordpress-paypal | trunk/wp-admin/css/colors/ectoplasm/colors.css | CSS | gpl3 | 12,669 |
$base-color: #523f6d;
$icon-color: #ece6f6;
$highlight-color: #a3b745;
$notification-color: #d46f15;
$form-checked: $base-color;
@import "../_admin.scss";
| 01-wordpress-paypal | trunk/wp-admin/css/colors/ectoplasm/colors.scss | SCSS | gpl3 | 157 |
/*
* Button mixin- creates 3d-ish button effect with correct
* highlights/shadows, based on a base color.
*/
html {
background: #f1f1f1; }
/* Links */
a {
color: #0074a2; }
a:hover, a:active, a:focus {
color: #0099d5; }
#media-upload a.del-link:hover, div.dashboard-widget-submit input:hover, .subsubsub a:hover, .subsubsub a.current:hover {
color: #0099d5; }
/* Forms */
input[type=checkbox]:checked:before {
color: #523f6d; }
input[type=radio]:checked:before {
background: #523f6d; }
.wp-core-ui input[type="reset"]:hover, .wp-core-ui input[type="reset"]:active {
color: #0099d5; }
/* Core UI */
.wp-core-ui .button-primary {
background: #a3b745;
border-color: #839237;
color: white;
-webkit-box-shadow: inset 0 1px 0 #c0cd7b, 0 1px 0 rgba(0, 0, 0, 0.15);
box-shadow: inset 0 1px 0 #c0cd7b, 0 1px 0 rgba(0, 0, 0, 0.15); }
.wp-core-ui .button-primary:hover, .wp-core-ui .button-primary:focus {
background: #93a43e;
border-color: #727f30;
color: white;
-webkit-box-shadow: inset 0 1px 0 #b7c669, 0 1px 0 rgba(0, 0, 0, 0.15);
box-shadow: inset 0 1px 0 #b7c669, 0 1px 0 rgba(0, 0, 0, 0.15); }
.wp-core-ui .button-primary:active {
background: #839237;
border-color: #727f30;
color: white;
-webkit-box-shadow: inset 0 2px 5px -3px rgba(0, 0, 0, 0.5);
box-shadow: inset 0 2px 5px -3px rgba(0, 0, 0, 0.5); }
.wp-core-ui .button-primary[disabled], .wp-core-ui .button-primary:disabled, .wp-core-ui .button-primary.button-primary-disabled, .wp-core-ui .button-primary.disabled {
color: #cfd1c7 !important;
background: #89993a !important;
border-color: #727f30 !important;
text-shadow: none !important; }
.wp-core-ui .wp-ui-primary {
color: #fff;
background-color: #523f6d; }
.wp-core-ui .wp-ui-text-primary {
color: #523f6d; }
.wp-core-ui .wp-ui-highlight {
color: #fff;
background-color: #a3b745; }
.wp-core-ui .wp-ui-text-highlight {
color: #a3b745; }
.wp-core-ui .wp-ui-notification {
color: #fff;
background-color: #d46f15; }
.wp-core-ui .wp-ui-text-notification {
color: #d46f15; }
.wp-core-ui .wp-ui-text-icon {
color: #ece6f6; }
/* List tables */
.wrap .add-new-h2:hover, #add-new-comment a:hover, .tablenav .tablenav-pages a:hover, .tablenav .tablenav-pages a:focus {
color: #fff;
background-color: #523f6d; }
.view-switch a.current:before {
color: #523f6d; }
.view-switch a:hover:before {
color: #d46f15; }
.post-com-count:hover:after {
border-top-color: #523f6d; }
.post-com-count:hover span {
color: #fff;
background-color: #523f6d; }
strong .post-com-count:after {
border-top-color: #d46f15; }
strong .post-com-count span {
background-color: #d46f15; }
/* Admin Menu */
#adminmenuback, #adminmenuwrap, #adminmenu {
background: #523f6d; }
#adminmenu a {
color: #fff; }
#adminmenu div.wp-menu-image:before {
color: #ece6f6; }
#adminmenu a:hover, #adminmenu li.menu-top:hover, #adminmenu li.opensub > a.menu-top, #adminmenu li > a.menu-top:focus {
color: #fff;
background-color: #a3b745; }
#adminmenu li.menu-top:hover div.wp-menu-image:before, #adminmenu li.opensub > a.menu-top div.wp-menu-image:before {
color: #fff; }
/* Active tabs use a bottom border color that matches the page background color. */
.about-wrap h2 .nav-tab-active, .nav-tab-active, .nav-tab-active:hover {
background-color: #f1f1f1;
border-bottom-color: #f1f1f1; }
/* Admin Menu: submenu */
#adminmenu .wp-submenu, #adminmenu .wp-has-current-submenu .wp-submenu, #adminmenu .wp-has-current-submenu.opensub .wp-submenu, .folded #adminmenu .wp-has-current-submenu .wp-submenu, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu {
background: #413256; }
#adminmenu li.wp-has-submenu.wp-not-current-submenu.opensub:hover:after {
border-left-color: #413256; }
#adminmenu .wp-submenu .wp-submenu-head {
color: #cbc5d3; }
#adminmenu .wp-submenu a, #adminmenu .wp-has-current-submenu .wp-submenu a, .folded #adminmenu .wp-has-current-submenu .wp-submenu a, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu a, #adminmenu .wp-has-current-submenu.opensub .wp-submenu a {
color: #cbc5d3; }
#adminmenu .wp-submenu a:focus, #adminmenu .wp-submenu a:hover, #adminmenu .wp-has-current-submenu .wp-submenu a:focus, #adminmenu .wp-has-current-submenu .wp-submenu a:hover, .folded #adminmenu .wp-has-current-submenu .wp-submenu a:focus, .folded #adminmenu .wp-has-current-submenu .wp-submenu a:hover, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu a:focus, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu a:hover, #adminmenu .wp-has-current-submenu.opensub .wp-submenu a:focus, #adminmenu .wp-has-current-submenu.opensub .wp-submenu a:hover {
color: #a3b745; }
/* Admin Menu: current */
#adminmenu .wp-submenu li.current a, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a, #adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a {
color: #fff; }
#adminmenu .wp-submenu li.current a:hover, #adminmenu .wp-submenu li.current a:focus, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a:hover, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a:focus, #adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:hover, #adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:focus {
color: #a3b745; }
ul#adminmenu a.wp-has-current-submenu:after, ul#adminmenu > li.current > a.current:after {
border-left-color: #f1f1f1; }
#adminmenu li.current a.menu-top, #adminmenu li.wp-has-current-submenu a.wp-has-current-submenu, #adminmenu li.wp-has-current-submenu .wp-submenu .wp-submenu-head, .folded #adminmenu li.current.menu-top {
color: #fff;
background: #a3b745; }
#adminmenu li.wp-has-current-submenu div.wp-menu-image:before {
color: #fff; }
/* Admin Menu: bubble */
#adminmenu .awaiting-mod, #adminmenu .update-plugins {
color: #fff;
background: #d46f15; }
#adminmenu li.current a .awaiting-mod, #adminmenu li a.wp-has-current-submenu .update-plugins, #adminmenu li:hover a .awaiting-mod, #adminmenu li.menu-top:hover > a .update-plugins {
color: #fff;
background: #413256; }
/* Admin Menu: collapse button */
#collapse-menu {
color: #ece6f6; }
#collapse-menu:hover {
color: #fff; }
#collapse-button div:after {
color: #ece6f6; }
#collapse-menu:hover #collapse-button div:after {
color: #fff; }
/* Admin Bar */
#wpadminbar {
color: #fff;
background: #523f6d; }
#wpadminbar .ab-item, #wpadminbar a.ab-item, #wpadminbar > #wp-toolbar span.ab-label, #wpadminbar > #wp-toolbar span.noticon {
color: #fff; }
#wpadminbar .ab-icon, #wpadminbar .ab-icon:before, #wpadminbar .ab-item:before, #wpadminbar .ab-item:after {
color: #ece6f6; }
#wpadminbar .ab-top-menu > li:hover > .ab-item, #wpadminbar .ab-top-menu > li.hover > .ab-item, #wpadminbar .ab-top-menu > li > .ab-item:focus, #wpadminbar.nojq .quicklinks .ab-top-menu > li > .ab-item:focus, #wpadminbar-nojs .ab-top-menu > li.menupop:hover > .ab-item, #wpadminbar .ab-top-menu > li.menupop.hover > .ab-item {
color: #a3b745;
background: #413256; }
#wpadminbar > #wp-toolbar li:hover span.ab-label, #wpadminbar > #wp-toolbar li.hover span.ab-label, #wpadminbar > #wp-toolbar a:focus span.ab-label {
color: #a3b745; }
#wpadminbar li:hover .ab-icon:before, #wpadminbar li:hover .ab-item:before, #wpadminbar li:hover .ab-item:after, #wpadminbar li:hover #adminbarsearch:before {
color: #fff; }
/* Admin Bar: submenu */
#wpadminbar .menupop .ab-sub-wrapper {
background: #413256; }
#wpadminbar .quicklinks .menupop ul.ab-sub-secondary, #wpadminbar .quicklinks .menupop ul.ab-sub-secondary .ab-submenu {
background: #64537c; }
#wpadminbar .ab-submenu .ab-item, #wpadminbar .quicklinks .menupop ul li a, #wpadminbar .quicklinks .menupop.hover ul li a, #wpadminbar-nojs .quicklinks .menupop:hover ul li a {
color: #cbc5d3; }
#wpadminbar .quicklinks li .blavatar, #wpadminbar .menupop .menupop > .ab-item:before {
color: #ece6f6; }
#wpadminbar .quicklinks .menupop ul li a:hover, #wpadminbar .quicklinks .menupop ul li a:focus, #wpadminbar .quicklinks .menupop ul li a:hover strong, #wpadminbar .quicklinks .menupop ul li a:focus strong, #wpadminbar .quicklinks .menupop.hover ul li a:hover, #wpadminbar .quicklinks .menupop.hover ul li a:focus, #wpadminbar.nojs .quicklinks .menupop:hover ul li a:hover, #wpadminbar.nojs .quicklinks .menupop:hover ul li a:focus, #wpadminbar li:hover .ab-icon:before, #wpadminbar li:hover .ab-item:before, #wpadminbar li a:focus .ab-icon:before, #wpadminbar li .ab-item:focus:before, #wpadminbar li.hover .ab-icon:before, #wpadminbar li.hover .ab-item:before, #wpadminbar li:hover .ab-item:after, #wpadminbar li.hover .ab-item:after, #wpadminbar li:hover #adminbarsearch:before {
color: #a3b745; }
#wpadminbar .quicklinks li a:hover .blavatar, #wpadminbar .menupop .menupop > .ab-item:hover:before {
color: #a3b745; }
/* Admin Bar: search */
#wpadminbar #adminbarsearch:before {
color: #ece6f6; }
#wpadminbar > #wp-toolbar > #wp-admin-bar-top-secondary > #wp-admin-bar-search #adminbarsearch input.adminbar-input:focus {
color: #fff;
background: #624c84; }
#wpadminbar #adminbarsearch .adminbar-input::-webkit-input-placeholder {
color: #fff;
opacity: 0.7; }
#wpadminbar #adminbarsearch .adminbar-input:-moz-placeholder {
color: #fff;
opacity: 0.7; }
#wpadminbar #adminbarsearch .adminbar-input::-moz-placeholder {
color: #fff;
opacity: 0.7; }
#wpadminbar #adminbarsearch .adminbar-input:-ms-input-placeholder {
color: #fff;
opacity: 0.7; }
/* Admin Bar: my account */
#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar > a img {
border-color: #624c84;
background-color: #624c84; }
#wpadminbar #wp-admin-bar-user-info .display-name {
color: #fff; }
#wpadminbar #wp-admin-bar-user-info a:hover .display-name {
color: #a3b745; }
#wpadminbar #wp-admin-bar-user-info .username {
color: #cbc5d3; }
/* Pointers */
.wp-pointer .wp-pointer-content h3 {
background-color: #a3b745;
border-color: #93a43e; }
.wp-pointer .wp-pointer-content h3:before {
color: #a3b745; }
.wp-pointer.wp-pointer-top .wp-pointer-arrow, .wp-pointer.wp-pointer-undefined .wp-pointer-arrow {
border-bottom-color: #a3b745; }
/* Media Uploader */
.media-item .bar, .media-progress-bar div {
background-color: #a3b745; }
.details.attachment {
-webkit-box-shadow: 0 0 0 1px #fff, 0 0 0 5px #a3b745;
box-shadow: 0 0 0 1px #fff, 0 0 0 5px #a3b745; }
.attachment.details .check {
background-color: #a3b745;
-webkit-box-shadow: 0 0 0 1px #fff, 0 0 0 2px #a3b745;
box-shadow: 0 0 0 1px #fff, 0 0 0 2px #a3b745; }
/* Themes */
.theme-browser .theme.active .theme-name, .theme-browser .theme.add-new-theme:hover:after {
background: #a3b745; }
.theme-browser .theme.add-new-theme:hover span:after {
color: #a3b745; }
.theme-overlay .theme-header .close:hover, .theme-overlay .theme-header .right:hover, .theme-overlay .theme-header .left:hover {
background: #a3b745; }
.theme-section.current, .theme-filter.current {
border-bottom-color: #523f6d; }
body.more-filters-opened .more-filters, body.more-filters-opened .more-filters:before {
color: #fff;
background-color: #523f6d; }
body.more-filters-opened .more-filters:hover, body.more-filters-opened .more-filters:focus, body.more-filters-opened .more-filters:hover:before, body.more-filters-opened .more-filters:focus:before {
background-color: #a3b745;
color: #fff; }
/* Widgets */
.widgets-chooser li.widgets-chooser-selected {
background-color: #a3b745;
color: #fff; }
.widgets-chooser li.widgets-chooser-selected:before, .widgets-chooser li.widgets-chooser-selected:focus:before {
color: #fff; }
/* Customize */
#customize-theme-controls .widget-area-select .selected {
background-color: #a3b745;
color: #fff; }
/* jQuery UI Slider */
.wp-slider .ui-slider-handle, .wp-slider .ui-slider-handle.ui-state-hover, .wp-slider .ui-slider-handle.focus {
background: #a3b745;
border-color: #839237;
-webkit-box-shadow: inset 0 1px 0 #c0cd7b, 0 1px 0 rgba(0, 0, 0, 0.15);
box-shadow: inset 0 1px 0 #c0cd7b, 0 1px 0 rgba(0, 0, 0, 0.15); }
/* Thickbox: Plugin information */
#sidemenu a.current {
background: #f1f1f1;
border-bottom-color: #f1f1f1; }
#plugin-information .action-button {
background: #a3b745; }
/* Responsive Component */
div#wp-responsive-toggle a:before {
color: #ece6f6; }
.wp-responsive-open div#wp-responsive-toggle a {
border-color: transparent;
background: #a3b745; }
.star-rating .star {
color: #a3b745; }
.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle a {
background: #413256; }
| 01-wordpress-paypal | trunk/wp-admin/css/colors/ectoplasm/colors-rtl.css | CSS | gpl3 | 12,667 |
/*
* Button mixin- creates 3d-ish button effect with correct
* highlights/shadows, based on a base color.
*/
html {
background: #f1f1f1; }
/* Links */
a {
color: #0074a2; }
a:hover, a:active, a:focus {
color: #0099d5; }
#media-upload a.del-link:hover, div.dashboard-widget-submit input:hover, .subsubsub a:hover, .subsubsub a.current:hover {
color: #0099d5; }
/* Forms */
input[type=checkbox]:checked:before {
color: #096484; }
input[type=radio]:checked:before {
background: #096484; }
.wp-core-ui input[type="reset"]:hover, .wp-core-ui input[type="reset"]:active {
color: #0099d5; }
/* Core UI */
.wp-core-ui .button-primary {
background: #e1a948;
border-color: #d39323;
color: white;
-webkit-box-shadow: inset 0 1px 0 #ecc88a, 0 1px 0 rgba(0, 0, 0, 0.15);
box-shadow: inset 0 1px 0 #ecc88a, 0 1px 0 rgba(0, 0, 0, 0.15); }
.wp-core-ui .button-primary:hover, .wp-core-ui .button-primary:focus {
background: #dd9f32;
border-color: #bd831f;
color: white;
-webkit-box-shadow: inset 0 1px 0 #e8be74, 0 1px 0 rgba(0, 0, 0, 0.15);
box-shadow: inset 0 1px 0 #e8be74, 0 1px 0 rgba(0, 0, 0, 0.15); }
.wp-core-ui .button-primary:active {
background: #d39323;
border-color: #bd831f;
color: white;
-webkit-box-shadow: inset 0 2px 5px -3px rgba(0, 0, 0, 0.5);
box-shadow: inset 0 2px 5px -3px rgba(0, 0, 0, 0.5); }
.wp-core-ui .button-primary[disabled], .wp-core-ui .button-primary:disabled, .wp-core-ui .button-primary.button-primary-disabled, .wp-core-ui .button-primary.disabled {
color: #d1cdc7 !important;
background: #db9825 !important;
border-color: #bd831f !important;
text-shadow: none !important; }
.wp-core-ui .wp-ui-primary {
color: #fff;
background-color: #52accc; }
.wp-core-ui .wp-ui-text-primary {
color: #52accc; }
.wp-core-ui .wp-ui-highlight {
color: #fff;
background-color: #096484; }
.wp-core-ui .wp-ui-text-highlight {
color: #096484; }
.wp-core-ui .wp-ui-notification {
color: #fff;
background-color: #e1a948; }
.wp-core-ui .wp-ui-text-notification {
color: #e1a948; }
.wp-core-ui .wp-ui-text-icon {
color: #e5f8ff; }
/* List tables */
.wrap .add-new-h2:hover, #add-new-comment a:hover, .tablenav .tablenav-pages a:hover, .tablenav .tablenav-pages a:focus {
color: #fff;
background-color: #52accc; }
.view-switch a.current:before {
color: #52accc; }
.view-switch a:hover:before {
color: #e1a948; }
.post-com-count:hover:after {
border-top-color: #52accc; }
.post-com-count:hover span {
color: #fff;
background-color: #52accc; }
strong .post-com-count:after {
border-top-color: #e1a948; }
strong .post-com-count span {
background-color: #e1a948; }
/* Admin Menu */
#adminmenuback, #adminmenuwrap, #adminmenu {
background: #52accc; }
#adminmenu a {
color: #fff; }
#adminmenu div.wp-menu-image:before {
color: #e5f8ff; }
#adminmenu a:hover, #adminmenu li.menu-top:hover, #adminmenu li.opensub > a.menu-top, #adminmenu li > a.menu-top:focus {
color: #fff;
background-color: #096484; }
#adminmenu li.menu-top:hover div.wp-menu-image:before, #adminmenu li.opensub > a.menu-top div.wp-menu-image:before {
color: #fff; }
/* Active tabs use a bottom border color that matches the page background color. */
.about-wrap h2 .nav-tab-active, .nav-tab-active, .nav-tab-active:hover {
background-color: #f1f1f1;
border-bottom-color: #f1f1f1; }
/* Admin Menu: submenu */
#adminmenu .wp-submenu, #adminmenu .wp-has-current-submenu .wp-submenu, #adminmenu .wp-has-current-submenu.opensub .wp-submenu, .folded #adminmenu .wp-has-current-submenu .wp-submenu, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu {
background: #4796b3; }
#adminmenu li.wp-has-submenu.wp-not-current-submenu.opensub:hover:after {
border-right-color: #4796b3; }
#adminmenu .wp-submenu .wp-submenu-head {
color: #e2ecf1; }
#adminmenu .wp-submenu a, #adminmenu .wp-has-current-submenu .wp-submenu a, .folded #adminmenu .wp-has-current-submenu .wp-submenu a, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu a, #adminmenu .wp-has-current-submenu.opensub .wp-submenu a {
color: #e2ecf1; }
#adminmenu .wp-submenu a:focus, #adminmenu .wp-submenu a:hover, #adminmenu .wp-has-current-submenu .wp-submenu a:focus, #adminmenu .wp-has-current-submenu .wp-submenu a:hover, .folded #adminmenu .wp-has-current-submenu .wp-submenu a:focus, .folded #adminmenu .wp-has-current-submenu .wp-submenu a:hover, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu a:focus, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu a:hover, #adminmenu .wp-has-current-submenu.opensub .wp-submenu a:focus, #adminmenu .wp-has-current-submenu.opensub .wp-submenu a:hover {
color: #fff; }
/* Admin Menu: current */
#adminmenu .wp-submenu li.current a, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a, #adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a {
color: #fff; }
#adminmenu .wp-submenu li.current a:hover, #adminmenu .wp-submenu li.current a:focus, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a:hover, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a:focus, #adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:hover, #adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:focus {
color: #fff; }
ul#adminmenu a.wp-has-current-submenu:after, ul#adminmenu > li.current > a.current:after {
border-right-color: #f1f1f1; }
#adminmenu li.current a.menu-top, #adminmenu li.wp-has-current-submenu a.wp-has-current-submenu, #adminmenu li.wp-has-current-submenu .wp-submenu .wp-submenu-head, .folded #adminmenu li.current.menu-top {
color: #fff;
background: #096484; }
#adminmenu li.wp-has-current-submenu div.wp-menu-image:before {
color: #fff; }
/* Admin Menu: bubble */
#adminmenu .awaiting-mod, #adminmenu .update-plugins {
color: #fff;
background: #e1a948; }
#adminmenu li.current a .awaiting-mod, #adminmenu li a.wp-has-current-submenu .update-plugins, #adminmenu li:hover a .awaiting-mod, #adminmenu li.menu-top:hover > a .update-plugins {
color: #fff;
background: #4796b3; }
/* Admin Menu: collapse button */
#collapse-menu {
color: #e5f8ff; }
#collapse-menu:hover {
color: #fff; }
#collapse-button div:after {
color: #e5f8ff; }
#collapse-menu:hover #collapse-button div:after {
color: #fff; }
/* Admin Bar */
#wpadminbar {
color: #fff;
background: #52accc; }
#wpadminbar .ab-item, #wpadminbar a.ab-item, #wpadminbar > #wp-toolbar span.ab-label, #wpadminbar > #wp-toolbar span.noticon {
color: #fff; }
#wpadminbar .ab-icon, #wpadminbar .ab-icon:before, #wpadminbar .ab-item:before, #wpadminbar .ab-item:after {
color: #e5f8ff; }
#wpadminbar .ab-top-menu > li:hover > .ab-item, #wpadminbar .ab-top-menu > li.hover > .ab-item, #wpadminbar .ab-top-menu > li > .ab-item:focus, #wpadminbar.nojq .quicklinks .ab-top-menu > li > .ab-item:focus, #wpadminbar-nojs .ab-top-menu > li.menupop:hover > .ab-item, #wpadminbar .ab-top-menu > li.menupop.hover > .ab-item {
color: #fff;
background: #4796b3; }
#wpadminbar > #wp-toolbar li:hover span.ab-label, #wpadminbar > #wp-toolbar li.hover span.ab-label, #wpadminbar > #wp-toolbar a:focus span.ab-label {
color: #fff; }
#wpadminbar li:hover .ab-icon:before, #wpadminbar li:hover .ab-item:before, #wpadminbar li:hover .ab-item:after, #wpadminbar li:hover #adminbarsearch:before {
color: #fff; }
/* Admin Bar: submenu */
#wpadminbar .menupop .ab-sub-wrapper {
background: #4796b3; }
#wpadminbar .quicklinks .menupop ul.ab-sub-secondary, #wpadminbar .quicklinks .menupop ul.ab-sub-secondary .ab-submenu {
background: #74b7ce; }
#wpadminbar .ab-submenu .ab-item, #wpadminbar .quicklinks .menupop ul li a, #wpadminbar .quicklinks .menupop.hover ul li a, #wpadminbar-nojs .quicklinks .menupop:hover ul li a {
color: #e2ecf1; }
#wpadminbar .quicklinks li .blavatar, #wpadminbar .menupop .menupop > .ab-item:before {
color: #e5f8ff; }
#wpadminbar .quicklinks .menupop ul li a:hover, #wpadminbar .quicklinks .menupop ul li a:focus, #wpadminbar .quicklinks .menupop ul li a:hover strong, #wpadminbar .quicklinks .menupop ul li a:focus strong, #wpadminbar .quicklinks .menupop.hover ul li a:hover, #wpadminbar .quicklinks .menupop.hover ul li a:focus, #wpadminbar.nojs .quicklinks .menupop:hover ul li a:hover, #wpadminbar.nojs .quicklinks .menupop:hover ul li a:focus, #wpadminbar li:hover .ab-icon:before, #wpadminbar li:hover .ab-item:before, #wpadminbar li a:focus .ab-icon:before, #wpadminbar li .ab-item:focus:before, #wpadminbar li.hover .ab-icon:before, #wpadminbar li.hover .ab-item:before, #wpadminbar li:hover .ab-item:after, #wpadminbar li.hover .ab-item:after, #wpadminbar li:hover #adminbarsearch:before {
color: #fff; }
#wpadminbar .quicklinks li a:hover .blavatar, #wpadminbar .menupop .menupop > .ab-item:hover:before {
color: #fff; }
/* Admin Bar: search */
#wpadminbar #adminbarsearch:before {
color: #e5f8ff; }
#wpadminbar > #wp-toolbar > #wp-admin-bar-top-secondary > #wp-admin-bar-search #adminbarsearch input.adminbar-input:focus {
color: #fff;
background: #6ebad4; }
#wpadminbar #adminbarsearch .adminbar-input::-webkit-input-placeholder {
color: #fff;
opacity: 0.7; }
#wpadminbar #adminbarsearch .adminbar-input:-moz-placeholder {
color: #fff;
opacity: 0.7; }
#wpadminbar #adminbarsearch .adminbar-input::-moz-placeholder {
color: #fff;
opacity: 0.7; }
#wpadminbar #adminbarsearch .adminbar-input:-ms-input-placeholder {
color: #fff;
opacity: 0.7; }
/* Admin Bar: my account */
#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar > a img {
border-color: #6ebad4;
background-color: #6ebad4; }
#wpadminbar #wp-admin-bar-user-info .display-name {
color: #fff; }
#wpadminbar #wp-admin-bar-user-info a:hover .display-name {
color: #fff; }
#wpadminbar #wp-admin-bar-user-info .username {
color: #e2ecf1; }
/* Pointers */
.wp-pointer .wp-pointer-content h3 {
background-color: #096484;
border-color: #07536c; }
.wp-pointer .wp-pointer-content h3:before {
color: #096484; }
.wp-pointer.wp-pointer-top .wp-pointer-arrow, .wp-pointer.wp-pointer-undefined .wp-pointer-arrow {
border-bottom-color: #096484; }
/* Media Uploader */
.media-item .bar, .media-progress-bar div {
background-color: #096484; }
.details.attachment {
-webkit-box-shadow: 0 0 0 1px #fff, 0 0 0 5px #096484;
box-shadow: 0 0 0 1px #fff, 0 0 0 5px #096484; }
.attachment.details .check {
background-color: #096484;
-webkit-box-shadow: 0 0 0 1px #fff, 0 0 0 2px #096484;
box-shadow: 0 0 0 1px #fff, 0 0 0 2px #096484; }
/* Themes */
.theme-browser .theme.active .theme-name, .theme-browser .theme.add-new-theme:hover:after {
background: #096484; }
.theme-browser .theme.add-new-theme:hover span:after {
color: #096484; }
.theme-overlay .theme-header .close:hover, .theme-overlay .theme-header .right:hover, .theme-overlay .theme-header .left:hover {
background: #096484; }
.theme-section.current, .theme-filter.current {
border-bottom-color: #52accc; }
body.more-filters-opened .more-filters, body.more-filters-opened .more-filters:before {
color: #fff;
background-color: #52accc; }
body.more-filters-opened .more-filters:hover, body.more-filters-opened .more-filters:focus, body.more-filters-opened .more-filters:hover:before, body.more-filters-opened .more-filters:focus:before {
background-color: #096484;
color: #fff; }
/* Widgets */
.widgets-chooser li.widgets-chooser-selected {
background-color: #096484;
color: #fff; }
.widgets-chooser li.widgets-chooser-selected:before, .widgets-chooser li.widgets-chooser-selected:focus:before {
color: #fff; }
/* Customize */
#customize-theme-controls .widget-area-select .selected {
background-color: #096484;
color: #fff; }
/* jQuery UI Slider */
.wp-slider .ui-slider-handle, .wp-slider .ui-slider-handle.ui-state-hover, .wp-slider .ui-slider-handle.focus {
background: #e1a948;
border-color: #d39323;
-webkit-box-shadow: inset 0 1px 0 #ecc88a, 0 1px 0 rgba(0, 0, 0, 0.15);
box-shadow: inset 0 1px 0 #ecc88a, 0 1px 0 rgba(0, 0, 0, 0.15); }
/* Thickbox: Plugin information */
#sidemenu a.current {
background: #f1f1f1;
border-bottom-color: #f1f1f1; }
#plugin-information .action-button {
background: #e1a948; }
/* Responsive Component */
div#wp-responsive-toggle a:before {
color: #e5f8ff; }
.wp-responsive-open div#wp-responsive-toggle a {
border-color: transparent;
background: #096484; }
.star-rating .star {
color: #096484; }
.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle a {
background: #4796b3; }
| 01-wordpress-paypal | trunk/wp-admin/css/colors/blue/colors.css | CSS | gpl3 | 12,648 |
$base-color: #52accc;
$icon-color: #e5f8ff;
$highlight-color: #096484;
$notification-color: #e1a948;
$button-color: #e1a948;
$menu-submenu-text: #e2ecf1;
$menu-submenu-focus-text: #fff;
$menu-submenu-background: #4796b3;
@import "../_admin.scss";
| 01-wordpress-paypal | trunk/wp-admin/css/colors/blue/colors.scss | SCSS | gpl3 | 249 |
/*
* Button mixin- creates 3d-ish button effect with correct
* highlights/shadows, based on a base color.
*/
html {
background: #f1f1f1; }
/* Links */
a {
color: #0074a2; }
a:hover, a:active, a:focus {
color: #0099d5; }
#media-upload a.del-link:hover, div.dashboard-widget-submit input:hover, .subsubsub a:hover, .subsubsub a.current:hover {
color: #0099d5; }
/* Forms */
input[type=checkbox]:checked:before {
color: #096484; }
input[type=radio]:checked:before {
background: #096484; }
.wp-core-ui input[type="reset"]:hover, .wp-core-ui input[type="reset"]:active {
color: #0099d5; }
/* Core UI */
.wp-core-ui .button-primary {
background: #e1a948;
border-color: #d39323;
color: white;
-webkit-box-shadow: inset 0 1px 0 #ecc88a, 0 1px 0 rgba(0, 0, 0, 0.15);
box-shadow: inset 0 1px 0 #ecc88a, 0 1px 0 rgba(0, 0, 0, 0.15); }
.wp-core-ui .button-primary:hover, .wp-core-ui .button-primary:focus {
background: #dd9f32;
border-color: #bd831f;
color: white;
-webkit-box-shadow: inset 0 1px 0 #e8be74, 0 1px 0 rgba(0, 0, 0, 0.15);
box-shadow: inset 0 1px 0 #e8be74, 0 1px 0 rgba(0, 0, 0, 0.15); }
.wp-core-ui .button-primary:active {
background: #d39323;
border-color: #bd831f;
color: white;
-webkit-box-shadow: inset 0 2px 5px -3px rgba(0, 0, 0, 0.5);
box-shadow: inset 0 2px 5px -3px rgba(0, 0, 0, 0.5); }
.wp-core-ui .button-primary[disabled], .wp-core-ui .button-primary:disabled, .wp-core-ui .button-primary.button-primary-disabled, .wp-core-ui .button-primary.disabled {
color: #d1cdc7 !important;
background: #db9825 !important;
border-color: #bd831f !important;
text-shadow: none !important; }
.wp-core-ui .wp-ui-primary {
color: #fff;
background-color: #52accc; }
.wp-core-ui .wp-ui-text-primary {
color: #52accc; }
.wp-core-ui .wp-ui-highlight {
color: #fff;
background-color: #096484; }
.wp-core-ui .wp-ui-text-highlight {
color: #096484; }
.wp-core-ui .wp-ui-notification {
color: #fff;
background-color: #e1a948; }
.wp-core-ui .wp-ui-text-notification {
color: #e1a948; }
.wp-core-ui .wp-ui-text-icon {
color: #e5f8ff; }
/* List tables */
.wrap .add-new-h2:hover, #add-new-comment a:hover, .tablenav .tablenav-pages a:hover, .tablenav .tablenav-pages a:focus {
color: #fff;
background-color: #52accc; }
.view-switch a.current:before {
color: #52accc; }
.view-switch a:hover:before {
color: #e1a948; }
.post-com-count:hover:after {
border-top-color: #52accc; }
.post-com-count:hover span {
color: #fff;
background-color: #52accc; }
strong .post-com-count:after {
border-top-color: #e1a948; }
strong .post-com-count span {
background-color: #e1a948; }
/* Admin Menu */
#adminmenuback, #adminmenuwrap, #adminmenu {
background: #52accc; }
#adminmenu a {
color: #fff; }
#adminmenu div.wp-menu-image:before {
color: #e5f8ff; }
#adminmenu a:hover, #adminmenu li.menu-top:hover, #adminmenu li.opensub > a.menu-top, #adminmenu li > a.menu-top:focus {
color: #fff;
background-color: #096484; }
#adminmenu li.menu-top:hover div.wp-menu-image:before, #adminmenu li.opensub > a.menu-top div.wp-menu-image:before {
color: #fff; }
/* Active tabs use a bottom border color that matches the page background color. */
.about-wrap h2 .nav-tab-active, .nav-tab-active, .nav-tab-active:hover {
background-color: #f1f1f1;
border-bottom-color: #f1f1f1; }
/* Admin Menu: submenu */
#adminmenu .wp-submenu, #adminmenu .wp-has-current-submenu .wp-submenu, #adminmenu .wp-has-current-submenu.opensub .wp-submenu, .folded #adminmenu .wp-has-current-submenu .wp-submenu, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu {
background: #4796b3; }
#adminmenu li.wp-has-submenu.wp-not-current-submenu.opensub:hover:after {
border-left-color: #4796b3; }
#adminmenu .wp-submenu .wp-submenu-head {
color: #e2ecf1; }
#adminmenu .wp-submenu a, #adminmenu .wp-has-current-submenu .wp-submenu a, .folded #adminmenu .wp-has-current-submenu .wp-submenu a, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu a, #adminmenu .wp-has-current-submenu.opensub .wp-submenu a {
color: #e2ecf1; }
#adminmenu .wp-submenu a:focus, #adminmenu .wp-submenu a:hover, #adminmenu .wp-has-current-submenu .wp-submenu a:focus, #adminmenu .wp-has-current-submenu .wp-submenu a:hover, .folded #adminmenu .wp-has-current-submenu .wp-submenu a:focus, .folded #adminmenu .wp-has-current-submenu .wp-submenu a:hover, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu a:focus, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu a:hover, #adminmenu .wp-has-current-submenu.opensub .wp-submenu a:focus, #adminmenu .wp-has-current-submenu.opensub .wp-submenu a:hover {
color: #fff; }
/* Admin Menu: current */
#adminmenu .wp-submenu li.current a, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a, #adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a {
color: #fff; }
#adminmenu .wp-submenu li.current a:hover, #adminmenu .wp-submenu li.current a:focus, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a:hover, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a:focus, #adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:hover, #adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:focus {
color: #fff; }
ul#adminmenu a.wp-has-current-submenu:after, ul#adminmenu > li.current > a.current:after {
border-left-color: #f1f1f1; }
#adminmenu li.current a.menu-top, #adminmenu li.wp-has-current-submenu a.wp-has-current-submenu, #adminmenu li.wp-has-current-submenu .wp-submenu .wp-submenu-head, .folded #adminmenu li.current.menu-top {
color: #fff;
background: #096484; }
#adminmenu li.wp-has-current-submenu div.wp-menu-image:before {
color: #fff; }
/* Admin Menu: bubble */
#adminmenu .awaiting-mod, #adminmenu .update-plugins {
color: #fff;
background: #e1a948; }
#adminmenu li.current a .awaiting-mod, #adminmenu li a.wp-has-current-submenu .update-plugins, #adminmenu li:hover a .awaiting-mod, #adminmenu li.menu-top:hover > a .update-plugins {
color: #fff;
background: #4796b3; }
/* Admin Menu: collapse button */
#collapse-menu {
color: #e5f8ff; }
#collapse-menu:hover {
color: #fff; }
#collapse-button div:after {
color: #e5f8ff; }
#collapse-menu:hover #collapse-button div:after {
color: #fff; }
/* Admin Bar */
#wpadminbar {
color: #fff;
background: #52accc; }
#wpadminbar .ab-item, #wpadminbar a.ab-item, #wpadminbar > #wp-toolbar span.ab-label, #wpadminbar > #wp-toolbar span.noticon {
color: #fff; }
#wpadminbar .ab-icon, #wpadminbar .ab-icon:before, #wpadminbar .ab-item:before, #wpadminbar .ab-item:after {
color: #e5f8ff; }
#wpadminbar .ab-top-menu > li:hover > .ab-item, #wpadminbar .ab-top-menu > li.hover > .ab-item, #wpadminbar .ab-top-menu > li > .ab-item:focus, #wpadminbar.nojq .quicklinks .ab-top-menu > li > .ab-item:focus, #wpadminbar-nojs .ab-top-menu > li.menupop:hover > .ab-item, #wpadminbar .ab-top-menu > li.menupop.hover > .ab-item {
color: #fff;
background: #4796b3; }
#wpadminbar > #wp-toolbar li:hover span.ab-label, #wpadminbar > #wp-toolbar li.hover span.ab-label, #wpadminbar > #wp-toolbar a:focus span.ab-label {
color: #fff; }
#wpadminbar li:hover .ab-icon:before, #wpadminbar li:hover .ab-item:before, #wpadminbar li:hover .ab-item:after, #wpadminbar li:hover #adminbarsearch:before {
color: #fff; }
/* Admin Bar: submenu */
#wpadminbar .menupop .ab-sub-wrapper {
background: #4796b3; }
#wpadminbar .quicklinks .menupop ul.ab-sub-secondary, #wpadminbar .quicklinks .menupop ul.ab-sub-secondary .ab-submenu {
background: #74b7ce; }
#wpadminbar .ab-submenu .ab-item, #wpadminbar .quicklinks .menupop ul li a, #wpadminbar .quicklinks .menupop.hover ul li a, #wpadminbar-nojs .quicklinks .menupop:hover ul li a {
color: #e2ecf1; }
#wpadminbar .quicklinks li .blavatar, #wpadminbar .menupop .menupop > .ab-item:before {
color: #e5f8ff; }
#wpadminbar .quicklinks .menupop ul li a:hover, #wpadminbar .quicklinks .menupop ul li a:focus, #wpadminbar .quicklinks .menupop ul li a:hover strong, #wpadminbar .quicklinks .menupop ul li a:focus strong, #wpadminbar .quicklinks .menupop.hover ul li a:hover, #wpadminbar .quicklinks .menupop.hover ul li a:focus, #wpadminbar.nojs .quicklinks .menupop:hover ul li a:hover, #wpadminbar.nojs .quicklinks .menupop:hover ul li a:focus, #wpadminbar li:hover .ab-icon:before, #wpadminbar li:hover .ab-item:before, #wpadminbar li a:focus .ab-icon:before, #wpadminbar li .ab-item:focus:before, #wpadminbar li.hover .ab-icon:before, #wpadminbar li.hover .ab-item:before, #wpadminbar li:hover .ab-item:after, #wpadminbar li.hover .ab-item:after, #wpadminbar li:hover #adminbarsearch:before {
color: #fff; }
#wpadminbar .quicklinks li a:hover .blavatar, #wpadminbar .menupop .menupop > .ab-item:hover:before {
color: #fff; }
/* Admin Bar: search */
#wpadminbar #adminbarsearch:before {
color: #e5f8ff; }
#wpadminbar > #wp-toolbar > #wp-admin-bar-top-secondary > #wp-admin-bar-search #adminbarsearch input.adminbar-input:focus {
color: #fff;
background: #6ebad4; }
#wpadminbar #adminbarsearch .adminbar-input::-webkit-input-placeholder {
color: #fff;
opacity: 0.7; }
#wpadminbar #adminbarsearch .adminbar-input:-moz-placeholder {
color: #fff;
opacity: 0.7; }
#wpadminbar #adminbarsearch .adminbar-input::-moz-placeholder {
color: #fff;
opacity: 0.7; }
#wpadminbar #adminbarsearch .adminbar-input:-ms-input-placeholder {
color: #fff;
opacity: 0.7; }
/* Admin Bar: my account */
#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar > a img {
border-color: #6ebad4;
background-color: #6ebad4; }
#wpadminbar #wp-admin-bar-user-info .display-name {
color: #fff; }
#wpadminbar #wp-admin-bar-user-info a:hover .display-name {
color: #fff; }
#wpadminbar #wp-admin-bar-user-info .username {
color: #e2ecf1; }
/* Pointers */
.wp-pointer .wp-pointer-content h3 {
background-color: #096484;
border-color: #07536c; }
.wp-pointer .wp-pointer-content h3:before {
color: #096484; }
.wp-pointer.wp-pointer-top .wp-pointer-arrow, .wp-pointer.wp-pointer-undefined .wp-pointer-arrow {
border-bottom-color: #096484; }
/* Media Uploader */
.media-item .bar, .media-progress-bar div {
background-color: #096484; }
.details.attachment {
-webkit-box-shadow: 0 0 0 1px #fff, 0 0 0 5px #096484;
box-shadow: 0 0 0 1px #fff, 0 0 0 5px #096484; }
.attachment.details .check {
background-color: #096484;
-webkit-box-shadow: 0 0 0 1px #fff, 0 0 0 2px #096484;
box-shadow: 0 0 0 1px #fff, 0 0 0 2px #096484; }
/* Themes */
.theme-browser .theme.active .theme-name, .theme-browser .theme.add-new-theme:hover:after {
background: #096484; }
.theme-browser .theme.add-new-theme:hover span:after {
color: #096484; }
.theme-overlay .theme-header .close:hover, .theme-overlay .theme-header .right:hover, .theme-overlay .theme-header .left:hover {
background: #096484; }
.theme-section.current, .theme-filter.current {
border-bottom-color: #52accc; }
body.more-filters-opened .more-filters, body.more-filters-opened .more-filters:before {
color: #fff;
background-color: #52accc; }
body.more-filters-opened .more-filters:hover, body.more-filters-opened .more-filters:focus, body.more-filters-opened .more-filters:hover:before, body.more-filters-opened .more-filters:focus:before {
background-color: #096484;
color: #fff; }
/* Widgets */
.widgets-chooser li.widgets-chooser-selected {
background-color: #096484;
color: #fff; }
.widgets-chooser li.widgets-chooser-selected:before, .widgets-chooser li.widgets-chooser-selected:focus:before {
color: #fff; }
/* Customize */
#customize-theme-controls .widget-area-select .selected {
background-color: #096484;
color: #fff; }
/* jQuery UI Slider */
.wp-slider .ui-slider-handle, .wp-slider .ui-slider-handle.ui-state-hover, .wp-slider .ui-slider-handle.focus {
background: #e1a948;
border-color: #d39323;
-webkit-box-shadow: inset 0 1px 0 #ecc88a, 0 1px 0 rgba(0, 0, 0, 0.15);
box-shadow: inset 0 1px 0 #ecc88a, 0 1px 0 rgba(0, 0, 0, 0.15); }
/* Thickbox: Plugin information */
#sidemenu a.current {
background: #f1f1f1;
border-bottom-color: #f1f1f1; }
#plugin-information .action-button {
background: #e1a948; }
/* Responsive Component */
div#wp-responsive-toggle a:before {
color: #e5f8ff; }
.wp-responsive-open div#wp-responsive-toggle a {
border-color: transparent;
background: #096484; }
.star-rating .star {
color: #096484; }
.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle a {
background: #4796b3; }
| 01-wordpress-paypal | trunk/wp-admin/css/colors/blue/colors-rtl.css | CSS | gpl3 | 12,646 |
/*
* Button mixin- creates 3d-ish button effect with correct
* highlights/shadows, based on a base color.
*/
html {
background: #f1f1f1; }
/* Links */
a {
color: #0074a2; }
a:hover, a:active, a:focus {
color: #0099d5; }
#media-upload a.del-link:hover, div.dashboard-widget-submit input:hover, .subsubsub a:hover, .subsubsub a.current:hover {
color: #0099d5; }
/* Forms */
input[type=checkbox]:checked:before {
color: #59524c; }
input[type=radio]:checked:before {
background: #59524c; }
.wp-core-ui input[type="reset"]:hover, .wp-core-ui input[type="reset"]:active {
color: #0099d5; }
/* Core UI */
.wp-core-ui .button-primary {
background: #c7a589;
border-color: #b78a66;
color: white;
-webkit-box-shadow: inset 0 1px 0 #e0cdbd, 0 1px 0 rgba(0, 0, 0, 0.15);
box-shadow: inset 0 1px 0 #e0cdbd, 0 1px 0 rgba(0, 0, 0, 0.15); }
.wp-core-ui .button-primary:hover, .wp-core-ui .button-primary:focus {
background: #bf9878;
border-color: #ae7d55;
color: white;
-webkit-box-shadow: inset 0 1px 0 #d7bfac, 0 1px 0 rgba(0, 0, 0, 0.15);
box-shadow: inset 0 1px 0 #d7bfac, 0 1px 0 rgba(0, 0, 0, 0.15); }
.wp-core-ui .button-primary:active {
background: #b78a66;
border-color: #ae7d55;
color: white;
-webkit-box-shadow: inset 0 2px 5px -3px rgba(0, 0, 0, 0.5);
box-shadow: inset 0 2px 5px -3px rgba(0, 0, 0, 0.5); }
.wp-core-ui .button-primary[disabled], .wp-core-ui .button-primary:disabled, .wp-core-ui .button-primary.button-primary-disabled, .wp-core-ui .button-primary.disabled {
color: #d1cbc7 !important;
background: #ba906d !important;
border-color: #ae7d55 !important;
text-shadow: none !important; }
.wp-core-ui .wp-ui-primary {
color: #fff;
background-color: #59524c; }
.wp-core-ui .wp-ui-text-primary {
color: #59524c; }
.wp-core-ui .wp-ui-highlight {
color: #fff;
background-color: #c7a589; }
.wp-core-ui .wp-ui-text-highlight {
color: #c7a589; }
.wp-core-ui .wp-ui-notification {
color: #fff;
background-color: #9ea476; }
.wp-core-ui .wp-ui-text-notification {
color: #9ea476; }
.wp-core-ui .wp-ui-text-icon {
color: #f3f2f1; }
/* List tables */
.wrap .add-new-h2:hover, #add-new-comment a:hover, .tablenav .tablenav-pages a:hover, .tablenav .tablenav-pages a:focus {
color: #fff;
background-color: #59524c; }
.view-switch a.current:before {
color: #59524c; }
.view-switch a:hover:before {
color: #9ea476; }
.post-com-count:hover:after {
border-top-color: #59524c; }
.post-com-count:hover span {
color: #fff;
background-color: #59524c; }
strong .post-com-count:after {
border-top-color: #9ea476; }
strong .post-com-count span {
background-color: #9ea476; }
/* Admin Menu */
#adminmenuback, #adminmenuwrap, #adminmenu {
background: #59524c; }
#adminmenu a {
color: #fff; }
#adminmenu div.wp-menu-image:before {
color: #f3f2f1; }
#adminmenu a:hover, #adminmenu li.menu-top:hover, #adminmenu li.opensub > a.menu-top, #adminmenu li > a.menu-top:focus {
color: #fff;
background-color: #c7a589; }
#adminmenu li.menu-top:hover div.wp-menu-image:before, #adminmenu li.opensub > a.menu-top div.wp-menu-image:before {
color: #fff; }
/* Active tabs use a bottom border color that matches the page background color. */
.about-wrap h2 .nav-tab-active, .nav-tab-active, .nav-tab-active:hover {
background-color: #f1f1f1;
border-bottom-color: #f1f1f1; }
/* Admin Menu: submenu */
#adminmenu .wp-submenu, #adminmenu .wp-has-current-submenu .wp-submenu, #adminmenu .wp-has-current-submenu.opensub .wp-submenu, .folded #adminmenu .wp-has-current-submenu .wp-submenu, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu {
background: #46403c; }
#adminmenu li.wp-has-submenu.wp-not-current-submenu.opensub:hover:after {
border-right-color: #46403c; }
#adminmenu .wp-submenu .wp-submenu-head {
color: #cdcbc9; }
#adminmenu .wp-submenu a, #adminmenu .wp-has-current-submenu .wp-submenu a, .folded #adminmenu .wp-has-current-submenu .wp-submenu a, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu a, #adminmenu .wp-has-current-submenu.opensub .wp-submenu a {
color: #cdcbc9; }
#adminmenu .wp-submenu a:focus, #adminmenu .wp-submenu a:hover, #adminmenu .wp-has-current-submenu .wp-submenu a:focus, #adminmenu .wp-has-current-submenu .wp-submenu a:hover, .folded #adminmenu .wp-has-current-submenu .wp-submenu a:focus, .folded #adminmenu .wp-has-current-submenu .wp-submenu a:hover, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu a:focus, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu a:hover, #adminmenu .wp-has-current-submenu.opensub .wp-submenu a:focus, #adminmenu .wp-has-current-submenu.opensub .wp-submenu a:hover {
color: #c7a589; }
/* Admin Menu: current */
#adminmenu .wp-submenu li.current a, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a, #adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a {
color: #fff; }
#adminmenu .wp-submenu li.current a:hover, #adminmenu .wp-submenu li.current a:focus, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a:hover, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a:focus, #adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:hover, #adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:focus {
color: #c7a589; }
ul#adminmenu a.wp-has-current-submenu:after, ul#adminmenu > li.current > a.current:after {
border-right-color: #f1f1f1; }
#adminmenu li.current a.menu-top, #adminmenu li.wp-has-current-submenu a.wp-has-current-submenu, #adminmenu li.wp-has-current-submenu .wp-submenu .wp-submenu-head, .folded #adminmenu li.current.menu-top {
color: #fff;
background: #c7a589; }
#adminmenu li.wp-has-current-submenu div.wp-menu-image:before {
color: #fff; }
/* Admin Menu: bubble */
#adminmenu .awaiting-mod, #adminmenu .update-plugins {
color: #fff;
background: #9ea476; }
#adminmenu li.current a .awaiting-mod, #adminmenu li a.wp-has-current-submenu .update-plugins, #adminmenu li:hover a .awaiting-mod, #adminmenu li.menu-top:hover > a .update-plugins {
color: #fff;
background: #46403c; }
/* Admin Menu: collapse button */
#collapse-menu {
color: #f3f2f1; }
#collapse-menu:hover {
color: #fff; }
#collapse-button div:after {
color: #f3f2f1; }
#collapse-menu:hover #collapse-button div:after {
color: #fff; }
/* Admin Bar */
#wpadminbar {
color: #fff;
background: #59524c; }
#wpadminbar .ab-item, #wpadminbar a.ab-item, #wpadminbar > #wp-toolbar span.ab-label, #wpadminbar > #wp-toolbar span.noticon {
color: #fff; }
#wpadminbar .ab-icon, #wpadminbar .ab-icon:before, #wpadminbar .ab-item:before, #wpadminbar .ab-item:after {
color: #f3f2f1; }
#wpadminbar .ab-top-menu > li:hover > .ab-item, #wpadminbar .ab-top-menu > li.hover > .ab-item, #wpadminbar .ab-top-menu > li > .ab-item:focus, #wpadminbar.nojq .quicklinks .ab-top-menu > li > .ab-item:focus, #wpadminbar-nojs .ab-top-menu > li.menupop:hover > .ab-item, #wpadminbar .ab-top-menu > li.menupop.hover > .ab-item {
color: #c7a589;
background: #46403c; }
#wpadminbar > #wp-toolbar li:hover span.ab-label, #wpadminbar > #wp-toolbar li.hover span.ab-label, #wpadminbar > #wp-toolbar a:focus span.ab-label {
color: #c7a589; }
#wpadminbar li:hover .ab-icon:before, #wpadminbar li:hover .ab-item:before, #wpadminbar li:hover .ab-item:after, #wpadminbar li:hover #adminbarsearch:before {
color: #fff; }
/* Admin Bar: submenu */
#wpadminbar .menupop .ab-sub-wrapper {
background: #46403c; }
#wpadminbar .quicklinks .menupop ul.ab-sub-secondary, #wpadminbar .quicklinks .menupop ul.ab-sub-secondary .ab-submenu {
background: #656463; }
#wpadminbar .ab-submenu .ab-item, #wpadminbar .quicklinks .menupop ul li a, #wpadminbar .quicklinks .menupop.hover ul li a, #wpadminbar-nojs .quicklinks .menupop:hover ul li a {
color: #cdcbc9; }
#wpadminbar .quicklinks li .blavatar, #wpadminbar .menupop .menupop > .ab-item:before {
color: #f3f2f1; }
#wpadminbar .quicklinks .menupop ul li a:hover, #wpadminbar .quicklinks .menupop ul li a:focus, #wpadminbar .quicklinks .menupop ul li a:hover strong, #wpadminbar .quicklinks .menupop ul li a:focus strong, #wpadminbar .quicklinks .menupop.hover ul li a:hover, #wpadminbar .quicklinks .menupop.hover ul li a:focus, #wpadminbar.nojs .quicklinks .menupop:hover ul li a:hover, #wpadminbar.nojs .quicklinks .menupop:hover ul li a:focus, #wpadminbar li:hover .ab-icon:before, #wpadminbar li:hover .ab-item:before, #wpadminbar li a:focus .ab-icon:before, #wpadminbar li .ab-item:focus:before, #wpadminbar li.hover .ab-icon:before, #wpadminbar li.hover .ab-item:before, #wpadminbar li:hover .ab-item:after, #wpadminbar li.hover .ab-item:after, #wpadminbar li:hover #adminbarsearch:before {
color: #c7a589; }
#wpadminbar .quicklinks li a:hover .blavatar, #wpadminbar .menupop .menupop > .ab-item:hover:before {
color: #c7a589; }
/* Admin Bar: search */
#wpadminbar #adminbarsearch:before {
color: #f3f2f1; }
#wpadminbar > #wp-toolbar > #wp-admin-bar-top-secondary > #wp-admin-bar-search #adminbarsearch input.adminbar-input:focus {
color: #fff;
background: #6c645c; }
#wpadminbar #adminbarsearch .adminbar-input::-webkit-input-placeholder {
color: #fff;
opacity: 0.7; }
#wpadminbar #adminbarsearch .adminbar-input:-moz-placeholder {
color: #fff;
opacity: 0.7; }
#wpadminbar #adminbarsearch .adminbar-input::-moz-placeholder {
color: #fff;
opacity: 0.7; }
#wpadminbar #adminbarsearch .adminbar-input:-ms-input-placeholder {
color: #fff;
opacity: 0.7; }
/* Admin Bar: my account */
#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar > a img {
border-color: #6c645c;
background-color: #6c645c; }
#wpadminbar #wp-admin-bar-user-info .display-name {
color: #fff; }
#wpadminbar #wp-admin-bar-user-info a:hover .display-name {
color: #c7a589; }
#wpadminbar #wp-admin-bar-user-info .username {
color: #cdcbc9; }
/* Pointers */
.wp-pointer .wp-pointer-content h3 {
background-color: #c7a589;
border-color: #bf9878; }
.wp-pointer .wp-pointer-content h3:before {
color: #c7a589; }
.wp-pointer.wp-pointer-top .wp-pointer-arrow, .wp-pointer.wp-pointer-undefined .wp-pointer-arrow {
border-bottom-color: #c7a589; }
/* Media Uploader */
.media-item .bar, .media-progress-bar div {
background-color: #c7a589; }
.details.attachment {
-webkit-box-shadow: 0 0 0 1px #fff, 0 0 0 5px #c7a589;
box-shadow: 0 0 0 1px #fff, 0 0 0 5px #c7a589; }
.attachment.details .check {
background-color: #c7a589;
-webkit-box-shadow: 0 0 0 1px #fff, 0 0 0 2px #c7a589;
box-shadow: 0 0 0 1px #fff, 0 0 0 2px #c7a589; }
/* Themes */
.theme-browser .theme.active .theme-name, .theme-browser .theme.add-new-theme:hover:after {
background: #c7a589; }
.theme-browser .theme.add-new-theme:hover span:after {
color: #c7a589; }
.theme-overlay .theme-header .close:hover, .theme-overlay .theme-header .right:hover, .theme-overlay .theme-header .left:hover {
background: #c7a589; }
.theme-section.current, .theme-filter.current {
border-bottom-color: #59524c; }
body.more-filters-opened .more-filters, body.more-filters-opened .more-filters:before {
color: #fff;
background-color: #59524c; }
body.more-filters-opened .more-filters:hover, body.more-filters-opened .more-filters:focus, body.more-filters-opened .more-filters:hover:before, body.more-filters-opened .more-filters:focus:before {
background-color: #c7a589;
color: #fff; }
/* Widgets */
.widgets-chooser li.widgets-chooser-selected {
background-color: #c7a589;
color: #fff; }
.widgets-chooser li.widgets-chooser-selected:before, .widgets-chooser li.widgets-chooser-selected:focus:before {
color: #fff; }
/* Customize */
#customize-theme-controls .widget-area-select .selected {
background-color: #c7a589;
color: #fff; }
/* jQuery UI Slider */
.wp-slider .ui-slider-handle, .wp-slider .ui-slider-handle.ui-state-hover, .wp-slider .ui-slider-handle.focus {
background: #c7a589;
border-color: #b78a66;
-webkit-box-shadow: inset 0 1px 0 #e0cdbd, 0 1px 0 rgba(0, 0, 0, 0.15);
box-shadow: inset 0 1px 0 #e0cdbd, 0 1px 0 rgba(0, 0, 0, 0.15); }
/* Thickbox: Plugin information */
#sidemenu a.current {
background: #f1f1f1;
border-bottom-color: #f1f1f1; }
#plugin-information .action-button {
background: #c7a589; }
/* Responsive Component */
div#wp-responsive-toggle a:before {
color: #f3f2f1; }
.wp-responsive-open div#wp-responsive-toggle a {
border-color: transparent;
background: #c7a589; }
.star-rating .star {
color: #c7a589; }
.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle a {
background: #46403c; }
| 01-wordpress-paypal | trunk/wp-admin/css/colors/coffee/colors.css | CSS | gpl3 | 12,669 |
$base-color: #59524c;
$highlight-color: #c7a589;
$notification-color: #9ea476;
$form-checked: $base-color;
@import "../_admin.scss";
| 01-wordpress-paypal | trunk/wp-admin/css/colors/coffee/colors.scss | SCSS | gpl3 | 135 |
/*
* Button mixin- creates 3d-ish button effect with correct
* highlights/shadows, based on a base color.
*/
html {
background: #f1f1f1; }
/* Links */
a {
color: #0074a2; }
a:hover, a:active, a:focus {
color: #0099d5; }
#media-upload a.del-link:hover, div.dashboard-widget-submit input:hover, .subsubsub a:hover, .subsubsub a.current:hover {
color: #0099d5; }
/* Forms */
input[type=checkbox]:checked:before {
color: #59524c; }
input[type=radio]:checked:before {
background: #59524c; }
.wp-core-ui input[type="reset"]:hover, .wp-core-ui input[type="reset"]:active {
color: #0099d5; }
/* Core UI */
.wp-core-ui .button-primary {
background: #c7a589;
border-color: #b78a66;
color: white;
-webkit-box-shadow: inset 0 1px 0 #e0cdbd, 0 1px 0 rgba(0, 0, 0, 0.15);
box-shadow: inset 0 1px 0 #e0cdbd, 0 1px 0 rgba(0, 0, 0, 0.15); }
.wp-core-ui .button-primary:hover, .wp-core-ui .button-primary:focus {
background: #bf9878;
border-color: #ae7d55;
color: white;
-webkit-box-shadow: inset 0 1px 0 #d7bfac, 0 1px 0 rgba(0, 0, 0, 0.15);
box-shadow: inset 0 1px 0 #d7bfac, 0 1px 0 rgba(0, 0, 0, 0.15); }
.wp-core-ui .button-primary:active {
background: #b78a66;
border-color: #ae7d55;
color: white;
-webkit-box-shadow: inset 0 2px 5px -3px rgba(0, 0, 0, 0.5);
box-shadow: inset 0 2px 5px -3px rgba(0, 0, 0, 0.5); }
.wp-core-ui .button-primary[disabled], .wp-core-ui .button-primary:disabled, .wp-core-ui .button-primary.button-primary-disabled, .wp-core-ui .button-primary.disabled {
color: #d1cbc7 !important;
background: #ba906d !important;
border-color: #ae7d55 !important;
text-shadow: none !important; }
.wp-core-ui .wp-ui-primary {
color: #fff;
background-color: #59524c; }
.wp-core-ui .wp-ui-text-primary {
color: #59524c; }
.wp-core-ui .wp-ui-highlight {
color: #fff;
background-color: #c7a589; }
.wp-core-ui .wp-ui-text-highlight {
color: #c7a589; }
.wp-core-ui .wp-ui-notification {
color: #fff;
background-color: #9ea476; }
.wp-core-ui .wp-ui-text-notification {
color: #9ea476; }
.wp-core-ui .wp-ui-text-icon {
color: #f3f2f1; }
/* List tables */
.wrap .add-new-h2:hover, #add-new-comment a:hover, .tablenav .tablenav-pages a:hover, .tablenav .tablenav-pages a:focus {
color: #fff;
background-color: #59524c; }
.view-switch a.current:before {
color: #59524c; }
.view-switch a:hover:before {
color: #9ea476; }
.post-com-count:hover:after {
border-top-color: #59524c; }
.post-com-count:hover span {
color: #fff;
background-color: #59524c; }
strong .post-com-count:after {
border-top-color: #9ea476; }
strong .post-com-count span {
background-color: #9ea476; }
/* Admin Menu */
#adminmenuback, #adminmenuwrap, #adminmenu {
background: #59524c; }
#adminmenu a {
color: #fff; }
#adminmenu div.wp-menu-image:before {
color: #f3f2f1; }
#adminmenu a:hover, #adminmenu li.menu-top:hover, #adminmenu li.opensub > a.menu-top, #adminmenu li > a.menu-top:focus {
color: #fff;
background-color: #c7a589; }
#adminmenu li.menu-top:hover div.wp-menu-image:before, #adminmenu li.opensub > a.menu-top div.wp-menu-image:before {
color: #fff; }
/* Active tabs use a bottom border color that matches the page background color. */
.about-wrap h2 .nav-tab-active, .nav-tab-active, .nav-tab-active:hover {
background-color: #f1f1f1;
border-bottom-color: #f1f1f1; }
/* Admin Menu: submenu */
#adminmenu .wp-submenu, #adminmenu .wp-has-current-submenu .wp-submenu, #adminmenu .wp-has-current-submenu.opensub .wp-submenu, .folded #adminmenu .wp-has-current-submenu .wp-submenu, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu {
background: #46403c; }
#adminmenu li.wp-has-submenu.wp-not-current-submenu.opensub:hover:after {
border-left-color: #46403c; }
#adminmenu .wp-submenu .wp-submenu-head {
color: #cdcbc9; }
#adminmenu .wp-submenu a, #adminmenu .wp-has-current-submenu .wp-submenu a, .folded #adminmenu .wp-has-current-submenu .wp-submenu a, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu a, #adminmenu .wp-has-current-submenu.opensub .wp-submenu a {
color: #cdcbc9; }
#adminmenu .wp-submenu a:focus, #adminmenu .wp-submenu a:hover, #adminmenu .wp-has-current-submenu .wp-submenu a:focus, #adminmenu .wp-has-current-submenu .wp-submenu a:hover, .folded #adminmenu .wp-has-current-submenu .wp-submenu a:focus, .folded #adminmenu .wp-has-current-submenu .wp-submenu a:hover, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu a:focus, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu a:hover, #adminmenu .wp-has-current-submenu.opensub .wp-submenu a:focus, #adminmenu .wp-has-current-submenu.opensub .wp-submenu a:hover {
color: #c7a589; }
/* Admin Menu: current */
#adminmenu .wp-submenu li.current a, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a, #adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a {
color: #fff; }
#adminmenu .wp-submenu li.current a:hover, #adminmenu .wp-submenu li.current a:focus, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a:hover, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a:focus, #adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:hover, #adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:focus {
color: #c7a589; }
ul#adminmenu a.wp-has-current-submenu:after, ul#adminmenu > li.current > a.current:after {
border-left-color: #f1f1f1; }
#adminmenu li.current a.menu-top, #adminmenu li.wp-has-current-submenu a.wp-has-current-submenu, #adminmenu li.wp-has-current-submenu .wp-submenu .wp-submenu-head, .folded #adminmenu li.current.menu-top {
color: #fff;
background: #c7a589; }
#adminmenu li.wp-has-current-submenu div.wp-menu-image:before {
color: #fff; }
/* Admin Menu: bubble */
#adminmenu .awaiting-mod, #adminmenu .update-plugins {
color: #fff;
background: #9ea476; }
#adminmenu li.current a .awaiting-mod, #adminmenu li a.wp-has-current-submenu .update-plugins, #adminmenu li:hover a .awaiting-mod, #adminmenu li.menu-top:hover > a .update-plugins {
color: #fff;
background: #46403c; }
/* Admin Menu: collapse button */
#collapse-menu {
color: #f3f2f1; }
#collapse-menu:hover {
color: #fff; }
#collapse-button div:after {
color: #f3f2f1; }
#collapse-menu:hover #collapse-button div:after {
color: #fff; }
/* Admin Bar */
#wpadminbar {
color: #fff;
background: #59524c; }
#wpadminbar .ab-item, #wpadminbar a.ab-item, #wpadminbar > #wp-toolbar span.ab-label, #wpadminbar > #wp-toolbar span.noticon {
color: #fff; }
#wpadminbar .ab-icon, #wpadminbar .ab-icon:before, #wpadminbar .ab-item:before, #wpadminbar .ab-item:after {
color: #f3f2f1; }
#wpadminbar .ab-top-menu > li:hover > .ab-item, #wpadminbar .ab-top-menu > li.hover > .ab-item, #wpadminbar .ab-top-menu > li > .ab-item:focus, #wpadminbar.nojq .quicklinks .ab-top-menu > li > .ab-item:focus, #wpadminbar-nojs .ab-top-menu > li.menupop:hover > .ab-item, #wpadminbar .ab-top-menu > li.menupop.hover > .ab-item {
color: #c7a589;
background: #46403c; }
#wpadminbar > #wp-toolbar li:hover span.ab-label, #wpadminbar > #wp-toolbar li.hover span.ab-label, #wpadminbar > #wp-toolbar a:focus span.ab-label {
color: #c7a589; }
#wpadminbar li:hover .ab-icon:before, #wpadminbar li:hover .ab-item:before, #wpadminbar li:hover .ab-item:after, #wpadminbar li:hover #adminbarsearch:before {
color: #fff; }
/* Admin Bar: submenu */
#wpadminbar .menupop .ab-sub-wrapper {
background: #46403c; }
#wpadminbar .quicklinks .menupop ul.ab-sub-secondary, #wpadminbar .quicklinks .menupop ul.ab-sub-secondary .ab-submenu {
background: #656463; }
#wpadminbar .ab-submenu .ab-item, #wpadminbar .quicklinks .menupop ul li a, #wpadminbar .quicklinks .menupop.hover ul li a, #wpadminbar-nojs .quicklinks .menupop:hover ul li a {
color: #cdcbc9; }
#wpadminbar .quicklinks li .blavatar, #wpadminbar .menupop .menupop > .ab-item:before {
color: #f3f2f1; }
#wpadminbar .quicklinks .menupop ul li a:hover, #wpadminbar .quicklinks .menupop ul li a:focus, #wpadminbar .quicklinks .menupop ul li a:hover strong, #wpadminbar .quicklinks .menupop ul li a:focus strong, #wpadminbar .quicklinks .menupop.hover ul li a:hover, #wpadminbar .quicklinks .menupop.hover ul li a:focus, #wpadminbar.nojs .quicklinks .menupop:hover ul li a:hover, #wpadminbar.nojs .quicklinks .menupop:hover ul li a:focus, #wpadminbar li:hover .ab-icon:before, #wpadminbar li:hover .ab-item:before, #wpadminbar li a:focus .ab-icon:before, #wpadminbar li .ab-item:focus:before, #wpadminbar li.hover .ab-icon:before, #wpadminbar li.hover .ab-item:before, #wpadminbar li:hover .ab-item:after, #wpadminbar li.hover .ab-item:after, #wpadminbar li:hover #adminbarsearch:before {
color: #c7a589; }
#wpadminbar .quicklinks li a:hover .blavatar, #wpadminbar .menupop .menupop > .ab-item:hover:before {
color: #c7a589; }
/* Admin Bar: search */
#wpadminbar #adminbarsearch:before {
color: #f3f2f1; }
#wpadminbar > #wp-toolbar > #wp-admin-bar-top-secondary > #wp-admin-bar-search #adminbarsearch input.adminbar-input:focus {
color: #fff;
background: #6c645c; }
#wpadminbar #adminbarsearch .adminbar-input::-webkit-input-placeholder {
color: #fff;
opacity: 0.7; }
#wpadminbar #adminbarsearch .adminbar-input:-moz-placeholder {
color: #fff;
opacity: 0.7; }
#wpadminbar #adminbarsearch .adminbar-input::-moz-placeholder {
color: #fff;
opacity: 0.7; }
#wpadminbar #adminbarsearch .adminbar-input:-ms-input-placeholder {
color: #fff;
opacity: 0.7; }
/* Admin Bar: my account */
#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar > a img {
border-color: #6c645c;
background-color: #6c645c; }
#wpadminbar #wp-admin-bar-user-info .display-name {
color: #fff; }
#wpadminbar #wp-admin-bar-user-info a:hover .display-name {
color: #c7a589; }
#wpadminbar #wp-admin-bar-user-info .username {
color: #cdcbc9; }
/* Pointers */
.wp-pointer .wp-pointer-content h3 {
background-color: #c7a589;
border-color: #bf9878; }
.wp-pointer .wp-pointer-content h3:before {
color: #c7a589; }
.wp-pointer.wp-pointer-top .wp-pointer-arrow, .wp-pointer.wp-pointer-undefined .wp-pointer-arrow {
border-bottom-color: #c7a589; }
/* Media Uploader */
.media-item .bar, .media-progress-bar div {
background-color: #c7a589; }
.details.attachment {
-webkit-box-shadow: 0 0 0 1px #fff, 0 0 0 5px #c7a589;
box-shadow: 0 0 0 1px #fff, 0 0 0 5px #c7a589; }
.attachment.details .check {
background-color: #c7a589;
-webkit-box-shadow: 0 0 0 1px #fff, 0 0 0 2px #c7a589;
box-shadow: 0 0 0 1px #fff, 0 0 0 2px #c7a589; }
/* Themes */
.theme-browser .theme.active .theme-name, .theme-browser .theme.add-new-theme:hover:after {
background: #c7a589; }
.theme-browser .theme.add-new-theme:hover span:after {
color: #c7a589; }
.theme-overlay .theme-header .close:hover, .theme-overlay .theme-header .right:hover, .theme-overlay .theme-header .left:hover {
background: #c7a589; }
.theme-section.current, .theme-filter.current {
border-bottom-color: #59524c; }
body.more-filters-opened .more-filters, body.more-filters-opened .more-filters:before {
color: #fff;
background-color: #59524c; }
body.more-filters-opened .more-filters:hover, body.more-filters-opened .more-filters:focus, body.more-filters-opened .more-filters:hover:before, body.more-filters-opened .more-filters:focus:before {
background-color: #c7a589;
color: #fff; }
/* Widgets */
.widgets-chooser li.widgets-chooser-selected {
background-color: #c7a589;
color: #fff; }
.widgets-chooser li.widgets-chooser-selected:before, .widgets-chooser li.widgets-chooser-selected:focus:before {
color: #fff; }
/* Customize */
#customize-theme-controls .widget-area-select .selected {
background-color: #c7a589;
color: #fff; }
/* jQuery UI Slider */
.wp-slider .ui-slider-handle, .wp-slider .ui-slider-handle.ui-state-hover, .wp-slider .ui-slider-handle.focus {
background: #c7a589;
border-color: #b78a66;
-webkit-box-shadow: inset 0 1px 0 #e0cdbd, 0 1px 0 rgba(0, 0, 0, 0.15);
box-shadow: inset 0 1px 0 #e0cdbd, 0 1px 0 rgba(0, 0, 0, 0.15); }
/* Thickbox: Plugin information */
#sidemenu a.current {
background: #f1f1f1;
border-bottom-color: #f1f1f1; }
#plugin-information .action-button {
background: #c7a589; }
/* Responsive Component */
div#wp-responsive-toggle a:before {
color: #f3f2f1; }
.wp-responsive-open div#wp-responsive-toggle a {
border-color: transparent;
background: #c7a589; }
.star-rating .star {
color: #c7a589; }
.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle a {
background: #46403c; }
| 01-wordpress-paypal | trunk/wp-admin/css/colors/coffee/colors-rtl.css | CSS | gpl3 | 12,667 |
/*
* Button mixin- creates 3d-ish button effect with correct
* highlights/shadows, based on a base color.
*/
html {
background: #f1f1f1; }
/* Links */
a {
color: #0074a2; }
a:hover, a:active, a:focus {
color: #0099d5; }
#media-upload a.del-link:hover, div.dashboard-widget-submit input:hover, .subsubsub a:hover, .subsubsub a.current:hover {
color: #0099d5; }
/* Forms */
input[type=checkbox]:checked:before {
color: #e14d43; }
input[type=radio]:checked:before {
background: #e14d43; }
.wp-core-ui input[type="reset"]:hover, .wp-core-ui input[type="reset"]:active {
color: #0099d5; }
/* Core UI */
.wp-core-ui .button-primary {
background: #e14d43;
border-color: #d02a21;
color: white;
-webkit-box-shadow: inset 0 1px 0 #ec8a85, 0 1px 0 rgba(0, 0, 0, 0.15);
box-shadow: inset 0 1px 0 #ec8a85, 0 1px 0 rgba(0, 0, 0, 0.15); }
.wp-core-ui .button-primary:hover, .wp-core-ui .button-primary:focus {
background: #dd362d;
border-color: #ba251e;
color: white;
-webkit-box-shadow: inset 0 1px 0 #e8756f, 0 1px 0 rgba(0, 0, 0, 0.15);
box-shadow: inset 0 1px 0 #e8756f, 0 1px 0 rgba(0, 0, 0, 0.15); }
.wp-core-ui .button-primary:active {
background: #d02a21;
border-color: #ba251e;
color: white;
-webkit-box-shadow: inset 0 2px 5px -3px rgba(0, 0, 0, 0.5);
box-shadow: inset 0 2px 5px -3px rgba(0, 0, 0, 0.5); }
.wp-core-ui .button-primary[disabled], .wp-core-ui .button-primary:disabled, .wp-core-ui .button-primary.button-primary-disabled, .wp-core-ui .button-primary.disabled {
color: #d1c7c7 !important;
background: #d92c23 !important;
border-color: #ba251e !important;
text-shadow: none !important; }
.wp-core-ui .wp-ui-primary {
color: #fff;
background-color: #363b3f; }
.wp-core-ui .wp-ui-text-primary {
color: #363b3f; }
.wp-core-ui .wp-ui-highlight {
color: #fff;
background-color: #e14d43; }
.wp-core-ui .wp-ui-text-highlight {
color: #e14d43; }
.wp-core-ui .wp-ui-notification {
color: #fff;
background-color: #69a8bb; }
.wp-core-ui .wp-ui-text-notification {
color: #69a8bb; }
.wp-core-ui .wp-ui-text-icon {
color: #f1f2f3; }
/* List tables */
.wrap .add-new-h2:hover, #add-new-comment a:hover, .tablenav .tablenav-pages a:hover, .tablenav .tablenav-pages a:focus {
color: #fff;
background-color: #363b3f; }
.view-switch a.current:before {
color: #363b3f; }
.view-switch a:hover:before {
color: #69a8bb; }
.post-com-count:hover:after {
border-top-color: #363b3f; }
.post-com-count:hover span {
color: #fff;
background-color: #363b3f; }
strong .post-com-count:after {
border-top-color: #69a8bb; }
strong .post-com-count span {
background-color: #69a8bb; }
/* Admin Menu */
#adminmenuback, #adminmenuwrap, #adminmenu {
background: #363b3f; }
#adminmenu a {
color: #fff; }
#adminmenu div.wp-menu-image:before {
color: #f1f2f3; }
#adminmenu a:hover, #adminmenu li.menu-top:hover, #adminmenu li.opensub > a.menu-top, #adminmenu li > a.menu-top:focus {
color: #fff;
background-color: #e14d43; }
#adminmenu li.menu-top:hover div.wp-menu-image:before, #adminmenu li.opensub > a.menu-top div.wp-menu-image:before {
color: #fff; }
/* Active tabs use a bottom border color that matches the page background color. */
.about-wrap h2 .nav-tab-active, .nav-tab-active, .nav-tab-active:hover {
background-color: #f1f1f1;
border-bottom-color: #f1f1f1; }
/* Admin Menu: submenu */
#adminmenu .wp-submenu, #adminmenu .wp-has-current-submenu .wp-submenu, #adminmenu .wp-has-current-submenu.opensub .wp-submenu, .folded #adminmenu .wp-has-current-submenu .wp-submenu, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu {
background: #26292c; }
#adminmenu li.wp-has-submenu.wp-not-current-submenu.opensub:hover:after {
border-right-color: #26292c; }
#adminmenu .wp-submenu .wp-submenu-head {
color: #c2c4c5; }
#adminmenu .wp-submenu a, #adminmenu .wp-has-current-submenu .wp-submenu a, .folded #adminmenu .wp-has-current-submenu .wp-submenu a, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu a, #adminmenu .wp-has-current-submenu.opensub .wp-submenu a {
color: #c2c4c5; }
#adminmenu .wp-submenu a:focus, #adminmenu .wp-submenu a:hover, #adminmenu .wp-has-current-submenu .wp-submenu a:focus, #adminmenu .wp-has-current-submenu .wp-submenu a:hover, .folded #adminmenu .wp-has-current-submenu .wp-submenu a:focus, .folded #adminmenu .wp-has-current-submenu .wp-submenu a:hover, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu a:focus, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu a:hover, #adminmenu .wp-has-current-submenu.opensub .wp-submenu a:focus, #adminmenu .wp-has-current-submenu.opensub .wp-submenu a:hover {
color: #e14d43; }
/* Admin Menu: current */
#adminmenu .wp-submenu li.current a, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a, #adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a {
color: #fff; }
#adminmenu .wp-submenu li.current a:hover, #adminmenu .wp-submenu li.current a:focus, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a:hover, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a:focus, #adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:hover, #adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:focus {
color: #e14d43; }
ul#adminmenu a.wp-has-current-submenu:after, ul#adminmenu > li.current > a.current:after {
border-right-color: #f1f1f1; }
#adminmenu li.current a.menu-top, #adminmenu li.wp-has-current-submenu a.wp-has-current-submenu, #adminmenu li.wp-has-current-submenu .wp-submenu .wp-submenu-head, .folded #adminmenu li.current.menu-top {
color: #fff;
background: #e14d43; }
#adminmenu li.wp-has-current-submenu div.wp-menu-image:before {
color: #fff; }
/* Admin Menu: bubble */
#adminmenu .awaiting-mod, #adminmenu .update-plugins {
color: #fff;
background: #69a8bb; }
#adminmenu li.current a .awaiting-mod, #adminmenu li a.wp-has-current-submenu .update-plugins, #adminmenu li:hover a .awaiting-mod, #adminmenu li.menu-top:hover > a .update-plugins {
color: #fff;
background: #26292c; }
/* Admin Menu: collapse button */
#collapse-menu {
color: #f1f2f3; }
#collapse-menu:hover {
color: #fff; }
#collapse-button div:after {
color: #f1f2f3; }
#collapse-menu:hover #collapse-button div:after {
color: #fff; }
/* Admin Bar */
#wpadminbar {
color: #fff;
background: #363b3f; }
#wpadminbar .ab-item, #wpadminbar a.ab-item, #wpadminbar > #wp-toolbar span.ab-label, #wpadminbar > #wp-toolbar span.noticon {
color: #fff; }
#wpadminbar .ab-icon, #wpadminbar .ab-icon:before, #wpadminbar .ab-item:before, #wpadminbar .ab-item:after {
color: #f1f2f3; }
#wpadminbar .ab-top-menu > li:hover > .ab-item, #wpadminbar .ab-top-menu > li.hover > .ab-item, #wpadminbar .ab-top-menu > li > .ab-item:focus, #wpadminbar.nojq .quicklinks .ab-top-menu > li > .ab-item:focus, #wpadminbar-nojs .ab-top-menu > li.menupop:hover > .ab-item, #wpadminbar .ab-top-menu > li.menupop.hover > .ab-item {
color: #e14d43;
background: #26292c; }
#wpadminbar > #wp-toolbar li:hover span.ab-label, #wpadminbar > #wp-toolbar li.hover span.ab-label, #wpadminbar > #wp-toolbar a:focus span.ab-label {
color: #e14d43; }
#wpadminbar li:hover .ab-icon:before, #wpadminbar li:hover .ab-item:before, #wpadminbar li:hover .ab-item:after, #wpadminbar li:hover #adminbarsearch:before {
color: #fff; }
/* Admin Bar: submenu */
#wpadminbar .menupop .ab-sub-wrapper {
background: #26292c; }
#wpadminbar .quicklinks .menupop ul.ab-sub-secondary, #wpadminbar .quicklinks .menupop ul.ab-sub-secondary .ab-submenu {
background: #4c4c4d; }
#wpadminbar .ab-submenu .ab-item, #wpadminbar .quicklinks .menupop ul li a, #wpadminbar .quicklinks .menupop.hover ul li a, #wpadminbar-nojs .quicklinks .menupop:hover ul li a {
color: #c2c4c5; }
#wpadminbar .quicklinks li .blavatar, #wpadminbar .menupop .menupop > .ab-item:before {
color: #f1f2f3; }
#wpadminbar .quicklinks .menupop ul li a:hover, #wpadminbar .quicklinks .menupop ul li a:focus, #wpadminbar .quicklinks .menupop ul li a:hover strong, #wpadminbar .quicklinks .menupop ul li a:focus strong, #wpadminbar .quicklinks .menupop.hover ul li a:hover, #wpadminbar .quicklinks .menupop.hover ul li a:focus, #wpadminbar.nojs .quicklinks .menupop:hover ul li a:hover, #wpadminbar.nojs .quicklinks .menupop:hover ul li a:focus, #wpadminbar li:hover .ab-icon:before, #wpadminbar li:hover .ab-item:before, #wpadminbar li a:focus .ab-icon:before, #wpadminbar li .ab-item:focus:before, #wpadminbar li.hover .ab-icon:before, #wpadminbar li.hover .ab-item:before, #wpadminbar li:hover .ab-item:after, #wpadminbar li.hover .ab-item:after, #wpadminbar li:hover #adminbarsearch:before {
color: #e14d43; }
#wpadminbar .quicklinks li a:hover .blavatar, #wpadminbar .menupop .menupop > .ab-item:hover:before {
color: #e14d43; }
/* Admin Bar: search */
#wpadminbar #adminbarsearch:before {
color: #f1f2f3; }
#wpadminbar > #wp-toolbar > #wp-admin-bar-top-secondary > #wp-admin-bar-search #adminbarsearch input.adminbar-input:focus {
color: #fff;
background: #464d52; }
#wpadminbar #adminbarsearch .adminbar-input::-webkit-input-placeholder {
color: #fff;
opacity: 0.7; }
#wpadminbar #adminbarsearch .adminbar-input:-moz-placeholder {
color: #fff;
opacity: 0.7; }
#wpadminbar #adminbarsearch .adminbar-input::-moz-placeholder {
color: #fff;
opacity: 0.7; }
#wpadminbar #adminbarsearch .adminbar-input:-ms-input-placeholder {
color: #fff;
opacity: 0.7; }
/* Admin Bar: my account */
#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar > a img {
border-color: #464d52;
background-color: #464d52; }
#wpadminbar #wp-admin-bar-user-info .display-name {
color: #fff; }
#wpadminbar #wp-admin-bar-user-info a:hover .display-name {
color: #e14d43; }
#wpadminbar #wp-admin-bar-user-info .username {
color: #c2c4c5; }
/* Pointers */
.wp-pointer .wp-pointer-content h3 {
background-color: #e14d43;
border-color: #dd362d; }
.wp-pointer .wp-pointer-content h3:before {
color: #e14d43; }
.wp-pointer.wp-pointer-top .wp-pointer-arrow, .wp-pointer.wp-pointer-undefined .wp-pointer-arrow {
border-bottom-color: #e14d43; }
/* Media Uploader */
.media-item .bar, .media-progress-bar div {
background-color: #e14d43; }
.details.attachment {
-webkit-box-shadow: 0 0 0 1px #fff, 0 0 0 5px #e14d43;
box-shadow: 0 0 0 1px #fff, 0 0 0 5px #e14d43; }
.attachment.details .check {
background-color: #e14d43;
-webkit-box-shadow: 0 0 0 1px #fff, 0 0 0 2px #e14d43;
box-shadow: 0 0 0 1px #fff, 0 0 0 2px #e14d43; }
/* Themes */
.theme-browser .theme.active .theme-name, .theme-browser .theme.add-new-theme:hover:after {
background: #e14d43; }
.theme-browser .theme.add-new-theme:hover span:after {
color: #e14d43; }
.theme-overlay .theme-header .close:hover, .theme-overlay .theme-header .right:hover, .theme-overlay .theme-header .left:hover {
background: #e14d43; }
.theme-section.current, .theme-filter.current {
border-bottom-color: #363b3f; }
body.more-filters-opened .more-filters, body.more-filters-opened .more-filters:before {
color: #fff;
background-color: #363b3f; }
body.more-filters-opened .more-filters:hover, body.more-filters-opened .more-filters:focus, body.more-filters-opened .more-filters:hover:before, body.more-filters-opened .more-filters:focus:before {
background-color: #e14d43;
color: #fff; }
/* Widgets */
.widgets-chooser li.widgets-chooser-selected {
background-color: #e14d43;
color: #fff; }
.widgets-chooser li.widgets-chooser-selected:before, .widgets-chooser li.widgets-chooser-selected:focus:before {
color: #fff; }
/* Customize */
#customize-theme-controls .widget-area-select .selected {
background-color: #e14d43;
color: #fff; }
/* jQuery UI Slider */
.wp-slider .ui-slider-handle, .wp-slider .ui-slider-handle.ui-state-hover, .wp-slider .ui-slider-handle.focus {
background: #e14d43;
border-color: #d02a21;
-webkit-box-shadow: inset 0 1px 0 #ec8a85, 0 1px 0 rgba(0, 0, 0, 0.15);
box-shadow: inset 0 1px 0 #ec8a85, 0 1px 0 rgba(0, 0, 0, 0.15); }
/* Thickbox: Plugin information */
#sidemenu a.current {
background: #f1f1f1;
border-bottom-color: #f1f1f1; }
#plugin-information .action-button {
background: #e14d43; }
/* Responsive Component */
div#wp-responsive-toggle a:before {
color: #f1f2f3; }
.wp-responsive-open div#wp-responsive-toggle a {
border-color: transparent;
background: #e14d43; }
.star-rating .star {
color: #e14d43; }
.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle a {
background: #26292c; }
| 01-wordpress-paypal | trunk/wp-admin/css/colors/midnight/colors.css | CSS | gpl3 | 12,669 |
$base-color: #363b3f;
$highlight-color: #e14d43;
$notification-color: #69a8bb;
@import "../_admin.scss";
| 01-wordpress-paypal | trunk/wp-admin/css/colors/midnight/colors.scss | SCSS | gpl3 | 106 |
/*
* Button mixin- creates 3d-ish button effect with correct
* highlights/shadows, based on a base color.
*/
html {
background: #f1f1f1; }
/* Links */
a {
color: #0074a2; }
a:hover, a:active, a:focus {
color: #0099d5; }
#media-upload a.del-link:hover, div.dashboard-widget-submit input:hover, .subsubsub a:hover, .subsubsub a.current:hover {
color: #0099d5; }
/* Forms */
input[type=checkbox]:checked:before {
color: #e14d43; }
input[type=radio]:checked:before {
background: #e14d43; }
.wp-core-ui input[type="reset"]:hover, .wp-core-ui input[type="reset"]:active {
color: #0099d5; }
/* Core UI */
.wp-core-ui .button-primary {
background: #e14d43;
border-color: #d02a21;
color: white;
-webkit-box-shadow: inset 0 1px 0 #ec8a85, 0 1px 0 rgba(0, 0, 0, 0.15);
box-shadow: inset 0 1px 0 #ec8a85, 0 1px 0 rgba(0, 0, 0, 0.15); }
.wp-core-ui .button-primary:hover, .wp-core-ui .button-primary:focus {
background: #dd362d;
border-color: #ba251e;
color: white;
-webkit-box-shadow: inset 0 1px 0 #e8756f, 0 1px 0 rgba(0, 0, 0, 0.15);
box-shadow: inset 0 1px 0 #e8756f, 0 1px 0 rgba(0, 0, 0, 0.15); }
.wp-core-ui .button-primary:active {
background: #d02a21;
border-color: #ba251e;
color: white;
-webkit-box-shadow: inset 0 2px 5px -3px rgba(0, 0, 0, 0.5);
box-shadow: inset 0 2px 5px -3px rgba(0, 0, 0, 0.5); }
.wp-core-ui .button-primary[disabled], .wp-core-ui .button-primary:disabled, .wp-core-ui .button-primary.button-primary-disabled, .wp-core-ui .button-primary.disabled {
color: #d1c7c7 !important;
background: #d92c23 !important;
border-color: #ba251e !important;
text-shadow: none !important; }
.wp-core-ui .wp-ui-primary {
color: #fff;
background-color: #363b3f; }
.wp-core-ui .wp-ui-text-primary {
color: #363b3f; }
.wp-core-ui .wp-ui-highlight {
color: #fff;
background-color: #e14d43; }
.wp-core-ui .wp-ui-text-highlight {
color: #e14d43; }
.wp-core-ui .wp-ui-notification {
color: #fff;
background-color: #69a8bb; }
.wp-core-ui .wp-ui-text-notification {
color: #69a8bb; }
.wp-core-ui .wp-ui-text-icon {
color: #f1f2f3; }
/* List tables */
.wrap .add-new-h2:hover, #add-new-comment a:hover, .tablenav .tablenav-pages a:hover, .tablenav .tablenav-pages a:focus {
color: #fff;
background-color: #363b3f; }
.view-switch a.current:before {
color: #363b3f; }
.view-switch a:hover:before {
color: #69a8bb; }
.post-com-count:hover:after {
border-top-color: #363b3f; }
.post-com-count:hover span {
color: #fff;
background-color: #363b3f; }
strong .post-com-count:after {
border-top-color: #69a8bb; }
strong .post-com-count span {
background-color: #69a8bb; }
/* Admin Menu */
#adminmenuback, #adminmenuwrap, #adminmenu {
background: #363b3f; }
#adminmenu a {
color: #fff; }
#adminmenu div.wp-menu-image:before {
color: #f1f2f3; }
#adminmenu a:hover, #adminmenu li.menu-top:hover, #adminmenu li.opensub > a.menu-top, #adminmenu li > a.menu-top:focus {
color: #fff;
background-color: #e14d43; }
#adminmenu li.menu-top:hover div.wp-menu-image:before, #adminmenu li.opensub > a.menu-top div.wp-menu-image:before {
color: #fff; }
/* Active tabs use a bottom border color that matches the page background color. */
.about-wrap h2 .nav-tab-active, .nav-tab-active, .nav-tab-active:hover {
background-color: #f1f1f1;
border-bottom-color: #f1f1f1; }
/* Admin Menu: submenu */
#adminmenu .wp-submenu, #adminmenu .wp-has-current-submenu .wp-submenu, #adminmenu .wp-has-current-submenu.opensub .wp-submenu, .folded #adminmenu .wp-has-current-submenu .wp-submenu, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu {
background: #26292c; }
#adminmenu li.wp-has-submenu.wp-not-current-submenu.opensub:hover:after {
border-left-color: #26292c; }
#adminmenu .wp-submenu .wp-submenu-head {
color: #c2c4c5; }
#adminmenu .wp-submenu a, #adminmenu .wp-has-current-submenu .wp-submenu a, .folded #adminmenu .wp-has-current-submenu .wp-submenu a, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu a, #adminmenu .wp-has-current-submenu.opensub .wp-submenu a {
color: #c2c4c5; }
#adminmenu .wp-submenu a:focus, #adminmenu .wp-submenu a:hover, #adminmenu .wp-has-current-submenu .wp-submenu a:focus, #adminmenu .wp-has-current-submenu .wp-submenu a:hover, .folded #adminmenu .wp-has-current-submenu .wp-submenu a:focus, .folded #adminmenu .wp-has-current-submenu .wp-submenu a:hover, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu a:focus, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu a:hover, #adminmenu .wp-has-current-submenu.opensub .wp-submenu a:focus, #adminmenu .wp-has-current-submenu.opensub .wp-submenu a:hover {
color: #e14d43; }
/* Admin Menu: current */
#adminmenu .wp-submenu li.current a, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a, #adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a {
color: #fff; }
#adminmenu .wp-submenu li.current a:hover, #adminmenu .wp-submenu li.current a:focus, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a:hover, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a:focus, #adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:hover, #adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:focus {
color: #e14d43; }
ul#adminmenu a.wp-has-current-submenu:after, ul#adminmenu > li.current > a.current:after {
border-left-color: #f1f1f1; }
#adminmenu li.current a.menu-top, #adminmenu li.wp-has-current-submenu a.wp-has-current-submenu, #adminmenu li.wp-has-current-submenu .wp-submenu .wp-submenu-head, .folded #adminmenu li.current.menu-top {
color: #fff;
background: #e14d43; }
#adminmenu li.wp-has-current-submenu div.wp-menu-image:before {
color: #fff; }
/* Admin Menu: bubble */
#adminmenu .awaiting-mod, #adminmenu .update-plugins {
color: #fff;
background: #69a8bb; }
#adminmenu li.current a .awaiting-mod, #adminmenu li a.wp-has-current-submenu .update-plugins, #adminmenu li:hover a .awaiting-mod, #adminmenu li.menu-top:hover > a .update-plugins {
color: #fff;
background: #26292c; }
/* Admin Menu: collapse button */
#collapse-menu {
color: #f1f2f3; }
#collapse-menu:hover {
color: #fff; }
#collapse-button div:after {
color: #f1f2f3; }
#collapse-menu:hover #collapse-button div:after {
color: #fff; }
/* Admin Bar */
#wpadminbar {
color: #fff;
background: #363b3f; }
#wpadminbar .ab-item, #wpadminbar a.ab-item, #wpadminbar > #wp-toolbar span.ab-label, #wpadminbar > #wp-toolbar span.noticon {
color: #fff; }
#wpadminbar .ab-icon, #wpadminbar .ab-icon:before, #wpadminbar .ab-item:before, #wpadminbar .ab-item:after {
color: #f1f2f3; }
#wpadminbar .ab-top-menu > li:hover > .ab-item, #wpadminbar .ab-top-menu > li.hover > .ab-item, #wpadminbar .ab-top-menu > li > .ab-item:focus, #wpadminbar.nojq .quicklinks .ab-top-menu > li > .ab-item:focus, #wpadminbar-nojs .ab-top-menu > li.menupop:hover > .ab-item, #wpadminbar .ab-top-menu > li.menupop.hover > .ab-item {
color: #e14d43;
background: #26292c; }
#wpadminbar > #wp-toolbar li:hover span.ab-label, #wpadminbar > #wp-toolbar li.hover span.ab-label, #wpadminbar > #wp-toolbar a:focus span.ab-label {
color: #e14d43; }
#wpadminbar li:hover .ab-icon:before, #wpadminbar li:hover .ab-item:before, #wpadminbar li:hover .ab-item:after, #wpadminbar li:hover #adminbarsearch:before {
color: #fff; }
/* Admin Bar: submenu */
#wpadminbar .menupop .ab-sub-wrapper {
background: #26292c; }
#wpadminbar .quicklinks .menupop ul.ab-sub-secondary, #wpadminbar .quicklinks .menupop ul.ab-sub-secondary .ab-submenu {
background: #4c4c4d; }
#wpadminbar .ab-submenu .ab-item, #wpadminbar .quicklinks .menupop ul li a, #wpadminbar .quicklinks .menupop.hover ul li a, #wpadminbar-nojs .quicklinks .menupop:hover ul li a {
color: #c2c4c5; }
#wpadminbar .quicklinks li .blavatar, #wpadminbar .menupop .menupop > .ab-item:before {
color: #f1f2f3; }
#wpadminbar .quicklinks .menupop ul li a:hover, #wpadminbar .quicklinks .menupop ul li a:focus, #wpadminbar .quicklinks .menupop ul li a:hover strong, #wpadminbar .quicklinks .menupop ul li a:focus strong, #wpadminbar .quicklinks .menupop.hover ul li a:hover, #wpadminbar .quicklinks .menupop.hover ul li a:focus, #wpadminbar.nojs .quicklinks .menupop:hover ul li a:hover, #wpadminbar.nojs .quicklinks .menupop:hover ul li a:focus, #wpadminbar li:hover .ab-icon:before, #wpadminbar li:hover .ab-item:before, #wpadminbar li a:focus .ab-icon:before, #wpadminbar li .ab-item:focus:before, #wpadminbar li.hover .ab-icon:before, #wpadminbar li.hover .ab-item:before, #wpadminbar li:hover .ab-item:after, #wpadminbar li.hover .ab-item:after, #wpadminbar li:hover #adminbarsearch:before {
color: #e14d43; }
#wpadminbar .quicklinks li a:hover .blavatar, #wpadminbar .menupop .menupop > .ab-item:hover:before {
color: #e14d43; }
/* Admin Bar: search */
#wpadminbar #adminbarsearch:before {
color: #f1f2f3; }
#wpadminbar > #wp-toolbar > #wp-admin-bar-top-secondary > #wp-admin-bar-search #adminbarsearch input.adminbar-input:focus {
color: #fff;
background: #464d52; }
#wpadminbar #adminbarsearch .adminbar-input::-webkit-input-placeholder {
color: #fff;
opacity: 0.7; }
#wpadminbar #adminbarsearch .adminbar-input:-moz-placeholder {
color: #fff;
opacity: 0.7; }
#wpadminbar #adminbarsearch .adminbar-input::-moz-placeholder {
color: #fff;
opacity: 0.7; }
#wpadminbar #adminbarsearch .adminbar-input:-ms-input-placeholder {
color: #fff;
opacity: 0.7; }
/* Admin Bar: my account */
#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar > a img {
border-color: #464d52;
background-color: #464d52; }
#wpadminbar #wp-admin-bar-user-info .display-name {
color: #fff; }
#wpadminbar #wp-admin-bar-user-info a:hover .display-name {
color: #e14d43; }
#wpadminbar #wp-admin-bar-user-info .username {
color: #c2c4c5; }
/* Pointers */
.wp-pointer .wp-pointer-content h3 {
background-color: #e14d43;
border-color: #dd362d; }
.wp-pointer .wp-pointer-content h3:before {
color: #e14d43; }
.wp-pointer.wp-pointer-top .wp-pointer-arrow, .wp-pointer.wp-pointer-undefined .wp-pointer-arrow {
border-bottom-color: #e14d43; }
/* Media Uploader */
.media-item .bar, .media-progress-bar div {
background-color: #e14d43; }
.details.attachment {
-webkit-box-shadow: 0 0 0 1px #fff, 0 0 0 5px #e14d43;
box-shadow: 0 0 0 1px #fff, 0 0 0 5px #e14d43; }
.attachment.details .check {
background-color: #e14d43;
-webkit-box-shadow: 0 0 0 1px #fff, 0 0 0 2px #e14d43;
box-shadow: 0 0 0 1px #fff, 0 0 0 2px #e14d43; }
/* Themes */
.theme-browser .theme.active .theme-name, .theme-browser .theme.add-new-theme:hover:after {
background: #e14d43; }
.theme-browser .theme.add-new-theme:hover span:after {
color: #e14d43; }
.theme-overlay .theme-header .close:hover, .theme-overlay .theme-header .right:hover, .theme-overlay .theme-header .left:hover {
background: #e14d43; }
.theme-section.current, .theme-filter.current {
border-bottom-color: #363b3f; }
body.more-filters-opened .more-filters, body.more-filters-opened .more-filters:before {
color: #fff;
background-color: #363b3f; }
body.more-filters-opened .more-filters:hover, body.more-filters-opened .more-filters:focus, body.more-filters-opened .more-filters:hover:before, body.more-filters-opened .more-filters:focus:before {
background-color: #e14d43;
color: #fff; }
/* Widgets */
.widgets-chooser li.widgets-chooser-selected {
background-color: #e14d43;
color: #fff; }
.widgets-chooser li.widgets-chooser-selected:before, .widgets-chooser li.widgets-chooser-selected:focus:before {
color: #fff; }
/* Customize */
#customize-theme-controls .widget-area-select .selected {
background-color: #e14d43;
color: #fff; }
/* jQuery UI Slider */
.wp-slider .ui-slider-handle, .wp-slider .ui-slider-handle.ui-state-hover, .wp-slider .ui-slider-handle.focus {
background: #e14d43;
border-color: #d02a21;
-webkit-box-shadow: inset 0 1px 0 #ec8a85, 0 1px 0 rgba(0, 0, 0, 0.15);
box-shadow: inset 0 1px 0 #ec8a85, 0 1px 0 rgba(0, 0, 0, 0.15); }
/* Thickbox: Plugin information */
#sidemenu a.current {
background: #f1f1f1;
border-bottom-color: #f1f1f1; }
#plugin-information .action-button {
background: #e14d43; }
/* Responsive Component */
div#wp-responsive-toggle a:before {
color: #f1f2f3; }
.wp-responsive-open div#wp-responsive-toggle a {
border-color: transparent;
background: #e14d43; }
.star-rating .star {
color: #e14d43; }
.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle a {
background: #26292c; }
| 01-wordpress-paypal | trunk/wp-admin/css/colors/midnight/colors-rtl.css | CSS | gpl3 | 12,667 |
@import url(common.css);
@import url(forms.css);
@import url(admin-menu.css);
@import url(dashboard.css);
@import url(list-tables.css);
@import url(edit.css);
@import url(revisions.css);
@import url(media.css);
@import url(themes.css);
@import url(press-this.css);
@import url(about.css);
@import url(nav-menus.css);
@import url(widgets.css);
@import url(l10n.css);
| 01-wordpress-paypal | trunk/wp-admin/css/wp-admin.css | CSS | gpl3 | 366 |
#wpbody-content #dashboard-widgets.columns-1 .postbox-container {
width: 100%;
}
#wpbody-content #dashboard-widgets.columns-2 .postbox-container {
width: 49.5%;
}
#wpbody-content #dashboard-widgets.columns-2 #postbox-container-2,
#wpbody-content #dashboard-widgets.columns-2 #postbox-container-3,
#wpbody-content #dashboard-widgets.columns-2 #postbox-container-4 {
float: right;
width: 50.5%;
}
#wpbody-content #dashboard-widgets.columns-3 .postbox-container {
width: 33.5%;
}
#wpbody-content #dashboard-widgets.columns-3 #postbox-container-1 {
width: 33%;
}
#wpbody-content #dashboard-widgets.columns-3 #postbox-container-3,
#wpbody-content #dashboard-widgets.columns-3 #postbox-container-4 {
float: right;
}
#wpbody-content #dashboard-widgets.columns-4 .postbox-container {
width: 25%;
}
#dashboard-widgets .postbox-container {
width: 25%;
}
#dashboard-widgets-wrap .columns-3 #postbox-container-4 .empty-container {
border: none !important;
}
.ie8 #wpbody-content #dashboard-widgets .postbox-container {
width: 49.5%;
}
.ie8 #wpbody-content #dashboard-widgets #postbox-container-2,
.ie8 #wpbody-content #dashboard-widgets #postbox-container-3,
.ie8 #wpbody-content #dashboard-widgets #postbox-container-4 {
float: right;
width: 50.5%;
}
.ie8 #dashboard-widgets #postbox-container-3 .empty-container,
.ie8 #dashboard-widgets #postbox-container-4 .empty-container {
border: 0 none;
height: 0;
min-height: 0;
}
/*------------------------------------------------------------------------------
9.0 - Dashboard
------------------------------------------------------------------------------*/
#dashboard-widgets-wrap {
overflow: hidden;
margin: 0 -8px;
}
#dashboard-widgets .postbox .inside {
margin-bottom: 0;
}
#dashboard-widgets .meta-box-sortables {
margin: 0 8px;
min-height: 100px;
}
h3.dashboard-widget-title,
h3.dashboard-widget-title span,
h3.dashboard-widget-title small {
color: #333;
}
h3.dashboard-widget-title small a {
color: #d7d7d7;
}
h3.dashboard-widget-title small a:hover {
color: #fff;
}
/* @todo: this was originally in this section, but likely belongs elsewhere */
#the-comment-list td.comment p.comment-author {
margin-top: 0;
margin-left: 0;
}
#the-comment-list p.comment-author img {
float: left;
margin-right: 8px;
}
#the-comment-list p.comment-author strong a {
border: none;
}
#the-comment-list td {
vertical-align: top;
}
#the-comment-list td.comment {
word-wrap: break-word;
}
#the-comment-list td.comment img {
max-width: 100%;
}
/* Welcome Panel */
.welcome-panel {
position: relative;
overflow: auto;
margin: 16px 0;
padding: 23px 10px 0;
border: 1px solid #e5e5e5;
-webkit-box-shadow: 0 1px 1px rgba(0,0,0,0.04);
box-shadow: 0 1px 1px rgba(0,0,0,0.04);
background: #fff;
font-size: 13px;
line-height: 2.1em;
}
.welcome-panel h3 {
margin: 0;
font-size: 21px;
font-weight: normal;
line-height: 1.2;
}
.welcome-panel h4 {
margin: 1.33em 0 0;
font-size: 16px;
}
.welcome-panel li {
font-size: 14px;
}
.welcome-panel p {
color: #777;
}
.welcome-panel a {
text-decoration: none;
}
.welcome-panel .about-description {
font-size: 16px;
margin: 0;
}
.welcome-panel .welcome-panel-close {
position: absolute;
top: 5px;
right: 10px;
padding: 20px 15px 0 3px;
font-size: 13px;
text-decoration: none;
line-height: 1;
}
#welcome-panel.welcome-panel .welcome-panel-close::before {
position: absolute;
left: -18px;
margin-top: -2px;
-webkit-transition: all .1s ease-in-out;
transition: all .1s ease-in-out;
}
.wp-core-ui .welcome-panel .button.button-hero {
margin: 15px 0 3px;
}
.welcome-panel-content {
margin-left: 13px;
max-width: 1500px;
}
.welcome-panel .welcome-panel-column-container {
clear: both;
overflow: hidden;
position: relative;
}
.welcome-panel .welcome-panel-column {
width: 32%;
min-width: 200px;
float: left;
}
.ie8 .welcome-panel .welcome-panel-column {
min-width: 230px;
}
.welcome-panel .welcome-panel-column:first-child {
width: 36%;
}
.welcome-panel-column p.hide-if-no-customize {
margin-top: 10px;
}
.welcome-panel-column p {
margin-top: 7px;
color: #464646;
}
.welcome-panel .welcome-icon {
display: block;
padding: 0 0 8px;
background: transparent !important;
}
.welcome-panel .welcome-icon:before {
color: #888;
font: normal 20px/1 'dashicons';
speak: none;
display: inline-block;
padding: 0 10px 0 0;
top: -1px;
position: relative;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-decoration: none !important;
vertical-align: top;
}
.welcome-panel .welcome-write-blog:before,
.welcome-panel .welcome-edit-page:before {
content:'\f119';
top: -3px;
}
.welcome-panel .welcome-add-page:before {
content:'\f132';
}
.welcome-panel .welcome-view-site:before {
content:'\f115';
top: -2px;
}
.welcome-panel .welcome-widgets-menus:before {
content:'\f116';
top: -2px;
}
.welcome-panel .welcome-comments:before {
content:'\f117';
top: -1px;
}
.welcome-panel .welcome-learn-more:before {
content:'\f118';
top: -1px;
}
.welcome-panel .welcome-widgets-menus {
line-height: 16px;
}
.welcome-panel .welcome-panel-column ul {
margin: 0.8em 1em 1em 0;
}
.welcome-panel .welcome-panel-column li {
line-height: 16px;
list-style-type: none;
}
/* Dashboard WordPress news */
#dashboard_primary .inside {
margin: 0;
padding: 0;
}
#dashboard_primary .widget-loading,
#dashboard_primary .dashboard-widget-control-form {
padding: 12px 12px 0;
}
body #dashboard-widgets .postbox form .submit {
margin: 0;
}
.dashboard-widget-control-form {
overflow: hidden;
}
.dashboard-widget-control-form p {
margin-top: 0;
}
/* @todo: are these actually used anywhere? no non-CSS results in plugin search */
div.dashboard-widget-error {
background-color: #c43;
}
div.dashboard-widget-notice {
background-color: #cfe1ef;
}
.rssSummary {
color: #777;
margin-top: 4px;
}
#dashboard_primary .rss-widget {
border-bottom: 1px solid #eee;
font-size: 13px;
padding: 8px 12px 10px;
}
#dashboard_primary .rss-widget:last-child {
border-bottom: none;
padding-bottom: 8px;
}
#dashboard_primary .rss-widget a {
font-weight: normal;
}
#dashboard_primary .rss-widget span,
#dashboard_primary .rss-widget span.rss-date {
color: #777;
}
#dashboard_primary .rss-widget span.rss-date {
margin-left: 12px;
}
#dashboard_primary .rss-widget ul li {
margin-bottom: 8px;
}
/* Dashboard right now */
#dashboard_right_now ul {
margin: 0;
overflow: hidden;
}
#dashboard_right_now li {
width: 50%;
float: left;
margin-bottom: 10px;
}
#dashboard_right_now .inside {
overflow: hidden;
padding: 0;
}
#dashboard_right_now .main {
overflow: hidden;
padding: 0 12px 11px;
}
#dashboard_right_now .main p {
margin: 0;
}
#dashboard_right_now #wp-version-message .button {
clear: right;
float: right;
position: relative;
top: -5px;
}
.mu-storage {
overflow: hidden;
}
#dashboard-widgets h4.mu-storage {
margin-bottom: 10px;
}
/* Dashboard right now - Colors */
#dashboard_right_now li a:before,
#dashboard_right_now li span:before {
color: #888;
}
#dashboard_right_now .sub {
color: #777;
background: #f5f5f5;
border-top: 1px solid #eee;
padding: 10px 12px 6px 12px;
}
#dashboard_right_now .sub h4 {
color: #555;
}
#dashboard_right_now .sub p {
margin: 0 0 1em;
}
#dashboard_right_now .warning a:before,
#dashboard_right_now .warning span:before {
color: #d54e21;
}
/* Dashboard right now - Icons */
#dashboard_right_now li a:before,
#dashboard_right_now li span:before {
content: '\f159';
font: normal 20px/1 'dashicons';
speak: none;
display: block;
float: left;
margin: 0 5px 0 0;
padding: 0;
text-indent: 0;
text-align: center;
position: relative;
-webkit-font-smoothing: antialiased;
text-decoration: none !important;
}
#dashboard_right_now .page-count a:before,
#dashboard_right_now .page-count span:before {
content: '\f105';
}
#dashboard_right_now .post-count a:before,
#dashboard_right_now .post-count span:before {
content: '\f109';
}
#dashboard_right_now .comment-count a:before {
content: '\f101';
}
#dashboard_right_now .comment-mod-count a:before {
content: '\f125';
}
#dashboard_right_now .storage-count a:before {
content: '\f104';
}
#dashboard_right_now .storage-count.warning a:before {
content: '\f153';
}
/* Dashboard Quick Draft */
#dashboard_quick_press .inside {
margin: 0;
padding: 0;
}
#dashboard_quick_press div.updated {
margin-bottom: 10px;
border: 1px solid #eee;
border-width: 1px 1px 1px 0;
}
#dashboard_quick_press form {
overflow: hidden;
margin: 12px;
}
#dashboard_quick_press .drafts,
#dashboard_quick_press .easy-blogging {
padding: 10px 0 0;
}
/* Dashboard Quick Draft - Form styling */
input#save-post {
float: left;
}
form.initial-form.quickpress-open label.prompt {
font-style: normal;
}
form.initial-form.quickpress-open input#title {
height: auto;
}
#dashboard_quick_press input,
#dashboard_quick_press textarea {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
margin: 0;
}
#dashboard_quick_press textarea {
resize: vertical;
}
#dashboard-widgets .postbox form .submit {
margin: -39px 0;
float: right;
}
#description-wrap {
margin-top: 12px;
}
#title-wrap #title-prompt-text,
.textarea-wrap #content-prompt-text {
color: #777;
}
#title-wrap #title-prompt-text {
font-size: 1.1em;
padding: 7px 8px;
}
.input-text-wrap,
.textarea-wrap {
position: relative;
}
.input-text-wrap .prompt,
.textarea-wrap .prompt {
position: absolute;
}
.textarea-wrap #content-prompt-text {
font-size: 1.1em;
padding: 7px 8px;
}
.textarea-wrap textarea#content {
margin: 0 0 8px;
padding: 6px 7px;
}
#quick-press textarea#content {
min-height: 90px;
max-height: 1300px;
resize: none;
}
/* Dashboard Quick Draft - Drafts list */
.js #dashboard_quick_press .drafts {
border-top: 1px solid #eee;
}
#dashboard_quick_press .drafts abbr {
border: none;
}
#dashboard_quick_press .drafts h4 {
margin: 0 12px 8px;
font-weight: normal;
}
#dashboard_quick_press .drafts .view-all {
float: right;
margin: 0 12px 0 0;
}
#dashboard_primary a.rsswidget {
font-weight: normal;
}
#dashboard_quick_press .drafts ul {
margin: 0 12px;
}
#dashboard_quick_press .drafts li {
margin-bottom: 1em;
}
#dashboard_quick_press .drafts li time {
color: #777;
}
#dashboard_quick_press .drafts p {
margin: 0;
word-wrap: break-word;
}
#dashboard_quick_press .draft-title {
overflow: hidden;
}
#dashboard_quick_press .draft-title a,
#dashboard_quick_press .draft-title time {
float: left;
margin: 0 5px 0 0;
}
/* Dashboard activity widget */
#dashboard-widgets #dashboard_activity h4 {
margin: 0 0 8px 12px;
font-weight: normal;
}
#dashboard-widgets #dashboard_activity h4.comment-meta {
margin: 0;
}
#dashboard_activity h4.comment-meta {
margin-bottom: 4px;
}
#dashboard_activity ul {
padding: 0 12px;
}
#dashboard_activity .comment-meta span.approve:before {
content: '\f227';
font: 20px/.5 "dashicons";
margin-left: 12px;
vertical-align: middle;
position: relative;
top: -1px;
margin-right: 2px;
}
#dashboard_activity .inside {
padding: 0;
margin: 0;
}
#dashboard_activity .no-activity {
overflow: hidden;
padding: 0 12px 12px;
text-align: center;
}
#dashboard_activity .no-activity p {
color: #999;
font-size: 16px;
}
#dashboard_activity .no-activity .smiley {
margin-top: 0;
}
#dashboard_activity .no-activity .smiley:before {
content: '\f328';
font: normal 120px/1 'dashicons';
speak: none;
display: block;
margin: 0 5px 0 0;
padding: 0;
text-indent: 0;
text-align: center;
position: relative;
-webkit-font-smoothing: antialiased;
text-decoration: none !important;
}
#dashboard_activity .subsubsub {
float: none;
border-top: 1px solid #eeeeee;
margin-top: 0;
padding: 8px 12px 4px;
}
#future-posts ul,
#published-posts ul {
clear: both;
margin-bottom: 0;
}
#future-posts li,
#published-posts li {
overflow: hidden;
margin-bottom: 8px;
}
#future-posts ul span,
#published-posts ul span {
color: #777;
float: left;
margin-right: 8px;
min-width: 150px;
}
.activity-block {
border-bottom: 1px solid #eee;
overflow: hidden;
padding: 8px 0 4px;
}
.activity-block:last-child {
border-bottom: none;
}
.activity-block .subsubsub li {
color: #ddd;
}
/* Dashboard activity widget - Comments */
/* @todo: needs serious de-duplication */
#activity-widget #the-comment-list tr.undo,
#activity-widget #the-comment-list div.undo {
background: none;
padding: 6px 0;
}
#activity-widget #the-comment-list .alternate,
#activity-widget #the-comment-list .alt {
background: none;
}
#activity-widget #the-comment-list .comment-item {
background: #fafafa;
padding: 12px;
position: relative;
}
#activity-widget #the-comment-list img {
position: absolute;
left: 13px;
top: 13px;
}
#activity-widget #the-comment-list .dashboard-comment-wrap {
padding-left: 63px;
}
#activity-widget #the-comment-list .dashboard-comment-wrap blockquote {
margin: 1em 0;
}
#activity-widget #the-comment-list .comment-item h4 {
font-size: 13px;
color: #999;
}
#activity-widget #the-comment-list .comment-item p.row-actions {
margin: 4px 0 0 0;
}
#activity-widget #the-comment-list .comment-item:first-child {
border-top: 1px solid #eeeeee;
}
#activity-widget #the-comment-list .unapproved {
background-color: #fef7f1;
}
#activity-widget #the-comment-list .unapproved:before {
content: "";
display: block;
position: absolute;
left: 0;
top: 0;
bottom: 0;
background: #d54e21;
width: 4px;
}
#activity-widget #the-comment-list .spam-undo-inside .avatar,
#activity-widget #the-comment-list .trash-undo-inside .avatar {
margin-right: 20px;
position: relative;
top: 0;
}
/* Browse happy box */
#dashboard-widgets #dashboard_browser_nag.postbox .inside {
margin: 10px;
}
.edit-box {
display: none;
}
h3:hover .edit-box {
display: inline;
}
#dashboard-widgets form .input-text-wrap input {
width: 100%;
}
#dashboard-widgets form .textarea-wrap textarea {
width: 100%;
}
#dashboard-widgets .postbox form .submit {
float: none;
margin: .5em 0 0;
padding: 0;
border: none;
}
#dashboard-widgets-wrap #dashboard-widgets .postbox form .submit #publish {
min-width: 0;
}
#dashboard-widgets a {
text-decoration: none;
}
#dashboard-widgets h3 a {
text-decoration: underline;
}
#dashboard-widgets h3 .postbox-title-action {
position: absolute;
right: 10px;
padding: 0;
top: 5px;
}
.js #dashboard-widgets h3 .postbox-title-action {
right: 33px;
}
#dashboard-widgets h4 {
color: #222;
font-weight: normal;
font-size: 14px;
margin: 0 0 .2em;
padding: 0;
}
#dashboard_plugins h5 {
font-size: 14px;
}
/* Recent Comments */
#latest-comments #the-comment-list {
position: relative;
}
#activity-widget #the-comment-list .comment {
-webkit-box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.06);
box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.06);
}
#activity-widget .comments #the-comment-list .alt {
background-color: transparent;
}
#activity-widget #latest-comments #the-comment-list .comment-item {
padding: 1em 12px;
}
#latest-comments #the-comment-list .pingback {
padding-left: 12px !important;
}
#latest-comments #the-comment-list .comment-item:first-child {
border-top: none;
}
#latest-comments #the-comment-list .comment-item h4 {
line-height: 1.5em;
margin-top: 0;
color: #666;
}
#latest-comments #the-comment-list .comment-item h4 cite {
font-style: normal;
font-weight: normal;
}
#latest-comments #the-comment-list .comment-item blockquote,
#latest-comments #the-comment-list .comment-item blockquote p {
margin: 0;
padding: 0;
display: inline;
}
#latest-comments #the-comment-list .comment-item p.row-actions {
margin: 3px 0 0;
padding: 0;
font-size: 13px;
}
/* QuickDraft */
#title-wrap label {
cursor: text;
}
#title-wrap #title {
padding: 2px 6px;
font-size: 1.3em;
line-height: 100%;
outline: none;
}
#title-wrap #title-prompt-text {
font-size: 1.1em;
padding: 5px 8px;
}
/* Feeds */
.rss-widget ul {
margin: 0;
padding: 0;
list-style: none;
}
a.rsswidget {
font-size: 14px;
font-weight: 600;
line-height: 1.7em;
}
.rss-widget ul li {
line-height: 1.5em;
margin-bottom: 12px;
}
.rss-widget span.rss-date {
color: #999;
font-size: 13px;
margin-left: 3px;
}
.rss-widget cite {
display: block;
text-align: right;
margin: 0 0 1em;
padding: 0;
}
.rss-widget cite:before {
content: '\2014';
}
.dashboard-comment-wrap {
overflow: hidden;
word-wrap: break-word;
}
/* Browser Nag */
#dashboard_browser_nag a.update-browser-link {
font-size: 1.2em;
font-weight: 600;
}
#dashboard_browser_nag a {
text-decoration: underline;
}
#dashboard_browser_nag p.browser-update-nag.has-browser-icon {
padding-right: 125px;
}
#dashboard_browser_nag .browser-icon {
margin-top: -35px;
}
#dashboard_browser_nag.postbox.browser-insecure {
background-color: #ac1b1b;
border-color: #ac1b1b;
}
#dashboard_browser_nag.postbox {
background-color: #e29808;
background-image: none;
border-color: #edc048;
color: #fff;
-webkit-box-shadow: none;
box-shadow: none;
}
#dashboard_browser_nag.postbox.browser-insecure h3 {
border-bottom-color: #cd5a5a;
color: #fff;
}
#dashboard_browser_nag.postbox h3 {
border-bottom-color: #f6e2ac;
background: transparent none;
color: #fff;
-webkit-box-shadow: none;
box-shadow: none;
}
#dashboard_browser_nag a {
color: #fff;
}
/* Make the browser nags easier to read with Open Sans */
#dashboard_browser_nag h3.hndle {
border: none;
font-weight: 600;
font-size: 20px;
padding-top: 10px;
}
.postbox#dashboard_browser_nag p a.dismiss {
font-size: 14px;
}
.postbox#dashboard_browser_nag p,
.postbox#dashboard_browser_nag a,
.postbox#dashboard_browser_nag p.browser-update-nag {
font-size: 16px;
}
/* =Media Queries
-------------------------------------------------------------- */
/* one column on the dash */
@media only screen and (max-width: 799px) {
#wpbody-content #dashboard-widgets .postbox-container {
width: 100%;
}
}
/* two columns on the dash, but keep the setting if one is selected */
@media only screen and (min-width: 800px) and (max-width: 1499px) {
#wpbody-content #dashboard-widgets .postbox-container {
width: 49.5%;
}
#wpbody-content #dashboard-widgets #postbox-container-2,
#wpbody-content #dashboard-widgets #postbox-container-3,
#wpbody-content #dashboard-widgets #postbox-container-4 {
float: right;
width: 50.5%;
}
#dashboard-widgets #postbox-container-3 .empty-container,
#dashboard-widgets #postbox-container-4 .empty-container {
border: 0 none;
height: 0;
min-height: 0;
}
#wpbody #wpbody-content #dashboard-widgets.columns-1 .postbox-container {
width: 100%;
}
#wpbody #wpbody-content .metabox-holder.columns-1 .postbox-container .empty-container {
border: 0 none;
height: 0;
min-height: 0;
}
/* show the radio buttons for column prefs only for one or two columns */
.index-php .screen-layout,
.index-php .columns-prefs {
display: block;
}
.columns-prefs .columns-prefs-3,
.columns-prefs .columns-prefs-4 {
display: none;
}
}
/* three columns on the dash */
@media only screen and (min-width: 1500px) and (max-width: 1800px) {
#wpbody-content #dashboard-widgets .postbox-container {
width: 33.5%;
}
#wpbody-content #dashboard-widgets #postbox-container-1 {
width: 33%;
}
#wpbody-content #dashboard-widgets #postbox-container-3,
#wpbody-content #dashboard-widgets #postbox-container-4 {
float: right;
}
#dashboard-widgets #postbox-container-4 .empty-container {
border: 0 none;
height: 0;
min-height: 0;
}
}
@media screen and (max-width: 870px) {
.welcome-panel .welcome-panel-column,
.welcome-panel .welcome-panel-column:first-child {
display: block;
float: none;
width: 100%;
}
.welcome-panel .welcome-panel-column li {
display: inline-block;
margin-right: 13px;
}
.welcome-panel .welcome-panel-column ul {
margin: 0.4em 0 0;
}
}
@media screen and ( max-width: 782px ) {
#dashboard_recent_comments #the-comment-list .comment-item .avatar {
height: 30px;
width: 30px;
margin: 4px 10px 5px 0;
}
}
/* Smartphone */
@media screen and (max-width: 600px) {
/* Keep the close icon from overlapping the Welcome text. */
.welcome-panel .welcome-panel-close {
overflow: hidden;
text-indent: 100%;
white-space: nowrap;
width: 20px;
height: 20px;
right: 0;
padding: 5px;
}
/* Make the close icon larger for tappability. */
#welcome-panel.welcome-panel .welcome-panel-close::before {
font-size: 20px;
margin: 0;
}
}
| 01-wordpress-paypal | trunk/wp-admin/css/dashboard.css | CSS | gpl3 | 20,509 |
/* nav-menu */
/* @todo: determine if this is truly for nav menus only */
.no-js #message {
display: block;
}
ul.add-menu-item-tabs li {
padding: 3px 8px 3px 5px;
}
.accordion-section ul.category-tabs,
.accordion-section ul.add-menu-item-tabs,
.accordion-section ul.wp-tab-bar {
margin: 0;
}
.accordion-section .categorychecklist {
margin: 13px 0;
}
#nav-menu-meta .accordion-section-content {
padding: 18px 13px;
}
#nav-menu-meta .button-controls {
margin-bottom: 0;
}
#nav-menus-frame {
margin-right: 300px;
margin-top: 23px;
}
#wpbody-content #menu-settings-column {
display:inline;
width:281px;
margin-right: -300px;
clear: both;
float: right;
padding-top: 0;
}
#menu-settings-column .inside {
clear: both;
margin: 10px 0 0;
}
.metabox-holder-disabled .postbox,
.metabox-holder-disabled .accordion-section-content,
.metabox-holder-disabled .accordion-section-title {
opacity: 0.5;
filter: alpha(opacity=50);
}
.metabox-holder-disabled .button-controls .select-all {
display: none;
}
#wpbody {
position: relative;
}
.blank-slate .menu-name {
height: 2em;
}
.blank-slate .menu-settings {
border: none;
margin-top: 0;
padding-top: 0;
overflow: hidden;
}
.is-submenu {
color: #999;
font-style: italic;
font-weight: normal;
margin-right: 4px;
}
.manage-menus {
margin-top: 23px;
padding: 10px;
overflow: hidden;
background: #fbfbfb;
}
.manage-menus select {
float: right;
margin-left: 6px;
}
.manage-menus .selected-menu {
float: right;
margin: 5px 0 0 6px;
}
.manage-menus .submit-btn {
float: right;
margin-top: 1px;
}
.menu-edit p {
margin: .3em 0 .6em;
}
.menu-edit #post-body-content h3 {
margin: 1em 0 10px;
}
.menu-settings {
border-top: 1px solid #eee;
margin-top: 2em;
}
.menu-settings dl {
margin: 0 0 10px;
overflow: hidden;
padding-right: 18%;
}
.menu-settings dd {
float: right;
margin: 0;
width: 100%;
}
.menu-settings dt {
float: right;
clear: both;
width: 21.951%;
padding: 3px 0 0;
margin-right: -21.951%;
}
.menu-settings label {
vertical-align: baseline;
}
.menu-edit .checkbox-input {
margin-top: 4px;
}
.theme-location-set {
color: #999;
font-size: 11px;
}
/* Menu Container */
#menu-management-liquid {
float: right;
min-width: 100%;
margin-top: 3px;
}
#menu-management {
position: relative;
margin-left: 20px;
margin-top: -3px;
width: 100%;
background: #f5f5f5;
}
#menu-management .menu-edit {
margin-bottom: 20px;
}
.nav-menus-php #post-body {
padding: 0 10px 10px;
border-top: 1px solid #fff;
border-bottom: 1px solid #dfdfdf;
background: #fff;
}
#nav-menu-header,
#nav-menu-footer {
padding: 0 10px;
}
#nav-menu-header {
border-bottom: 1px solid #dfdfdf;
margin-bottom: 0;
}
#nav-menu-header .menu-name-label {
margin-top: 4px;
}
.nav-menus-php #post-body div.updated,
.nav-menus-php #post-body div.error {
margin: 0;
}
.nav-menus-php #post-body-content {
position: relative;
float: none;
}
#menu-management .menu-add-new abbr {
font-weight:600;
}
#select-nav-menu-container {
text-align: left;
padding: 0 10px 3px 10px;
margin-bottom: 5px;
}
#select-nav-menu {
width: 100px;
display: inline;
}
#menu-name-label {
margin-top: -2px;
}
.widefat td.menu-location-menus {
padding-bottom: 5px;
}
.menu-location-menus select {
float: right;
}
#locations-nav-menu-wrapper {
padding: 5px 0;
}
.locations-nav-menu-select select {
float: right;
width: 160px;
margin-left: 5px;
}
.locations-row-links {
float: right;
margin: 6px 6px 0 0;
}
.locations-edit-menu-link,
.locations-add-menu-link {
margin: 0 3px;
}
.locations-edit-menu-link {
padding-left: 3px;
border-left: 1px solid #ccc;
}
#wpbody .open-label {
display: block;
float:right;
}
#wpbody .open-label span {
padding-left: 10px;
}
.js .input-with-default-title {
color: #aaa;
font-style: italic;
}
#menu-management .inside {
padding: 0 10px;
}
/* Add Menu Item Boxes */
.postbox .howto input,
.accordion-container .howto input {
width: 180px;
float: left;
}
.accordion-container .outer-border {
margin: 0;
}
.customlinkdiv .howto input {
width: 180px;
}
.customlinkdiv p {
margin-top: 0
}
#nav-menu-theme-locations .howto select {
width: 100%;
}
#nav-menu-theme-locations .button-controls {
text-align: left;
}
.add-menu-item-view-all {
height: 400px;
}
/* Button Primary Actions */
#menu-container .submit {
margin: 0 0 10px;
padding: 0;
}
.nav-menus-php .add-new-menu-action {
float: right;
margin: 6px 6px 0 0;
line-height: 15px;
}
.nav-menus-php .meta-sep,
.nav-menus-php .submitdelete,
.nav-menus-php .submitcancel {
display: block;
float: right;
margin: 6px 0;
line-height: 15px;
}
.meta-sep {
padding: 0 2px;
}
/* @todo: is this actually used? */
#cancel-save {
text-decoration: underline;
font-size: 12px;
margin-right: 20px;
margin-top: 5px;
}
.button.right, .button-secondary.right, .button-primary.right {
float: left;
}
/* Button Secondary Actions */
.list-controls {
float: right;
margin-top: 5px;
}
.add-to-menu {
float: left;
}
.postbox .spinner {
display: none;
vertical-align: middle;
}
.button-controls {
clear:both;
margin: 10px 0;
}
.show-all,
.hide-all {
cursor: pointer;
}
.hide-all {
display: none;
}
/* Create Menu */
#menu-name {
width: 270px;
}
#manage-menu .inside {
padding: 0px 0px;
}
/* Custom Links */
#available-links dt {
display: block;
}
#add-custom-link .howto {
font-size: 12px;
}
#add-custom-link label span {
display: block;
float: right;
margin-top: 5px;
padding-left: 5px;
}
.menu-item-textbox {
width: 180px;
}
.nav-menus-php .howto span {
margin-top: 6px;
display: block;
float: right;
}
/* Menu item types */
.quick-search {
width: 190px;
}
.nav-menus-php .list-wrap {
display: none;
clear: both;
margin-bottom: 10px;
}
.nav-menus-php .postbox p.submit {
margin-bottom: 0;
}
/* Listings */
.nav-menus-php .list li {
display: none;
margin: 0;
margin-bottom: 5px;
}
.nav-menus-php .list li .menu-item-title {
cursor: pointer;
display: block;
}
.nav-menus-php .list li .menu-item-title input {
margin-left: 3px;
margin-top: -3px;
}
.menu-item-title input[type=checkbox] {
display: inline-block;
margin-top: -4px;
}
/* Nav Menu */
#menu-container .inside {
padding-bottom: 10px;
}
.menu {
padding-top:1em;
}
#menu-to-edit {
margin: 0;
padding: 0.1em 0;
}
.menu ul {
width: 100%;
}
.menu li {
margin-bottom: 0;
position:relative;
}
.menu-item-bar {
clear:both;
line-height:1.5em;
position:relative;
margin: 9px 0 0;
}
.menu-item-bar .menu-item-handle {
border: 1px solid #dfdfdf;
position: relative;
padding: 10px 15px;
height: auto;
width: 382px;
line-height: 30px;
overflow: hidden;
word-wrap: break-word;
}
.menu-item-bar .menu-item-handle:hover {
border-color: #999;
}
#menu-to-edit .menu-item-invalid .menu-item-handle {
background: #f6c9cc;
border-color: #f1acb1;
}
.no-js .menu-item-edit-active .item-edit {
display: none;
}
.js .menu-item-handle {
cursor: move;
}
.menu li.deleting .menu-item-handle {
background-image: none;
background-color: #f66;
}
.menu-item-handle .item-title {
font-size: 13px;
font-weight: 600;
line-height: 20px;
display: block;
margin-left: 13em;
}
/* Sortables */
li.menu-item.ui-sortable-helper dl {
margin-top: 0;
}
li.menu-item.ui-sortable-helper .menu-item-transport dl {
margin-top: 13px;
}
.menu .sortable-placeholder {
height: 35px;
width: 410px;
margin-top: 13px;
}
/* WARNING: The factor of 30px is hardcoded into the nav-menus javascript. */
.menu-item-depth-0 { margin-right: 0px; }
.menu-item-depth-1 { margin-right: 30px; }
.menu-item-depth-2 { margin-right: 60px; }
.menu-item-depth-3 { margin-right: 90px; }
.menu-item-depth-4 { margin-right: 120px; }
.menu-item-depth-5 { margin-right: 150px; }
.menu-item-depth-6 { margin-right: 180px; }
.menu-item-depth-7 { margin-right: 210px; }
.menu-item-depth-8 { margin-right: 240px; }
.menu-item-depth-9 { margin-right: 270px; }
.menu-item-depth-10 { margin-right: 300px; }
.menu-item-depth-11 { margin-right: 330px; }
.menu-item-depth-0 .menu-item-transport { margin-right: 0px; }
.menu-item-depth-1 .menu-item-transport { margin-right: -30px; }
.menu-item-depth-2 .menu-item-transport { margin-right: -60px; }
.menu-item-depth-3 .menu-item-transport { margin-right: -90px; }
.menu-item-depth-4 .menu-item-transport { margin-right: -120px; }
.menu-item-depth-5 .menu-item-transport { margin-right: -150px; }
.menu-item-depth-6 .menu-item-transport { margin-right: -180px; }
.menu-item-depth-7 .menu-item-transport { margin-right: -210px; }
.menu-item-depth-8 .menu-item-transport { margin-right: -240px; }
.menu-item-depth-9 .menu-item-transport { margin-right: -270px; }
.menu-item-depth-10 .menu-item-transport { margin-right: -300px; }
.menu-item-depth-11 .menu-item-transport { margin-right: -330px; }
body.menu-max-depth-0 { min-width: 950px !important; }
body.menu-max-depth-1 { min-width: 980px !important; }
body.menu-max-depth-2 { min-width: 1010px !important; }
body.menu-max-depth-3 { min-width: 1040px !important; }
body.menu-max-depth-4 { min-width: 1070px !important; }
body.menu-max-depth-5 { min-width: 1100px !important; }
body.menu-max-depth-6 { min-width: 1130px !important; }
body.menu-max-depth-7 { min-width: 1160px !important; }
body.menu-max-depth-8 { min-width: 1190px !important; }
body.menu-max-depth-9 { min-width: 1220px !important; }
body.menu-max-depth-10 { min-width: 1250px !important; }
body.menu-max-depth-11 { min-width: 1280px !important; }
/* Menu item controls */
.item-type {
color: #777;
font-size: 12px;
padding: 12px 10px;
line-height: 18px;
display: block;
}
.item-controls {
font-size: 12px;
position: absolute;
left: 20px;
top: -1px;
}
.item-controls a {
text-decoration: none;
}
.item-controls a:hover {
cursor: pointer;
}
.item-controls .item-order {
padding-left: 10px;
}
.nav-menus-php .item-edit {
position: absolute;
left: -20px;
top: 0;
display: block;
width: 30px;
height: 40px;
margin-left: 0 !important;
text-indent: 100%;
outline: none;
overflow: hidden;
white-space: nowrap;
}
/* Menu editing */
.menu-instructions-inactive {
display: none;
}
.menu-item-settings {
display: block;
width: 402px;
padding: 10px 10px 10px 0;
position: relative;
z-index: 10; /* Keep .item-title's shadow from appearing on top of .menu-item-settings */
border: 1px solid #e5e5e5;
border-top: none;
-webkit-box-shadow: 0 1px 1px rgba(0,0,0,0.04);
box-shadow: 0 1px 1px rgba(0,0,0,0.04);
}
.menu-item-settings .field-move a {
display: none;
margin: 0 2px;
}
.menu-item-edit-active .menu-item-settings {
display: block;
}
.menu-item-edit-inactive .menu-item-settings {
display: none;
}
.add-menu-item-pagelinks {
margin: .5em auto;
text-align: center;
}
.link-to-original {
display: block;
margin: 0 0 10px;
padding: 3px 5px 5px;
border: 1px solid #dfdfdf;
color: #777;
font-size: 12px;
font-style: italic;
}
.link-to-original a {
padding-right: 4px;
font-style: normal;
}
.hidden-field {
display: none;
}
.menu-item-settings .description-thin,
.menu-item-settings .description-wide {
margin-left: 10px;
float: right;
}
.description-thin {
width: 190px;
height: 40px;
}
.description-wide {
width: 390px;
}
.menu-item-actions {
padding-top: 15px;
}
#cancel-save {
cursor: pointer;
}
/* Major/minor publishing actions (classes) */
.nav-menus-php .major-publishing-actions {
clear: both;
padding: 3px 0 6px;
}
.nav-menus-php .major-publishing-actions .publishing-action {
text-align: left;
float: left;
line-height: 23px;
margin: 4px 0 1px;
}
.nav-menus-php .blank-slate .menu-settings {
display: none;
}
.nav-menus-php .delete-action {
float: right;
margin-top: 2px;
}
.nav-menus-php .submitbox .submitcancel {
border-bottom: 1px solid #0074a2;
padding: 1px 2px;
color: #0074a2;
text-decoration: none;
}
.nav-menus-php .submitbox .submitcancel:hover {
background: #0074a2;
color: #fff;
}
.nav-menus-php .major-publishing-actions .form-invalid {
padding-right: 4px;
margin-right: -4px;
}
/* Clearfix */
#menu-item-name-wrap:after,
#menu-item-url-wrap:after,
#menu-name-label:after,
#menu-settings-column .inside:after,
#nav-menus-frame:after,
.nav-menus-php #post-body-content:after,
.nav-menus-php .button-controls:after,
.nav-menus-php .major-publishing-actions:after,
.nav-menus-php .menu-item-settings:after {
clear: both;
content: ".";
display: block;
height: 0;
visibility: hidden;
}
#nav-menus-frame,
.button-controls,
#menu-item-url-wrap,
#menu-item-name-wrap {
display: block;
}
/* =Media Queries
-------------------------------------------------------------- */
@media screen and ( max-width: 782px ) {
body.nav-menus-php {
min-width: 0 !important;
}
#nav-menus-frame {
margin-right: 0;
float: none;
width: 100%;
}
#wpbody-content #menu-settings-column {
display: block;
width: 100%;
float: none;
margin-right: 0;
}
#side-sortables .add-menu-item-tabs {
margin: 15px 0 14px;
}
ul.add-menu-item-tabs li.tabs {
padding: 13px 15px 14px;
}
.nav-menus-php .item-controls .item-type {
margin-top: 2px;
}
.nav-menus-php .customlinkdiv .howto input {
width: 65%;
}
.nav-menus-php .quick-search {
width: 85%;
}
#menu-management-liquid {
margin-top: 25px;
}
.nav-menus-php .menu-name-label.howto span {
margin-top: 13px
}
.menu-name-label #menu-name {
margin-top: 4px;
}
.nav-menus-php .major-publishing-actions .publishing-action {
margin-top: 6px;
}
.nav-menus-php .delete-action {
font-size: 14px;
line-height: 50px;
margin-top: 12px;
}
.menu-item-bar .menu-item-handle,
.menu-item-settings,
.description-wide {
width: auto;
}
.menu-item-settings {
padding: 10px;
}
.menu-item-settings .description-thin,
.menu-item-settings .description-wide {
width: 100%;
height: auto;
}
.menu-item-settings input {
width: 100%;
}
.menu-settings dl {
padding-right: 0;
}
.menu-settings dd {
float: none;
width: 100%;
margin-bottom: 15px;
}
.menu-settings dt {
float: none;
width: auto;
margin-right: 0;
margin-bottom: 15px;
}
}
@media only screen and (max-width: 768px) {
/* menu locations */
#menu-locations-wrap .widefat {
width: 100%;
}
}
| 01-wordpress-paypal | trunk/wp-admin/css/nav-menus-rtl.css | CSS | gpl3 | 14,213 |
/*------------------------------------------------------------------------------
11.2 - Post Revisions
------------------------------------------------------------------------------*/
.revisions-control-frame,
.revisions-diff-frame {
position: relative;
}
.revisions-controls {
padding-top: 40px;
height: 100px;
z-index: 1;
}
.revisions-controls input[type="checkbox"] {
position: relative;
top: -1px;
vertical-align: text-bottom;
}
.revisions.pinned .revisions-controls {
position: fixed;
top: 0;
height: 82px;
background: #fff;
-webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.1);
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.revisions-tickmarks {
position: relative;
margin: 0 auto;
height: 0.7em;
top: 7px;
max-width: 70%;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
background-color: #fff;
}
.revisions-tickmarks > div {
position: absolute;
height: 100%;
border-right: 1px solid #aaa;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.revisions-tickmarks > div:first-child {
border-width: 0;
}
.comparing-two-revisions .revisions-controls {
height: 140px;
}
.comparing-two-revisions.pinned .revisions-controls {
height: 124px;
}
.revisions .diff-error {
position: absolute;
text-align: center;
margin: 0 auto;
width: 100%;
display: none;
}
.revisions.diff-error .diff-error {
display: block;
}
.revisions .loading-indicator {
position: fixed;
vertical-align: middle;
opacity: 0;
width: 100%;
top: 50%;
margin-right: -90px;
-webkit-transition: opacity 0.5s;
transition: opacity 0.5s;
filter: alpha(opacity=0); /* ie8 and earlier */
}
body.folded .revisions .loading-indicator {
margin-right: -32px;
}
.revisions .loading-indicator span.spinner {
display: block;
margin: 0 auto;
float: none;
}
.revisions.loading .loading-indicator {
opacity: 1;
filter: alpha(opacity=100); /* ie8 and earlier */
}
.revisions .diff {
-webkit-transition: opacity 0.5s;
transition: opacity 0.5s;
}
.revisions.loading .diff {
opacity: 0.5;
filter: alpha(opacity=50); /* ie8 and earlier */
}
.revisions.diff-error .diff {
visibility: hidden;
}
.revisions-meta {
margin-top: 20px;
background-color: #fff;
-webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.1);
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.revisions.pinned .revisions-meta {
-webkit-box-shadow: none;
box-shadow: none;
}
.revision-toggle-compare-mode {
position: absolute;
top: 0;
left: 0;
}
.comparing-two-revisions .revisions-previous,
.comparing-two-revisions .revisions-next,
.revisions-meta .diff-meta-to strong {
display: none;
}
.revisions-controls .author-card .date {
color: #777;
}
.revisions-controls .author-card.autosave {
color: #d54e21;
}
.revisions-controls .author-card .author-name {
font-weight: bold;
}
.comparing-two-revisions .diff-meta-to strong {
display: block;
}
.revisions.pinned .revisions-buttons {
padding: 0 11px;
}
.revisions-previous,
.revisions-next {
position: relative;
z-index: 1;
}
.revisions-previous {
float: right;
}
.revisions-next {
float: left;
}
.revisions-controls .wp-slider {
max-width: 70%;
margin: 0 auto;
top: -3px;
}
.revisions-diff {
padding: 15px;
background-color: #fff;
-webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.1);
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.revisions-diff h3:first-child {
margin-top: 0;
}
/* Revision meta box */
.post-revisions li img,
#revisions-meta-restored img {
vertical-align: middle;
}
table.diff tbody tr td:nth-child(2) {
width: 4%;
}
table.diff {
table-layout: fixed;
width: 100%;
white-space: pre-wrap;
}
table.diff col.content {
width: auto;
}
table.diff col.content.diffsplit {
width: 48%;
}
table.diff col.diffsplit.middle {
width: auto;
}
table.diff col.ltype {
width: 30px;
}
table.diff tr {
background-color: transparent;
}
table.diff td,
table.diff th {
font-family: Consolas, Monaco, monospace;
font-size: 14px;
line-height: 1.618;
padding: .5em;
vertical-align: top;
word-wrap: break-word;
}
table.diff td h1,
table.diff td h2,
table.diff td h3,
table.diff td h4,
table.diff td h5,
table.diff td h6 {
margin: 0;
}
table.diff .diff-deletedline del,
table.diff .diff-addedline ins {
text-decoration: none;
}
table.diff .diff-deletedline {
background-color: #ffe9e9;
}
table.diff .diff-deletedline del {
background-color: #faa;
}
table.diff .diff-addedline {
background-color: #e9ffe9;
}
table.diff .diff-addedline ins {
background-color: #afa;
}
.diff-meta {
padding: 5px;
clear: both;
min-height: 32px;
}
.diff-title strong {
line-height: 32px;
min-width: 60px;
text-align: left;
float: right;
margin-left: 5px;
}
.revisions-controls .author-card .author-info {
font-size: 12px;
line-height: 16px;
}
.revisions-controls .author-card .avatar,
.revisions-controls .author-card .author-info {
float: right;
margin-right: 6px;
margin-left: 6px;
}
.revisions-controls .author-card .byline {
display: block;
font-size: 12px;
}
.revisions-controls .author-card .avatar {
vertical-align: middle;
}
.diff-meta input.restore-revision {
float: left;
margin-right: 6px;
margin-left: 6px;
margin-top: 4px;
}
.diff-meta-from {
display: none;
}
.comparing-two-revisions .diff-meta-from {
display: block;
}
.revisions-tooltip {
position: absolute;
bottom: 105px;
margin-left: 0;
margin-right: -69px;
z-index: 0;
max-width: 350px;
min-width: 130px;
padding: 8px 4px;
display: none;
opacity: 0;
}
.revisions-tooltip.flipped {
margin-right: 0;
margin-left: -70px;
}
.revisions.pinned .revisions-tooltip {
display: none !important;
}
.comparing-two-revisions .revisions-tooltip {
bottom: 145px;
}
.revisions-tooltip-arrow {
width: 70px;
height: 15px;
overflow: hidden;
position: absolute;
right: 0;
margin-right: 35px;
bottom: -15px;
}
.revisions-tooltip.flipped .revisions-tooltip-arrow {
margin-right: 0;
margin-left: 35px;
right: auto;
left: 0;
}
.revisions-tooltip-arrow > span {
content: "";
position: absolute;
right: 20px;
top: -20px;
width: 25px;
height: 25px;
-webkit-transform: rotate(45deg);
-ms-transform: rotate(45deg);
transform: rotate(45deg);
}
.revisions-tooltip.flipped .revisions-tooltip-arrow > span {
right: auto;
left: 20px;
}
.ie8 .revisions-tooltip-arrow > span {
right: 15px;
top: -25px;
-ms-filter: "progid:DXImageTransform.Microsoft.Matrix(SizingMethod='auto expand', M11=0.7071067811865476, M12=-0.7071067811865475, M21=0.7071067811865475, M22=0.7071067811865476)";
}
.ie8 .revisions-tooltip.flipped .revisions-tooltip-arrow > span {
left: 25px;
}
.revisions-tooltip,
.revisions-tooltip-arrow > span {
border: 1px solid #d7d7d7;
background-color: #fff;
}
.revisions-tooltip {
display: none;
}
.arrow {
width: 70px;
height: 16px;
overflow: hidden;
position: absolute;
right: 0;
margin-right: -35px;
bottom: 90px;
z-index: 10000;
}
.arrow::after {
z-index: 9999;
background-color: #fff;
-webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.1);
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.arrow.top {
top: -16px;
bottom: auto;
}
.arrow.left {
right: 20%;
}
.arrow:after {
content: "";
position: absolute;
right: 20px;
top: -20px;
width: 25px;
height: 25px;
-webkit-transform: rotate(45deg);
-ms-transform: rotate(45deg);
transform: rotate(45deg);
}
.revisions-tooltip,
.revisions-tooltip-arrow:after {
border-width: 1px;
border-style: solid;
}
div.revisions-controls > .wp-slider > .ui-slider-handle {
margin-right: -10px;
}
.rtl div.revisions-controls > .wp-slider > .ui-slider-handle {
margin-left: -10px;
}
/* jQuery UI Slider */
.wp-slider.ui-slider {
position: relative;
border: 1px solid #d7d7d7;
text-align: right;
cursor: pointer;
}
.wp-slider .ui-slider-handle {
-webkit-border-radius: 50%;
border-radius: 50%;
height: 18px;
margin-top: -3px;
outline: none;
position: absolute;
width: 18px;
z-index: 2;
}
.wp-slider .ui-slider-handle,
.wp-slider .ui-slider-handle.ui-state-hover,
.wp-slider .ui-slider-handle.focus {
background: #2ea2cc;
border: 1px solid #0074a2;
-webkit-box-shadow: inset 0 1px 0 #78c8e6, 0 1px 0 rgba(0,0,0,.15);
box-shadow: inset 0 1px 0 #78c8e6, 0 1px 0 rgba(0,0,0,.15);
}
.wp-slider .ui-slider-handle:before {
background: none;
position: absolute;
top: 0;
right: 0;
color: #fff;
content: "\f229";
font: normal 18px/1 'dashicons';
speak: none;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.wp-slider .ui-slider-handle.from-handle:before,
.wp-slider .ui-slider-handle.to-handle:before {
font-size: 20px !important;
margin: -1px -1px 0 0;
}
.wp-slider .ui-slider-handle.from-handle:before {
content: '\f139';
}
.wp-slider .ui-slider-handle.to-handle:before {
content: '\f141';
}
.rtl .wp-slider .ui-slider-handle.from-handle:before {
content: '\f141';
}
.rtl .wp-slider .ui-slider-handle.to-handle:before {
content: '\f139';
left: -1px;
}
.wp-slider .ui-slider-range {
position: absolute;
font-size: .7em;
display: block;
border: 0;
background-color: transparent;
background-image: none;
}
.wp-slider.ui-slider-horizontal {
height: .7em;
}
.wp-slider.ui-slider-horizontal .ui-slider-handle {
top: -.25em;
margin-right: -.6em;
}
.wp-slider.ui-slider-horizontal .ui-slider-range {
top: 0;
height: 100%;
}
.wp-slider.ui-slider-horizontal .ui-slider-range-min {
right: 0;
}
.wp-slider.ui-slider-horizontal .ui-slider-range-max {
left: 0;
}
/* =Media Queries
-------------------------------------------------------------- */
/**
* HiDPI Displays
*/
@media print,
(-o-min-device-pixel-ratio: 5/4),
(-webkit-min-device-pixel-ratio: 1.25),
(min-resolution: 120dpi) {
.revision-tick.completed-false {
background-image: url(../images/spinner-2x.gif);
}
}
@media screen and ( max-width: 782px ) {
#diff-next-revision,
#diff-previous-revision {
margin-top: -1em;
}
table.diff {
-ms-word-break: break-all;
word-break: break-all;
word-wrap: break-word;
}
}
| 01-wordpress-paypal | trunk/wp-admin/css/revisions-rtl.css | CSS | gpl3 | 9,963 |
html {
background: #f1f1f1;
margin: 0 20px;
}
body {
background: #fff;
color: #444;
font-family: "Open Sans", sans-serif;
margin: 140px auto 25px;
padding: 20px 20px 10px 20px;
max-width: 700px;
-webkit-font-smoothing: subpixel-antialiased;
-webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.13);
box-shadow: 0 1px 3px rgba(0,0,0,0.13);
}
a {
color: #0074a2;
text-decoration: none;
}
a:hover {
color: #2ea2cc;
}
h1 {
border-bottom: 1px solid #dedede;
clear: both;
color: #666;
font-size: 24px;
margin: 30px 0;
padding: 0;
padding-bottom: 7px;
font-weight: normal;
}
h2 {
font-size: 16px;
}
p, li, dd, dt {
padding-bottom: 2px;
font-size: 14px;
line-height: 1.5;
}
code, .code {
font-family: Consolas, Monaco, monospace;
}
ul, ol, dl {
padding: 5px 5px 5px 22px;
}
a img {
border:0
}
abbr {
border: 0;
font-variant: normal;
}
#logo {
margin: 6px 0 14px 0;
border-bottom: none;
text-align:center
}
#logo a {
background-image: url(../images/w-logo-blue.png?ver=20131202);
background-image: none, url(../images/wordpress-logo.svg?ver=20131107);
-webkit-background-size: 80px 80px;
background-size: 80px 80px;
background-position: center top;
background-repeat: no-repeat;
color: #999;
height: 80px;
font-size: 20px;
font-weight: normal;
line-height: 1.3em;
margin: -130px auto 25px;
padding: 0;
text-decoration: none;
width: 80px;
text-indent: -9999px;
outline: none;
overflow: hidden;
display: block;
}
.step {
margin: 20px 0 15px;
}
.step, th {
text-align: left;
padding: 0;
}
.step .button-large {
font-size: 14px;
}
textarea {
border: 1px solid #dfdfdf;
font-family: "Open Sans", sans-serif;
width: 100%;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.form-table {
border-collapse: collapse;
margin-top: 1em;
width: 100%;
}
.form-table td {
margin-bottom: 9px;
padding: 10px 20px 10px 0;
border-bottom: 8px solid #fff;
font-size: 14px;
vertical-align: top
}
.form-table th {
font-size: 14px;
text-align: left;
padding: 16px 20px 10px 0;
width: 140px;
vertical-align: top;
}
.form-table code {
line-height: 18px;
font-size: 14px;
}
.form-table p {
margin: 4px 0 0 0;
font-size: 11px;
}
.form-table input {
line-height: 20px;
font-size: 15px;
padding: 3px 5px;
border: 1px solid #ddd;
-webkit-box-shadow: inset 0 1px 2px rgba(0,0,0,0.07);
box-shadow: inset 0 1px 2px rgba(0,0,0,0.07);
}
input,
submit {
font-family: "Open Sans", sans-serif;
}
.form-table input[type=text],
.form-table input[type=password] {
width: 206px;
}
.form-table th p {
font-weight: normal;
}
.form-table.install-success td {
vertical-align: middle;
padding: 16px 20px 10px 0;
}
.form-table.install-success td p {
margin: 0;
font-size: 14px;
}
.form-table.install-success td code {
margin: 0;
font-size: 18px;
}
#error-page {
margin-top: 50px;
}
#error-page p {
font-size: 14px;
line-height: 18px;
margin: 25px 0 20px;
}
#error-page code, .code {
font-family: Consolas, Monaco, monospace;
}
#pass-strength-result {
background-color: #eee;
border-color: #ddd !important;
border-style: solid;
border-width: 1px;
margin: 5px 5px 5px 0;
padding: 5px;
text-align: center;
width: 200px;
display: none;
}
#pass-strength-result.bad {
background-color: #ffb78c;
border-color: #ff853c !important;
}
#pass-strength-result.good {
background-color: #ffec8b;
border-color: #ffcc00 !important;
}
#pass-strength-result.short {
background-color: #ffa0a0;
border-color: #f04040 !important;
}
#pass-strength-result.strong {
background-color: #c3ff88;
border-color: #8dff1c !important;
}
.message {
border: 1px solid #c00;
padding: 0.5em 0.7em;
margin: 5px 0 15px;
background-color: #ffebe8;
}
/* @noflip */
#dbname,
#uname,
#pwd,
#dbhost,
#prefix,
#user_login,
#admin_email,
#pass1,
#pass2 {
direction: ltr;
}
/* localization */
body.rtl,
.rtl textarea,
.rtl input,
.rtl submit {
font-family: Tahoma, sans-serif;
}
:lang(he-il) body.rtl,
:lang(he-il) .rtl textarea,
:lang(he-il) .rtl input,
:lang(he-il) .rtl submit {
font-family: Arial, sans-serif;
}
@media only screen and (max-width: 799px) {
body {
margin-top: 115px;
}
#logo a {
margin: -125px auto 30px;
}
}
@media screen and ( max-width: 782px ) {
.form-table {
margin-top: 0;
}
.form-table th,
.form-table td {
display: block;
width: auto;
vertical-align: middle;
}
.form-table th {
padding: 20px 0 0;
}
.form-table td {
padding: 5px 0;
border: 0;
margin: 0;
}
textarea,
input {
font-size: 16px;
}
.form-table td input[type="text"],
.form-table td input[type="password"],
.form-table td select,
.form-table td textarea,
.form-table span.description {
width: 100%;
font-size: 16px;
line-height: 1.5;
padding: 7px 10px;
display: block;
max-width: none;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
}
| 01-wordpress-paypal | trunk/wp-admin/css/install.css | CSS | gpl3 | 4,912 |
/*------------------------------------------------------------------------------
11.2 - Post Revisions
------------------------------------------------------------------------------*/
.revisions-control-frame,
.revisions-diff-frame {
position: relative;
}
.revisions-controls {
padding-top: 40px;
height: 100px;
z-index: 1;
}
.revisions-controls input[type="checkbox"] {
position: relative;
top: -1px;
vertical-align: text-bottom;
}
.revisions.pinned .revisions-controls {
position: fixed;
top: 0;
height: 82px;
background: #fff;
-webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.1);
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.revisions-tickmarks {
position: relative;
margin: 0 auto;
height: 0.7em;
top: 7px;
max-width: 70%;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
background-color: #fff;
}
.revisions-tickmarks > div {
position: absolute;
height: 100%;
border-left: 1px solid #aaa;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.revisions-tickmarks > div:first-child {
border-width: 0;
}
.comparing-two-revisions .revisions-controls {
height: 140px;
}
.comparing-two-revisions.pinned .revisions-controls {
height: 124px;
}
.revisions .diff-error {
position: absolute;
text-align: center;
margin: 0 auto;
width: 100%;
display: none;
}
.revisions.diff-error .diff-error {
display: block;
}
.revisions .loading-indicator {
position: fixed;
vertical-align: middle;
opacity: 0;
width: 100%;
top: 50%;
margin-left: -90px;
-webkit-transition: opacity 0.5s;
transition: opacity 0.5s;
filter: alpha(opacity=0); /* ie8 and earlier */
}
body.folded .revisions .loading-indicator {
margin-left: -32px;
}
.revisions .loading-indicator span.spinner {
display: block;
margin: 0 auto;
float: none;
}
.revisions.loading .loading-indicator {
opacity: 1;
filter: alpha(opacity=100); /* ie8 and earlier */
}
.revisions .diff {
-webkit-transition: opacity 0.5s;
transition: opacity 0.5s;
}
.revisions.loading .diff {
opacity: 0.5;
filter: alpha(opacity=50); /* ie8 and earlier */
}
.revisions.diff-error .diff {
visibility: hidden;
}
.revisions-meta {
margin-top: 20px;
background-color: #fff;
-webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.1);
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.revisions.pinned .revisions-meta {
-webkit-box-shadow: none;
box-shadow: none;
}
.revision-toggle-compare-mode {
position: absolute;
top: 0;
right: 0;
}
.comparing-two-revisions .revisions-previous,
.comparing-two-revisions .revisions-next,
.revisions-meta .diff-meta-to strong {
display: none;
}
.revisions-controls .author-card .date {
color: #777;
}
.revisions-controls .author-card.autosave {
color: #d54e21;
}
.revisions-controls .author-card .author-name {
font-weight: bold;
}
.comparing-two-revisions .diff-meta-to strong {
display: block;
}
.revisions.pinned .revisions-buttons {
padding: 0 11px;
}
.revisions-previous,
.revisions-next {
position: relative;
z-index: 1;
}
.revisions-previous {
float: left;
}
.revisions-next {
float: right;
}
.revisions-controls .wp-slider {
max-width: 70%;
margin: 0 auto;
top: -3px;
}
.revisions-diff {
padding: 15px;
background-color: #fff;
-webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.1);
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.revisions-diff h3:first-child {
margin-top: 0;
}
/* Revision meta box */
.post-revisions li img,
#revisions-meta-restored img {
vertical-align: middle;
}
table.diff tbody tr td:nth-child(2) {
width: 4%;
}
table.diff {
table-layout: fixed;
width: 100%;
white-space: pre-wrap;
}
table.diff col.content {
width: auto;
}
table.diff col.content.diffsplit {
width: 48%;
}
table.diff col.diffsplit.middle {
width: auto;
}
table.diff col.ltype {
width: 30px;
}
table.diff tr {
background-color: transparent;
}
table.diff td,
table.diff th {
font-family: Consolas, Monaco, monospace;
font-size: 14px;
line-height: 1.618;
padding: .5em;
vertical-align: top;
word-wrap: break-word;
}
table.diff td h1,
table.diff td h2,
table.diff td h3,
table.diff td h4,
table.diff td h5,
table.diff td h6 {
margin: 0;
}
table.diff .diff-deletedline del,
table.diff .diff-addedline ins {
text-decoration: none;
}
table.diff .diff-deletedline {
background-color: #ffe9e9;
}
table.diff .diff-deletedline del {
background-color: #faa;
}
table.diff .diff-addedline {
background-color: #e9ffe9;
}
table.diff .diff-addedline ins {
background-color: #afa;
}
.diff-meta {
padding: 5px;
clear: both;
min-height: 32px;
}
.diff-title strong {
line-height: 32px;
min-width: 60px;
text-align: right;
float: left;
margin-right: 5px;
}
.revisions-controls .author-card .author-info {
font-size: 12px;
line-height: 16px;
}
.revisions-controls .author-card .avatar,
.revisions-controls .author-card .author-info {
float: left;
margin-left: 6px;
margin-right: 6px;
}
.revisions-controls .author-card .byline {
display: block;
font-size: 12px;
}
.revisions-controls .author-card .avatar {
vertical-align: middle;
}
.diff-meta input.restore-revision {
float: right;
margin-left: 6px;
margin-right: 6px;
margin-top: 4px;
}
.diff-meta-from {
display: none;
}
.comparing-two-revisions .diff-meta-from {
display: block;
}
.revisions-tooltip {
position: absolute;
bottom: 105px;
margin-right: 0;
margin-left: -69px;
z-index: 0;
max-width: 350px;
min-width: 130px;
padding: 8px 4px;
display: none;
opacity: 0;
}
.revisions-tooltip.flipped {
margin-left: 0;
margin-right: -70px;
}
.revisions.pinned .revisions-tooltip {
display: none !important;
}
.comparing-two-revisions .revisions-tooltip {
bottom: 145px;
}
.revisions-tooltip-arrow {
width: 70px;
height: 15px;
overflow: hidden;
position: absolute;
left: 0;
margin-left: 35px;
bottom: -15px;
}
.revisions-tooltip.flipped .revisions-tooltip-arrow {
margin-left: 0;
margin-right: 35px;
left: auto;
right: 0;
}
.revisions-tooltip-arrow > span {
content: "";
position: absolute;
left: 20px;
top: -20px;
width: 25px;
height: 25px;
-webkit-transform: rotate(45deg);
-ms-transform: rotate(45deg);
transform: rotate(45deg);
}
.revisions-tooltip.flipped .revisions-tooltip-arrow > span {
left: auto;
right: 20px;
}
.ie8 .revisions-tooltip-arrow > span {
left: 15px;
top: -25px;
-ms-filter: "progid:DXImageTransform.Microsoft.Matrix(SizingMethod='auto expand', M11=0.7071067811865476, M12=-0.7071067811865475, M21=0.7071067811865475, M22=0.7071067811865476)";
}
.ie8 .revisions-tooltip.flipped .revisions-tooltip-arrow > span {
right: 25px;
}
.revisions-tooltip,
.revisions-tooltip-arrow > span {
border: 1px solid #d7d7d7;
background-color: #fff;
}
.revisions-tooltip {
display: none;
}
.arrow {
width: 70px;
height: 16px;
overflow: hidden;
position: absolute;
left: 0;
margin-left: -35px;
bottom: 90px;
z-index: 10000;
}
.arrow::after {
z-index: 9999;
background-color: #fff;
-webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.1);
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.arrow.top {
top: -16px;
bottom: auto;
}
.arrow.left {
left: 20%;
}
.arrow:after {
content: "";
position: absolute;
left: 20px;
top: -20px;
width: 25px;
height: 25px;
-webkit-transform: rotate(45deg);
-ms-transform: rotate(45deg);
transform: rotate(45deg);
}
.revisions-tooltip,
.revisions-tooltip-arrow:after {
border-width: 1px;
border-style: solid;
}
div.revisions-controls > .wp-slider > .ui-slider-handle {
margin-left: -10px;
}
.rtl div.revisions-controls > .wp-slider > .ui-slider-handle {
margin-right: -10px;
}
/* jQuery UI Slider */
.wp-slider.ui-slider {
position: relative;
border: 1px solid #d7d7d7;
text-align: left;
cursor: pointer;
}
.wp-slider .ui-slider-handle {
-webkit-border-radius: 50%;
border-radius: 50%;
height: 18px;
margin-top: -3px;
outline: none;
position: absolute;
width: 18px;
z-index: 2;
}
.wp-slider .ui-slider-handle,
.wp-slider .ui-slider-handle.ui-state-hover,
.wp-slider .ui-slider-handle.focus {
background: #2ea2cc;
border: 1px solid #0074a2;
-webkit-box-shadow: inset 0 1px 0 #78c8e6, 0 1px 0 rgba(0,0,0,.15);
box-shadow: inset 0 1px 0 #78c8e6, 0 1px 0 rgba(0,0,0,.15);
}
.wp-slider .ui-slider-handle:before {
background: none;
position: absolute;
top: 0;
left: 0;
color: #fff;
content: "\f229";
font: normal 18px/1 'dashicons';
speak: none;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.wp-slider .ui-slider-handle.from-handle:before,
.wp-slider .ui-slider-handle.to-handle:before {
font-size: 20px !important;
margin: -1px 0 0 -1px;
}
.wp-slider .ui-slider-handle.from-handle:before {
content: '\f139';
}
.wp-slider .ui-slider-handle.to-handle:before {
content: '\f141';
}
.rtl .wp-slider .ui-slider-handle.from-handle:before {
content: '\f141';
}
.rtl .wp-slider .ui-slider-handle.to-handle:before {
content: '\f139';
right: -1px;
}
.wp-slider .ui-slider-range {
position: absolute;
font-size: .7em;
display: block;
border: 0;
background-color: transparent;
background-image: none;
}
.wp-slider.ui-slider-horizontal {
height: .7em;
}
.wp-slider.ui-slider-horizontal .ui-slider-handle {
top: -.25em;
margin-left: -.6em;
}
.wp-slider.ui-slider-horizontal .ui-slider-range {
top: 0;
height: 100%;
}
.wp-slider.ui-slider-horizontal .ui-slider-range-min {
left: 0;
}
.wp-slider.ui-slider-horizontal .ui-slider-range-max {
right: 0;
}
/* =Media Queries
-------------------------------------------------------------- */
/**
* HiDPI Displays
*/
@media print,
(-o-min-device-pixel-ratio: 5/4),
(-webkit-min-device-pixel-ratio: 1.25),
(min-resolution: 120dpi) {
.revision-tick.completed-false {
background-image: url(../images/spinner-2x.gif);
}
}
@media screen and ( max-width: 782px ) {
#diff-next-revision,
#diff-previous-revision {
margin-top: -1em;
}
table.diff {
-ms-word-break: break-all;
word-break: break-all;
word-wrap: break-word;
}
}
| 01-wordpress-paypal | trunk/wp-admin/css/revisions.css | CSS | gpl3 | 9,953 |
#poststuff {
padding-top: 10px;
min-width: 763px;
}
#poststuff #post-body {
padding: 0;
}
#poststuff .postbox-container {
width: 100%;
}
#poststuff #post-body.columns-2 {
margin-left: 300px;
}
/*------------------------------------------------------------------------------
11.0 - Write/Edit Post Screen
------------------------------------------------------------------------------*/
#show-comments {
overflow: hidden;
}
#save-action .spinner,
#show-comments a,
#show-comments .spinner {
float: right;
}
#lost-connection-notice .spinner {
display: block;
float: right;
margin: 0 0 0 5px;
}
#titlediv {
position: relative;
margin-bottom: 10px;
}
#titlediv label {
cursor: text;
}
#titlediv div.inside {
margin: 0;
}
#poststuff #titlewrap {
border: 0;
padding: 0;
}
#titlediv #title {
padding: 3px 8px;
font-size: 1.7em;
line-height: 100%;
height: 1.7em;
width: 100%;
outline: none;
margin: 0;
background-color: #fff;
}
#titlediv #title-prompt-text {
color: #777;
position: absolute;
font-size: 1.7em;
padding: 11px 10px;
}
#wp-fullscreen-save .fs-saved {
color: #999;
float: left;
margin-top: 4px;
}
#poststuff .inside-submitbox,
#side-sortables .inside-submitbox {
margin: 0 3px;
font-size: 11px;
}
input#link_description,
input#link_url {
width: 98%;
}
#pending {
background: 0 none;
border: 0 none;
padding: 0;
font-size: 11px;
margin-top: -1px;
}
#edit-slug-box {
line-height: 24px;
min-height: 25px; /* Yes, line-height + 1 */
margin-top: 5px;
padding: 0 10px;
color: #666;
}
#edit-slug-box .cancel {
margin-left: 10px;
font-size: 11px;
}
#editable-post-name-full {
display: none;
}
#editable-post-name {
background-color: #fffbcc;
}
#editable-post-name input {
font-size: 13px;
height: 22px;
margin: 0;
width: 16em;
}
.postarea h3 label {
float: right;
}
.submitbox .submit {
text-align: right;
padding: 12px 10px 10px;
font-size: 11px;
background-color: #464646;
color: #ccc;
}
.submitbox .submitdelete {
text-decoration: none;
padding: 1px 2px;
}
/* @todo: do we really need this? word on the street is we don't and this
stray rule may actually be compensated for elsewhere. */
#normal-sortables .submitbox .submitdelete:hover {
color: #000;
background-color: #f00;
border-bottom-color: #f00;
}
.submitbox .submit a:hover {
text-decoration: underline;
}
.submitbox .submit input {
margin-bottom: 8px;
margin-left: 4px;
padding: 6px;
}
.inside-submitbox #post_status {
margin: 2px -2px 2px 0;
}
#post-status-select {
margin-top: 3px;
}
/* Post Screen */
#post-body #normal-sortables {
min-height: 50px;
}
.postbox {
position: relative;
min-width: 255px;
border: 1px solid #e5e5e5;
-webkit-box-shadow: 0 1px 1px rgba(0,0,0,0.04);
box-shadow: 0 1px 1px rgba(0,0,0,0.04);
background: #fff;
}
#trackback_url {
width: 99%;
}
#normal-sortables .postbox .submit {
background: transparent none;
border: 0 none;
float: left;
padding: 0 12px;
margin:0;
}
.category-add input[type="text"],
.category-add select {
width: 100%;
max-width: 260px;
vertical-align: baseline;
}
#side-sortables .category-add input[type="text"],
#side-sortables .category-add select {
margin: 0 0 1em;
}
ul.category-tabs li,
#side-sortables .add-menu-item-tabs li,
.wp-tab-bar li {
display: inline;
line-height: 1.35em;
}
.no-js .category-tabs li.hide-if-no-js {
display: none;
}
.category-tabs a,
#side-sortables .add-menu-item-tabs a,
.wp-tab-bar a {
text-decoration: none;
}
/* @todo: do these really need to be so specific? */
#side-sortables .category-tabs .tabs a,
#side-sortables .add-menu-item-tabs .tabs a,
.wp-tab-bar .wp-tab-active a,
#post-body ul.category-tabs li.tabs a,
#post-body ul.add-menu-item-tabs li.tabs a {
color: #333;
}
.category-tabs {
margin: 8px 0 5px;
}
#category-adder h4 {
margin: 10px 0;
}
#side-sortables .add-menu-item-tabs,
.wp-tab-bar {
margin-bottom: 3px;
}
#normal-sortables .postbox #replyrow .submit {
float: none;
margin: 0;
padding: 0 7px 5px;
}
#side-sortables .submitbox .submit input,
#side-sortables .submitbox .submit .preview,
#side-sortables .submitbox .submit a.preview:hover {
border: 0 none;
}
#side-sortables .inside-submitbox .insidebox,
.stuffbox .insidebox {
margin: 11px 0;
}
/* @todo: make this a more generic class */
ul.category-tabs,
ul.add-menu-item-tabs,
ul.wp-tab-bar {
margin-top: 12px;
}
ul.category-tabs li,
ul.add-menu-item-tabs li {
border: solid 1px transparent;
position: relative;
}
ul.category-tabs li.tabs,
ul.add-menu-item-tabs li.tabs,
.wp-tab-active {
border: 1px solid #dfdfdf;
border-bottom-color: #fdfdfd;
background-color: #fdfdfd;
}
ul.category-tabs li,
ul.add-menu-item-tabs li,
ul.wp-tab-bar li {
padding: 3px 5px 5px;
}
#postimagediv .inside img {
max-width: 100%;
height: auto;
}
form#tags-filter {
position: relative;
}
/* Edit posts */
td.post-title strong,
td.plugin-title strong {
display: block;
margin-bottom: .2em;
font-size: 14px;
}
td.post-title p,
td.plugin-title p {
margin: 6px 0;
}
/* Global classes */
.wp-hidden-children .wp-hidden-child,
.ui-tabs-hide {
display: none;
}
#post-body .tagsdiv #newtag {
margin-left: 5px;
width: 16em;
}
#side-sortables input#post_password {
width: 94%
}
#side-sortables .tagsdiv #newtag {
width: 68%;
}
#post-status-info {
width: 100%;
border-spacing: 0;
border: 1px solid #e5e5e5;
border-top: none;
background-color: #f7f7f7;
-webkit-box-shadow: 0 1px 1px rgba(0,0,0,0.04);
box-shadow: 0 1px 1px rgba(0,0,0,0.04);
}
#post-status-info td {
font-size: 12px;
}
.autosave-info {
padding: 2px;
text-align: left;
}
#editorcontent #post-status-info {
border: none;
}
#content-resize-handle {
background: transparent url(../images/resize.gif) no-repeat scroll left bottom;
width: 12px;
cursor: n-resize;
}
.rtl #content-resize-handle {
background: transparent url(../images/resize-rtl.gif) no-repeat scroll right bottom;
}
#wp-word-count {
display: block;
padding: 2px 10px;
}
#timestampdiv select {
height: 21px;
line-height: 14px;
padding: 0;
vertical-align: top;
font-size: 12px;
}
#aa, #jj, #hh, #mn {
padding: 1px;
font-size: 12px;
}
#jj, #hh, #mn {
width: 2em;
}
#aa {
width: 3.4em;
}
.curtime #timestamp {
padding: 2px 0 1px 0;
display: inline !important;
height: auto !important;
}
#misc-publishing-actions label[for="post_status"]:before,
#post-body #visibility:before,
.curtime #timestamp:before,
#post-body .misc-pub-revisions:before,
span.wp-media-buttons-icon:before {
color: #888;
}
#post-body #visibility:before,
.curtime #timestamp:before,
#post-body .misc-pub-revisions:before {
font: normal 20px/1 'dashicons';
speak: none;
display: inline-block;
padding: 0 0 0 2px;
top: 0;
right: -1px;
position: relative;
vertical-align: top;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-decoration: none !important;
}
#post-body #visibility:before {
content: '\f177';
}
.curtime #timestamp:before {
content: '\f145';
top: -1px;
}
#post-body .misc-pub-revisions:before {
content: '\f321';
}
#timestampdiv {
padding-top: 5px;
line-height: 23px;
}
#timestampdiv p {
margin: 8px 0 6px;
}
#timestampdiv input {
border-width: 1px;
border-style: solid;
}
.notification-dialog {
position: fixed;
top: 30%;
right: 50%;
width: 450px;
margin-right: -225px;
background: #fff;
-webkit-box-shadow: 0 3px 6px rgba( 0, 0, 0, 0.3 );
box-shadow: 0 3px 6px rgba( 0, 0, 0, 0.3 );
line-height: 1.5;
z-index: 1000005;
}
.notification-dialog-background {
position: fixed;
top: 0;
right: 0;
left: 0;
bottom: 0;
background: #000;
opacity: 0.7;
filter: alpha(opacity=70);
z-index: 1000000;
}
#post-lock-dialog .post-locked-message,
#post-lock-dialog .post-taken-over {
margin: 25px;
}
#post-lock-dialog .post-locked-message a.button {
margin-left: 10px;
}
#post-lock-dialog .post-locked-avatar {
float: right;
margin: 0 0 20px 20px;
}
#post-lock-dialog .wp-tab-first {
outline: 0;
}
#post-lock-dialog .locked-saving img {
float: right;
margin-left: 3px;
}
#post-lock-dialog.saving .locked-saving,
#post-lock-dialog.saved .locked-saved {
display: inline;
}
#excerpt,
.attachmentlinks {
margin: 0;
height: 4em;
width: 98%;
}
.tagchecklist {
margin-right: 14px;
font-size: 12px;
overflow: auto;
}
.tagchecklist br {
display: none;
}
.tagchecklist strong {
margin-right: -8px;
position: absolute;
}
.tagchecklist span {
margin-left: 25px;
display: block;
float: right;
font-size: 13px;
line-height: 1.8em;
white-space: nowrap;
cursor: default;
}
.tagchecklist span a {
margin: 1px -17px 0 0;
cursor: pointer;
width: 20px;
height: 20px;
display: block;
float: right;
text-indent: 0;
overflow: hidden;
position: absolute;
}
#poststuff h2 {
margin-top: 20px;
font-size: 1.5em;
margin-bottom: 15px;
padding: 0 0 3px;
clear: right;
}
#poststuff h3 {
font-size: 14px;
padding: 8px 12px;
margin: 0;
line-height: 1.4;
}
#poststuff .inside {
margin: 6px 0 0 0;
}
#poststuff .inside #parent_id,
#poststuff .inside #page_template {
max-width: 100%;
}
#poststuff .inside label.spam,
#poststuff .inside label.deleted {
color: red;
}
#poststuff .inside label.waiting {
color: orange;
}
#poststuff .inside label.approved {
color: green;
}
.ie8 #poststuff .inside #parent_id,
.ie8 #poststuff .inside #page_template {
width: 250px;
}
#post-visibility-select {
line-height: 1.5em;
margin-top: 3px;
}
#poststuff #submitdiv .inside {
margin: 0;
padding: 0;
}
.edit-form-section {
margin-bottom: 20px;
}
/*------------------------------------------------------------------------------
11.1 - Custom Fields
------------------------------------------------------------------------------*/
#postcustomstuff thead th {
padding: 5px 8px 8px;
background-color: #f1f1f1;
}
#postcustom #postcustomstuff .submit {
border: 0 none;
float: none;
padding: 0 8px 8px;
}
#side-sortables #postcustom #postcustomstuff .submit {
margin: 0;
padding: 0;
}
#side-sortables #postcustom #postcustomstuff #the-list textarea {
height: 85px;
}
#side-sortables #postcustom #postcustomstuff td.left input,
#side-sortables #postcustom #postcustomstuff td.left select,
#side-sortables #postcustomstuff #newmetaleft a {
margin: 3px 3px 0;
}
#postcustomstuff table {
margin: 0;
width: 100%;
border: 1px solid #dfdfdf;
border-spacing: 0;
background-color: #f9f9f9;
}
#postcustomstuff tr {
vertical-align: top;
}
#postcustomstuff table input,
#postcustomstuff table select,
#postcustomstuff table textarea {
width: 96%;
margin: 8px;
}
#side-sortables #postcustomstuff table input,
#side-sortables #postcustomstuff table select,
#side-sortables #postcustomstuff table textarea {
margin: 3px;
}
#postcustomstuff th.left,
#postcustomstuff td.left {
width: 38%;
}
#postcustomstuff .submit input {
margin: 0;
width: auto;
}
#postcustomstuff #newmetaleft a {
display: inline-block;
margin: 0 8px 8px;
text-decoration: none;
}
.no-js #postcustomstuff #enternew {
display: none;
}
#post-body-content .compat-attachment-fields {
margin-bottom: 20px;
}
.compat-attachment-fields th {
padding-top: 5px;
padding-left: 10px;
}
/*------------------------------------------------------------------------------
11.3 - Featured Images
------------------------------------------------------------------------------*/
#select-featured-image {
padding: 4px 0;
overflow: hidden;
}
#select-featured-image img {
max-width: 100%;
height: auto;
margin-bottom: 10px;
}
#select-featured-image a {
float: right;
clear: both;
}
#select-featured-image .remove {
display: none;
margin-top: 10px;
}
.js #select-featured-image.has-featured-image .remove {
display: inline-block;
}
.no-js #select-featured-image .choose {
display: none;
}
/*------------------------------------------------------------------------------
11.4 - Post formats
------------------------------------------------------------------------------*/
.post-state-format {
overflow: hidden;
display: inline-block;
vertical-align: middle;
height: 20px;
width: 20px;
margin-left: 5px;
margin-top: -4px;
}
.post-state-format:before {
display: block;
height: 20px;
width: 20px;
font: normal 20px/1 'dashicons' !important;
speak: none;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.post-state-format:before,
.post-format-icon:before {
color: #ddd;
-webkit-transition: all .1s ease-in-out;
transition: all .1s ease-in-out;
}
a.post-state-format:hover:before,
a.post-format-icon:hover:before {
color: #2ea2cc;
}
#post-formats-select {
line-height: 2em;
}
#post-formats-select .post-format-icon:before {
top: 5px;
}
input.post-format {
margin-top: 1px;
}
label.post-format-icon {
margin-right: 0px;
padding: 2px 0px 2px 0;
}
.post-format-icon:before {
position: relative;
display: inline-block;
margin-left: 7px;
font: normal 20px/1 'dashicons';
speak: none;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.post-state-format.post-format-standard:before,
.post-format-icon.post-format-standard:before,
a.post-state-format.format-standard:before {
content: '\f109';
}
.post-state-format.post-format-image:before,
.post-format-icon.post-format-image:before,
a.post-state-format.format-image:before {
content: '\f128';
}
.post-state-format.post-format-gallery:before,
.post-format-icon.post-format-gallery:before,
a.post-state-format.format-gallery:before {
content: '\f161';
}
.post-state-format.post-format-audio:before,
.post-format-icon.post-format-audio:before,
a.post-state-format.format-audio:before {
content: '\f127';
}
.post-state-format.post-format-video:before,
.post-format-icon.post-format-video:before,
a.post-state-format.format-video:before {
content: '\f126';
}
.post-state-format.post-format-chat:before,
.post-format-icon.post-format-chat:before,
a.post-state-format.format-chat:before {
content: '\f125';
}
.post-state-format.post-format-status:before,
.post-format-icon.post-format-status:before,
a.post-state-format.format-status:before {
content: '\f130';
}
.post-state-format.post-format-aside:before,
.post-format-icon.post-format-aside:before,
a.post-state-format.format-aside:before {
content: '\f123';
}
.post-state-format.post-format-quote:before,
.post-format-icon.post-format-quote:before,
a.post-state-format.format-quote:before {
content: '\f122';
}
.post-state-format.post-format-link:before,
.post-format-icon.post-format-link:before,
a.post-state-format.format-link:before {
content: '\f103';
}
/*------------------------------------------------------------------------------
12.0 - Categories
------------------------------------------------------------------------------*/
.category-adder {
margin-right: 120px;
padding: 4px 0;
}
.category-adder h4 {
margin: 0 0 8px;
}
#side-sortables .category-adder {
margin: 0;
}
.wp-tab-panel,
.categorydiv div.tabs-panel,
.customlinkdiv div.tabs-panel,
.posttypediv div.tabs-panel,
.taxonomydiv div.tabs-panel {
min-height: 42px;
max-height: 200px;
overflow: auto;
padding: 0 0.9em;
border: solid 1px #dfdfdf;
background-color: #fdfdfd;
}
div.tabs-panel-active {
display:block;
}
div.tabs-panel-inactive {
display:none;
}
#front-page-warning,
#front-static-pages ul,
ul.export-filters,
.inline-editor ul.cat-checklist ul,
.categorydiv ul.categorychecklist ul,
.customlinkdiv ul.categorychecklist ul,
.posttypediv ul.categorychecklist ul,
.taxonomydiv ul.categorychecklist ul {
margin-right: 18px;
}
ul.categorychecklist li {
margin: 0;
padding: 0;
line-height: 22px;
word-wrap: break-word;
}
.categorydiv .tabs-panel,
.customlinkdiv .tabs-panel,
.posttypediv .tabs-panel,
.taxonomydiv .tabs-panel {
border-width: 3px;
border-style: solid;
}
.form-wrap p,
.form-wrap label {
font-size: 11px;
}
.form-wrap label {
display: block;
padding: 2px;
font-size: 12px;
}
.form-field input,
.form-field textarea {
border-style: solid;
border-width: 1px;
width: 95%;
}
p.description,
.form-wrap p {
margin: 2px 0 5px;
color: #666;
}
p.help,
p.description,
span.description,
.form-wrap p {
font-size: 13px;
font-style: italic;
}
.form-wrap .form-field {
margin: 0 0 10px;
padding: 8px 0;
}
.form-wrap .form-field #parent {
max-width: 100%;
}
.col-wrap h3 {
margin: 12px 0;
font-size: 1.1em;
}
.col-wrap p.submit {
margin-top: -10px;
}
/*------------------------------------------------------------------------------
13.0 - Tags
------------------------------------------------------------------------------*/
.tagsdiv {
margin-top: -8px;
}
#poststuff .taghint {
color: #aaa;
margin: 15px 12px -24px 0;
}
#poststuff .tagsdiv .howto {
margin: 0 0 6px 0;
}
.ajaxtag .newtag {
position: relative;
}
.tagsdiv .newtag {
width: 180px;
}
.tagsdiv .the-tags {
display: block;
height: 60px;
margin: 0 auto;
overflow: auto;
width: 260px;
}
#post-body-content .tagsdiv .the-tags {
margin: 0 5px;
}
/* tag hints */
.taghint {
color: #aaa;
margin: -17px 7px 0 0;
visibility: hidden;
}
input.newtag ~ div.taghint {
visibility: visible;
}
input.newtag:focus ~ div.taghint {
visibility: hidden;
}
p.popular-tags {
border: none;
line-height: 2em;
max-width: 1000px;
padding: 8px 12px 12px;
text-align: justify;
}
p.popular-tags a {
padding: 0 3px;
}
.tagcloud {
width: 97%;
margin: 0 0 40px;
text-align: justify;
}
.tagcloud h3 {
margin: 2px 0 12px;
}
.ac_results {
padding: 0;
margin: 0;
list-style: none;
position: absolute;
z-index: 10000;
display: none;
border: 1px solid #808080;
background-color: #fff;
}
.wp-customizer .ac_results {
z-index: 500000;
}
.ac_results li {
padding: 2px 5px;
white-space: nowrap;
color: #101010;
text-align: right;
}
.ac_over {
background-color: #f0f0b8;
cursor: pointer;
}
.ac_match {
text-decoration: underline;
}
/* Comments */
.comment-php .wp-editor-area {
height: 200px;
}
.comment-ays {
margin-bottom: 0;
border-bottom-style: solid;
border-bottom-width: 1px;
}
.comment-ays .alt {
background-color: transparent;
}
.trash-undo-inside,
.spam-undo-inside {
margin: 1px 0 1px 8px;
line-height: 16px;
}
.spam-undo-inside .avatar,
.trash-undo-inside .avatar {
height: 20px;
width: 20px;
margin-left: 8px;
vertical-align: middle;
}
.stuffbox .editcomment {
clear: none;
}
#comment-status-radio p {
margin: 3px 0 5px;
}
#comment-status-radio input {
margin: 2px 0 5px 3px;
vertical-align: middle;
}
#comment-status-radio label {
padding: 5px 0;
}
/* links tables */
table.links-table {
width: 100%;
border-spacing: 0;
}
.links-table th {
font-weight: normal;
text-align: right;
vertical-align: top;
min-width: 80px;
width: 20%;
word-wrap: break-word;
}
.links-table th,
.links-table td {
padding: 5px 0;
}
.links-table td label {
margin-left: 8px;
}
.links-table td input[type="text"],
.links-table td textarea {
width: 100%;
}
.links-table #link_rel {
max-width: 280px;
}
/* =Media Queries
-------------------------------------------------------------- */
/**
* HiDPI Displays
*/
@media print,
(-o-min-device-pixel-ratio: 5/4),
(-webkit-min-device-pixel-ratio: 1.25),
(min-resolution: 120dpi) {
#content-resize-handle,
#post-body .wp_themeSkin .mceStatusbar a.mceResize {
background: transparent url(../images/resize-2x.gif) no-repeat scroll left bottom;
-webkit-background-size: 11px 11px;
background-size: 11px 11px;
}
.rtl #content-resize-handle,
.rtl #post-body .wp_themeSkin .mceStatusbar a.mceResize {
background: transparent url(../images/resize-rtl-2x.gif) no-repeat scroll left bottom;
}
}
/* one column on the post write/edit screen */
@media only screen and (max-width: 850px) {
#poststuff {
min-width: 0;
}
#wpbody-content #poststuff #post-body {
margin: 0;
}
#wpbody-content #post-body.columns-2 #postbox-container-1 {
margin-left: 0;
width: 100%;
}
#poststuff #postbox-container-1 .empty-container,
#poststuff #postbox-container-1 #side-sortables:empty {
border: 0 none;
height: 0;
min-height: 0;
}
#poststuff #post-body.columns-2 #side-sortables {
min-height: 0;
}
/* hide the radio buttons for column prefs */
.screen-layout,
.columns-prefs {
display: none;
}
}
@media screen and ( max-width: 782px ) {
#post-body-content {
min-width: 0;
}
#titlediv #title-prompt-text {
padding: 10px 10px;
}
#poststuff h3 {
padding: 12px;
}
.post-format-options {
padding-left: 0;
}
.post-format-options a {
margin-left: 5px;
margin-bottom: 5px;
min-width: 52px;
}
.post-format-options .post-format-title {
font-size: 11px;
}
.post-format-options a div {
height: 28px;
width: 28px;
}
.post-format-options a div:before {
font-size: 26px !important;
}
/* Publish Metabox Options */
#post-visibility-select {
line-height: 280%;
}
.wp-core-ui .save-post-visibility,
.wp-core-ui .save-timestamp {
vertical-align: middle;
margin-left: 15px;
}
.timestamp-wrap select#mm {
display: block;
width: 100%;
margin-bottom: 10px;
}
.timestamp-wrap #jj,
.timestamp-wrap #aa,
.timestamp-wrap #hh,
.timestamp-wrap #mn {
padding: 12px 3px;
font-size: 14px;
margin-bottom: 5px;
width: auto;
text-align: center;
}
/* Categories Metabox */
ul.category-tabs {
margin: 30px 0 15px;
}
ul.category-tabs li.tabs {
padding: 15px;
}
ul.categorychecklist li {
margin-bottom: 15px;
}
ul.categorychecklist ul {
margin-top: 15px;
}
.category-add input[type=text],
.category-add select {
max-width: none;
margin-bottom: 15px;
}
/* Tags Metabox */
.tagsdiv .newtag {
width: 100%;
height: auto;
margin-bottom: 15px;
}
.tagchecklist {
margin: 25px 10px;
}
.tagchecklist span {
font-size: 16px;
line-height: 120%;
}
/* Discussion */
#commentstatusdiv p {
line-height: 2.8;
}
/* TinyMCE Adjustments */
.mceToolbar * {
white-space: normal !important;
}
.mceToolbar tr,
.mceToolbar td {
float: right !important;
}
.wp_themeSkin a.mceButton {
width: 30px;
height: 30px;
}
.wp_themeSkin .mceButton .mceIcon {
margin-top: 5px;
margin-right: 5px;
}
.wp_themeSkin .mceSplitButton {
margin-top: 1px;
}
.wp_themeSkin .mceSplitButton td a.mceAction {
padding-top: 6px;
padding-bottom: 6px;
padding-right: 6px;
padding-left: 3px;
}
.wp_themeSkin .mceSplitButton td a.mceOpen,
.wp_themeSkin .mceSplitButtonEnabled:hover td a.mceOpen {
padding-top: 6px;
padding-bottom: 6px;
background-position: 1px 6px;
}
.wp_themeSkin table.mceListBox {
margin: 5px;
}
div.quicktags-toolbar input {
padding: 10px 20px;
}
#wp-content-editor-tools {
overflow: hidden;
padding: 20px 0 1px 15px;
top: 1px;
}
a.wp-switch-editor {
font-size: 16px;
line-height: 1em;
margin: 3px 7px 0 0;
padding: 12px 15px;
}
#wp-content-media-buttons a {
font-size: 16px;
line-height: 37px;
height: 39px;
padding: 0 15px 0 20px;
}
.wp-media-buttons span.wp-media-buttons-icon,
.wp-media-buttons span.jetpack-contact-form-icon {
width: 22px !important;
margin-top: -3px !important;
margin-right: -5px !important;
}
.wp-media-buttons .add_media span.wp-media-buttons-icon:before,
.wp-media-buttons #insert-jetpack-contact-form span.jetpack-contact-form-icon:before {
font-size: 20px !important;
}
#content_wp_fullscreen {
display: none;
}
.misc-pub-section {
padding: 20px 10px 20px;
}
.misc-pub-section > a {
float: left;
font-size: 16px;
}
#delete-action,
#publishing-action {
line-height: 47px;
}
/* Moderate Comment */
.comment-ays {
border-bottom: none;
}
/* Links */
.links-table #link_rel {
max-width: none;
}
.links-table th,
.links-table td {
padding: 10px 0;
}
}
@media only screen and (max-width: 500px) {
/* Align Add Media + Visual + Text tabs */
#wp-content-media-buttons a {
font-size: 14px;
padding: 0 10px 0 10px;
}
}
| 01-wordpress-paypal | trunk/wp-admin/css/edit-rtl.css | CSS | gpl3 | 23,865 |
/* General Widgets Styles */
.widget {
margin: 0 auto 10px;
position: relative;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.widget-top {
font-size: 13px;
font-weight: 600;
background: #f7f7f7;
}
.widget-top a.widget-action,
.widget-top a.widget-action:hover {
text-decoration: none;
}
.widget-title h4 {
margin: 0;
padding: 15px;
line-height: 1;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.widgets-holder-wrap .widget-inside {
border-top: none;
padding: 1px 15px 15px 15px;
line-height: 16px;
}
.in-widget-title,
#widgets-right a.widget-control-edit,
#available-widgets .widget-description {
color: #666;
}
.deleting .widget-title,
.deleting .widget-top a.widget-action:after {
color: #aaa;
}
/* Widget Dragging Helpers */
.widget.ui-draggable-dragging {
min-width: 100%;
}
.widget.ui-sortable-helper {
opacity: 0.8;
}
.widget-placeholder {
border: 1px dashed #bbb;
margin: 0 auto 10px;
height: 45px;
width: 100%;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
#widgets-right .widget-placeholder {
margin-top: 0;
}
#widgets-right .closed .widget-placeholder {
height: 0;
border: 0;
margin-top: -10px;
}
/* Widget Sidebars */
.sidebar-name {
position: relative;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.sidebar-name-arrow {
position: absolute;
top: 0;
left: 0;
bottom: 0;
}
.js .sidebar-name {
cursor: pointer;
}
.sidebar-name h3 {
margin: 0;
padding: 8px 10px;
overflow: hidden;
white-space: nowrap;
}
.widgets-holder-wrap .description {
padding: 0 0 15px;
margin: 0;
font-style: normal;
color: #777;
}
#widgets-right .widgets-holder-wrap .description {
padding-right: 7px;
padding-left: 7px;
}
/* Widgets 2-col Layout */
div.widget-liquid-left {
margin: 0;
width: 38%;
float: right;
}
div.widget-liquid-right {
float: left;
width: 58%;
}
/* Widgets Left - Available Widgets */
div#widgets-left {
padding-top: 12px;
}
div#widgets-left .closed .sidebar-name,
div#widgets-left .inactive-sidebar.closed .sidebar-name {
margin-bottom: 10px;
}
div#widgets-left .sidebar-name h3 {
padding: 10px 0;
margin: 0 0 0 10px;
}
div#widgets-left .sidebar-name .sidebar-name-arrow:before {
left: 0;
top: 4px;
padding: 4px 4px 4px 6px;
}
#widgets-left #available-widgets,
div#widgets-left .widget-holder {
background: transparent;
border: none;
}
#widgets-left .widgets-holder-wrap {
border: none;
-webkit-box-shadow: none;
box-shadow: none;
}
#available-widgets .widget-action {
display: none;
}
#available-widgets .widget {
margin: 0;
}
#available-widgets .widget:nth-child(odd) {
clear: both;
}
#available-widgets .widget .widget-description {
display: block;
padding: 10px 15px;
font-size: 12px;
}
#available-widgets #widget-list {
position: relative;
}
/* Inactive Sidebars */
#widgets-left .inactive-sidebar {
clear: both;
width: 100%;
background: transparent;
padding: 0;
margin: 0 0 20px 0;
border: none;
-webkit-box-shadow: none;
box-shadow: none;
}
#widgets-left .inactive-sidebar.first {
margin-top: 40px;
}
/* Not sure what this is for... */
div#widgets-left .inactive-sidebar .widget.expanded {
right: auto;
}
.widget-title-action {
float: left;
position: relative;
}
div#widgets-left .inactive-sidebar .widgets-sortables {
min-height: 42px;
padding: 0;
background: transparent;
margin: 0;
position: relative;
}
/* Widgets Right */
div#widgets-right:after {
content: ".";
display: block;
height: 0;
clear: both;
visibility: hidden;
}
div#widgets-right .sidebars-column-1,
div#widgets-right .sidebars-column-2 {
max-width: 450px;
}
div#widgets-right .widgets-holder-wrap {
margin: 10px 0 0 0;
}
div#widgets-right .sidebar-description {
min-height: 20px;
margin-top: -5px;
}
div#widgets-right .sidebar-name h3 {
padding: 15px 7px;
}
div#widgets-right .sidebar-name .sidebar-name-arrow:before {
left: 0;
top: 4px;
}
div#widgets-right .widget-top {
padding: 0;
}
div#widgets-right .widgets-sortables {
padding: 0 8px;
margin-bottom: 9px;
position: relative;
min-height: 123px;
}
div#widgets-right .closed .widgets-sortables {
min-height: 0;
margin-bottom: 0;
}
.sidebar-name .spinner {
margin: -5px 5px;
float: none;
}
/* Dragging a widget over a closed sidebar */
#widgets-right .widgets-holder-wrap.widget-hover {
border-color: #777;
-webkit-box-shadow: 0 1px 2px rgba(0,0,0,0.3);
box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
/* Accessibility Mode */
.widgets_access #widgets-left .widget .widget-top {
cursor: auto;
}
.widgets_access #wpwrap .widgets-holder-wrap.closed .sidebar-description,
.widgets_access #wpwrap .widgets-holder-wrap.closed .widget,
.widgets_access #wpwrap .widget-control-edit {
display: block;
}
.widgets_access #widgets-left .widget .widget-top:hover,
.widgets_access #widgets-right .widget .widget-top:hover {
border-color: #ddd;
}
#available-widgets .widget-control-edit .edit,
#widgets-left .inactive-sidebar .widget-control-edit .add,
#widgets-right .widget-control-edit .add {
display: none;
}
.widget-control-edit {
display: block;
color: #666;
background: #EEE;
padding: 0 15px;
line-height: 43px;
border-right: 1px solid #DDD;
}
#widgets-left .widget-control-edit:hover,
#widgets-right .widget-control-edit:hover {
color: #fff;
background: #444;
border-right: 0;
outline: 1px solid #444;
}
.widgets-holder-wrap .sidebar-name,
.widgets-holder-wrap .sidebar-description {
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.editwidget {
margin: 0 auto;
}
.editwidget .widget-inside {
display: block;
padding: 0 15px;
}
.editwidget .widget-control-actions {
margin-top: 20px;
}
.js .widgets-holder-wrap.closed .widget,
.js .widgets-holder-wrap.closed .sidebar-description,
.js .closed br.clear {
display: none;
}
/* Hide Widget Settings by Default */
.widget-inside,
.widget-description {
display: none;
}
.widget-inside {
background: #fff;
}
/* Dragging widgets over the available widget area show's a "Deactivate" message */
#removing-widget {
display: none;
font-weight: normal;
padding-right: 15px;
font-size: 12px;
line-height: 1;
color: black;
}
.js #removing-widget {
color: #2ea2cc;
}
.widget-control-noform,
#access-off,
.widgets_access .widget-action,
.widgets_access .sidebar-name-arrow,
.widgets_access #access-on,
.widgets_access .widget-holder .description,
.no-js .widget-holder .description {
display: none;
}
.widgets_access .widget-holder,
.widgets_access #widget-list {
padding-top: 10px;
}
.widgets_access #access-off {
display: inline;
}
.widgets_access .sidebar-name,
.widgets_access .widget .widget-top {
cursor: default;
}
/* Widgets Area Chooser */
.widget-liquid-left #widgets-left.chooser #available-widgets .widget,
.widget-liquid-left #widgets-left.chooser .inactive-sidebar {
-webkit-transition: opacity 0.1s linear;
transition: opacity 0.1s linear;
}
.widget-liquid-left #widgets-left.chooser #available-widgets .widget,
.widget-liquid-left #widgets-left.chooser .inactive-sidebar {
/* -webkit-filter: blur(1px); */
opacity: 0.2;
pointer-events: none;
}
.widget-liquid-left #widgets-left.chooser #available-widgets .widget-in-question {
/* -webkit-filter: none; */
opacity: 1;
pointer-events: auto;
}
.widgets-chooser ul,
#widgets-left .widget-in-question .widget-top,
#available-widgets .widget-top:hover,
div#widgets-right .widget-top:hover,
#widgets-left .widget-top:hover {
border-color: #999;
-webkit-box-shadow: 0 1px 2px rgba(0,0,0,0.1);
box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
.widgets-chooser ul.widgets-chooser-sidebars {
margin: 0;
list-style-type: none;
max-height: 300px;
overflow: auto;
}
.widgets-chooser {
display: none;
}
.widgets-chooser ul {
border: 1px solid #ccc;
}
.widgets-chooser li {
padding: 10px 35px 10px 15px;
border-bottom: 1px solid #ccc;
background: #fff;
margin: 0;
cursor: pointer;
outline: none;
position: relative;
-webkit-transition: background 0.2s ease-in-out;
transition: background 0.2s ease-in-out;
}
.widgets-chooser li:hover,
.widgets-chooser li:focus {
background: rgba(255,255,255,0.7);
}
.widgets-chooser li:focus:before {
content: '\f147';
display: block;
-webkit-font-smoothing: antialiased;
font: normal 26px/1 'dashicons';
color: #999;
position: absolute;
top: 7px;
right: 5px;
}
.widgets-chooser li:last-child {
border: none;
}
.widgets-chooser li.widgets-chooser-selected {
background: #2ea2cc;
color: #fff;
}
.widgets-chooser li.widgets-chooser-selected:before,
.widgets-chooser li.widgets-chooser-selected:focus:before {
content: '\f147';
display: block;
-webkit-font-smoothing: antialiased;
font: normal 26px/1 'dashicons';
color: #fff;
position: absolute;
top: 7px;
right: 5px;
}
.widgets-chooser .widgets-chooser-actions {
padding: 10px 0 12px 0;
text-align: center;
}
.widgets-chooser button {
margin-left: 5px;
}
#available-widgets .widget .widget-top {
cursor: pointer;
}
/* =Media Queries
-------------------------------------------------------------- */
@media screen and (max-width: 480px) {
div.widget-liquid-left {
width: 100%;
float: none;
border-left: none;
padding-left: 0;
}
#widgets-left .sidebar-name {
margin-left: 0;
}
#widgets-left #available-widgets .widget-top {
margin-left: 0;
}
#widgets-left .inactive-sidebar .widgets-sortables {
margin-left: 0;
}
div.widget-liquid-right {
width: 100%;
float: none;
}
div.widget {
margin: 0 auto 10px !important;
max-width: 480px;
}
}
@media screen and (max-width: 320px) {
div.widget {
max-width: 320px;
}
}
@media only screen and (min-width: 1250px) {
#widgets-left #available-widgets .widget {
width: 49%;
float: right;
}
.widget.ui-draggable-dragging {
min-width: 49%;
}
#widgets-left #available-widgets .widget:nth-child(even) {
float: left;
}
#widgets-right .sidebars-column-1,
#widgets-right .sidebars-column-2 {
float: right;
width: 49%;
}
#widgets-right .sidebars-column-1 {
margin-left: 2%;
}
#widgets-right.single-sidebar .sidebars-column-1,
#widgets-right.single-sidebar .sidebars-column-2 {
float: none;
width: 100%;
margin: 0;
}
}
| 01-wordpress-paypal | trunk/wp-admin/css/widgets-rtl.css | CSS | gpl3 | 10,380 |
/*------------------------------------------------------------------------------
14.0 - Media Screen
------------------------------------------------------------------------------*/
.media-item .describe {
border-collapse: collapse;
width: 100%;
border-top: 1px solid #dfdfdf;
clear: both;
cursor: default;
}
.media-item.media-blank .describe {
border: 0;
}
.media-item .describe th {
vertical-align: top;
text-align: right;
padding: 5px 10px 10px;
width: 140px;
}
.media-item .describe .align th {
padding-top: 0;
}
.media-item .media-item-info tr {
background-color: transparent;
}
.media-item .describe td {
padding: 0 0 8px 8px;
vertical-align: top;
}
.media-item thead.media-item-info td {
padding: 4px 10px 0;
}
.media-item .media-item-info .A1B1 {
padding: 0 10px 0 0;
}
.media-item td.savesend {
padding-bottom: 15px;
}
.media-item .thumbnail {
max-height: 128px;
max-width: 128px;
}
#wpbody-content #async-upload-wrap a {
display: none;
}
.media-upload-form {
margin-top: 20px;
}
.media-upload-form td label {
margin-left: 6px;
margin-right: 2px;
}
.media-upload-form .align .field label {
display: inline;
padding: 0 23px 0 0;
margin: 0 3px 0 1em;
font-weight: 600;
}
.media-upload-form tr.image-size label {
margin: 0 5px 0 0;
font-weight: 600;
}
.media-upload-form th.label label {
font-weight: 600;
margin: 0.5em;
font-size: 13px;
}
.media-upload-form th.label label span {
padding: 0 5px;
}
.media-item .describe input[type="text"],
.media-item .describe textarea {
width: 460px;
}
.media-item .describe p.help {
margin: 0;
padding: 0 5px 0 0;
}
.media-item .edit-attachment,
.describe-toggle-on,
.describe-toggle-off {
display: block;
line-height: 36px;
float: left;
}
.media-item .describe-toggle-off,
.media-item.open .describe-toggle-on {
display: none;
}
.media-item.open .describe-toggle-off {
display: block;
}
#media-items .media-item {
border-bottom: 1px solid #dfdfdf;
min-height: 36px;
position: relative;
width: 100%;
}
#media-items {
width: 623px;
}
.media-new-php #media-items {
margin: 1em 0;
}
#media-items:empty {
border: 0 none;
}
.media-item .filename {
line-height: 36px;
overflow: hidden;
}
.media-item .error-div {
padding-right: 10px;
}
.media-item .pinkynail {
float: right;
margin: 2px 0 0 10px;
max-width: 40px;
max-height: 32px;
}
.media-item .startopen,
.media-item .startclosed {
display: none;
}
.media-item .original {
position: relative;
height: 34px;
}
.media-item .progress {
float: left;
height: 22px;
margin: 7px 0 0;
width: 200px;
line-height: 2em;
padding: 0;
overflow: hidden;
margin-bottom: 2px;
-webkit-border-radius: 22px;
border-radius: 22px;
background: #ddd;
-webkit-box-shadow: inset 0px 1px 2px rgba(0,0,0,0.1);
box-shadow: inset 0px 1px 2px rgba(0,0,0,0.1);
}
.media-item .bar {
z-index: 9;
width: 0;
height: 100%;
margin-top: -22px;
-webkit-border-radius: 22px;
border-radius: 22px;
background-color: #0074a2;
-webkit-box-shadow: inset 0 0 2px rgba(0,0,0,0.3);
box-shadow: inset 0 0 2px rgba(0,0,0,0.3);
}
.media-item .progress .percent {
z-index: 10;
position: relative;
width: 200px;
padding: 0;
color: #fff;
text-align: center;
line-height: 22px;
font-weight: 400;
text-shadow: 0px 1px 2px rgba(0,0,0,0.2);
}
.upload-php .fixed .column-parent {
width: 15%;
}
.js .html-uploader #plupload-upload-ui {
display: none;
}
.js .html-uploader #html-upload-ui {
display: block;
}
.media-upload-form .media-item.error {
margin: 0;
padding: 0;
}
.media-upload-form .media-item.error p,
.media-item .error-div {
line-height: 16px;
margin: 5px 10px;
padding: 0;
}
.media-item .error-div a.dismiss {
display: block;
float: left;
margin: 5px 15px 0 4px;
}
/*------------------------------------------------------------------------------
14.1 - Media Library
------------------------------------------------------------------------------*/
.find-box {
background-color: #fff;
-webkit-box-shadow: 0 3px 6px rgba( 0, 0, 0, 0.3 );
box-shadow: 0 3px 6px rgba( 0, 0, 0, 0.3 );
width: 600px;
overflow: hidden;
margin-right: -300px;
position: fixed;
top: 30px;
bottom: 30px;
right: 50%;
z-index: 100105;
}
.find-box-head {
background: #fcfcfc;
border-bottom: 1px solid #dfdfdf;
height: 36px;
font-size: 18px;
font-weight: 600;
line-height: 36px;
padding: 0 16px 0 36px;
position: absolute;
top: 0;
right: 0;
left: 0;
}
.find-box-inside {
overflow: auto;
padding: 16px;
background-color: #fff;
position: absolute;
top: 37px;
bottom: 45px;
overflow-y: scroll;
width: 100%;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.find-box-search {
padding-bottom: 16px;
}
.find-box-search .spinner {
float: none;
right: 125px;
position: absolute;
top: 18px;
}
#find-posts-input,
#find-posts-search {
float: right;
}
#find-posts-input {
width: 140px;
height: 28px;
margin: 0 0 0 4px;
}
.widefat .found-radio {
padding-left: 0;
width: 16px;
}
#find-posts-close {
width: 36px;
height: 36px;
position: absolute;
top: 0;
left: 0;
cursor: pointer;
text-align: center;
color: #666;
}
#find-posts-close:hover {
color: #2ea2cc;
}
#find-posts-close:before {
font: normal 20px/36px 'dashicons';
vertical-align: top;
speak: none;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
content: '\f158';
}
.find-box-buttons {
padding: 8px 16px;
background: #fcfcfc;
border-top: 1px solid #dfdfdf;
position: absolute;
bottom: 0;
right: 0;
left: 0;
}
@media screen and ( max-width: 782px ) {
.find-box-inside {
bottom: 57px;
}
}
@media screen and ( max-width: 660px ) {
.find-box {
top: 0;
bottom: 0;
right: 0;
left: 0;
margin: 0;
width: 100%;
}
}
.ui-find-overlay {
position: fixed;
top: 0;
right: 0;
left: 0;
bottom: 0;
background: #000;
opacity: 0.7;
filter: alpha(opacity=70);
z-index: 100100;
}
ul#dismissed-updates {
display: none;
}
form.upgrade {
margin-top: 8px;
}
form.upgrade .hint {
font-style: italic;
font-size: 85%;
margin: -0.5em 0 2em 0;
}
#poststuff .inside .the-tagcloud {
margin: 5px 0 10px;
padding: 8px;
border: 1px solid #ddd;
line-height: 1.8em;
word-spacing: 3px;
-webkit-border-radius: 6px;
border-radius: 6px;
}
.drag-drop #drag-drop-area {
border: 4px dashed #bbb;
height: 200px;
}
.drag-drop .drag-drop-inside {
margin: 70px auto 0;
width: 250px;
}
.drag-drop-inside p {
color: #aaa;
font-size: 14px;
margin: 5px 0;
display: none;
}
.drag-drop .drag-drop-inside p {
text-align: center;
}
.drag-drop-inside p.drag-drop-info {
font-size: 20px;
}
.drag-drop .drag-drop-inside p,
.drag-drop-inside p.drag-drop-buttons {
display: block;
}
/*
#drag-drop-area:-moz-drag-over {
border-color: #83b4d8;
}
border color while dragging a file over the uploader drop area */
.drag-drop.drag-over #drag-drop-area {
border-color: #83b4d8;
}
#plupload-upload-ui {
position: relative;
}
/*------------------------------------------------------------------------------
14.2 - Image Editor
------------------------------------------------------------------------------*/
.wp_attachment_details label[for="content"] {
font-size: 13px;
line-height: 1.5;
margin: 1em 0;
}
.wp_attachment_details #attachment_caption {
height: 4em;
}
.describe .image-editor {
vertical-align: top;
}
.imgedit-wrap {
position: relative;
}
.imgedit-settings p {
margin: 8px 0 0;
}
.describe .imgedit-wrap .imgedit-settings {
padding: 0 5px;
}
.wp_attachment_holder div.updated {
margin-top: 0;
}
.wp_attachment_holder .imgedit-wrap > div {
height: auto;
overflow: hidden;
}
.wp_attachment_holder .imgedit-wrap .imgedit-panel-content {
padding-left: 16px;
width: auto;
overflow: hidden;
}
.wp_attachment_holder .imgedit-wrap .imgedit-settings {
float: left;
width: 250px;
}
.imgedit-settings input {
margin-top: 0;
vertical-align: middle;
}
.imgedit-wait {
position: absolute;
top: 0;
background: #fff url(../images/spinner.gif) no-repeat center;
-webkit-background-size: 20px 20px;
background-size: 20px 20px;
opacity: 0.7;
filter: alpha(opacity=70);
width: 100%;
height: 500px;
display: none;
}
.no-float {
float: none;
}
.media-disabled,
.imgedit-settings .disabled {
color: grey;
}
.wp_attachment_image,
.A1B1 {
overflow: hidden;
}
.wp_attachment_image .button,
.A1B1 .button {
float: right;
}
.no-js .wp_attachment_image .button {
display: none;
}
.wp_attachment_image .spinner,
.A1B1 .spinner {
float: right;
padding: 0 0 4px 0;
vertical-align: bottom;
}
.imgedit-menu {
margin: 0 0 12px;
min-width: 300px;
}
.imgedit-menu div {
float: right;
width: 32px;
border: 1px solid #d5d5d5;
background: #f1f1f1;
margin: 0 0 0 8px;
height: 32px;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
line-height: 28px;
color: #777;
cursor: pointer;
}
.imgedit-menu div:before {
font: normal 20px/1 'dashicons';
speak: none;
vertical-align: middle;
}
.imgedit-menu div:hover {
border-color: #c1c1c1;
background-color: #eaeaea;
color: #333;
}
.imgedit-menu div.disabled {
border-color: #ccc;
background-color: #ddd;
color: #777;
filter: alpha(opacity=50);
opacity: 0.5;
cursor: default;
}
.imgedit-crop:before {
content:'\f165';
}
.imgedit-rleft:before {
content:'\f166';
}
.imgedit-rright:before {
content:'\f167';
}
.imgedit-flipv:before {
content:'\f168';
}
.imgedit-fliph:before {
content:'\f169';
}
.imgedit-undo:before {
content:'\f171';
}
.imgedit-redo:before {
content:'\f172';
}
.imgedit-crop-wrap {
position: relative;
}
.imgedit-crop {
margin: 0 0 0 8px;
}
.imgedit-rleft {
margin: 0 3px;
}
.imgedit-rright {
margin: 0 3px 0 8px;
}
.imgedit-flipv {
margin: 0 3px;
}
.imgedit-fliph {
margin: 0 3px 0 8px;
}
.imgedit-undo {
margin: 0 3px;
}
.imgedit-redo {
margin: 0 3px 0 8px;
}
.imgedit-applyto img {
margin: 0 0 0 8px;
}
.imgedit-group-top {
margin: 5px 0;
}
#poststuff .imgedit-group-top h3 {
padding: 0;
}
.imgedit-group-top h3 a {
text-decoration: none;
}
.imgedit-applyto .imgedit-label {
padding: 2px 0 0;
display: block;
}
.imgedit-help {
display: none;
font-style: italic;
}
a.imgedit-help-toggle {
text-decoration: none;
}
.form-table td.imgedit-response {
padding: 0;
}
.imgedit-submit {
margin: 8px 0;
}
.imgedit-submit-btn {
margin-right: 20px;
}
.imgedit-wrap .nowrap {
white-space: nowrap;
}
span.imgedit-scale-warn {
color: red;
font-size: 20px;
font-style: normal;
visibility: hidden;
vertical-align: middle;
}
.imgedit-group {
margin-bottom: 8px;
padding: 2px 10px;
}
audio, video {
display: inline-block;
max-width: 100%;
}
.mejs-container {
width: 100%;
}
/* =Media Queries
-------------------------------------------------------------- */
/**
* HiDPI Displays
*/
@media print,
(-o-min-device-pixel-ratio: 5/4),
(-webkit-min-device-pixel-ratio: 1.25),
(min-resolution: 120dpi) {
.imgedit-wait {
background-image: url(../images/spinner-2x.gif);
}
}
@media screen and ( max-width: 782px ) {
.wp_attachment_details label[for="content"] {
font-size: 14px;
line-height: 1.5em;
}
}
| 01-wordpress-paypal | trunk/wp-admin/css/media-rtl.css | CSS | gpl3 | 11,172 |
/*------------------------------------------------------------------------------
27.0 - Localization
------------------------------------------------------------------------------*/
/* RTL except Hebrew (see below): Tahoma as the first font; */
body.rtl,
body.rtl .press-this a.wp-switch-editor {
font-family: Tahoma, Arial, sans-serif;
}
/* he_IL: Remove Tahoma from the font stack. Arial is best for Hebrew. */
body.locale-he-il,
body.locale-he-il .press-this a.wp-switch-editor {
font-family: Arial, sans-serif;
}
/* he_IL: Have <em> be bold rather than italic. */
.locale-he-il em {
font-style: normal;
font-weight: bold;
}
/* zh_CN: Remove italic properties. */
.locale-zh-cn .howto,
.locale-zh-cn .tablenav .displaying-num,
.locale-zh-cn .js .input-with-default-title,
.locale-zh-cn .link-to-original,
.locale-zh-cn .inline-edit-row fieldset span.title,
.locale-zh-cn .inline-edit-row fieldset span.checkbox-title,
.locale-zh-cn #utc-time,
.locale-zh-cn #local-time,
.locale-zh-cn p.install-help,
.locale-zh-cn p.help,
.locale-zh-cn p.description,
.locale-zh-cn span.description,
.locale-zh-cn .form-wrap p {
font-style: normal;
}
/* zh_CN: Enlarge dashboard widget 'Configure' link */
.locale-zh-cn .hdnle a { font-size: 12px; }
/* zn_CH: Enlarge font size, set font-size: normal */
.locale-zh-cn form.upgrade .hint { font-style: normal; font-size: 100%; }
/* Zn_CH: Distraction free writing.
* More beautiful font for "Just write."
* Larger text for HTML/Visual mode.
*/
.locale-zh-cn #wp-fullscreen-tagline { font-family: KaiTi, "楷体", sans-serif; }
.locale-zh-cn #wp-fullscreen-modes a { font-size: 12px; }
/* zh_CN: Enlarge font-size. */
.locale-zh-cn #sort-buttons { font-size: 1em !important; }
/* de_DE: Text needs more space for translation */
.locale-de-de .inline-edit-row fieldset label span.title {
width: 7em; /* default 5em */
}
.locale-de-de .inline-edit-row fieldset label span.input-text-wrap {
margin-left: 7em; /* default 5em */
}
.locale-de-de #customize-header-actions .button {
padding: 0 5px 1px; /* default 0 10px 1px */
}
.locale-de-de #customize-header-actions .spinner {
margin: 16px 3px 0; /* default 16px 4px 0 5px */
}
/* ru_RU: Text needs more room to breathe. */
.locale-ru-ru .inline-edit-row fieldset label span.title {
width: 8em; /* default 5em */
}
.locale-ru-ru .inline-edit-row fieldset label span.input-text-wrap {
margin-left: 8em; /* default 5em */
}
.locale-ru-ru.post-php .tagsdiv .newtag {
width: 165px; /* default 180px - 15px */
}
.locale-ru-ru.press-this .posting {
margin-right: 277px; /* default 252px + 25px */
}
.locale-ru-ru .press-this-sidebar {
width: 265px; /* default 240px + 25px */
}
.locale-ru-ru #customize-header-actions .button {
padding: 0 5px 1px; /* default 0 10px 1px */
}
.locale-ru-ru #customize-header-actions .spinner {
margin: 16px 3px 0; /* default 16px 4px 0 5px */
}
/* lt_LT: QuickEdit */
.locale-lt-lt .inline-edit-row fieldset label span.title {
width: 8em;
}
.locale-lt-lt .inline-edit-row fieldset label span.input-text-wrap {
margin-left: 8em;
}
| 01-wordpress-paypal | trunk/wp-admin/css/l10n.css | CSS | gpl3 | 3,074 |
.press-this #message {
border-right: 4px solid #7ad03a;
padding: 1px 12px;
background-color: #fff;
-webkit-box-shadow: 0 1px 1px 0 rgba(0,0,0,0.1);
box-shadow: 0 1px 1px 0 rgba(0,0,0,0.1);
}
.press-this #side-sortables .category-tabs li {
display: inline;
line-height: 1.35em;
}
body.press-this ul.category-tabs li.tabs a {
color: #333;
}
.press-this #content-resize-handle {
bottom: 2px;
}
body.press-this {
color: #333;
margin: 0;
padding: 0;
min-width: 708px;
min-height: 400px;
}
.press-this #titlediv #title {
font-size: 1.4em;
}
.press-this #site-heading:before {
top: 3px;
position: relative;
display: inline-block;
font: normal 18px/1 'dashicons';
speak: none;
color: #727272;
content: '\f120';
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.press-this #wphead {
height: 32px;
margin-right: 0;
margin-left: 0;
margin-bottom: 5px;
}
.press-this #header-logo {
float: right;
margin: 7px 7px 0;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.press-this #wphead h1 {
font-weight: normal;
font-size: 16px;
line-height: 32px;
margin: 0;
float: right;
}
.press-this #wphead h1 a {
text-decoration: none;
}
.press-this #wphead h1 a:hover {
text-decoration: underline;
}
.press-this #message {
margin: 10px 0;
}
.press-this .posting {
margin-left: 250px;
}
.press-this-sidebar {
float: left;
width: 240px;
padding-top: 10px;
}
.press-this #title {
margin-right: 0;
margin-left: 0;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.press-this .tagchecklist {
margin-top: 8px;
}
.press-this #titlediv {
margin: 0;
}
.press-this #wp-content-wrap #wp-content-editor-tools {
padding: 0;
top: 3px;
overflow: hidden;
}
.press-this .wp-media-buttons {
cursor: default;
padding: 8px 8px 6px;
}
.press-this #wp-content-wrap #wp-content-media-buttons a {
padding: 0;
line-height: normal;
height: auto;
font-size: 16px;
}
.press-this #wp-content-wrap .mce-toolbar .mce-btn-group .mce-btn {
margin: 0 1px;
}
.press-this #wp-content-wrap .mce-toolbar .mce-btn button {
padding: 2px 3px;
}
.press-this #wp-content-wrap div.mce-toolbar-grp,
.press-this #wp-content-wrap .quicktags-toolbar {
padding-left: 3px;
}
.press-this .howto {
margin-top: 2px;
margin-bottom: 3px;
font-size: 12px;
font-style: italic;
display: block;
}
.press-this #wp-content-editor-container {
clear: none;
}
.press-this #poststuff .inside {
margin-top: 18px;
}
.press-this .category-tabs {
margin-bottom: 3px;
}
/* Editor/Main Column */
.press-this #poststuff {
margin: 0 8px;
padding: 0;
}
.press-this #photo-add-url-div input[type="text"] {
width: 220px;
}
#poststuff #editor-toolbar {
height: 30px;
}
.posting {
margin-left: 212px;
position: relative;
}
.press-this .inner-sidebar {
width: 200px;
}
.press-this .inner-sidebar .sleeve {
padding-top: 5px;
}
.press-this #submitdiv p {
margin: 0;
padding: 6px;
}
.press-this #submitdiv #publishing-actions {
border-bottom: 1px solid #dfdfdf;
}
.press-this #publish {
float: left;
}
.press-this #poststuff h2,
.press-this #poststuff h3 {
font-size: 14px;
line-height: 1;
}
.press-this #tagsdiv-post_tag h3,
.press-this #categorydiv h3 {
cursor: pointer;
}
.press-this #submitdiv h3 {
cursor: default;
}
h3.tb {
font-weight: 600;
font-size: 12px;
margin-right: 5px;
}
.press-this .postbox,
.press-this .stuffbox {
margin-bottom: 10px;
min-width: 0;
}
.press-this #submitdiv:hover .handlediv {
background: none;
}
.tbtitle {
font-size: 1.7em;
outline: none;
padding: 3px 4px;
border: 1px solid #dfdfdf;
}
.press-this .actions {
float: left;
margin: -19px 0 0;
}
.press-this #extra-fields .actions {
margin: -32px 0 0 -7px;
}
.press-this .actions li {
float: right;
list-style: none;
margin-left: 10px;
}
#extra-fields .button {
margin-left: 5px;
}
/* Photo Styles */
#photo_saving {
margin: 0 8px 8px;
vertical-align: middle;
}
#img_container_container {
overflow: auto;
}
#extra-fields {
margin-top: 10px;
position: relative;
}
#extra-fields h2 {
margin: 12px;
}
#waiting {
margin-top: 10px;
overflow: hidden;
}
#waiting span {
float: left;
margin: 0 5px 0 0;
}
#waiting .spinner {
display: block;
}
#extra-fields .postbox {
margin-bottom: 5px;
}
#extra-fields .titlewrap {
padding: 0;
overflow: auto;
height: 120px;
}
#img_container a {
display: block;
float: right;
overflow: hidden;
}
#img_container img,
#img_container a {
width: 68px;
height: 68px;
}
#img_container img {
border: none;
background-color: #f4f4f4;
cursor: pointer;
}
#img_container a,
#img_container a:link,
#img_container a:visited {
border: 1px solid #ccc;
display: block;
position: relative;
}
#img_container a:hover,
#img_container a:active {
border-color: #000;
z-index: 1000;
border-width: 1px;
}
/* Video */
#embed-code {
width: 100%;
height: 98px;
}
/* Categories */
.press-this .categorydiv div.tabs-panel {
height: 100px;
}
/* Tags */
.press-this .tagsdiv .newtag {
width: 120px;
}
.press-this #content {
margin: 5px 0;
padding: 0 5px;
border: 0 none;
height: 340px;
font-family: Consolas, Monaco, monospace;
font-size: 13px;
line-height: 19px;
background: transparent;
}
/* Submit */
.press-this #publishing-actions .spinner {
display: inline;
vertical-align: middle;
}
/* =Media Queries
-------------------------------------------------------------- */
/* Reset responsive styles in Press This */
@media screen and ( max-width: 782px ) {
.press-this ul.category-tabs li.tabs {
padding: 3px 5px 5px; /* Reset tabs in Press This to standard size */
}
.press-this a.wp-switch-editor {
font: 13px/19px "Open Sans", sans-serif;
margin: 5px 5px 0 0;
padding: 3px 8px 4px;
}
.press-this #wp-content-media-buttons a {
padding: 0;
line-height: normal;
height: auto;
}
.press-this #wp-content-editor-tools {
padding: 0;
top: 3px;
}
.press-this .category-tabs {
margin-top: 0;
}
.press-this .tagsdiv .newtag {
width: 120px;
padding: 3px 5px;
margin-bottom: 0;
}
.press-this .tagchecklist {
padding: 0;
margin-bottom: 0;
}
.press-this .wp_themeSkin a.mceButton {
width: 20px;
height: 20px;
}
.press-this .wp_themeSkin .mceButton .mceIcon {
margin: 0;
}
.press-this #poststuff h3,
.press-this .metabox-holder h3 {
padding: 7px 12px;
}
.press-this input[type=checkbox],
.press-this input[type=radio] {
height: 16px;
width: 16px;
}
.press-this input[type=checkbox]:checked:before {
width: 16px;
font: normal 21px/1 'dashicons';
margin: -3px -4px 0 0;
}
.press-this input[type=radio]:checked:before {
font: normal 21px/1 'dashicons';
width: 6px;
height: 6px;
margin: 4px;
}
.press-this ul.categorychecklist ul,
.press-this ul.categorychecklist li {
margin-top: 0;
margin-bottom: 0;
}
.press-this div.quicktags-toolbar input {
padding: 2px 4px;
}
.press-this textarea,
.press-this input {
font-size: 14px;
}
.press-this .tagchecklist span {
font-size: 13px;
line-height: 1.8em;
}
}
| 01-wordpress-paypal | trunk/wp-admin/css/press-this-rtl.css | CSS | gpl3 | 7,135 |
/* Styles for the media library iframe (not used on the Library screen) */
div#media-upload-header {
margin: 0;
padding: 5px 5px 0;
font-weight: bold;
position: relative;
border-bottom: 1px solid #dfdfdf;
background: #f9f9f9;
}
body#media-upload ul#sidemenu {
font-weight: normal;
margin: 0 5px;
left: 0;
bottom: -1px;
float: none;
overflow: hidden;
}
#media-upload:after { /* clearfix */
content: "";
display: table;
clear: both;
}
#media-upload,
#media-upload .media-item .slidetoggle {
background: #fff;
}
#media-upload .slidetoggle {
border-top-color: #dfdfdf;
}
#media-upload input[type="radio"] {
padding: 0;
}
form {
margin: 1em;
}
#search-filter {
text-align: right;
}
th {
position: relative;
}
.media-upload-form label.form-help, td.help {
font-family: sans-serif;
font-style: italic;
font-weight: normal;
}
.media-upload-form p.help {
margin: 0;
padding: 0;
}
.media-upload-form fieldset {
width: 100%;
border: none;
text-align: justify;
margin: 0 0 1em 0;
padding: 0;
}
/* specific to the image upload form */
.image-align-none-label {
background: url(../images/align-none.png) no-repeat center left;
}
.image-align-left-label {
background: url(../images/align-left.png) no-repeat center left;
}
.image-align-center-label {
background: url(../images/align-center.png) no-repeat center left;
}
.image-align-right-label {
background: url(../images/align-right.png) no-repeat center left;
}
tr.image-size td {
width: 460px;
}
tr.image-size div.image-size-item {
margin: 0 0 5px;
}
#library-form .progress,
#gallery-form .progress,
.insert-gallery,
.describe.startopen,
.describe.startclosed {
display: none;
}
.media-item .thumbnail {
max-width: 128px;
max-height: 128px;
}
thead.media-item-info tr {
background-color: transparent;
}
.form-table thead.media-item-info {
border: 8px solid #fff;
}
abbr.required {
text-decoration: none;
border: none;
}
.describe label {
display: inline;
}
.describe td.error {
padding: 2px 8px;
}
.describe td.A1 {
width: 132px;
}
.describe input[type="text"],
.describe textarea {
width: 460px;
border-width: 1px;
border-style: solid;
}
/* Specific to Uploader */
#media-upload p.ml-submit {
padding: 1em 0;
}
#media-upload p.help,
#media-upload label.help {
font-family: sans-serif;
font-style: italic;
font-weight: normal;
}
#media-upload .ui-sortable .media-item {
cursor: move;
}
#media-upload tr.image-size {
margin-bottom: 1em;
height: 3em;
}
#media-upload #filter {
width: 623px;
}
#media-upload #filter .subsubsub {
margin: 8px 0;
}
#filter .tablenav select {
border-style: solid;
border-width: 1px;
padding: 2px;
vertical-align: top;
width: auto;
}
#media-upload .del-attachment {
display: none;
margin: 5px 0;
}
.menu_order {
float: right;
font-size: 11px;
margin: 10px 10px 0;
}
.menu_order_input {
border: 1px solid #ddd;
font-size: 10px;
padding: 1px;
width: 23px;
}
.ui-sortable-helper {
background-color: #fff;
border: 1px solid #aaa;
opacity: 0.6;
filter: alpha(opacity=60);
}
#media-upload th.order-head {
width: 20%;
text-align: center;
}
#media-upload th.actions-head {
width: 25%;
text-align: center;
}
#media-upload a.wp-post-thumbnail {
margin: 0 20px;
}
#media-upload .widefat {
width: 626px;
border-style: solid solid none;
}
.sorthelper {
height: 37px;
width: 623px;
display: block;
}
#gallery-settings th.label {
width: 160px;
}
#gallery-settings #basic th.label {
padding: 5px 5px 5px 0;
}
#gallery-settings .title {
clear: both;
padding: 0 0 3px;
font-size: 1.6em;
border-bottom: 1px solid #DADADA;
}
h3.media-title {
font-size: 1.6em;
}
h4.media-sub-title {
border-bottom: 1px solid #DADADA;
font-size: 1.3em;
margin: 12px;
padding: 0 0 3px;
}
#gallery-settings .title,
h3.media-title,
h4.media-sub-title {
font-family: Georgia,"Times New Roman",Times,serif;
font-weight: normal;
color: #5A5A5A;
}
#gallery-settings .describe td {
vertical-align: middle;
height: 3em;
}
#gallery-settings .describe th.label {
padding-top: .5em;
text-align: left;
}
#gallery-settings .describe {
padding: 5px;
width: 615px;
clear: both;
cursor: default;
}
#gallery-settings .describe select {
width: 15em;
}
#gallery-settings .describe select option,
#gallery-settings .describe td {
padding: 0;
}
#gallery-settings label,
#gallery-settings legend {
font-size: 13px;
color: #464646;
margin-right: 15px;
}
#gallery-settings .align .field label {
margin: 0 1em 0 3px;
}
#gallery-settings p.ml-submit {
border-top: 1px solid #dfdfdf;
}
#gallery-settings select#columns {
width: 6em;
}
#sort-buttons {
font-size: 0.8em;
margin: 3px 25px -8px 0;
text-align: right;
max-width: 625px;
}
#sort-buttons a {
text-decoration: none;
}
#sort-buttons #asc,
#sort-buttons #showall {
padding-left: 5px;
}
#sort-buttons span {
margin-right: 25px;
}
p.media-types {
margin: 1em;
}
tr.not-image {
display: none;
}
table.not-image tr.not-image {
display: table-row;
}
table.not-image tr.image-only {
display: none;
}
/**
* HiDPI Displays
*/
@media print,
(-o-min-device-pixel-ratio: 5/4),
(-webkit-min-device-pixel-ratio: 1.25),
(min-resolution: 120dpi) {
.image-align-none-label {
background-image: url(../images/align-none-2x.png?ver=20120916);
-webkit-background-size: 21px 15px;
background-size: 21px 15px;
}
.image-align-left-label {
background-image: url(../images/align-left-2x.png?ver=20120916);
-webkit-background-size: 22px 15px;
background-size: 22px 15px;
}
.image-align-center-label {
background-image: url(../images/align-center-2x.png?ver=20120916);
-webkit-background-size: 21px 15px;
background-size: 21px 15px;
}
.image-align-right-label {
background-image: url(../images/align-right-2x.png?ver=20120916);
-webkit-background-size: 22px 15px;
background-size: 22px 15px;
}
}
| 01-wordpress-paypal | trunk/wp-admin/css/deprecated-media.css | CSS | gpl3 | 5,868 |
.press-this #message {
border-left: 4px solid #7ad03a;
padding: 1px 12px;
background-color: #fff;
-webkit-box-shadow: 0 1px 1px 0 rgba(0,0,0,0.1);
box-shadow: 0 1px 1px 0 rgba(0,0,0,0.1);
}
.press-this #side-sortables .category-tabs li {
display: inline;
line-height: 1.35em;
}
body.press-this ul.category-tabs li.tabs a {
color: #333;
}
.press-this #content-resize-handle {
bottom: 2px;
}
body.press-this {
color: #333;
margin: 0;
padding: 0;
min-width: 708px;
min-height: 400px;
}
.press-this #titlediv #title {
font-size: 1.4em;
}
.press-this #site-heading:before {
top: 3px;
position: relative;
display: inline-block;
font: normal 18px/1 'dashicons';
speak: none;
color: #727272;
content: '\f120';
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.press-this #wphead {
height: 32px;
margin-left: 0;
margin-right: 0;
margin-bottom: 5px;
}
.press-this #header-logo {
float: left;
margin: 7px 7px 0;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.press-this #wphead h1 {
font-weight: normal;
font-size: 16px;
line-height: 32px;
margin: 0;
float: left;
}
.press-this #wphead h1 a {
text-decoration: none;
}
.press-this #wphead h1 a:hover {
text-decoration: underline;
}
.press-this #message {
margin: 10px 0;
}
.press-this .posting {
margin-right: 250px;
}
.press-this-sidebar {
float: right;
width: 240px;
padding-top: 10px;
}
.press-this #title {
margin-left: 0;
margin-right: 0;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.press-this .tagchecklist {
margin-top: 8px;
}
.press-this #titlediv {
margin: 0;
}
.press-this #wp-content-wrap #wp-content-editor-tools {
padding: 0;
top: 3px;
overflow: hidden;
}
.press-this .wp-media-buttons {
cursor: default;
padding: 8px 8px 6px;
}
.press-this #wp-content-wrap #wp-content-media-buttons a {
padding: 0;
line-height: normal;
height: auto;
font-size: 16px;
}
.press-this #wp-content-wrap .mce-toolbar .mce-btn-group .mce-btn {
margin: 0 1px;
}
.press-this #wp-content-wrap .mce-toolbar .mce-btn button {
padding: 2px 3px;
}
.press-this #wp-content-wrap div.mce-toolbar-grp,
.press-this #wp-content-wrap .quicktags-toolbar {
padding-right: 3px;
}
.press-this .howto {
margin-top: 2px;
margin-bottom: 3px;
font-size: 12px;
font-style: italic;
display: block;
}
.press-this #wp-content-editor-container {
clear: none;
}
.press-this #poststuff .inside {
margin-top: 18px;
}
.press-this .category-tabs {
margin-bottom: 3px;
}
/* Editor/Main Column */
.press-this #poststuff {
margin: 0 8px;
padding: 0;
}
.press-this #photo-add-url-div input[type="text"] {
width: 220px;
}
#poststuff #editor-toolbar {
height: 30px;
}
.posting {
margin-right: 212px;
position: relative;
}
.press-this .inner-sidebar {
width: 200px;
}
.press-this .inner-sidebar .sleeve {
padding-top: 5px;
}
.press-this #submitdiv p {
margin: 0;
padding: 6px;
}
.press-this #submitdiv #publishing-actions {
border-bottom: 1px solid #dfdfdf;
}
.press-this #publish {
float: right;
}
.press-this #poststuff h2,
.press-this #poststuff h3 {
font-size: 14px;
line-height: 1;
}
.press-this #tagsdiv-post_tag h3,
.press-this #categorydiv h3 {
cursor: pointer;
}
.press-this #submitdiv h3 {
cursor: default;
}
h3.tb {
font-weight: 600;
font-size: 12px;
margin-left: 5px;
}
.press-this .postbox,
.press-this .stuffbox {
margin-bottom: 10px;
min-width: 0;
}
.press-this #submitdiv:hover .handlediv {
background: none;
}
.tbtitle {
font-size: 1.7em;
outline: none;
padding: 3px 4px;
border: 1px solid #dfdfdf;
}
.press-this .actions {
float: right;
margin: -19px 0 0;
}
.press-this #extra-fields .actions {
margin: -32px -7px 0 0;
}
.press-this .actions li {
float: left;
list-style: none;
margin-right: 10px;
}
#extra-fields .button {
margin-right: 5px;
}
/* Photo Styles */
#photo_saving {
margin: 0 8px 8px;
vertical-align: middle;
}
#img_container_container {
overflow: auto;
}
#extra-fields {
margin-top: 10px;
position: relative;
}
#extra-fields h2 {
margin: 12px;
}
#waiting {
margin-top: 10px;
overflow: hidden;
}
#waiting span {
float: right;
margin: 0 0 0 5px;
}
#waiting .spinner {
display: block;
}
#extra-fields .postbox {
margin-bottom: 5px;
}
#extra-fields .titlewrap {
padding: 0;
overflow: auto;
height: 120px;
}
#img_container a {
display: block;
float: left;
overflow: hidden;
}
#img_container img,
#img_container a {
width: 68px;
height: 68px;
}
#img_container img {
border: none;
background-color: #f4f4f4;
cursor: pointer;
}
#img_container a,
#img_container a:link,
#img_container a:visited {
border: 1px solid #ccc;
display: block;
position: relative;
}
#img_container a:hover,
#img_container a:active {
border-color: #000;
z-index: 1000;
border-width: 1px;
}
/* Video */
#embed-code {
width: 100%;
height: 98px;
}
/* Categories */
.press-this .categorydiv div.tabs-panel {
height: 100px;
}
/* Tags */
.press-this .tagsdiv .newtag {
width: 120px;
}
.press-this #content {
margin: 5px 0;
padding: 0 5px;
border: 0 none;
height: 340px;
font-family: Consolas, Monaco, monospace;
font-size: 13px;
line-height: 19px;
background: transparent;
}
/* Submit */
.press-this #publishing-actions .spinner {
display: inline;
vertical-align: middle;
}
/* =Media Queries
-------------------------------------------------------------- */
/* Reset responsive styles in Press This */
@media screen and ( max-width: 782px ) {
.press-this ul.category-tabs li.tabs {
padding: 3px 5px 5px; /* Reset tabs in Press This to standard size */
}
.press-this a.wp-switch-editor {
font: 13px/19px "Open Sans", sans-serif;
margin: 5px 0 0 5px;
padding: 3px 8px 4px;
}
.press-this #wp-content-media-buttons a {
padding: 0;
line-height: normal;
height: auto;
}
.press-this #wp-content-editor-tools {
padding: 0;
top: 3px;
}
.press-this .category-tabs {
margin-top: 0;
}
.press-this .tagsdiv .newtag {
width: 120px;
padding: 3px 5px;
margin-bottom: 0;
}
.press-this .tagchecklist {
padding: 0;
margin-bottom: 0;
}
.press-this .wp_themeSkin a.mceButton {
width: 20px;
height: 20px;
}
.press-this .wp_themeSkin .mceButton .mceIcon {
margin: 0;
}
.press-this #poststuff h3,
.press-this .metabox-holder h3 {
padding: 7px 12px;
}
.press-this input[type=checkbox],
.press-this input[type=radio] {
height: 16px;
width: 16px;
}
.press-this input[type=checkbox]:checked:before {
width: 16px;
font: normal 21px/1 'dashicons';
margin: -3px 0 0 -4px;
}
.press-this input[type=radio]:checked:before {
font: normal 21px/1 'dashicons';
width: 6px;
height: 6px;
margin: 4px;
}
.press-this ul.categorychecklist ul,
.press-this ul.categorychecklist li {
margin-top: 0;
margin-bottom: 0;
}
.press-this div.quicktags-toolbar input {
padding: 2px 4px;
}
.press-this textarea,
.press-this input {
font-size: 14px;
}
.press-this .tagchecklist span {
font-size: 13px;
line-height: 1.8em;
}
}
| 01-wordpress-paypal | trunk/wp-admin/css/press-this.css | CSS | gpl3 | 7,138 |
.farbtastic {
position: relative;
}
.farbtastic * {
position: absolute;
cursor: crosshair;
}
.farbtastic,
.farbtastic .wheel {
width: 195px;
height: 195px;
}
.farbtastic .color,
.farbtastic .overlay {
top: 47px;
right: 47px;
width: 101px;
height: 101px;
}
.farbtastic .wheel {
background: url(../images/wheel.png) no-repeat;
width: 195px;
height: 195px;
}
.farbtastic .overlay {
background: url(../images/mask.png) no-repeat;
}
.farbtastic .marker {
width: 17px;
height: 17px;
margin: -8px -8px 0 0;
overflow: hidden;
background: url(../images/marker.png) no-repeat;
}
| 01-wordpress-paypal | trunk/wp-admin/css/farbtastic-rtl.css | CSS | gpl3 | 612 |
#poststuff {
padding-top: 10px;
min-width: 763px;
}
#poststuff #post-body {
padding: 0;
}
#poststuff .postbox-container {
width: 100%;
}
#poststuff #post-body.columns-2 {
margin-right: 300px;
}
/*------------------------------------------------------------------------------
11.0 - Write/Edit Post Screen
------------------------------------------------------------------------------*/
#show-comments {
overflow: hidden;
}
#save-action .spinner,
#show-comments a,
#show-comments .spinner {
float: left;
}
#lost-connection-notice .spinner {
display: block;
float: left;
margin: 0 5px 0 0;
}
#titlediv {
position: relative;
margin-bottom: 10px;
}
#titlediv label {
cursor: text;
}
#titlediv div.inside {
margin: 0;
}
#poststuff #titlewrap {
border: 0;
padding: 0;
}
#titlediv #title {
padding: 3px 8px;
font-size: 1.7em;
line-height: 100%;
height: 1.7em;
width: 100%;
outline: none;
margin: 0;
background-color: #fff;
}
#titlediv #title-prompt-text {
color: #777;
position: absolute;
font-size: 1.7em;
padding: 11px 10px;
}
#wp-fullscreen-save .fs-saved {
color: #999;
float: right;
margin-top: 4px;
}
#poststuff .inside-submitbox,
#side-sortables .inside-submitbox {
margin: 0 3px;
font-size: 11px;
}
input#link_description,
input#link_url {
width: 98%;
}
#pending {
background: 0 none;
border: 0 none;
padding: 0;
font-size: 11px;
margin-top: -1px;
}
#edit-slug-box {
line-height: 24px;
min-height: 25px; /* Yes, line-height + 1 */
margin-top: 5px;
padding: 0 10px;
color: #666;
}
#edit-slug-box .cancel {
margin-right: 10px;
font-size: 11px;
}
#editable-post-name-full {
display: none;
}
#editable-post-name {
background-color: #fffbcc;
}
#editable-post-name input {
font-size: 13px;
height: 22px;
margin: 0;
width: 16em;
}
.postarea h3 label {
float: left;
}
.submitbox .submit {
text-align: left;
padding: 12px 10px 10px;
font-size: 11px;
background-color: #464646;
color: #ccc;
}
.submitbox .submitdelete {
text-decoration: none;
padding: 1px 2px;
}
/* @todo: do we really need this? word on the street is we don't and this
stray rule may actually be compensated for elsewhere. */
#normal-sortables .submitbox .submitdelete:hover {
color: #000;
background-color: #f00;
border-bottom-color: #f00;
}
.submitbox .submit a:hover {
text-decoration: underline;
}
.submitbox .submit input {
margin-bottom: 8px;
margin-right: 4px;
padding: 6px;
}
.inside-submitbox #post_status {
margin: 2px 0 2px -2px;
}
#post-status-select {
margin-top: 3px;
}
/* Post Screen */
#post-body #normal-sortables {
min-height: 50px;
}
.postbox {
position: relative;
min-width: 255px;
border: 1px solid #e5e5e5;
-webkit-box-shadow: 0 1px 1px rgba(0,0,0,0.04);
box-shadow: 0 1px 1px rgba(0,0,0,0.04);
background: #fff;
}
#trackback_url {
width: 99%;
}
#normal-sortables .postbox .submit {
background: transparent none;
border: 0 none;
float: right;
padding: 0 12px;
margin:0;
}
.category-add input[type="text"],
.category-add select {
width: 100%;
max-width: 260px;
vertical-align: baseline;
}
#side-sortables .category-add input[type="text"],
#side-sortables .category-add select {
margin: 0 0 1em;
}
ul.category-tabs li,
#side-sortables .add-menu-item-tabs li,
.wp-tab-bar li {
display: inline;
line-height: 1.35em;
}
.no-js .category-tabs li.hide-if-no-js {
display: none;
}
.category-tabs a,
#side-sortables .add-menu-item-tabs a,
.wp-tab-bar a {
text-decoration: none;
}
/* @todo: do these really need to be so specific? */
#side-sortables .category-tabs .tabs a,
#side-sortables .add-menu-item-tabs .tabs a,
.wp-tab-bar .wp-tab-active a,
#post-body ul.category-tabs li.tabs a,
#post-body ul.add-menu-item-tabs li.tabs a {
color: #333;
}
.category-tabs {
margin: 8px 0 5px;
}
#category-adder h4 {
margin: 10px 0;
}
#side-sortables .add-menu-item-tabs,
.wp-tab-bar {
margin-bottom: 3px;
}
#normal-sortables .postbox #replyrow .submit {
float: none;
margin: 0;
padding: 0 7px 5px;
}
#side-sortables .submitbox .submit input,
#side-sortables .submitbox .submit .preview,
#side-sortables .submitbox .submit a.preview:hover {
border: 0 none;
}
#side-sortables .inside-submitbox .insidebox,
.stuffbox .insidebox {
margin: 11px 0;
}
/* @todo: make this a more generic class */
ul.category-tabs,
ul.add-menu-item-tabs,
ul.wp-tab-bar {
margin-top: 12px;
}
ul.category-tabs li,
ul.add-menu-item-tabs li {
border: solid 1px transparent;
position: relative;
}
ul.category-tabs li.tabs,
ul.add-menu-item-tabs li.tabs,
.wp-tab-active {
border: 1px solid #dfdfdf;
border-bottom-color: #fdfdfd;
background-color: #fdfdfd;
}
ul.category-tabs li,
ul.add-menu-item-tabs li,
ul.wp-tab-bar li {
padding: 3px 5px 5px;
}
#postimagediv .inside img {
max-width: 100%;
height: auto;
}
form#tags-filter {
position: relative;
}
/* Edit posts */
td.post-title strong,
td.plugin-title strong {
display: block;
margin-bottom: .2em;
font-size: 14px;
}
td.post-title p,
td.plugin-title p {
margin: 6px 0;
}
/* Global classes */
.wp-hidden-children .wp-hidden-child,
.ui-tabs-hide {
display: none;
}
#post-body .tagsdiv #newtag {
margin-right: 5px;
width: 16em;
}
#side-sortables input#post_password {
width: 94%
}
#side-sortables .tagsdiv #newtag {
width: 68%;
}
#post-status-info {
width: 100%;
border-spacing: 0;
border: 1px solid #e5e5e5;
border-top: none;
background-color: #f7f7f7;
-webkit-box-shadow: 0 1px 1px rgba(0,0,0,0.04);
box-shadow: 0 1px 1px rgba(0,0,0,0.04);
}
#post-status-info td {
font-size: 12px;
}
.autosave-info {
padding: 2px;
text-align: right;
}
#editorcontent #post-status-info {
border: none;
}
#content-resize-handle {
background: transparent url(../images/resize.gif) no-repeat scroll right bottom;
width: 12px;
cursor: n-resize;
}
.rtl #content-resize-handle {
background: transparent url(../images/resize-rtl.gif) no-repeat scroll left bottom;
}
#wp-word-count {
display: block;
padding: 2px 10px;
}
#timestampdiv select {
height: 21px;
line-height: 14px;
padding: 0;
vertical-align: top;
font-size: 12px;
}
#aa, #jj, #hh, #mn {
padding: 1px;
font-size: 12px;
}
#jj, #hh, #mn {
width: 2em;
}
#aa {
width: 3.4em;
}
.curtime #timestamp {
padding: 2px 0 1px 0;
display: inline !important;
height: auto !important;
}
#misc-publishing-actions label[for="post_status"]:before,
#post-body #visibility:before,
.curtime #timestamp:before,
#post-body .misc-pub-revisions:before,
span.wp-media-buttons-icon:before {
color: #888;
}
#post-body #visibility:before,
.curtime #timestamp:before,
#post-body .misc-pub-revisions:before {
font: normal 20px/1 'dashicons';
speak: none;
display: inline-block;
padding: 0 2px 0 0;
top: 0;
left: -1px;
position: relative;
vertical-align: top;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-decoration: none !important;
}
#post-body #visibility:before {
content: '\f177';
}
.curtime #timestamp:before {
content: '\f145';
top: -1px;
}
#post-body .misc-pub-revisions:before {
content: '\f321';
}
#timestampdiv {
padding-top: 5px;
line-height: 23px;
}
#timestampdiv p {
margin: 8px 0 6px;
}
#timestampdiv input {
border-width: 1px;
border-style: solid;
}
.notification-dialog {
position: fixed;
top: 30%;
left: 50%;
width: 450px;
margin-left: -225px;
background: #fff;
-webkit-box-shadow: 0 3px 6px rgba( 0, 0, 0, 0.3 );
box-shadow: 0 3px 6px rgba( 0, 0, 0, 0.3 );
line-height: 1.5;
z-index: 1000005;
}
.notification-dialog-background {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: #000;
opacity: 0.7;
filter: alpha(opacity=70);
z-index: 1000000;
}
#post-lock-dialog .post-locked-message,
#post-lock-dialog .post-taken-over {
margin: 25px;
}
#post-lock-dialog .post-locked-message a.button {
margin-right: 10px;
}
#post-lock-dialog .post-locked-avatar {
float: left;
margin: 0 20px 20px 0;
}
#post-lock-dialog .wp-tab-first {
outline: 0;
}
#post-lock-dialog .locked-saving img {
float: left;
margin-right: 3px;
}
#post-lock-dialog.saving .locked-saving,
#post-lock-dialog.saved .locked-saved {
display: inline;
}
#excerpt,
.attachmentlinks {
margin: 0;
height: 4em;
width: 98%;
}
.tagchecklist {
margin-left: 14px;
font-size: 12px;
overflow: auto;
}
.tagchecklist br {
display: none;
}
.tagchecklist strong {
margin-left: -8px;
position: absolute;
}
.tagchecklist span {
margin-right: 25px;
display: block;
float: left;
font-size: 13px;
line-height: 1.8em;
white-space: nowrap;
cursor: default;
}
.tagchecklist span a {
margin: 1px 0 0 -17px;
cursor: pointer;
width: 20px;
height: 20px;
display: block;
float: left;
text-indent: 0;
overflow: hidden;
position: absolute;
}
#poststuff h2 {
margin-top: 20px;
font-size: 1.5em;
margin-bottom: 15px;
padding: 0 0 3px;
clear: left;
}
#poststuff h3 {
font-size: 14px;
padding: 8px 12px;
margin: 0;
line-height: 1.4;
}
#poststuff .inside {
margin: 6px 0 0 0;
}
#poststuff .inside #parent_id,
#poststuff .inside #page_template {
max-width: 100%;
}
#poststuff .inside label.spam,
#poststuff .inside label.deleted {
color: red;
}
#poststuff .inside label.waiting {
color: orange;
}
#poststuff .inside label.approved {
color: green;
}
.ie8 #poststuff .inside #parent_id,
.ie8 #poststuff .inside #page_template {
width: 250px;
}
#post-visibility-select {
line-height: 1.5em;
margin-top: 3px;
}
#poststuff #submitdiv .inside {
margin: 0;
padding: 0;
}
.edit-form-section {
margin-bottom: 20px;
}
/*------------------------------------------------------------------------------
11.1 - Custom Fields
------------------------------------------------------------------------------*/
#postcustomstuff thead th {
padding: 5px 8px 8px;
background-color: #f1f1f1;
}
#postcustom #postcustomstuff .submit {
border: 0 none;
float: none;
padding: 0 8px 8px;
}
#side-sortables #postcustom #postcustomstuff .submit {
margin: 0;
padding: 0;
}
#side-sortables #postcustom #postcustomstuff #the-list textarea {
height: 85px;
}
#side-sortables #postcustom #postcustomstuff td.left input,
#side-sortables #postcustom #postcustomstuff td.left select,
#side-sortables #postcustomstuff #newmetaleft a {
margin: 3px 3px 0;
}
#postcustomstuff table {
margin: 0;
width: 100%;
border: 1px solid #dfdfdf;
border-spacing: 0;
background-color: #f9f9f9;
}
#postcustomstuff tr {
vertical-align: top;
}
#postcustomstuff table input,
#postcustomstuff table select,
#postcustomstuff table textarea {
width: 96%;
margin: 8px;
}
#side-sortables #postcustomstuff table input,
#side-sortables #postcustomstuff table select,
#side-sortables #postcustomstuff table textarea {
margin: 3px;
}
#postcustomstuff th.left,
#postcustomstuff td.left {
width: 38%;
}
#postcustomstuff .submit input {
margin: 0;
width: auto;
}
#postcustomstuff #newmetaleft a {
display: inline-block;
margin: 0 8px 8px;
text-decoration: none;
}
.no-js #postcustomstuff #enternew {
display: none;
}
#post-body-content .compat-attachment-fields {
margin-bottom: 20px;
}
.compat-attachment-fields th {
padding-top: 5px;
padding-right: 10px;
}
/*------------------------------------------------------------------------------
11.3 - Featured Images
------------------------------------------------------------------------------*/
#select-featured-image {
padding: 4px 0;
overflow: hidden;
}
#select-featured-image img {
max-width: 100%;
height: auto;
margin-bottom: 10px;
}
#select-featured-image a {
float: left;
clear: both;
}
#select-featured-image .remove {
display: none;
margin-top: 10px;
}
.js #select-featured-image.has-featured-image .remove {
display: inline-block;
}
.no-js #select-featured-image .choose {
display: none;
}
/*------------------------------------------------------------------------------
11.4 - Post formats
------------------------------------------------------------------------------*/
.post-state-format {
overflow: hidden;
display: inline-block;
vertical-align: middle;
height: 20px;
width: 20px;
margin-right: 5px;
margin-top: -4px;
}
.post-state-format:before {
display: block;
height: 20px;
width: 20px;
font: normal 20px/1 'dashicons' !important;
speak: none;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.post-state-format:before,
.post-format-icon:before {
color: #ddd;
-webkit-transition: all .1s ease-in-out;
transition: all .1s ease-in-out;
}
a.post-state-format:hover:before,
a.post-format-icon:hover:before {
color: #2ea2cc;
}
#post-formats-select {
line-height: 2em;
}
#post-formats-select .post-format-icon:before {
top: 5px;
}
input.post-format {
margin-top: 1px;
}
label.post-format-icon {
margin-left: 0px;
padding: 2px 0 2px 0px;
}
.post-format-icon:before {
position: relative;
display: inline-block;
margin-right: 7px;
font: normal 20px/1 'dashicons';
speak: none;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.post-state-format.post-format-standard:before,
.post-format-icon.post-format-standard:before,
a.post-state-format.format-standard:before {
content: '\f109';
}
.post-state-format.post-format-image:before,
.post-format-icon.post-format-image:before,
a.post-state-format.format-image:before {
content: '\f128';
}
.post-state-format.post-format-gallery:before,
.post-format-icon.post-format-gallery:before,
a.post-state-format.format-gallery:before {
content: '\f161';
}
.post-state-format.post-format-audio:before,
.post-format-icon.post-format-audio:before,
a.post-state-format.format-audio:before {
content: '\f127';
}
.post-state-format.post-format-video:before,
.post-format-icon.post-format-video:before,
a.post-state-format.format-video:before {
content: '\f126';
}
.post-state-format.post-format-chat:before,
.post-format-icon.post-format-chat:before,
a.post-state-format.format-chat:before {
content: '\f125';
}
.post-state-format.post-format-status:before,
.post-format-icon.post-format-status:before,
a.post-state-format.format-status:before {
content: '\f130';
}
.post-state-format.post-format-aside:before,
.post-format-icon.post-format-aside:before,
a.post-state-format.format-aside:before {
content: '\f123';
}
.post-state-format.post-format-quote:before,
.post-format-icon.post-format-quote:before,
a.post-state-format.format-quote:before {
content: '\f122';
}
.post-state-format.post-format-link:before,
.post-format-icon.post-format-link:before,
a.post-state-format.format-link:before {
content: '\f103';
}
/*------------------------------------------------------------------------------
12.0 - Categories
------------------------------------------------------------------------------*/
.category-adder {
margin-left: 120px;
padding: 4px 0;
}
.category-adder h4 {
margin: 0 0 8px;
}
#side-sortables .category-adder {
margin: 0;
}
.wp-tab-panel,
.categorydiv div.tabs-panel,
.customlinkdiv div.tabs-panel,
.posttypediv div.tabs-panel,
.taxonomydiv div.tabs-panel {
min-height: 42px;
max-height: 200px;
overflow: auto;
padding: 0 0.9em;
border: solid 1px #dfdfdf;
background-color: #fdfdfd;
}
div.tabs-panel-active {
display:block;
}
div.tabs-panel-inactive {
display:none;
}
#front-page-warning,
#front-static-pages ul,
ul.export-filters,
.inline-editor ul.cat-checklist ul,
.categorydiv ul.categorychecklist ul,
.customlinkdiv ul.categorychecklist ul,
.posttypediv ul.categorychecklist ul,
.taxonomydiv ul.categorychecklist ul {
margin-left: 18px;
}
ul.categorychecklist li {
margin: 0;
padding: 0;
line-height: 22px;
word-wrap: break-word;
}
.categorydiv .tabs-panel,
.customlinkdiv .tabs-panel,
.posttypediv .tabs-panel,
.taxonomydiv .tabs-panel {
border-width: 3px;
border-style: solid;
}
.form-wrap p,
.form-wrap label {
font-size: 11px;
}
.form-wrap label {
display: block;
padding: 2px;
font-size: 12px;
}
.form-field input,
.form-field textarea {
border-style: solid;
border-width: 1px;
width: 95%;
}
p.description,
.form-wrap p {
margin: 2px 0 5px;
color: #666;
}
p.help,
p.description,
span.description,
.form-wrap p {
font-size: 13px;
font-style: italic;
}
.form-wrap .form-field {
margin: 0 0 10px;
padding: 8px 0;
}
.form-wrap .form-field #parent {
max-width: 100%;
}
.col-wrap h3 {
margin: 12px 0;
font-size: 1.1em;
}
.col-wrap p.submit {
margin-top: -10px;
}
/*------------------------------------------------------------------------------
13.0 - Tags
------------------------------------------------------------------------------*/
.tagsdiv {
margin-top: -8px;
}
#poststuff .taghint {
color: #aaa;
margin: 15px 0 -24px 12px;
}
#poststuff .tagsdiv .howto {
margin: 0 0 6px 0;
}
.ajaxtag .newtag {
position: relative;
}
.tagsdiv .newtag {
width: 180px;
}
.tagsdiv .the-tags {
display: block;
height: 60px;
margin: 0 auto;
overflow: auto;
width: 260px;
}
#post-body-content .tagsdiv .the-tags {
margin: 0 5px;
}
/* tag hints */
.taghint {
color: #aaa;
margin: -17px 0 0 7px;
visibility: hidden;
}
input.newtag ~ div.taghint {
visibility: visible;
}
input.newtag:focus ~ div.taghint {
visibility: hidden;
}
p.popular-tags {
border: none;
line-height: 2em;
max-width: 1000px;
padding: 8px 12px 12px;
text-align: justify;
}
p.popular-tags a {
padding: 0 3px;
}
.tagcloud {
width: 97%;
margin: 0 0 40px;
text-align: justify;
}
.tagcloud h3 {
margin: 2px 0 12px;
}
.ac_results {
padding: 0;
margin: 0;
list-style: none;
position: absolute;
z-index: 10000;
display: none;
border: 1px solid #808080;
background-color: #fff;
}
.wp-customizer .ac_results {
z-index: 500000;
}
.ac_results li {
padding: 2px 5px;
white-space: nowrap;
color: #101010;
text-align: left;
}
.ac_over {
background-color: #f0f0b8;
cursor: pointer;
}
.ac_match {
text-decoration: underline;
}
/* Comments */
.comment-php .wp-editor-area {
height: 200px;
}
.comment-ays {
margin-bottom: 0;
border-bottom-style: solid;
border-bottom-width: 1px;
}
.comment-ays .alt {
background-color: transparent;
}
.trash-undo-inside,
.spam-undo-inside {
margin: 1px 8px 1px 0;
line-height: 16px;
}
.spam-undo-inside .avatar,
.trash-undo-inside .avatar {
height: 20px;
width: 20px;
margin-right: 8px;
vertical-align: middle;
}
.stuffbox .editcomment {
clear: none;
}
#comment-status-radio p {
margin: 3px 0 5px;
}
#comment-status-radio input {
margin: 2px 3px 5px 0;
vertical-align: middle;
}
#comment-status-radio label {
padding: 5px 0;
}
/* links tables */
table.links-table {
width: 100%;
border-spacing: 0;
}
.links-table th {
font-weight: normal;
text-align: left;
vertical-align: top;
min-width: 80px;
width: 20%;
word-wrap: break-word;
}
.links-table th,
.links-table td {
padding: 5px 0;
}
.links-table td label {
margin-right: 8px;
}
.links-table td input[type="text"],
.links-table td textarea {
width: 100%;
}
.links-table #link_rel {
max-width: 280px;
}
/* =Media Queries
-------------------------------------------------------------- */
/**
* HiDPI Displays
*/
@media print,
(-o-min-device-pixel-ratio: 5/4),
(-webkit-min-device-pixel-ratio: 1.25),
(min-resolution: 120dpi) {
#content-resize-handle,
#post-body .wp_themeSkin .mceStatusbar a.mceResize {
background: transparent url(../images/resize-2x.gif) no-repeat scroll right bottom;
-webkit-background-size: 11px 11px;
background-size: 11px 11px;
}
.rtl #content-resize-handle,
.rtl #post-body .wp_themeSkin .mceStatusbar a.mceResize {
background: transparent url(../images/resize-rtl-2x.gif) no-repeat scroll right bottom;
}
}
/* one column on the post write/edit screen */
@media only screen and (max-width: 850px) {
#poststuff {
min-width: 0;
}
#wpbody-content #poststuff #post-body {
margin: 0;
}
#wpbody-content #post-body.columns-2 #postbox-container-1 {
margin-right: 0;
width: 100%;
}
#poststuff #postbox-container-1 .empty-container,
#poststuff #postbox-container-1 #side-sortables:empty {
border: 0 none;
height: 0;
min-height: 0;
}
#poststuff #post-body.columns-2 #side-sortables {
min-height: 0;
}
/* hide the radio buttons for column prefs */
.screen-layout,
.columns-prefs {
display: none;
}
}
@media screen and ( max-width: 782px ) {
#post-body-content {
min-width: 0;
}
#titlediv #title-prompt-text {
padding: 10px 10px;
}
#poststuff h3 {
padding: 12px;
}
.post-format-options {
padding-right: 0;
}
.post-format-options a {
margin-right: 5px;
margin-bottom: 5px;
min-width: 52px;
}
.post-format-options .post-format-title {
font-size: 11px;
}
.post-format-options a div {
height: 28px;
width: 28px;
}
.post-format-options a div:before {
font-size: 26px !important;
}
/* Publish Metabox Options */
#post-visibility-select {
line-height: 280%;
}
.wp-core-ui .save-post-visibility,
.wp-core-ui .save-timestamp {
vertical-align: middle;
margin-right: 15px;
}
.timestamp-wrap select#mm {
display: block;
width: 100%;
margin-bottom: 10px;
}
.timestamp-wrap #jj,
.timestamp-wrap #aa,
.timestamp-wrap #hh,
.timestamp-wrap #mn {
padding: 12px 3px;
font-size: 14px;
margin-bottom: 5px;
width: auto;
text-align: center;
}
/* Categories Metabox */
ul.category-tabs {
margin: 30px 0 15px;
}
ul.category-tabs li.tabs {
padding: 15px;
}
ul.categorychecklist li {
margin-bottom: 15px;
}
ul.categorychecklist ul {
margin-top: 15px;
}
.category-add input[type=text],
.category-add select {
max-width: none;
margin-bottom: 15px;
}
/* Tags Metabox */
.tagsdiv .newtag {
width: 100%;
height: auto;
margin-bottom: 15px;
}
.tagchecklist {
margin: 25px 10px;
}
.tagchecklist span {
font-size: 16px;
line-height: 120%;
}
/* Discussion */
#commentstatusdiv p {
line-height: 2.8;
}
/* TinyMCE Adjustments */
.mceToolbar * {
white-space: normal !important;
}
.mceToolbar tr,
.mceToolbar td {
float: left !important;
}
.wp_themeSkin a.mceButton {
width: 30px;
height: 30px;
}
.wp_themeSkin .mceButton .mceIcon {
margin-top: 5px;
margin-left: 5px;
}
.wp_themeSkin .mceSplitButton {
margin-top: 1px;
}
.wp_themeSkin .mceSplitButton td a.mceAction {
padding-top: 6px;
padding-bottom: 6px;
padding-left: 6px;
padding-right: 3px;
}
.wp_themeSkin .mceSplitButton td a.mceOpen,
.wp_themeSkin .mceSplitButtonEnabled:hover td a.mceOpen {
padding-top: 6px;
padding-bottom: 6px;
background-position: 1px 6px;
}
.wp_themeSkin table.mceListBox {
margin: 5px;
}
div.quicktags-toolbar input {
padding: 10px 20px;
}
#wp-content-editor-tools {
overflow: hidden;
padding: 20px 15px 1px 0;
top: 1px;
}
a.wp-switch-editor {
font-size: 16px;
line-height: 1em;
margin: 3px 0 0 7px;
padding: 12px 15px;
}
#wp-content-media-buttons a {
font-size: 16px;
line-height: 37px;
height: 39px;
padding: 0 20px 0 15px;
}
.wp-media-buttons span.wp-media-buttons-icon,
.wp-media-buttons span.jetpack-contact-form-icon {
width: 22px !important;
margin-top: -3px !important;
margin-left: -5px !important;
}
.wp-media-buttons .add_media span.wp-media-buttons-icon:before,
.wp-media-buttons #insert-jetpack-contact-form span.jetpack-contact-form-icon:before {
font-size: 20px !important;
}
#content_wp_fullscreen {
display: none;
}
.misc-pub-section {
padding: 20px 10px 20px;
}
.misc-pub-section > a {
float: right;
font-size: 16px;
}
#delete-action,
#publishing-action {
line-height: 47px;
}
/* Moderate Comment */
.comment-ays {
border-bottom: none;
}
/* Links */
.links-table #link_rel {
max-width: none;
}
.links-table th,
.links-table td {
padding: 10px 0;
}
}
@media only screen and (max-width: 500px) {
/* Align Add Media + Visual + Text tabs */
#wp-content-media-buttons a {
font-size: 14px;
padding: 0 10px 0 10px;
}
}
| 01-wordpress-paypal | trunk/wp-admin/css/edit.css | CSS | gpl3 | 23,864 |
@import url(forms.css);
@import url(l10n.css);
html,
body {
height: 100%;
margin: 0;
padding: 0;
}
html {
background: #f1f1f1;
}
body {
background: #f1f1f1;
min-width: 0;
color: #444;
font-family: "Open Sans", sans-serif;
font-size: 13px;
line-height: 1.4em;
}
a {
color: #0074a2;
-webkit-transition-property: border, background, color;
transition-property: border, background, color;
-webkit-transition-duration: .05s;
transition-duration: .05s;
-webkit-transition-timing-function: ease-in-out;
transition-timing-function: ease-in-out;
}
a {
outline: 0;
}
a:hover,
a:active {
color: #2ea2cc;
}
a:focus {
color: #124964;
}
a:focus,
a:active {
outline: thin dotted;
}
p {
line-height: 1.5;
}
.login .message {
border-right: 4px solid #7ad03a;
padding: 1px 12px;
background-color: #fff;
-webkit-box-shadow: 0 1px 1px 0 rgba(0,0,0,0.1);
box-shadow: 0 1px 1px 0 rgba(0,0,0,0.1);
}
.login #login_error {
border-right: 4px solid #dd3d36;
background: #fff;
-webkit-box-shadow: 0 1px 1px 0 rgba(0,0,0,0.1);
box-shadow: 0 1px 1px 0 rgba(0,0,0,0.1);
}
#loginform p.submit,
.login-action-lostpassword p.submit {
border: none;
margin: -10px 0 20px; /* May want to revisit this */
}
.login * {
margin: 0;
padding: 0;
}
.login form {
margin-top: 20px;
margin-right: 0;
padding: 26px 24px 46px;
font-weight: normal;
overflow: hidden;
background: #fff;
-webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.13);
box-shadow: 0 1px 3px rgba(0,0,0,0.13);
}
.login form .forgetmenot {
font-weight: normal;
float: right;
margin-bottom: 0;
}
.login .button-primary {
float: left;
}
#login form p {
margin-bottom: 0;
}
#login form p.submit {
margin: 0;
padding: 0;
}
.login label {
color: #777;
font-size: 14px;
}
.login form .forgetmenot label {
font-size: 12px;
line-height: 19px;
}
.login h1 {
text-align: center;
}
.login h1 a {
background-image: url(../images/w-logo-blue.png?ver=20131202);
background-image: none, url(../images/wordpress-logo.svg?ver=20131107);
-webkit-background-size: 80px 80px;
background-size: 80px 80px;
background-position: center top;
background-repeat: no-repeat;
color: #999;
height: 80px;
font-size: 20px;
font-weight: normal;
line-height: 1.3em;
margin: 0 auto 25px;
padding: 0;
text-decoration: none;
width: 80px;
text-indent: -9999px;
outline: none;
overflow: hidden;
display: block;
}
#login {
width: 320px;
padding: 8% 0 0;
margin: auto;
}
#login_error,
.login .message {
margin-right: 0;
padding: 12px;
}
.login #nav,
.login #backtoblog {
font-size: 13px;
padding: 0 24px 0;
}
.login #nav {
margin: 24px 0 0 0;
}
#backtoblog {
margin: 16px 0 0 0;
}
.login #nav a,
.login #backtoblog a {
text-decoration: none;
color: #999;
}
.login #nav a:hover,
.login #backtoblog a:hover,
.login h1 a:hover {
color: #2ea2cc;
}
.login form .input,
.login input[type="text"] {
font-size: 24px;
line-height: 1;
width: 100%;
padding: 3px;
margin: 2px 0 16px 6px;
}
.login form .input,
.login input[type="text"],
.login form input[type="checkbox"] {
background: #fbfbfb;
}
.ie7 .login form .input,
.ie8 .login form .input {
font-family: sans-serif;
}
.login #pass-strength-result {
width: 250px;
font-weight: 600;
margin: 12px 0 6px;
padding: 6px 5px;
text-align: center;
}
.mobile #login {
padding: 20px 0;
}
.mobile #login form,
.mobile #login .message,
.mobile #login_error {
margin-right: 0;
}
.mobile #login #nav,
.mobile #login #backtoblog {
margin-right: 8px;
}
.mobile #login h1 a {
width: auto;
}
body.interim-login {
height: auto;
}
.interim-login #login {
padding: 0;
margin: 5px auto 20px;
}
.interim-login.login h1 a {
width: auto;
}
.interim-login #login_error,
.interim-login.login .message {
margin: 0 0 16px;
}
.interim-login.login form {
margin: 0;
}
@-ms-viewport {
width: device-width;
}
@media screen and ( max-width: 782px ) {
.interim-login input[type=checkbox] {
height: 16px;
width: 16px;
}
.interim-login input[type=checkbox]:checked:before {
width: 16px;
font: normal 21px/1 'dashicons';
margin: -3px -4px 0 0;
}
} | 01-wordpress-paypal | trunk/wp-admin/css/login-rtl.css | CSS | gpl3 | 4,094 |
#adminmenuback,
#adminmenuwrap,
#adminmenu,
#adminmenu .wp-submenu {
width: 160px;
background-color: #222;
}
#adminmenuback {
position: absolute;
top: 0;
bottom: 0;
z-index: -1;
}
#adminmenu {
clear: right;
margin: 12px 0 0;
padding: 0;
list-style: none;
}
.folded #adminmenuback,
.folded #adminmenuwrap,
.folded #adminmenu,
.folded #adminmenu li.menu-top {
width: 36px;
}
.icon16 {
height: 18px;
width: 18px;
padding: 6px 6px;
margin: -6px -8px 0 0;
float: right;
}
/* New Menu icons */
.icon16:before {
color: #999;
font: normal 20px/1 'dashicons';
speak: none;
padding: 6px 0;
height: 34px;
width: 20px;
display: inline-block;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
-webkit-transition: all .1s ease-in-out;
transition: all .1s ease-in-out;
}
.icon16.icon-dashboard:before {
content: '\f226';
}
.icon16.icon-post:before {
content: '\f109';
}
.icon16.icon-media:before {
content: '\f104';
}
.icon16.icon-links:before {
content: '\f103';
}
.icon16.icon-page:before {
content: '\f105';
}
.icon16.icon-comments:before {
content: '\f101';
margin-top: 1px;
}
.icon16.icon-appearance:before {
content: '\f100';
}
.icon16.icon-plugins:before {
content: '\f106';
}
.icon16.icon-users:before {
content: '\f110';
}
.icon16.icon-tools:before {
content: '\f107';
}
.icon16.icon-settings:before {
content: '\f108';
}
.icon16.icon-site:before {
content: '\f112'
}
.icon16.icon-generic:before {
content: '\f111';
}
/* hide background-image for icons above */
.icon16.icon-dashboard,
.menu-icon-dashboard div.wp-menu-image,
.icon16.icon-post,
.menu-icon-post div.wp-menu-image,
.icon16.icon-media,
.menu-icon-media div.wp-menu-image,
.icon16.icon-links,
.menu-icon-links div.wp-menu-image,
.icon16.icon-page,
.menu-icon-page div.wp-menu-image,
.icon16.icon-comments,
.menu-icon-comments div.wp-menu-image,
.icon16.icon-appearance,
.menu-icon-appearance div.wp-menu-image,
.icon16.icon-plugins,
.menu-icon-plugins div.wp-menu-image,
.icon16.icon-users,
.menu-icon-users div.wp-menu-image,
.icon16.icon-tools,
.menu-icon-tools div.wp-menu-image,
.icon16.icon-settings,
.menu-icon-settings div.wp-menu-image,
.icon16.icon-site,
.menu-icon-site div.wp-menu-image,
.icon16.icon-generic,
.menu-icon-generic div.wp-menu-image {
background-image: none !important;
}
/*------------------------------------------------------------------------------
7.0 - Main Navigation (Left Menu)
------------------------------------------------------------------------------*/
#adminmenuwrap {
position: relative;
float: right;
}
/* side admin menu */
#adminmenu * {
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
#adminmenu li {
margin: 0;
padding: 0;
cursor: pointer;
}
#adminmenu a {
display: block;
line-height: 18px;
padding: 2px 5px;
color: #eee;
}
#adminmenu .wp-submenu a {
color: #bbb;
}
#adminmenu .wp-submenu a:hover,
#adminmenu .wp-submenu a:focus {
background: none;
}
#adminmenu a:hover,
#adminmenu li.menu-top > a:focus,
#adminmenu .wp-submenu a:hover,
#adminmenu .wp-submenu a:focus {
color: #2ea2cc;
}
#adminmenu li.menu-top {
border: none;
min-height: 34px;
position: relative;
}
#adminmenu .wp-submenu {
list-style: none;
position: absolute;
top: -1000em;
right: 160px;
overflow: visible;
word-wrap: break-word;
}
#adminmenu .wp-submenu,
.folded #adminmenu a.wp-has-current-submenu:focus + .wp-submenu,
.folded #adminmenu .wp-has-current-submenu .wp-submenu {
padding: 7px 0 8px;
z-index: 9999;
background-color: #333;
-webkit-box-shadow: 0 3px 5px rgba(0,0,0,0.2);
box-shadow: 0 3px 5px rgba(0,0,0,0.2);
}
.js #adminmenu .sub-open,
.js #adminmenu .opensub .wp-submenu,
#adminmenu a.menu-top:focus + .wp-submenu,
.no-js li.wp-has-submenu:hover .wp-submenu {
top: -1px;
}
#adminmenu .wp-has-current-submenu .wp-submenu,
.no-js li.wp-has-current-submenu:hover .wp-submenu,
#adminmenu a.wp-has-current-submenu:focus + .wp-submenu,
#adminmenu .wp-has-current-submenu .wp-submenu.sub-open,
#adminmenu .wp-has-current-submenu.opensub .wp-submenu {
position: relative;
z-index: 3;
top: auto;
right: auto;
left: auto;
bottom: auto;
border: 0 none;
margin-top: 0;
-webkit-box-shadow: none;
box-shadow: none;
background-color: #333;
}
/* ensure that wp-submenu's box shadow doesn't appear on top of the focused menu item's background. */
#adminmenu li.menu-top:hover,
#adminmenu li.opensub > a.menu-top,
#adminmenu li > a.menu-top:focus {
position: relative;
background-color: #111;
}
.folded #adminmenu li.menu-top:hover,
.folded #adminmenu li.opensub > a.menu-top,
.folded #adminmenu li > a.menu-top:focus {
z-index: 10000;
}
#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu,
#adminmenu li.current a.menu-top,
.folded #adminmenu li.wp-has-current-submenu,
.folded #adminmenu li.current.menu-top,
#adminmenu .wp-menu-arrow,
#adminmenu .wp-has-current-submenu .wp-submenu .wp-submenu-head,
#adminmenu .wp-menu-arrow div {
background: #0074a2;
color: #fff;
}
.folded #adminmenu .wp-submenu.sub-open,
.folded #adminmenu .opensub .wp-submenu,
.folded #adminmenu .wp-has-current-submenu .wp-submenu.sub-open,
.folded #adminmenu .wp-has-current-submenu.opensub .wp-submenu,
.folded #adminmenu a.menu-top:focus + .wp-submenu,
.folded #adminmenu .wp-has-current-submenu a.menu-top:focus + .wp-submenu,
.no-js.folded #adminmenu .wp-has-submenu:hover .wp-submenu {
top: 0;
right: 36px;
}
.folded #adminmenu a.wp-has-current-submenu:focus + .wp-submenu,
.folded #adminmenu .wp-has-current-submenu .wp-submenu {
position: absolute;
top: -1000em;
}
#adminmenu .wp-not-current-submenu .wp-submenu,
.folded #adminmenu .wp-has-current-submenu .wp-submenu {
min-width: 160px;
width: auto;
}
#adminmenu .wp-submenu a {
font-size: 13px;
line-height: 1.2;
margin: 0;
padding: 6px 0;
}
#adminmenu .wp-submenu li.current,
#adminmenu .wp-submenu li.current a,
#adminmenu .opensub .wp-submenu li.current a,
#adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a,
#adminmenu .wp-submenu li.current a:hover,
#adminmenu .wp-submenu li.current a:focus {
color: #fff;
}
#adminmenu .wp-not-current-submenu li > a,
.folded #adminmenu .wp-has-current-submenu li > a {
padding-left: 16px;
padding-right: 14px;
-webkit-transition: all .1s ease-in-out;
transition: all .1s ease-in-out;
}
#adminmenu .wp-has-current-submenu ul > li > a,
.folded #adminmenu li.menu-top .wp-submenu > li > a {
padding: 6px 12px;
}
#adminmenu a.menu-top,
#adminmenu .wp-submenu-head {
font-size: 14px;
font-weight: 400;
line-height: 18px;
padding: 0;
}
#adminmenu .wp-submenu-head,
.folded #adminmenu .wp-menu-name {
display: none;
}
.folded #adminmenu .wp-submenu-head {
display: block;
}
#adminmenu .wp-submenu li {
padding: 0;
margin: 0;
overflow: hidden;
}
#adminmenu .wp-menu-image img {
padding: 9px 0 0 0;
opacity: 0.6;
filter: alpha(opacity=60);
}
#adminmenu div.wp-menu-name {
padding: 8px 0;
}
#adminmenu div.wp-menu-image {
float: right;
width: 36px;
height: 34px;
margin: 0;
text-align: center;
}
#adminmenu div.wp-menu-image.svg {
background-repeat: no-repeat;
background-position: center;
-webkit-background-size: 20px auto;
background-size: 20px auto;
}
div.wp-menu-image:before {
color: #999;
padding: 7px 0;
-webkit-transition: all .1s ease-in-out;
transition: all .1s ease-in-out;
}
#adminmenu div.wp-menu-image:before {
color: #999;
}
#adminmenu li.wp-has-current-submenu:hover div.wp-menu-image:before,
#adminmenu .wp-has-current-submenu div.wp-menu-image:before,
#adminmenu .current div.wp-menu-image:before,
#adminmenu a.wp-has-current-submenu:hover div.wp-menu-image:before,
#adminmenu a.current:hover div.wp-menu-image:before {
color: #fff;
}
#adminmenu li:hover div.wp-menu-image:before {
color: #2ea2cc;
}
.folded #adminmenu div.wp-menu-image {
width: 35px;
height: 30px;
position: absolute;
z-index: 25;
}
.folded #adminmenu a.menu-top {
height: 34px;
}
/* No @font-face support */
.no-font-face #adminmenu .wp-menu-image {
display: none;
}
.no-font-face #adminmenu div.wp-menu-name {
padding: 8px 12px;
}
.no-font-face.auto-fold #adminmenu .wp-menu-name {
margin-right: 0;
}
/* End no @font-face support */
/* Sticky admin menu */
.sticky-menu #adminmenuwrap {
position: fixed;
z-index: 9999; /* Match the z-index of .wp-submenu to ensure flyout menus don't appear underneath main column elements */
}
/* A new arrow */
.wp-menu-arrow {
display: none !important;
}
ul#adminmenu a.wp-has-current-submenu {
position: relative;
}
ul#adminmenu a.wp-has-current-submenu:after,
ul#adminmenu > li.current > a.current:after {
left: 0;
border: solid 8px transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
border-left-color: #f1f1f1;
top: 50%;
margin-top: -8px;
}
.folded ul#adminmenu li:hover a.wp-has-current-submenu:after {
display: none;
}
.folded ul#adminmenu a.wp-has-current-submenu:after,
.folded ul#adminmenu > li a.current:after {
border-width: 4px;
margin-top: -4px;
}
/* flyout menu arrow */
#adminmenu li.wp-has-submenu.wp-not-current-submenu:hover:after {
left: 0;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
border-width: 8px;
top: 10px;
z-index: 10000;
}
.folded ul#adminmenu li.wp-has-submenu.wp-not-current-submenu:hover:after {
border-width: 4px;
margin-top: -4px;
top: 18px;
}
#adminmenu li.wp-has-submenu.wp-not-current-submenu.opensub:hover:after {
border-left-color: #333;
}
#adminmenu li.menu-top:hover .wp-menu-image img,
#adminmenu li.wp-has-current-submenu .wp-menu-image img {
opacity: 1;
filter: alpha(opacity=100);
}
#adminmenu li.wp-menu-separator {
height: 5px;
padding: 0;
margin: 0 0 6px 0;
cursor: inherit;
}
/* @todo: is this even needed given that it's nested beneath the above li.wp-menu-separator? */
#adminmenu div.separator {
height: 2px;
padding: 0;
}
#adminmenu .wp-submenu .wp-submenu-head {
color: #fff;
font-weight: 400;
font-size: 14px;
padding: 8px 11px 8px 4px;
margin: -7px 0px 4px;
}
#adminmenu li.current,
.folded #adminmenu li.wp-menu-open {
border: 0 none;
}
#adminmenu .awaiting-mod,
#adminmenu span.update-plugins,
#sidemenu li a span.update-plugins {
display: inline-block;
background-color: #d54e21;
color: #fff;
font-size: 9px;
line-height: 17px;
font-weight: 600;
margin: 1px 2px 0 0;
vertical-align: top;
-webkit-border-radius: 10px;
border-radius: 10px;
z-index: 26;
}
#adminmenu li .awaiting-mod span,
#adminmenu li span.update-plugins span,
#sidemenu li a span.update-plugins span {
display: block;
padding: 0 6px;
}
#adminmenu li.current a .awaiting-mod,
#adminmenu li a.wp-has-current-submenu .update-plugins {
background-color: #2ea2cc;
color: #fff;
}
#adminmenu li span.count-0,
#sidemenu li a .count-0 {
display: none;
}
#collapse-menu {
font-size: 13px;
line-height: 34px;
margin-top: 10px;
color: #aaa;
-webkit-transition: all .1s ease-in-out;
transition: all .1s ease-in-out;
}
#collapse-menu:hover,
#collapse-menu:hover #collapse-button div:after {
color: #2ea2cc;
}
.folded #collapse-menu span {
display: none;
}
#collapse-button,
#collapse-button div {
width: 15px;
height: 15px;
}
#collapse-button {
float: right;
height: 15px;
margin: 10px 11px 10px 8px;
width: 15px;
-webkit-border-radius: 10px;
border-radius: 10px;
}
#wpwrap #collapse-button div {
padding: 0;
}
#collapse-button div:after {
content: '\f148';
display: block;
line-height: 15px;
right: -3px;
top: -3px;
color: #aaa;
font: normal 20px/1 'dashicons' !important;
speak: none;
margin: 0 auto;
padding: 0 !important;
position: relative;
text-align: center;
width: 20px;
-webkit-transition: all .1s ease-in-out;
transition: all .1s ease-in-out;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.folded #collapse-button div:after,
.rtl #collapse-button div:after {
-webkit-transform: rotate(180deg);
-ms-transform: rotate(180deg);
transform: rotate(180deg);
}
.rtl.folded #collapse-button div:after {
-webkit-transform: none;
-ms-transform: none;
transform: none;
}
/**
* Toolbar menu toggle
*/
li#wp-admin-bar-menu-toggle {
display: none;
}
/* Auto-folding of the admin menu */
@media only screen and (max-width: 900px) {
.auto-fold #wpcontent,
.auto-fold #wpfooter {
margin-right: 56px;
}
.auto-fold #adminmenuback,
.auto-fold #adminmenuwrap,
.auto-fold #adminmenu,
.auto-fold #adminmenu li.menu-top {
width: 36px;
}
.auto-fold #adminmenu .wp-submenu.sub-open,
.auto-fold #adminmenu .opensub .wp-submenu,
.auto-fold #adminmenu .wp-has-current-submenu .wp-submenu.sub-open,
.auto-fold #adminmenu .wp-has-current-submenu.opensub .wp-submenu,
.auto-fold #adminmenu a.menu-top:focus + .wp-submenu,
.auto-fold #adminmenu .wp-has-current-submenu a.menu-top:focus + .wp-submenu {
top: 0px;
right: 36px;
}
.auto-fold #adminmenu a.wp-has-current-submenu:focus + .wp-submenu,
.auto-fold #adminmenu .wp-has-current-submenu .wp-submenu {
position: absolute;
top: -1000em;
margin-left: -1px;
padding: 7px 0 8px;
z-index: 9999;
}
.auto-fold #adminmenu .wp-has-current-submenu .wp-submenu {
min-width: 150px;
width: auto;
}
.auto-fold #adminmenu .wp-has-current-submenu li > a {
padding-left: 16px;
padding-right: 14px;
}
.auto-fold #adminmenu li.menu-top .wp-submenu > li > a {
padding-right: 12px;
}
.auto-fold #adminmenu .wp-menu-name {
display: none;
}
.auto-fold #adminmenu .wp-submenu-head {
display: block;
}
.auto-fold #adminmenu div.wp-menu-image {
height: 30px;
width: 34px;
position: absolute;
z-index: 25;
}
.auto-fold #adminmenu a.menu-top {
height: 34px;
}
.auto-fold #adminmenu li.wp-menu-open {
border: 0 none;
}
.auto-fold #adminmenu .wp-has-current-submenu.menu-top-last {
margin-bottom: 0;
}
.auto-fold ul#adminmenu li:hover a.wp-has-current-submenu:after {
display: none;
}
.auto-fold ul#adminmenu li.wp-has-submenu.wp-not-current-submenu:hover:after {
border-width: 4px;
margin-top: -4px;
top: 16px;
}
.auto-fold ul#adminmenu a.wp-has-current-submenu:after,
.auto-fold ul#adminmenu > li a.current:after {
border-width: 4px;
margin-top: -4px;
}
.auto-fold #adminmenu li.menu-top:hover,
.auto-fold #adminmenu li.opensub > a.menu-top,
.auto-fold #adminmenu li > a.menu-top:focus {
z-index: 10000;
}
.auto-fold #collapse-menu span {
display: none;
}
.auto-fold #collapse-button div {
background: none;
}
.auto-fold #collapse-button div:after {
-webkit-transform: rotate(180deg);
-ms-transform: rotate(180deg);
transform: rotate(180deg);
}
.rtl.auto-fold #collapse-button div:after {
-webkit-transform: none;
-ms-transform: none;
transform: none;
}
}
@media screen and ( max-width: 782px ) {
.auto-fold #wpcontent {
position: relative;
margin-right: 0;
padding-right: 10px;
}
.sticky-menu #adminmenuwrap {
position: relative;
z-index: auto;
top: 0;
}
/* Sidebar Adjustments */
.auto-fold #adminmenu,
.auto-fold #adminmenuback,
.auto-fold #adminmenuwrap {
position: absolute;
width: 190px;
z-index: 100;
}
.auto-fold #adminmenuback,
.auto-fold #adminmenuwrap {
display: none;
}
.auto-fold .wp-responsive-open #adminmenuback,
.auto-fold .wp-responsive-open #adminmenuwrap {
display: block;
}
.auto-fold #adminmenu li.menu-top {
width: 100%;
}
/* Resize the admin menu items to a comfortable touch size */
.auto-fold #adminmenu li a {
font-size: 16px;
padding: 5px;
}
.auto-fold #adminmenu li.menu-top .wp-submenu > li > a {
padding: 10px 20px 10px 10px;
}
/* Restore the menu names */
.auto-fold #adminmenu .wp-menu-name {
display: block;
margin-right: 35px;
}
/* Switch the arrow side */
.auto-fold ul#adminmenu a.wp-has-current-submenu:after,
.auto-fold ul#adminmenu > li.current > a.current:after {
border-width: 8px;
margin-top: -8px;
}
.auto-fold ul#adminmenu li.wp-has-submenu.wp-not-current-submenu:hover:after {
display: none;
}
/* Make the submenus appear correctly when tapped. */
#adminmenu .wp-submenu {
position: relative;
display: none;
}
.auto-fold #adminmenu .selected .wp-submenu,
.auto-fold #adminmenu .wp-menu-open .wp-submenu {
position: relative;
display: block;
top: 0;
right: -1px;
-webkit-box-shadow: none;
box-shadow: none;
}
.auto-fold #adminmenu .selected .wp-submenu:after,
.auto-fold #adminmenu .wp-menu-open .wp-submenu:after {
display: none;
}
.auto-fold #adminmenu .opensub .wp-submenu {
display: none;
}
.auto-fold #adminmenu .selected .wp-submenu {
display: block;
}
.auto-fold ul#adminmenu li:hover a.wp-has-current-submenu:after {
display: block;
}
.auto-fold #adminmenu a.menu-top:focus + .wp-submenu,
.auto-fold #adminmenu .wp-has-current-submenu a.menu-top:focus + .wp-submenu {
position: relative;
right: -1px;
left: 0;
top: 0;
}
/* Remove submenu headers and adjust sub meu*/
#adminmenu .wp-submenu .wp-submenu-head {
display: none;
}
/* Toolbar menu toggle */
#wp-responsive-toggle {
position: fixed;
top: 5px;
right: 4px;
padding-left: 10px;
z-index: 99999;
border: none;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
#wpadminbar #wp-admin-bar-menu-toggle a {
display: block;
padding: 0;
overflow: hidden;
outline: none;
text-decoration: none;
border: 1px solid transparent;
background: none;
height: 44px;
margin-right: -1px;
}
.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle a {
background: #333;
}
li#wp-admin-bar-menu-toggle {
display: block;
}
#wpadminbar #wp-admin-bar-menu-toggle a:hover {
border: 1px solid transparent;
}
#wpadminbar #wp-admin-bar-menu-toggle .ab-icon:before {
content: '\f228';
display: inline-block;
float: right;
font: normal 40px/45px 'Dashicons';
vertical-align: middle;
outline: none;
margin: 0;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
height: 44px;
width: 50px;
padding: 0;
border: none;
text-align: center;
text-decoration: none;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
}
/* Smartphone */
@media screen and (max-width: 600px) {
#adminmenuwrap,
#adminmenuback {
display: none;
}
.wp-responsive-open #adminmenuwrap,
.wp-responsive-open #adminmenuback {
display: block;
}
.auto-fold #adminmenu {
top: 46px;
}
}
| 01-wordpress-paypal | trunk/wp-admin/css/admin-menu-rtl.css | CSS | gpl3 | 18,576 |
/*------------------------------------------------------------------------------
14.0 - Media Screen
------------------------------------------------------------------------------*/
.media-item .describe {
border-collapse: collapse;
width: 100%;
border-top: 1px solid #dfdfdf;
clear: both;
cursor: default;
}
.media-item.media-blank .describe {
border: 0;
}
.media-item .describe th {
vertical-align: top;
text-align: left;
padding: 5px 10px 10px;
width: 140px;
}
.media-item .describe .align th {
padding-top: 0;
}
.media-item .media-item-info tr {
background-color: transparent;
}
.media-item .describe td {
padding: 0 8px 8px 0;
vertical-align: top;
}
.media-item thead.media-item-info td {
padding: 4px 10px 0;
}
.media-item .media-item-info .A1B1 {
padding: 0 0 0 10px;
}
.media-item td.savesend {
padding-bottom: 15px;
}
.media-item .thumbnail {
max-height: 128px;
max-width: 128px;
}
#wpbody-content #async-upload-wrap a {
display: none;
}
.media-upload-form {
margin-top: 20px;
}
.media-upload-form td label {
margin-right: 6px;
margin-left: 2px;
}
.media-upload-form .align .field label {
display: inline;
padding: 0 0 0 23px;
margin: 0 1em 0 3px;
font-weight: 600;
}
.media-upload-form tr.image-size label {
margin: 0 0 0 5px;
font-weight: 600;
}
.media-upload-form th.label label {
font-weight: 600;
margin: 0.5em;
font-size: 13px;
}
.media-upload-form th.label label span {
padding: 0 5px;
}
.media-item .describe input[type="text"],
.media-item .describe textarea {
width: 460px;
}
.media-item .describe p.help {
margin: 0;
padding: 0 0 0 5px;
}
.media-item .edit-attachment,
.describe-toggle-on,
.describe-toggle-off {
display: block;
line-height: 36px;
float: right;
}
.media-item .describe-toggle-off,
.media-item.open .describe-toggle-on {
display: none;
}
.media-item.open .describe-toggle-off {
display: block;
}
#media-items .media-item {
border-bottom: 1px solid #dfdfdf;
min-height: 36px;
position: relative;
width: 100%;
}
#media-items {
width: 623px;
}
.media-new-php #media-items {
margin: 1em 0;
}
#media-items:empty {
border: 0 none;
}
.media-item .filename {
line-height: 36px;
overflow: hidden;
}
.media-item .error-div {
padding-left: 10px;
}
.media-item .pinkynail {
float: left;
margin: 2px 10px 0 0;
max-width: 40px;
max-height: 32px;
}
.media-item .startopen,
.media-item .startclosed {
display: none;
}
.media-item .original {
position: relative;
height: 34px;
}
.media-item .progress {
float: right;
height: 22px;
margin: 7px 0 0;
width: 200px;
line-height: 2em;
padding: 0;
overflow: hidden;
margin-bottom: 2px;
-webkit-border-radius: 22px;
border-radius: 22px;
background: #ddd;
-webkit-box-shadow: inset 0px 1px 2px rgba(0,0,0,0.1);
box-shadow: inset 0px 1px 2px rgba(0,0,0,0.1);
}
.media-item .bar {
z-index: 9;
width: 0;
height: 100%;
margin-top: -22px;
-webkit-border-radius: 22px;
border-radius: 22px;
background-color: #0074a2;
-webkit-box-shadow: inset 0 0 2px rgba(0,0,0,0.3);
box-shadow: inset 0 0 2px rgba(0,0,0,0.3);
}
.media-item .progress .percent {
z-index: 10;
position: relative;
width: 200px;
padding: 0;
color: #fff;
text-align: center;
line-height: 22px;
font-weight: 400;
text-shadow: 0px 1px 2px rgba(0,0,0,0.2);
}
.upload-php .fixed .column-parent {
width: 15%;
}
.js .html-uploader #plupload-upload-ui {
display: none;
}
.js .html-uploader #html-upload-ui {
display: block;
}
.media-upload-form .media-item.error {
margin: 0;
padding: 0;
}
.media-upload-form .media-item.error p,
.media-item .error-div {
line-height: 16px;
margin: 5px 10px;
padding: 0;
}
.media-item .error-div a.dismiss {
display: block;
float: right;
margin: 5px 4px 0 15px;
}
/*------------------------------------------------------------------------------
14.1 - Media Library
------------------------------------------------------------------------------*/
.find-box {
background-color: #fff;
-webkit-box-shadow: 0 3px 6px rgba( 0, 0, 0, 0.3 );
box-shadow: 0 3px 6px rgba( 0, 0, 0, 0.3 );
width: 600px;
overflow: hidden;
margin-left: -300px;
position: fixed;
top: 30px;
bottom: 30px;
left: 50%;
z-index: 100105;
}
.find-box-head {
background: #fcfcfc;
border-bottom: 1px solid #dfdfdf;
height: 36px;
font-size: 18px;
font-weight: 600;
line-height: 36px;
padding: 0 36px 0 16px;
position: absolute;
top: 0;
left: 0;
right: 0;
}
.find-box-inside {
overflow: auto;
padding: 16px;
background-color: #fff;
position: absolute;
top: 37px;
bottom: 45px;
overflow-y: scroll;
width: 100%;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.find-box-search {
padding-bottom: 16px;
}
.find-box-search .spinner {
float: none;
left: 125px;
position: absolute;
top: 18px;
}
#find-posts-input,
#find-posts-search {
float: left;
}
#find-posts-input {
width: 140px;
height: 28px;
margin: 0 4px 0 0;
}
.widefat .found-radio {
padding-right: 0;
width: 16px;
}
#find-posts-close {
width: 36px;
height: 36px;
position: absolute;
top: 0;
right: 0;
cursor: pointer;
text-align: center;
color: #666;
}
#find-posts-close:hover {
color: #2ea2cc;
}
#find-posts-close:before {
font: normal 20px/36px 'dashicons';
vertical-align: top;
speak: none;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
content: '\f158';
}
.find-box-buttons {
padding: 8px 16px;
background: #fcfcfc;
border-top: 1px solid #dfdfdf;
position: absolute;
bottom: 0;
left: 0;
right: 0;
}
@media screen and ( max-width: 782px ) {
.find-box-inside {
bottom: 57px;
}
}
@media screen and ( max-width: 660px ) {
.find-box {
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: 0;
width: 100%;
}
}
.ui-find-overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: #000;
opacity: 0.7;
filter: alpha(opacity=70);
z-index: 100100;
}
ul#dismissed-updates {
display: none;
}
form.upgrade {
margin-top: 8px;
}
form.upgrade .hint {
font-style: italic;
font-size: 85%;
margin: -0.5em 0 2em 0;
}
#poststuff .inside .the-tagcloud {
margin: 5px 0 10px;
padding: 8px;
border: 1px solid #ddd;
line-height: 1.8em;
word-spacing: 3px;
-webkit-border-radius: 6px;
border-radius: 6px;
}
.drag-drop #drag-drop-area {
border: 4px dashed #bbb;
height: 200px;
}
.drag-drop .drag-drop-inside {
margin: 70px auto 0;
width: 250px;
}
.drag-drop-inside p {
color: #aaa;
font-size: 14px;
margin: 5px 0;
display: none;
}
.drag-drop .drag-drop-inside p {
text-align: center;
}
.drag-drop-inside p.drag-drop-info {
font-size: 20px;
}
.drag-drop .drag-drop-inside p,
.drag-drop-inside p.drag-drop-buttons {
display: block;
}
/*
#drag-drop-area:-moz-drag-over {
border-color: #83b4d8;
}
border color while dragging a file over the uploader drop area */
.drag-drop.drag-over #drag-drop-area {
border-color: #83b4d8;
}
#plupload-upload-ui {
position: relative;
}
/*------------------------------------------------------------------------------
14.2 - Image Editor
------------------------------------------------------------------------------*/
.wp_attachment_details label[for="content"] {
font-size: 13px;
line-height: 1.5;
margin: 1em 0;
}
.wp_attachment_details #attachment_caption {
height: 4em;
}
.describe .image-editor {
vertical-align: top;
}
.imgedit-wrap {
position: relative;
}
.imgedit-settings p {
margin: 8px 0 0;
}
.describe .imgedit-wrap .imgedit-settings {
padding: 0 5px;
}
.wp_attachment_holder div.updated {
margin-top: 0;
}
.wp_attachment_holder .imgedit-wrap > div {
height: auto;
overflow: hidden;
}
.wp_attachment_holder .imgedit-wrap .imgedit-panel-content {
padding-right: 16px;
width: auto;
overflow: hidden;
}
.wp_attachment_holder .imgedit-wrap .imgedit-settings {
float: right;
width: 250px;
}
.imgedit-settings input {
margin-top: 0;
vertical-align: middle;
}
.imgedit-wait {
position: absolute;
top: 0;
background: #fff url(../images/spinner.gif) no-repeat center;
-webkit-background-size: 20px 20px;
background-size: 20px 20px;
opacity: 0.7;
filter: alpha(opacity=70);
width: 100%;
height: 500px;
display: none;
}
.no-float {
float: none;
}
.media-disabled,
.imgedit-settings .disabled {
color: grey;
}
.wp_attachment_image,
.A1B1 {
overflow: hidden;
}
.wp_attachment_image .button,
.A1B1 .button {
float: left;
}
.no-js .wp_attachment_image .button {
display: none;
}
.wp_attachment_image .spinner,
.A1B1 .spinner {
float: left;
padding: 0 0 4px 0;
vertical-align: bottom;
}
.imgedit-menu {
margin: 0 0 12px;
min-width: 300px;
}
.imgedit-menu div {
float: left;
width: 32px;
border: 1px solid #d5d5d5;
background: #f1f1f1;
margin: 0 8px 0 0;
height: 32px;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
line-height: 28px;
color: #777;
cursor: pointer;
}
.imgedit-menu div:before {
font: normal 20px/1 'dashicons';
speak: none;
vertical-align: middle;
}
.imgedit-menu div:hover {
border-color: #c1c1c1;
background-color: #eaeaea;
color: #333;
}
.imgedit-menu div.disabled {
border-color: #ccc;
background-color: #ddd;
color: #777;
filter: alpha(opacity=50);
opacity: 0.5;
cursor: default;
}
.imgedit-crop:before {
content:'\f165';
}
.imgedit-rleft:before {
content:'\f166';
}
.imgedit-rright:before {
content:'\f167';
}
.imgedit-flipv:before {
content:'\f168';
}
.imgedit-fliph:before {
content:'\f169';
}
.imgedit-undo:before {
content:'\f171';
}
.imgedit-redo:before {
content:'\f172';
}
.imgedit-crop-wrap {
position: relative;
}
.imgedit-crop {
margin: 0 8px 0 0;
}
.imgedit-rleft {
margin: 0 3px;
}
.imgedit-rright {
margin: 0 8px 0 3px;
}
.imgedit-flipv {
margin: 0 3px;
}
.imgedit-fliph {
margin: 0 8px 0 3px;
}
.imgedit-undo {
margin: 0 3px;
}
.imgedit-redo {
margin: 0 8px 0 3px;
}
.imgedit-applyto img {
margin: 0 8px 0 0;
}
.imgedit-group-top {
margin: 5px 0;
}
#poststuff .imgedit-group-top h3 {
padding: 0;
}
.imgedit-group-top h3 a {
text-decoration: none;
}
.imgedit-applyto .imgedit-label {
padding: 2px 0 0;
display: block;
}
.imgedit-help {
display: none;
font-style: italic;
}
a.imgedit-help-toggle {
text-decoration: none;
}
.form-table td.imgedit-response {
padding: 0;
}
.imgedit-submit {
margin: 8px 0;
}
.imgedit-submit-btn {
margin-left: 20px;
}
.imgedit-wrap .nowrap {
white-space: nowrap;
}
span.imgedit-scale-warn {
color: red;
font-size: 20px;
font-style: normal;
visibility: hidden;
vertical-align: middle;
}
.imgedit-group {
margin-bottom: 8px;
padding: 2px 10px;
}
audio, video {
display: inline-block;
max-width: 100%;
}
.mejs-container {
width: 100%;
}
/* =Media Queries
-------------------------------------------------------------- */
/**
* HiDPI Displays
*/
@media print,
(-o-min-device-pixel-ratio: 5/4),
(-webkit-min-device-pixel-ratio: 1.25),
(min-resolution: 120dpi) {
.imgedit-wait {
background-image: url(../images/spinner-2x.gif);
}
}
@media screen and ( max-width: 782px ) {
.wp_attachment_details label[for="content"] {
font-size: 14px;
line-height: 1.5em;
}
}
| 01-wordpress-paypal | trunk/wp-admin/css/media.css | CSS | gpl3 | 11,168 |
.wp-full-overlay-sidebar {
overflow: visible;
}
/**
* Hide all sidebar sections by default, only show them (via JS) once the
* preview loads and we know whether the sidebars are used in the template.
*/
.control-section[id^="accordion-section-sidebar-widgets-"],
.customize-control-sidebar_widgets label,
.customize-control-sidebar_widgets .hide-if-js {
/* The link in .customize-control-sidebar_widgets .hide-if-js will fail if it ever gets used. */
display:none;
}
.customize-control-widget_form .widget-top {
-webkit-transition: opacity 0.5s;
transition: opacity 0.5s;
}
.customize-control-widget_form:not(.widget-rendered) .widget-top {
opacity: 0.5;
}
.customize-control-widget_form .widget-control-save,
.customize-control-widget_form .spinner {
display: none;
}
.customize-control-widget_form.previewer-loading .spinner {
display: inline;
}
.customize-control-widget_form.widget-form-disabled .widget-content {
opacity: 0.7;
pointer-events: none;
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
user-select: none;
}
.customize-control-widget_form .widget {
margin-bottom: 0;
}
.customize-control-widget_form.wide-widget-control .widget-inside {
position: fixed;
left: 299px;
top: 25%;
border: 1px solid rgb(229, 229, 229);
overflow: auto;
}
.customize-control-widget_form.wide-widget-control .widget-inside > .form {
padding: 20px;
}
.customize-control-widget_form.wide-widget-control .widget-top {
-webkit-transition: background-color 0.4s;
transition: background-color 0.4s;
}
.customize-control-widget_form.wide-widget-control.expanding .widget-top,
.customize-control-widget_form.wide-widget-control.expanded:not(.collapsing) .widget-top {
background-color: rgb(227, 227, 227);
}
.widget-inside {
padding: 1px 10px 10px 10px;
border-top: none;
line-height: 16px;
}
.widget-top {
cursor: move;
}
.customize-control-widget_form.expanded a.widget-action:after {
content: "\f142";
}
.customize-control-widget_form.wide-widget-control a.widget-action:after {
content: "\f139";
}
.customize-control-widget_form.wide-widget-control.expanded a.widget-action:after {
content: "\f141";
}
.widget-title-action {
cursor: pointer;
}
.customize-control-widget_form .widget .customize-control-title {
cursor: move;
}
.control-section.accordion-section.highlighted > .accordion-section-title,
.customize-control-widget_form.highlighted {
outline: none;
-webkit-box-shadow: 0 0 2px rgba(30,140,190,0.8);
box-shadow: 0 0 2px rgba(30,140,190,0.8);
position: relative;
z-index: 1;
}
#widget-customizer-control-templates {
display: none;
}
/**
* Widget reordering styles
**/
.reorder-toggle {
float: right;
padding: 5px 8px;
text-decoration: none;
cursor: pointer;
outline: none;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.reorder-toggle:focus {
outline: 1px dotted;
}
.reorder-done,
.reordering .reorder {
display: none;
}
.reordering .reorder-done {
display: block;
color: #aa0000;
}
#customize-theme-controls .reordering .add-new-widget {
opacity: 0.2;
pointer-events: none;
cursor: not-allowed;
}
#customize-theme-controls .widget-reorder-nav {
display: none;
float: right;
background-color: #fafafa;
}
.widget-reorder-nav span {
position: relative;
overflow: hidden;
float: left;
display: block;
width: 33px; /* was 42px for mobile */
height: 43px;
color: #888;
text-indent: -9999px;
cursor: pointer;
outline: none;
}
.widget-reorder-nav span:before {
display: inline-block;
position: absolute;
top: 0;
right: 0;
width: 100%;
height: 100%;
font: normal 20px/43px 'dashicons';
text-align: center;
text-indent: 0;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.widget-reorder-nav span:hover,
.widget-reorder-nav span:focus {
color: #444;
background: #eee;
}
.move-widget:before {
content: '\f504';
}
.move-widget-down:before {
content: '\f347';
}
.move-widget-up:before {
content: '\f343';
}
#customize-theme-controls .first-widget .move-widget-up,
#customize-theme-controls .last-widget .move-widget-down {
color: #d5d5d5;
cursor: default;
}
#customize-theme-controls .move-widget-area {
display: none;
background: #fff;
border: 1px solid #dedede;
border-top: none;
cursor: auto;
}
#customize-theme-controls .reordering .move-widget-area.active {
display: block;
}
#customize-theme-controls .move-widget-area .description {
margin: 0;
padding: 15px 20px;
font-weight: 400;
}
#customize-theme-controls .widget-area-select {
margin: 0;
padding: 0;
list-style: none;
}
#customize-theme-controls .widget-area-select li {
position: relative;
margin: 0;
padding: 13px 15px 15px 42px;
color: #555;
border-top: 1px solid #eee;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
#customize-theme-controls .widget-area-select li:before {
display: none;
content: '\f147';
position: absolute;
top: 12px;
left: 10px;
font: normal 20px/1 'dashicons';
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
#customize-theme-controls .widget-area-select li:last-child {
border-bottom: 1px solid #eee;
}
#customize-theme-controls .widget-area-select .selected {
color: #fff;
text-shadow: 0 -1px 0 rgba(0,0,0,.4);
background: #2ea2cc;
}
#customize-theme-controls .widget-area-select .selected:before {
display: block;
}
#customize-theme-controls .move-widget-actions {
text-align: right;
padding: 12px;
}
#customize-theme-controls .reordering .widget-title-action {
display: none;
}
#customize-theme-controls .reordering .widget-reorder-nav {
display: block;
}
/**
* Styles for new widget addition panel
*/
.wp-full-overlay-main {
right: auto; /* this overrides a right: 0; which causes the preview to resize, I'd rather have it go off screen at the normal size. */
width: 100%;
}
#customize-theme-controls .add-new-widget {
cursor: pointer;
float: right;
margin-left: 10px;
-webkit-transition: all 0.2s;
transition: all 0.2s;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
outline: none;
}
.add-new-widget:before {
content: "\f132";
display: inline-block;
position: relative;
left: -2px;
top: -1px;
font: normal 20px/1 'dashicons';
vertical-align: middle;
-webkit-transition: all 0.2s;
transition: all 0.2s;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
body.adding-widget .add-new-widget,
body.adding-widget .add-new-widget:hover {
background: #eee;
border-color: #999;
color: #333;
-webkit-box-shadow: inset 0 2px 5px -3px rgba(0, 0, 0, 0.5);
box-shadow: inset 0 2px 5px -3px rgba(0, 0, 0, 0.5);
}
body.adding-widget .add-new-widget:before {
-webkit-transform: rotate(45deg);
-ms-transform: rotate(45deg);
transform: rotate(45deg);
}
#available-widgets .widget {
position: static;
}
/* override widgets admin page rules in wp-admin/css/wp-admin.css */
#widgets-left #available-widgets .widget {
float: none !important;
width: auto !important;
}
#available-widgets {
position: absolute;
overflow: auto;
top: 0;
bottom: 0;
left: -301px;
width: 300px;
margin: 0;
z-index: 1;
background: #fff;
-webkit-transition: all 0.2s;
transition: all 0.2s;
border-right: 1px solid #dddddd;
}
#available-widgets-filter {
padding: 8px 17px 7px 13px;
border-bottom: 1px solid #e4e4e4;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
#available-widgets-filter input {
padding: 5px 10px 2px 10px;
width: 100%;
}
#available-widgets .widget-tpl {
position: relative;
padding: 20px 15px 20px 60px;
border-bottom: 1px solid #e4e4e4;
cursor: pointer;
display: none;
}
#available-widgets .widget-tpl:hover,
#available-widgets .widget-tpl.selected {
background: #fafafa;
}
#available-widgets .widget-top,
#available-widgets .widget-top:hover {
border: none;
background: transparent;
-webkit-box-shadow: none;
box-shadow: none;
}
#available-widgets .widget-title h4 {
padding: 0 0 5px;
font-size: 14px;
}
#available-widgets .widget .widget-description {
padding: 0;
color: #777;
}
#customize-preview {
-webkit-transition: all 0.2s;
transition: all 0.2s;
}
body.adding-widget #available-widgets {
left: 0;
}
body.adding-widget .wp-full-overlay-main {
left: 300px;
}
body.adding-widget #customize-preview {
opacity: 0.4;
}
/**
* Widget Icon styling
* No plurals in naming.
* Ordered from lowest to highest specificity.
**/
#available-widgets .widget-title {
position: relative;
}
#available-widgets .widget-title:before {
content: "\f132";
position: absolute;
top: -3px;
right: 100%;
margin-right: 20px;
width: 20px;
height: 20px;
color: #333;
font: normal 20px/1 'dashicons';
text-align: center;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
/* smiley */
#available-widgets [class*="easy"] .widget-title:before { content: "\f328"; top: -4px; }
/* star-filled */
#available-widgets [class*="super"] .widget-title:before,
#available-widgets [class*="like"] .widget-title:before { content: "\f155"; top: -4px; }
/* wordpress */
#available-widgets [class*="meta"] .widget-title:before { content: "\f120"; }
/* archive-box */
#available-widgets [class*="archives"] .widget-title:before { content: "\f480"; top: -4px; }
/* category */
#available-widgets [class*="categor"] .widget-title:before { content: "\f318"; top: -4px; }
/* comments */
#available-widgets [class*="comment"] .widget-title:before,
#available-widgets [class*="testimonial"] .widget-title:before,
#available-widgets [class*="chat"] .widget-title:before { content: "\f101"; }
/* post */
#available-widgets [class*="post"] .widget-title:before { content: "\f109"; }
/* admin-page */
#available-widgets [class*="page"] .widget-title:before { content: "\f105"; }
/* text */
#available-widgets [class*="text"] .widget-title:before { content: "\f478"; }
/* links */
#available-widgets [class*="link"] .widget-title:before { content: "\f103"; }
/* search */
#available-widgets [class*="search"] .widget-title:before { content: "\f179"; }
/* menu */
#available-widgets [class*="menu"] .widget-title:before,
#available-widgets [class*="nav"] .widget-title:before { content: "\f333"; }
/* tag-cloud */
#available-widgets [class*="tag"] .widget-title:before { content: "\f479"; }
/* rss */
#available-widgets [class*="rss"] .widget-title:before { content: "\f303"; top: -6px; }
/* calendar */
#available-widgets [class*="event"] .widget-title:before,
#available-widgets [class*="calendar"] .widget-title:before { content: "\f145"; top: -4px;}
/* format-image */
#available-widgets [class*="image"] .widget-title:before,
#available-widgets [class*="photo"] .widget-title:before,
#available-widgets [class*="slide"] .widget-title:before,
#available-widgets [class*="instagram"] .widget-title:before { content: "\f128"; }
/* format-gallery */
#available-widgets [class*="album"] .widget-title:before,
#available-widgets [class*="galler"] .widget-title:before { content: "\f161"; }
/* format-video */
#available-widgets [class*="video"] .widget-title:before,
#available-widgets [class*="tube"] .widget-title:before { content: "\f126"; }
/* format-audio */
#available-widgets [class*="music"] .widget-title:before,
#available-widgets [class*="radio"] .widget-title:before,
#available-widgets [class*="audio"] .widget-title:before { content: "\f127"; }
/* admin-users */
#available-widgets [class*="login"] .widget-title:before,
#available-widgets [class*="user"] .widget-title:before,
#available-widgets [class*="member"] .widget-title:before,
#available-widgets [class*="avatar"] .widget-title:before,
#available-widgets [class*="subscriber"] .widget-title:before,
#available-widgets [class*="profile"] .widget-title:before,
#available-widgets [class*="grofile"] .widget-title:before { content: "\f110"; }
/* cart */
#available-widgets [class*="commerce"] .widget-title:before,
#available-widgets [class*="shop"] .widget-title:before,
#available-widgets [class*="cart"] .widget-title:before { content: "\f174"; top: -4px; }
/* shield */
#available-widgets [class*="secur"] .widget-title:before,
#available-widgets [class*="firewall"] .widget-title:before { content: "\f332"; }
/* chart-bar */
#available-widgets [class*="analytic"] .widget-title:before,
#available-widgets [class*="stat"] .widget-title:before,
#available-widgets [class*="poll"] .widget-title:before { content: "\f185"; }
/* feedback */
#available-widgets [class*="form"] .widget-title:before { content: "\f175"; }
/* email-alt */
#available-widgets [class*="subscribe"] .widget-title:before,
#available-widgets [class*="news"] .widget-title:before,
#available-widgets [class*="contact"] .widget-title:before,
#available-widgets [class*="mail"] .widget-title:before { content: "\f466"; }
/* share */
#available-widgets [class*="share"] .widget-title:before,
#available-widgets [class*="socia"] .widget-title:before { content: "\f237"; }
/* translation */
#available-widgets [class*="lang"] .widget-title:before,
#available-widgets [class*="translat"] .widget-title:before { content: "\f326"; }
/* location-alt */
#available-widgets [class*="locat"] .widget-title:before,
#available-widgets [class*="map"] .widget-title:before { content: "\f231"; }
/* download */
#available-widgets [class*="download"] .widget-title:before { content: "\f316"; }
/* cloud */
#available-widgets [class*="weather"] .widget-title:before { content: "\f176"; top: -4px;}
/* facebook */
#available-widgets [class*="facebook"] .widget-title:before { content: "\f304"; }
/* twitter */
#available-widgets [class*="tweet"] .widget-title:before,
#available-widgets [class*="twitter"] .widget-title:before { content: "\f301"; }
@media screen and (max-height: 700px) and (min-width: 981px) {
.customize-control {
margin-bottom: 0;
}
.widget-top {
-webkit-box-shadow: none;
box-shadow: none;
margin-top: -1px;
}
.widget-top:hover {
position: relative;
z-index: 1;
}
.last-widget {
margin-bottom: 15px;
}
.widget-title h4 {
padding: 13px 15px;
}
.widget-top a.widget-action:after {
padding-top: 9px;
}
.widget-reorder-nav span {
height: 39px;
}
.widget-reorder-nav span:before {
line-height: 39px;
}
#customize-theme-controls .widget-area-select li {
padding: 9px 15px 11px 42px;
}
#customize-theme-controls .widget-area-select li:before {
top: 8px;
}
}
| 01-wordpress-paypal | trunk/wp-admin/css/customize-widgets.css | CSS | gpl3 | 14,572 |
.wp-color-picker {
width: 80px;
}
.wp-picker-container .hidden {
display: none;
}
.wp-color-result {
background-color: #f7f7f7;
border: 1px solid #ccc;
-webkit-border-radius: 3px;
border-radius: 3px;
cursor: pointer;
display: inline-block;
height: 22px;
margin: 0 0px 6px 6px;
position: relative;
top: 1px;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
vertical-align: bottom;
display: inline-block;
padding-right: 30px;
-webkit-box-shadow: 0 1px 0 rgba(0,0,0,.08);
box-shadow: 0 1px 0 rgba(0,0,0,.08);
}
.wp-color-result:after {
background: #f7f7f7;
-webkit-border-radius: 2px 0 0 2px;
border-radius: 2px 0 0 2px;
border-right: 1px solid #ccc;
color: #555;
content: attr( title );
display: block;
font-size: 11px;
line-height: 22px;
padding: 0 6px;
position: relative;
left: 0;
text-align: center;
top: 0;
-webkit-box-shadow: inset 0 1px 0 #fff;
box-shadow: inset 0 1px 0 #fff;
}
.wp-color-result:hover {
background: #fafafa;
border-color: #999;
color: #222;
}
.wp-color-result:hover:after {
color: #222;
border-color: #aaa;
border-right: 1px solid #999;
}
.wp-color-result {
top: 0;
}
.wp-color-result.wp-picker-open:after {
content: attr( data-current );
}
.wp-picker-container, .wp-picker-container:active {
display: inline-block;
outline: 0;
}
.wp-color-result:focus {
border-color: #888;
-webkit-box-shadow: 0 1px 2px rgba( 0, 0, 0, 0.2 );
box-shadow: 0 1px 2px rgba( 0, 0, 0, 0.2 );
}
.wp-color-result:focus:after {
border-color: #888;
}
.wp-picker-open + .wp-picker-input-wrap {
display: inline-block;
vertical-align: top;
}
.wp-picker-container .button {
margin-right: 6px;
}
.wp-picker-container .iris-square-slider .ui-slider-handle:focus {
background-color: #555
}
.wp-picker-container .iris-picker {
-webkit-border-radius: 0;
border-radius: 0;
border-color: #dfdfdf;
margin-top: 6px;
}
.wp-picker-container input[type="text"].wp-color-picker {
width: 65px;
font-size: 12px;
font-family: monospace;
text-align: center;
line-height: 16px;
margin: 0;
}
.wp-picker-container input[type="text"].wp-color-picker:focus::-webkit-input-placeholder {
color: transparent;
}
.wp-picker-container input[type="text"].wp-color-picker:-moz-placeholder {
color: #999;
}
.wp-picker-container input[type="text"].iris-error {
background-color: #ffebe8;
border-color: #c00;
color: #000;
}
| 01-wordpress-paypal | trunk/wp-admin/css/color-picker-rtl.css | CSS | gpl3 | 2,416 |
html {
background: #f1f1f1;
margin: 0 20px;
}
body {
background: #fff;
color: #444;
font-family: "Open Sans", sans-serif;
margin: 140px auto 25px;
padding: 20px 20px 10px 20px;
max-width: 700px;
-webkit-font-smoothing: subpixel-antialiased;
-webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.13);
box-shadow: 0 1px 3px rgba(0,0,0,0.13);
}
a {
color: #0074a2;
text-decoration: none;
}
a:hover {
color: #2ea2cc;
}
h1 {
border-bottom: 1px solid #dedede;
clear: both;
color: #666;
font-size: 24px;
margin: 30px 0;
padding: 0;
padding-bottom: 7px;
font-weight: normal;
}
h2 {
font-size: 16px;
}
p, li, dd, dt {
padding-bottom: 2px;
font-size: 14px;
line-height: 1.5;
}
code, .code {
font-family: Consolas, Monaco, monospace;
}
ul, ol, dl {
padding: 5px 22px 5px 5px;
}
a img {
border:0
}
abbr {
border: 0;
font-variant: normal;
}
#logo {
margin: 6px 0 14px 0;
border-bottom: none;
text-align:center
}
#logo a {
background-image: url(../images/w-logo-blue.png?ver=20131202);
background-image: none, url(../images/wordpress-logo.svg?ver=20131107);
-webkit-background-size: 80px 80px;
background-size: 80px 80px;
background-position: center top;
background-repeat: no-repeat;
color: #999;
height: 80px;
font-size: 20px;
font-weight: normal;
line-height: 1.3em;
margin: -130px auto 25px;
padding: 0;
text-decoration: none;
width: 80px;
text-indent: -9999px;
outline: none;
overflow: hidden;
display: block;
}
.step {
margin: 20px 0 15px;
}
.step, th {
text-align: right;
padding: 0;
}
.step .button-large {
font-size: 14px;
}
textarea {
border: 1px solid #dfdfdf;
font-family: "Open Sans", sans-serif;
width: 100%;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.form-table {
border-collapse: collapse;
margin-top: 1em;
width: 100%;
}
.form-table td {
margin-bottom: 9px;
padding: 10px 0 10px 20px;
border-bottom: 8px solid #fff;
font-size: 14px;
vertical-align: top
}
.form-table th {
font-size: 14px;
text-align: right;
padding: 16px 0 10px 20px;
width: 140px;
vertical-align: top;
}
.form-table code {
line-height: 18px;
font-size: 14px;
}
.form-table p {
margin: 4px 0 0 0;
font-size: 11px;
}
.form-table input {
line-height: 20px;
font-size: 15px;
padding: 3px 5px;
border: 1px solid #ddd;
-webkit-box-shadow: inset 0 1px 2px rgba(0,0,0,0.07);
box-shadow: inset 0 1px 2px rgba(0,0,0,0.07);
}
input,
submit {
font-family: "Open Sans", sans-serif;
}
.form-table input[type=text],
.form-table input[type=password] {
width: 206px;
}
.form-table th p {
font-weight: normal;
}
.form-table.install-success td {
vertical-align: middle;
padding: 16px 0 10px 20px;
}
.form-table.install-success td p {
margin: 0;
font-size: 14px;
}
.form-table.install-success td code {
margin: 0;
font-size: 18px;
}
#error-page {
margin-top: 50px;
}
#error-page p {
font-size: 14px;
line-height: 18px;
margin: 25px 0 20px;
}
#error-page code, .code {
font-family: Consolas, Monaco, monospace;
}
#pass-strength-result {
background-color: #eee;
border-color: #ddd !important;
border-style: solid;
border-width: 1px;
margin: 5px 0 5px 5px;
padding: 5px;
text-align: center;
width: 200px;
display: none;
}
#pass-strength-result.bad {
background-color: #ffb78c;
border-color: #ff853c !important;
}
#pass-strength-result.good {
background-color: #ffec8b;
border-color: #ffcc00 !important;
}
#pass-strength-result.short {
background-color: #ffa0a0;
border-color: #f04040 !important;
}
#pass-strength-result.strong {
background-color: #c3ff88;
border-color: #8dff1c !important;
}
.message {
border: 1px solid #c00;
padding: 0.5em 0.7em;
margin: 5px 0 15px;
background-color: #ffebe8;
}
/* @noflip */
#dbname,
#uname,
#pwd,
#dbhost,
#prefix,
#user_login,
#admin_email,
#pass1,
#pass2 {
direction: ltr;
}
/* localization */
body.rtl,
.rtl textarea,
.rtl input,
.rtl submit {
font-family: Tahoma, sans-serif;
}
:lang(he-il) body.rtl,
:lang(he-il) .rtl textarea,
:lang(he-il) .rtl input,
:lang(he-il) .rtl submit {
font-family: Arial, sans-serif;
}
@media only screen and (max-width: 799px) {
body {
margin-top: 115px;
}
#logo a {
margin: -125px auto 30px;
}
}
@media screen and ( max-width: 782px ) {
.form-table {
margin-top: 0;
}
.form-table th,
.form-table td {
display: block;
width: auto;
vertical-align: middle;
}
.form-table th {
padding: 20px 0 0;
}
.form-table td {
padding: 5px 0;
border: 0;
margin: 0;
}
textarea,
input {
font-size: 16px;
}
.form-table td input[type="text"],
.form-table td input[type="password"],
.form-table td select,
.form-table td textarea,
.form-table span.description {
width: 100%;
font-size: 16px;
line-height: 1.5;
padding: 7px 10px;
display: block;
max-width: none;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
}
| 01-wordpress-paypal | trunk/wp-admin/css/install-rtl.css | CSS | gpl3 | 4,914 |
/*------------------------------------------------------------------------------
16.0 - Themes
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
16.1 - Manage Themes
------------------------------------------------------------------------------*/
.theme-browser .themes {
clear: both;
padding: 0 0 100px;
}
.themes-php .wrap h2 {
float: right;
margin-bottom: 15px;
}
.network-admin.themes-php .wrap h2 {
margin-bottom: 0;
}
.themes-php .wrap h2 .button {
margin-right: 20px;
}
.themes-php .wrap .theme-count,
.theme-navigation .theme-count {
color: #fff;
-webkit-border-radius: 30px;
border-radius: 30px;
background: #777;
font-size: 14px;
padding: 4px 10px;
font-weight: 600;
margin-right: 5px;
margin-left: 20px;
position: relative;
top: -3px;
}
.theme-navigation a {
text-decoration:none;
}
/* Position admin messages */
.themes-php div.updated,
.themes-php div.error {
margin: 0 0 20px 0;
clear: both;
}
.themes-php div.updated a {
text-decoration: underline;
}
/**
* Main theme element
* (has flexible margins)
*/
.theme-browser .theme {
cursor: pointer;
float: right;
margin: 0 0 4% 4%;
position: relative;
width: 30.6%;
border: 1px solid #dedede;
-webkit-box-shadow: 0 1px 1px -1px rgba(0,0,0,0.1);
box-shadow: 0 1px 1px -1px rgba(0,0,0,0.1);
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.ie8 .theme-browser .theme {
width: 30%;
margin: 0 0 4% 3%;
}
.theme-browser .theme:nth-child(3n) {
margin-left: 0;
}
.theme-browser .theme:hover,
.theme-browser .theme:focus {
cursor: pointer;
}
.theme-browser .theme .theme-name {
font-size: 15px;
font-weight: 600;
height: 18px;
margin: 0;
padding: 15px;
-webkit-box-shadow: inset 0 1px 0 rgba(0,0,0,0.1);
box-shadow: inset 0 1px 0 rgba(0,0,0,0.1);
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
background: #fff;
background: rgba(255,255,255,0.65);
}
/* Activate and Customize buttons, shown on hover and focus */
.theme-browser .theme .theme-actions {
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
opacity: 0;
-webkit-transition: opacity 0.1s ease-in-out;
transition: opacity 0.1s ease-in-out;
position: absolute;
bottom: 0;
left: 0;
height: 38px;
padding: 9px 10px 0 10px;
background: rgba(244, 244, 244, 0.7);
border-right: 1px solid rgba(0,0,0,0.05);
}
.theme-browser .theme:hover .theme-actions,
.theme-browser .theme.focus .theme-actions,
.theme-browser .theme:focus .theme-actions {
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
opacity: 1;
}
.theme-browser .theme .theme-actions .button-primary {
margin-left: 3px;
}
.theme-browser .theme .theme-actions .button-secondary {
float: none;
margin-right: 3px;
}
/**
* Theme Screenshot
*
* Has a fixed aspect ratio of 1.5 to 1 regardless of screenshot size
* It is also responsive.
*/
.theme-browser .theme .theme-screenshot {
display: block;
overflow: hidden;
position: relative;
-webkit-transition: opacity 0.2s ease-in-out;
transition: opacity 0.2s ease-in-out;
}
.theme-browser .theme .theme-screenshot:after {
content: '';
display: block;
padding-top: 66.66666%; /* using a 3/2 aspect ratio */
}
.theme-browser .theme .theme-screenshot img {
height: auto;
position: absolute;
right: 0;
top: 0;
width: 100%;
-webkit-transform: translateZ( 0 ); /* Prevents rendering bugs in Chrome */
-webkit-transition: opacity 0.2s ease-in-out; /* Prevents rendering bugs in Chrome */
transition: opacity 0.2s ease-in-out;
}
.theme-browser .theme:hover .theme-screenshot,
.theme-browser .theme:focus .theme-screenshot {
background: #fff;
}
.theme-browser.rendered .theme:hover .theme-screenshot img,
.theme-browser.rendered .theme:focus .theme-screenshot img {
opacity: 0.4;
}
.theme-browser .theme .more-details {
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
opacity: 0;
position: absolute;
top: 35%;
left: 25%;
right: 25%;
background: #222;
background: rgba(0,0,0,0.7);
color: #fff;
font-size: 15px;
text-shadow: 0 1px 0 rgba(0,0,0,0.6);
-webkit-font-smoothing: antialiased;
font-weight: 600;
padding: 15px 12px;
text-align: center;
-webkit-border-radius: 3px;
border-radius: 3px;
-webkit-transition: opacity 0.1s ease-in-out;
transition: opacity 0.1s ease-in-out;
}
.theme-browser .theme:focus {
outline: 1px dotted #222;
}
.theme-browser .theme:focus .more-details {
opacity: 1;
}
/* Current theme needs to have its action always on view */
.theme-browser .theme.active:focus .theme-actions {
display: block;
}
.theme-browser.rendered .theme:hover .more-details,
.theme-browser.rendered .theme:focus .more-details {
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
opacity: 1;
}
/**
* Displays a theme update notice
* when an update is available.
*/
.theme-browser .theme .theme-update,
.theme-browser .theme .theme-installed {
background: #d54e21;
background: rgba(213, 78, 33, 0.95);
color: #fff;
display: block;
font-size: 13px;
font-weight: 400;
height: 48px;
line-height: 48px;
padding: 0 10px;
position: absolute;
top: 0;
left: 0;
right: 0;
border-bottom: 1px solid rgba(0,0,0,0.25);
overflow: hidden;
}
.theme-browser .theme .theme-update:before,
.theme-browser .theme .theme-installed:before {
content: '\f463';
display: inline-block;
font: normal 20px/1 'dashicons';
margin: 0 0 0 6px;
opacity: 0.8;
position: relative;
top: 5px;
speak: none;
-webkit-font-smoothing: antialiased;
}
/**
* The currently active theme
*/
.theme-browser .theme.active .theme-name {
background: #2f2f2f;
color: #fff;
padding-left: 110px;
font-weight: 300;
-webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,0.5);
box-shadow: inset 0 1px 1px rgba(0,0,0,0.5);
}
.theme-browser .theme.active .theme-name span {
font-weight: 600;
}
.theme-browser .theme.active .theme-actions {
background: rgba(49,49,49,0.7);
border-right: none;
opacity: 1;
}
.theme-browser .theme.active .theme-actions .button-primary {
margin-left: 0;
}
.theme-browser .theme .theme-author {
background: #222;
color: #eee;
display: none;
font-size: 14px;
margin: 0 10px;
padding: 5px 10px;
position: absolute;
bottom: 56px;
}
.theme-browser .theme.display-author .theme-author {
display: block;
}
.theme-browser .theme.display-author .theme-author a {
color: inherit;
text-decoration: none;
}
/**
* Add new theme
*/
.theme-browser .theme.add-new-theme {
border: none;
-webkit-box-shadow: none;
box-shadow: none;
}
.theme-browser .theme.add-new-theme a {
color: #999;
text-decoration: none;
display: block;
position: relative;
z-index: 1;
}
.theme-browser .theme.add-new-theme:after {
display: block;
content: '';
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
opacity: 1;
background: transparent;
background: rgba(0, 0, 0, 0);
position: absolute;
top: 0;
right: 0;
left: 0;
bottom: 0;
padding: 10% 0 0 0;
text-shadow: none;
border: 5px dashed #d5d2ca;
border: 5px dashed rgba(0, 0, 0, 0.1);
-webkit-transition: opacity 0.2s ease-in-out;
transition: opacity 0.2s ease-in-out;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.theme-browser .theme.add-new-theme span:after {
background: #e5e5e5;
background: rgba(153, 153, 153, 0.1);
-webkit-border-radius: 50%;
border-radius: 50%;
display: inline-block;
content: '\f132';
-webkit-font-smoothing: antialiased;
font: normal 74px/115px 'dashicons';
width: 100px;
height: 100px;
vertical-align: middle;
text-align: center;
color: rgb(153, 153, 153);
position: absolute;
top: 30%;
right: 50%;
margin-right: -50px;
text-indent: -4px;
padding: 0;
text-shadow: none;
z-index:4;
}
.rtl .theme-browser .theme.add-new-theme span:after {
text-indent: 4px;
}
.theme-browser .theme.add-new-theme:hover .theme-screenshot,
.theme-browser .theme.add-new-theme:focus .theme-screenshot {
background: none;
}
.theme-browser .theme.add-new-theme:hover span:after,
.theme-browser .theme.add-new-theme:focus span:after {
background: #fff;
color: #0074a2;
}
.theme-browser .theme.add-new-theme:hover:after,
.theme-browser .theme.add-new-theme:focus:after {
border-color: transparent;
color: #fff;
background: #0074a2;
content: '';
}
.theme-browser .theme.add-new-theme .theme-name {
background: none;
text-align: center;
-webkit-box-shadow: none;
box-shadow: none;
font-weight: 400;
position: relative;
top: 0;
margin-top: -10%;
margin-bottom: 10%;
}
.theme-browser .theme.add-new-theme:hover .theme-name,
.theme-browser .theme.add-new-theme:focus .theme-name {
color: #fff;
z-index: 2;
}
/*
* The search form
*/
.themes-php .theme-search {
position: relative;
top: -2px;
right: 20px;
font-size: 16px;
font-weight: 300;
line-height: 1.5;
width: 280px;
}
/**
* Theme Overlay
* Shown when clicking a theme
*/
.theme-overlay .theme-backdrop {
position: absolute;
right: -20px;
left: 0;
top: 0;
bottom: 0;
background: #f1f1f1;
background: rgba( 238, 238, 238, 0.9 );
z-index: 10;
}
body.theme-overlay-open {
overflow: hidden;
}
.theme-overlay .theme-header {
position: absolute;
top: 0;
right: 0;
left: 0;
height: 48px;
border-bottom: 1px solid #ddd;
}
.theme-overlay .theme-header .close {
cursor: pointer;
height: 48px;
width: 50px;
text-align: center;
float: left;
border: 0;
border-right: 1px solid #ddd;
background-color: transparent;
}
.theme-overlay .theme-header .close:hover:before,
.theme-overlay .theme-header .close:focus:before {
color: #fff;
}
.theme-overlay .theme-header .close:before {
font: normal 30px/50px 'dashicons' !important;
color: #777;
display: inline-block;
content: '\f335';
font-weight: 300;
}
/* Left and right navigation */
.theme-overlay .theme-header .right,
.theme-overlay .theme-header .left {
cursor: pointer;
color: #777;
background-color: transparent;
height: 48px;
width: 54px;
float: right;
text-align: center;
border: 0;
border-left: 1px solid #ddd;
}
.theme-overlay .theme-header .close:hover,
.theme-overlay .theme-header .right:hover,
.theme-overlay .theme-header .left:hover,
.theme-overlay .theme-header .close:focus,
.theme-overlay .theme-header .right:focus,
.theme-overlay .theme-header .left:focus {
background: #0074a2;
color: #fff;
}
.theme-overlay .theme-header .left.disabled,
.theme-overlay .theme-header .right.disabled,
.theme-overlay .theme-header .left.disabled:hover,
.theme-overlay .theme-header .right.disabled:hover {
color: #ccc;
background: inherit;
cursor: inherit;
}
.theme-overlay .theme-header .right:before,
.theme-overlay .theme-header .left:before {
font: normal 20px/50px 'dashicons' !important;
display: inline;
font-weight: 300;
}
.theme-overlay .theme-header .left:before {
content: '\f340';
}
.theme-overlay .theme-header .right:before {
content: '\f344';
}
.rtl .theme-overlay .theme-header .left:before {
content: '\f345';
}
.rtl .theme-overlay .theme-header .right:before {
content: '\f341';
}
.theme-overlay .theme-wrap {
clear: both;
position: fixed;
top: 9%;
right: 190px;
left: 30px;
bottom: 3%;
background: #fff;
-webkit-box-shadow: 0 1px 20px 5px rgba(0, 0, 0, 0.1);
box-shadow: 0 1px 20px 5px rgba(0, 0, 0, 0.1);
z-index: 20;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.theme-overlay .theme-wrap:after {
content: ".";
display: block;
height: 0;
clear: both;
visibility: hidden;
}
body.folded .theme-overlay .theme-wrap {
right: 70px;
}
.theme-overlay .theme-about {
position: absolute;
top: 49px;
bottom: 57px;
right: 0;
left: 0;
overflow: auto;
padding: 2% 4%;
}
.theme-overlay .theme-about:after {
content: ".";
display: block;
height: 0;
clear: both;
visibility: hidden;
}
.theme-overlay .theme-actions {
position: absolute;
text-align: center;
bottom: 0;
right: 0;
left: 0;
padding: 10px 25px 5px;
background: #f3f3f3;
z-index: 30;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
border-top: 1px solid #eee;
}
.ie8 .theme-overlay .theme-actions {
border: 1px solid #eee;
}
.theme-overlay .theme-actions a {
margin-left: 5px;
margin-bottom: 5px;
}
.theme-overlay .theme-actions .delete-theme {
color: #a00;
position: absolute;
left: 10px;
bottom: 5px;
text-decoration: none;
border-color: transparent;
-webkit-box-shadow: none;
box-shadow: none;
background: transparent;
}
.theme-overlay .theme-actions .delete-theme:hover,
.theme-overlay .theme-actions .delete-theme:focus {
background: #d54e21;
color: #fff;
border-color: #d54e21;
}
.theme-overlay .theme-actions .active-theme,
.theme-overlay.active .theme-actions .inactive-theme {
display: none;
}
.theme-overlay .theme-actions .inactive-theme,
.theme-overlay.active .theme-actions .active-theme {
display: block;
}
/**
* Theme Screenshots gallery
*/
.theme-overlay .theme-screenshots {
float: right;
margin: 0 0 0 30px;
width: 55%;
max-width: 880px;
text-align: center;
}
/* First screenshot, shown big */
.theme-overlay .screenshot {
border: 1px solid #fff;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
overflow: hidden;
position: relative;
-webkit-box-shadow: 0 0 0 1px rgba(0,0,0,0.2);
box-shadow: 0 0 0 1px rgba(0,0,0,0.2);
}
.theme-overlay .screenshot:after {
content: '';
display: block;
padding-top: 75%; /* using a 4/3 aspect ratio */
}
.theme-overlay .screenshot img {
height: auto;
position: absolute;
right: 0;
top: 0;
width: 100%;
}
/* Handles old 300px screenshots */
.theme-overlay.small-screenshot .theme-screenshots {
position: absolute;
width: 302px;
}
.theme-overlay.small-screenshot .theme-info {
margin-right: 350px;
width: auto;
}
/* Other screenshots, shown small and square */
.theme-overlay .screenshot.thumb {
background: #ccc;
border: 1px solid #eee;
float: none;
display: inline-block;
margin: 10px 5px 0;
width: 140px;
height: 80px;
cursor: pointer;
}
.theme-overlay .screenshot.thumb:after {
content: '';
display: block;
padding-top: 100%; /* using a 1/1 aspect ratio */
}
.theme-overlay .screenshot.thumb img {
cursor: pointer;
height: auto;
position: absolute;
right: 0;
top: 0;
width: 100%;
height: auto;
}
.theme-overlay .screenshot.selected {
background: transparent;
border: 2px solid #2ea2cc;
}
.theme-overlay .screenshot.selected img {
opacity: 0.8;
}
/* No screenshot placeholder */
.theme-browser .theme .theme-screenshot.blank,
.theme-overlay .screenshot.blank {
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAALElEQVQYGWO8d+/efwYkoKioiMRjYGBC4WHhUK6A8T8QIJt8//59ZC493AAAQssKpBK4F5AAAAAASUVORK5CYII=);
}
/**
* Theme heading information
*/
.theme-overlay .theme-info {
width: 40%;
float: right;
}
.theme-overlay .current-label {
background: #333;
color: #fff;
font-size: 11px;
display: inline-block;
padding: 2px 8px;
-webkit-border-radius: 2px;
border-radius: 2px;
margin: 0 0 -10px;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.theme-overlay .theme-name {
color: #222;
font-size: 32px;
font-weight: 100;
margin: 10px 0 0;
line-height: 1.3;
}
.theme-overlay .theme-version {
color: #999;
font-size: 13px;
font-weight: 400;
float: none;
display: inline-block;
margin-right: 10px;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.theme-overlay .theme-author {
color: #686868;
font-size: 16px;
font-weight: 400;
margin: 15px 0 25px;
}
.theme-overlay .theme-author a {
text-decoration: none;
}
.theme-overlay .theme-description {
color: #555;
font-size: 15px;
font-weight: 400;
line-height: 1.5;
margin: 30px 0 0 0;
}
.theme-overlay .theme-tags {
border-top: 3px solid #eee;
color: #888;
font-size: 13px;
font-weight: 400;
margin: 30px 0 0 0;
padding-top: 20px;
}
.theme-overlay .theme-tags span {
color: #444;
font-weight: bold;
margin-left: 5px;
}
/* Theme Updates info */
.theme-overlay .theme-update-message {
background: #fef7f1;
border: 1px solid #eee;
border-right: 4px solid #d54e21;
-webkit-border-radius: 3px;
border-radius: 3px;
padding: 5px 20px 10px;
}
.theme-overlay .theme-update {
color: #222;
font-size: 18px;
display: inline-block;
line-height: 40px;
margin: 0;
}
.theme-overlay .parent-theme {
background: #f7fcfe;
border: 1px solid #eee;
border-right: 4px solid #2ea2cc;
font-size: 14px;
font-weight: normal;
margin-top: 30px;
padding: 10px 20px 10px 10px;
}
.theme-overlay .parent-theme strong {
font-weight: 700;
}
/**
* Single Theme Mode
* Displays detailed view inline when a user has no switch capabilities
*/
.single-theme .theme-overlay .theme-backdrop,
.single-theme .theme-overlay .theme-header,
.single-theme .theme {
display: none;
}
.single-theme .theme-overlay .theme-wrap {
clear: both;
min-height: 330px;
position: relative;
right: auto;
left: auto;
top: auto;
bottom: auto;
}
.single-theme .theme-overlay .theme-about {
padding: 30px 30px 70px;
position: static;
}
.single-theme .theme-overlay .theme-actions {
position: absolute;
}
/**
* Basic Responsive structure...
*
* Shuffles theme columns around based on screen width
*/
@media only screen and (min-width: 2000px) {
#wpwrap .theme-browser .theme {
width: 17.6%;
margin: 0 0 3% 3%;
}
#wpwrap .theme-browser .theme:nth-child(3n),
#wpwrap .theme-browser .theme:nth-child(4n) {
margin-left: 3%;
}
#wpwrap .theme-browser .theme:nth-child(5n) {
margin-left: 0;
}
}
@media only screen and (min-width: 1680px) {
.theme-overlay .theme-wrap {
width: 1450px;
margin: 0 auto;
}
}
/* Maximum screenshot width reaches 440px */
@media only screen and (min-width: 1640px) {
.theme-browser .theme {
width: 22.7%;
margin: 0 0 3% 3%;
}
.theme-browser .theme .theme-screenshot:after {
padding-top: 75%; /* using a 4/3 aspect ratio */
}
.theme-browser .theme:nth-child(3n) {
margin-left: 3%;
}
.theme-browser .theme:nth-child(4n) {
margin-left: 0;
}
}
/* Maximum screenshot width reaches 440px */
@media only screen and (max-width: 1120px) {
.theme-browser .theme {
width: 47.5%;
margin-left: 0;
}
.theme-browser .theme:nth-child(even) {
margin-left: 0;
}
.theme-browser .theme:nth-child(odd) {
margin-left: 5%;
}
}
/* Admin menu is folded */
@media only screen and (max-width: 900px) {
.theme-overlay .theme-wrap {
right: 65px;
}
}
@media only screen and (max-width: 780px) {
body.folded .theme-overlay .theme-wrap,
.theme-overlay .theme-wrap {
top: 0; /* The adminmenu isn't fixed on mobile, so this can use the full viewport height */
left: 0;
bottom: 0;
right: 0;
padding: 70px 20px 20px;
border: none;
z-index: 500; /* should overlap #wpadminbar, which is 500 on mobile. */
position: fixed;
}
.theme-browser .theme.active .theme-name span {
/* Hide the "Active: " label on smaller screens. */
display: none;
}
.theme-overlay .theme-screenshots {
width: 40%;
}
.theme-overlay .theme-info {
width: 50%;
}
.single-theme .theme-wrap {
padding: 10px;
}
.theme-browser .theme .theme-actions {
padding: 5px 10px 4px 10px;
}
.theme-overlay.small-screenshot .theme-screenshots {
position: static;
float: none;
max-width: 302px;
}
.theme-overlay.small-screenshot .theme-info {
margin-right: 0;
width: auto;
}
.theme:not(.active):hover .theme-actions,
.theme:not(.active):focus .theme-actions,
.theme:hover .more-details,
.theme:focus .more-details {
display: none;
}
.theme-browser.rendered .theme:hover .theme-screenshot img,
.theme-browser.rendered .theme:focus .theme-screenshot img {
opacity: 1.0;
}
}
@media only screen and (max-width: 480px) {
.theme-browser .theme {
width: 100%;
margin-left: 0;
}
.theme-browser .theme:nth-child(2n),
.theme-browser .theme:nth-child(3n) {
margin-left: 0;
}
}
@media only screen and (max-width: 650px) {
.theme-overlay .theme-update,
.theme-overlay .theme-description {
margin-right: 0;
}
.theme-overlay .theme-actions .delete-theme {
position: relative;
left: auto;
bottom: auto;
}
.theme-overlay .theme-actions .inactive-theme {
display: inline;
}
.theme-overlay .theme-screenshots {
width: 100%;
float: none;
}
.theme-overlay .theme-info {
width: 100%;
}
.theme-overlay .theme-author {
margin: 5px 0 15px 0;
}
.theme-overlay .current-label {
margin-top: 10px;
font-size: 13px;
}
.themes-php .wrap h2 {
width: 100%;
}
.themes-php .theme-search {
float: none;
clear: both;
right: 0;
top: 0;
left: 0;
margin: 10px 0;
width: 100%;
}
.theme-browser .theme.add-new-theme span:after {
font: normal 60px/90px 'dashicons';
width: 80px;
height: 80px;
top: 30%;
right: 50%;
text-indent: 0;
margin-right: -40px;
}
.single-theme .theme-wrap {
margin: 0 -10px 0 -12px;
padding: 10px;
}
.single-theme .theme-overlay .theme-about {
padding: 10px;
overflow: visible;
}
.single-theme .current-label {
display: none;
}
.single-theme .theme-overlay .theme-actions {
position: static;
}
}
.broken-themes {
clear: both;
}
.broken-themes table {
text-align: right;
width: 50%;
border-spacing: 3px;
padding: 3px;
}
/*------------------------------------------------------------------------------
16.2 - Install Themes
------------------------------------------------------------------------------*/
/* Already installed theme */
.theme-browser .theme .theme-installed {
background: #0074a2;
}
.theme-browser .theme .theme-installed:before {
content: '\f147';
}
.theme-browser .theme.is-installed .theme-actions .button-primary {
display: none !important;
}
.theme-navigation {
background: #fff;
-webkit-box-shadow: 0 1px 1px 0 rgba(0,0,0,.1);
box-shadow: 0 1px 1px 0 rgba(0,0,0,.1);
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
color: #555;
display: inline-block;
font-size: 13px;
margin: 20px 0 30px;
padding: 0 20px;
position: relative;
width: 100%;
}
.theme-install-php a.upload,
.theme-install-php a.browse-themes {
cursor: pointer;
}
.theme-install-php a.browse-themes,
.theme-install-php.show-upload-theme a.upload {
display: none;
}
.theme-install-php.show-upload-theme a.browse-themes {
display: inline;
}
.upload-theme {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
display: none;
margin: 0px 0 0;
padding: 0;
width: 100%;
overflow: hidden;
position: relative;
top: 10px;
}
body.show-upload-theme .upload-theme {
display: block;
}
.upload-theme .wp-upload-form {
background: #fafafa;
border: 1px solid #e5e5e5;
padding: 30px;
margin: 30px auto;
max-width: 380px;
}
.upload-theme .install-help {
color: #999;
font-size: 18px;
font-style: normal;
margin: 0;
padding: 40px 0 0;
text-align: center;
}
body.show-upload-theme .upload-theme + .theme-navigation,
body.show-upload-theme .upload-theme + .theme-navigation + .theme-browser {
display: none;
}
.theme-navigation .theme-count {
margin-right: 0;
position: absolute;
top: 12px;
}
.theme-count + .theme-section {
margin-right: 60px;
}
.theme-section,
.theme-filter {
border-bottom: 4px solid #fff;
color: #666;
cursor: pointer;
display: inline-block;
margin: 0 10px;
padding: 15px 0;
}
.theme-section.current,
.theme-filter.current {
border-bottom: 4px solid #666;
color: #222;
}
.theme-top-filters {
display: inline-block;
}
.theme-navigation .more-filters {
color: #666;
cursor: pointer;
display: inline-block;
margin: 0 10px;
padding: 4px 6px;
}
body.more-filters-opened .more-filters,
body.more-filters-opened .more-filters:before {
background: #777;
-webkit-border-radius: 2px;
border-radius: 2px;
border: none;
color: #fff;
}
body.more-filters-opened .more-filters:hover,
body.more-filters-opened .more-filters:focus,
body.more-filters-opened .more-filters:hover:before,
body.more-filters-opened .more-filters:focus:before {
background: rgb(46, 162, 204);
}
.theme-install-php .theme-search {
position: absolute;
left: 10px;
top: 9px;
font-size: 16px;
font-weight: 300;
line-height: 1.5;
width: 280px;
}
.more-filters:before {
color: #777;
text-align: center;
margin: 0 0 0 5px;
content: "\f111";
display: inline-block;
width: 16px;
height: 16px;
-webkit-font-smoothing: antialiased;
font-size: 16px;
line-height: 1;
font-family: "dashicons";
text-decoration: inherit;
font-weight: normal;
font-style: normal;
vertical-align: top;
-webkit-transition: color .1s ease-in 0;
transition: color .1s ease-in 0;
text-align: center;
}
.more-filters.current:before {
color: #fff;
}
.more-filters-container {
display: none;
padding: 20px;
border-top: 1px solid #eee;
margin: 0 -20px;
background: #fafafa;
}
body.more-filters-opened .more-filters-container {
display: block;
overflow: hidden;
}
body.more-filters-opened .theme-section.current {
border-bottom: none;
}
body.more-filters-opened .theme-browser,
body.more-filters-opened.filters-applied.loading-themes .theme-browser {
display: none;
}
body.more-filters-opened.filters-applied .theme-browser {
display: block;
}
.more-filters-container .filters-group {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
float: right;
width: 19%;
background: #fff;
margin: 0 0 0 1%;
border: 1px solid #e5e5e5;
-webkit-box-shadow: 0 1px 1px rgba(0,0,0,0.04);
box-shadow: 0 1px 1px rgba(0,0,0,0.04);
padding: 10px;
}
.more-filters-container .wide-filters-group {
width: 38%;
}
.more-filters-container .feature-name {
margin: 0;
position: relative;
}
.more-filters-container ol {
list-style-type: none;
margin: 20px 0 0;
font-size: 12px;
}
.more-filters-container li {
display: inline-block;
vertical-align: top;
list-style-type: none;
margin: 5px 0;
padding-left: 25px;
width: 160px;
}
.theme-navigation .more-filters-container .apply-filters {
margin: 0 0 20px;
}
.theme-navigation .more-filters-container .clear-filters {
display: none;
margin: 0 10px 20px 0;
}
.more-filters-container .apply-filters span {
display: inline-block;
font-size: 12px;
text-indent: 10px;
opacity: 0.8;
}
.more-filters-container .filtering-by {
display: none;
margin: 0;
}
.more-filters-container .filtering-by > span {
font-weight: 600;
}
.more-filters-container .filtering-by .tags {
display: inline;
}
.more-filters-container .filtering-by .tag {
background: #fff;
border: 1px solid #e5e5e5;
-webkit-box-shadow: 0 1px 1px rgba(0,0,0,0.04);
box-shadow: 0 1px 1px rgba(0,0,0,0.04);
font-size: 11px;
margin: 0 5px;
padding: 4px 8px;
}
.more-filters-container .filtering-by a {
margin-right: 10px;
}
body.filters-applied .more-filters-container .filters-group,
body.filters-applied .more-filters-container a.button,
body.filters-applied .more-filters-container br {
display: none !important;
}
body.filters-applied .more-filters-container .filtering-by {
display: block;
}
body.filters-applied .more-filters-container {
padding: 20px;
}
p.no-themes {
color: #999;
font-size: 18px;
font-style: normal;
margin: 0;
padding: 0;
text-align: center;
display: none;
}
body.no-results p.no-themes {
display: block;
}
body.show-upload-theme p.no-themes {
display: none !important;
}
.theme-install-php .add-new-theme {
display: none !important;
}
@media only screen and (max-width: 1120px) {
.theme-install-php .theme-search {
margin: 20px 0;
position: static;
width: 100%;
}
.more-filters-container {
border-bottom: 1px solid #eee;
}
.upload-theme .wp-upload-form {
margin: 20px 0;
max-width: 100%;
}
.upload-theme .install-help {
font-size: 15px;
padding: 20px 0 0;
text-align: right;
}
.more-filters-container .filters-group {
margin-bottom: 0;
margin-top: 5px;
width: 100%;
}
.more-filters-container .filters-group li {
margin: 10px 0;
}
}
@media only screen and (max-width: 782px) {
.more-filters-container .filters-group {
width: 100%;
}
.more-filters-container .filters-group li {
width: 100%;
}
}
.rating {
margin: 30px 0;
}
.rating span:before {
color: #e6b800;
content: "\f154";
display: inline-block;
-webkit-font-smoothing: antialiased;
font: normal 20px/1 'dashicons';
vertical-align: top;
}
/* Half stars */
.rating-10 span.one:before,
.rating-30 span.two:before,
.rating-50 span.three:before,
.rating-70 span.four:before,
.rating-90 span.five:before {
content: "\f459";
}
/* Full stars */
.rating-20 span.one:before {
content: "\f155";
}
.rating-30 span.one:before,
.rating-40 span.one:before,
.rating-40 span.two:before {
content: "\f155";
}
.rating-50 span.one:before,
.rating-50 span.two:before,
.rating-60 span.one:before,
.rating-60 span.two:before,
.rating-60 span.three:before {
content: "\f155";
}
.rating-70 span.one:before,
.rating-70 span.two:before,
.rating-70 span.three:before,
.rating-80 span.one:before,
.rating-80 span.two:before,
.rating-80 span.three:before,
.rating-80 span.four:before {
content: "\f155";
}
.rating-90 span.one:before,
.rating-90 span.two:before,
.rating-90 span.three:before,
.rating-90 span.four:before,
.rating-100 span.one:before,
.rating-100 span.two:before,
.rating-100 span.three:before,
.rating-100 span.four:before,
.rating-100 span.five:before {
content: "\f155";
}
.rating .ratings {
display: inline;
margin-right: 10px;
line-height: 20px;
color: #999;
}
.loading-themes .theme-browser,
.error .theme-browser {
display: none;
}
.loading-themes .spinner {
display: block;
margin: 40px auto 0;
float: none;
}
/*------------------------------------------------------------------------------
16.3 - Custom Header Screen
------------------------------------------------------------------------------*/
.appearance_page_custom-header #headimg {
border: 1px solid #DFDFDF;
overflow: hidden;
width: 100%;
}
.appearance_page_custom-header #upload-form p label {
font-size: 12px;
}
.appearance_page_custom-header .available-headers .default-header {
float: right;
margin: 0 0 20px 20px;
}
.appearance_page_custom-header .random-header {
clear: both;
margin: 0 0 20px 20px;
vertical-align: middle;
}
.appearance_page_custom-header .available-headers label input,
.appearance_page_custom-header .random-header label input {
margin-left: 10px;
}
.appearance_page_custom-header .available-headers label img {
vertical-align: middle;
}
/*------------------------------------------------------------------------------
16.4 - Custom Background Screen
------------------------------------------------------------------------------*/
div#custom-background-image {
min-height: 100px;
border: 1px solid #dfdfdf;
}
div#custom-background-image img {
max-width: 400px;
max-height: 300px;
}
/*------------------------------------------------------------------------------
23.0 - Full Overlay w/ Sidebar
------------------------------------------------------------------------------*/
body.full-overlay-active {
overflow: hidden;
}
.wp-full-overlay {
background: transparent;
z-index: 500000;
position: fixed;
overflow: visible;
top: 0;
bottom: 0;
right: 0;
left: 0;
height: 100%;
min-width: 0;
}
.wp-full-overlay-sidebar {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
position: fixed;
width: 300px;
height: 100%;
top: 0;
bottom: 0;
right: 0;
padding: 0;
margin: 0;
z-index: 10;
overflow: auto;
background: #eee;
border-left: none;
}
.wp-full-overlay.collapsed .wp-full-overlay-sidebar {
overflow: visible;
}
.wp-full-overlay.collapsed,
.wp-full-overlay.expanded .wp-full-overlay-sidebar {
margin-right: 0 !important;
}
.wp-full-overlay.expanded {
margin-right: 300px;
}
.wp-full-overlay.collapsed .wp-full-overlay-sidebar {
margin-right: -300px;
}
.wp-full-overlay-sidebar:after {
content: '';
display: block;
position: absolute;
top: 0;
bottom: 0;
left: 0;
width: 3px;
z-index: 1000;
}
.wp-full-overlay-main {
position: absolute;
right: 0;
left: 0;
top: 0;
bottom: 0;
height: 100%;
}
.wp-full-overlay-sidebar .wp-full-overlay-header {
position: absolute;
right: 0;
left: 0;
height: 45px;
padding: 0 15px;
line-height: 45px;
z-index: 10;
margin: 0;
border-top: none;
-webkit-box-shadow: none;
box-shadow: none;
}
.wp-full-overlay-sidebar .wp-full-overlay-header a.back {
margin-top: 9px;
}
.wp-full-overlay-sidebar .wp-full-overlay-footer {
bottom: 0;
border-bottom: none;
border-top: none;
-webkit-box-shadow: none;
box-shadow: none;
}
.wp-full-overlay-sidebar .wp-full-overlay-sidebar-content {
position: absolute;
top: 45px;
bottom: 45px;
right: 0;
left: 0;
overflow: auto;
}
/* Close Link */
.wp-full-overlay .close-full-overlay {
text-decoration: none;
}
/* Collapse Button */
.wp-full-overlay a.collapse-sidebar {
position: absolute;
bottom: 12px;
right: 0;
z-index: 50;
display: block;
width: 19px;
height: 19px;
margin-right: 15px;
padding: 0;
-webkit-border-radius: 50%;
border-radius: 50%;
color: #777;
text-decoration: none;
}
.wp-full-overlay a.collapse-sidebar:hover {
color: #0074a2;
}
.wp-full-overlay.collapsed .collapse-sidebar {
position: absolute;
right: 100%;
}
.wp-full-overlay .collapse-sidebar-arrow {
position: static;
margin-top: 0;
margin-right: 0;
display: block;
width: auto;
height: auto;
background: none;
}
.wp-full-overlay .collapse-sidebar-arrow:before {
-webkit-border-radius: 50%;
border-radius: 50%;
float: right;
content: "\f148";
background: #eee;
font: normal 20px/1 'dashicons';
speak: none;
display: block;
padding: 0;
text-indent: 0;
text-align: center;
position: relative;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-decoration: none !important;
}
.wp-full-overlay.collapsed .collapse-sidebar-arrow:before,
.rtl .wp-full-overlay .collapse-sidebar-arrow:before {
-webkit-transform: rotate(180deg);
-ms-transform: rotate(180deg);
transform: rotate(180deg);
}
.rtl .wp-full-overlay.collapsed .collapse-sidebar-arrow:before {
-webkit-transform: none;
-ms-transform: none;
transform: none;
}
.wp-full-overlay.collapsed .collapse-sidebar-arrow {
background-position: -1px -109px;
}
.wp-full-overlay .collapse-sidebar-label {
position: absolute;
right: 100%;
line-height: 20px;
margin-right: 10px;
}
.wp-full-overlay.collapsed .collapse-sidebar-label {
display: none;
}
.wp-full-overlay .theme-navigation {
padding: 10px 20px;
position: absolute;
bottom: 10px;
text-align: right;
}
.wp-full-overlay .theme-navigation .next-theme {
float: left;
}
.wp-full-overlay.no-navigation .theme-navigation {
display: none;
}
/* Animations */
.wp-full-overlay,
.wp-full-overlay-sidebar,
.wp-full-overlay .collapse-sidebar,
.wp-full-overlay-main {
-webkit-transition-property: right, left, top, bottom, width, margin;
transition-property: right, left, top, bottom, width, margin;
-webkit-transition-duration: 0.2s;
transition-duration: 0.2s;
}
/*------------------------------------------------------------------------------
24.0 - Customize Loader
------------------------------------------------------------------------------*/
.no-customize-support .hide-if-no-customize,
.customize-support .hide-if-customize,
.no-customize-support.wp-core-ui .hide-if-no-customize,
.no-customize-support .wp-core-ui .hide-if-no-customize,
.customize-support.wp-core-ui .hide-if-customize,
.customize-support .wp-core-ui .hide-if-customize {
display: none;
}
#customize-container {
display: none;
background: #fff;
z-index: 500000;
position: fixed;
overflow: visible;
top: 0;
bottom: 0;
right: 0;
left: 0;
height: 100%;
}
.customize-active #customize-container {
display: block;
}
.customize-loading #customize-container iframe {
opacity: 0;
}
.customize-loading #customize-container {
background: #fff url(../images/spinner.gif) no-repeat fixed center center;
-webkit-background-size: 20px 20px;
background-size: 20px 20px;
}
#customize-container iframe,
.theme-install-overlay iframe {
height: 100%;
width: 100%;
z-index: 20;
-webkit-transition: opacity 0.3s;
transition: opacity 0.3s;
}
#customize-container .collapse-sidebar {
bottom: 16px;
}
#customize-controls {
margin-top: 0;
}
.theme-install-overlay {
display: none;
}
.theme-install-overlay.single-theme {
display: block;
}
.install-theme-info {
display: none;
padding: 10px 20px 60px;
}
.single-theme .install-theme-info {
padding-top: 15px;
}
.theme-install-overlay .install-theme-info {
display: block;
}
.install-theme-info .theme-install {
float: left;
margin-top: 18px;
}
.install-theme-info .theme-name {
font-size: 16px;
line-height: 24px;
margin-bottom: 0;
margin-top: 0;
}
.install-theme-info .theme-screenshot {
margin-top: 15px;
width: 258px;
border: 1px solid #ccc;
}
.install-theme-info .theme-details {
overflow: hidden;
}
.theme-details .theme-version {
margin: 15px 0;
float: right;
}
.theme-details .star-rating {
margin: 7px 0;
float: left;
}
.theme-details .theme-description {
float: right;
color: #777;
line-height: 20px;
max-width: 100%;
}
.theme-install-overlay .wp-full-overlay-header {
margin-top: 9px;
}
.theme-install-overlay .wp-full-overlay-header .theme-install {
float: left;
/* For when .theme-install is a span rather than a.button-primary (already installed theme) */
line-height: 26px;
}
.theme-install-overlay .wp-full-overlay-sidebar {
background: #EEE;
border-left: 1px solid #DDD;
}
.theme-install-overlay .wp-full-overlay-main {
background: #fff url(../images/spinner.gif) no-repeat center center;
-webkit-background-size: 20px 20px;
background-size: 20px 20px;
}
/* =Media Queries
-------------------------------------------------------------- */
/**
* HiDPI Displays
*/
@media print,
(-o-min-device-pixel-ratio: 5/4),
(-webkit-min-device-pixel-ratio: 1.25),
(min-resolution: 120dpi) {
.wp-full-overlay .collapse-sidebar-arrow {
background-image: url(../images/arrows-2x.png);
-webkit-background-size: 15px 123px;
background-size: 15px 123px;
}
.customize-loading #customize-container,
.theme-install-overlay .wp-full-overlay-main {
background-image: url(../images/spinner-2x.gif);
}
}
@media screen and ( max-width: 782px ) {
.available-theme .action-links .delete-theme {
float: none;
margin: 0;
padding: 0;
clear: both;
}
.available-theme .action-links .delete-theme a {
padding: 0;
}
}
| 01-wordpress-paypal | trunk/wp-admin/css/themes-rtl.css | CSS | gpl3 | 38,516 |
/* 2 column liquid layout */
#wpwrap {
height: auto;
min-height: 100%;
width: 100%;
position: relative;
-webkit-font-smoothing: subpixel-antialiased;
}
#wpcontent {
height: 100%;
}
#wpcontent,
#wpfooter {
margin-left: 180px;
}
.folded #wpcontent,
.folded #wpfooter {
margin-left: 56px;
}
#wpbody-content {
padding-bottom: 65px;
float: left;
width: 100%;
overflow: visible !important;
}
/* inner 2 column liquid layout */
.inner-sidebar {
float: right;
clear: right;
display: none;
width: 281px;
position: relative;
}
.columns-2 .inner-sidebar {
margin-right: auto;
width: 286px;
display: block;
}
.inner-sidebar #side-sortables,
.columns-2 .inner-sidebar #side-sortables {
min-height: 300px;
width: 280px;
padding: 0;
}
.has-right-sidebar .inner-sidebar {
display: block;
}
.has-right-sidebar #post-body {
float: left;
clear: left;
width: 100%;
margin-right: -2000px;
}
.has-right-sidebar #post-body-content {
margin-right: 300px;
float: none;
width: auto;
}
/* 2 columns main area */
#col-container,
#col-left,
#col-right {
overflow: hidden;
padding: 0;
margin: 0;
}
#col-left {
width: 35%;
}
#col-right {
float: right;
clear: right;
width: 65%;
}
.col-wrap {
padding: 0 7px;
}
/* utility classes */
.alignleft {
float: left;
}
.alignright {
float: right;
}
.textleft {
text-align: left;
}
.textright {
text-align: right;
}
.clear {
clear: both;
}
/* Hide visually but not from screen readers */
.screen-reader-text,
.screen-reader-text span,
.ui-helper-hidden-accessible {
position: absolute;
margin: -1px;
padding: 0;
height: 1px;
width: 1px;
overflow: hidden;
clip: rect(0 0 0 0);
border: 0;
}
.screen-reader-shortcut {
position: absolute;
top: -1000em;
}
.screen-reader-shortcut:focus {
left: 6px;
top: -25px;
height: auto;
width: auto;
display: block;
font-size: 14px;
font-weight: 600;
padding: 15px 23px 14px;
background: #f1f1f1;
color: #21759b;
z-index: 100000;
line-height: normal;
-webkit-box-shadow: 0 0 2px 2px rgba(0,0,0,.6);
box-shadow: 0 0 2px 2px rgba(0,0,0,.6);
text-decoration: none;
outline: none;
}
.hidden,
.js .closed .inside,
.js .hide-if-js,
.no-js .hide-if-no-js,
.js.wp-core-ui .hide-if-js,
.js .wp-core-ui .hide-if-js,
.no-js.wp-core-ui .hide-if-no-js,
.no-js .wp-core-ui .hide-if-no-js {
display: none;
}
/* @todo: Take a second look. Large chunks of shared color, from the colors.css merge */
.widget-top,
.menu-item-handle,
.widget-inside,
#menu-settings-column .accordion-container,
#menu-management .menu-edit,
.manage-menus,
table.widefat,
.stuffbox,
p.popular-tags,
.widgets-holder-wrap,
.wp-editor-container,
.popular-tags,
.feature-filter,
.imgedit-group {
border: 1px solid #e5e5e5;
-webkit-box-shadow: 0 1px 1px rgba(0,0,0,0.04);
box-shadow: 0 1px 1px rgba(0,0,0,0.04);
}
table.widefat,
.wp-editor-container,
.stuffbox,
p.popular-tags,
.widgets-holder-wrap,
.popular-tags,
.feature-filter,
.imgedit-group {
background: #fff;
}
/* general */
html,
body {
height: 100%;
margin: 0;
padding: 0;
}
html {
background: #f1f1f1;
}
body {
color: #444;
font-family: "Open Sans", sans-serif;
font-size: 13px;
line-height: 1.4em;
min-width: 600px;
}
body.iframe {
min-width: 0;
padding-top: 1px;
}
iframe,
img {
border: 0;
}
td {
font-family: inherit;
font-size: inherit;
font-weight: inherit;
line-height: inherit;
}
a {
color: #0074a2;
-webkit-transition-property: border, background, color;
transition-property: border, background, color;
-webkit-transition-duration: .05s;
transition-duration: .05s;
-webkit-transition-timing-function: ease-in-out;
transition-timing-function: ease-in-out;
}
a,
div {
outline: 0;
}
a:hover,
a:active {
color: #2ea2cc;
}
a:focus {
color: #124964;
}
a:focus,
a:active {
outline: thin dotted;
}
#adminmenu a:focus,
#adminmenu a:active,
.screen-reader-text:focus {
outline: none;
}
blockquote,
q {
quotes: none;
}
blockquote:before,
blockquote:after,
q:before,
q:after {
content: '';
content: none;
}
p {
font-size: 13px;
line-height: 1.5;
margin: 1em 0;
}
blockquote {
margin: 1em;
}
li,
dd {
margin-bottom: 6px;
}
h1,
h2,
h3,
h4,
h5,
h6 {
display: block;
font-weight: 600;
}
h1 {
font-size: 2em;
margin: .67em 0;
}
h2 {
color: #222;
font-size: 1.5em;
margin: .83em 0;
font-weight: 400;
}
h3 {
color: #222;
font-size: 1.3em;
margin: 1em 0;
}
h4 {
font-size: 1em;
margin: 1.33em 0;
}
h5 {
font-size: 0.83em;
margin: 1.67em 0;
}
h6 {
font-size: 0.67em;
margin: 2.33em 0;
}
ul,
ol {
padding: 0;
}
ul {
list-style: none;
}
ol {
list-style-type: decimal;
margin-left: 2em;
}
ul.ul-disc {
list-style: disc outside;
}
ul.ul-square {
list-style: square outside;
}
ol.ol-decimal {
list-style: decimal outside;
}
ul.ul-disc,
ul.ul-square,
ol.ol-decimal {
margin-left: 1.8em;
}
ul.ul-disc > li,
ul.ul-square > li,
ol.ol-decimal > li {
margin: 0 0 0.5em;
}
/* @noflip */
.ltr {
direction: ltr;
}
/* @noflip */
.code,
code {
font-family: Consolas, Monaco, monospace;
direction: ltr;
}
kbd,
code {
padding: 3px 5px 2px 5px;
margin: 0 1px;
background: #eaeaea;
background: rgba(0,0,0,0.07);
font-size: 13px;
}
.subsubsub {
list-style: none;
margin: 8px 0 0;
padding: 0;
font-size: 13px;
float: left;
color: #666;
}
.subsubsub a {
line-height: 2;
padding: .2em;
text-decoration: none;
}
.subsubsub a .count,
.subsubsub a.current .count {
color: #999;
font-weight: normal;
}
.subsubsub a.current {
font-weight: 600;
border: none;
}
.subsubsub li {
display: inline-block;
margin: 0;
padding: 0;
white-space: nowrap;
}
/* .widefat - main style for tables */
.widefat {
border-spacing: 0;
width: 100%;
clear: both;
margin: 0;
}
.widefat * {
word-wrap: break-word;
}
.widefat a {
text-decoration: none;
}
.widefat td,
.widefat th {
padding: 8px 10px;
}
.widefat thead th {
border-bottom: 1px solid #e1e1e1;
}
.widefat tfoot th {
border-top: 1px solid #e1e1e1;
border-bottom: none;
}
.widefat .no-items td {
border-bottom-width: 0;
}
.widefat td {
vertical-align: top;
}
.widefat td,
.widefat td p,
.widefat td ol,
.widefat td ul {
font-size: 13px;
line-height: 1.5em;
}
.widefat th {
text-align: left;
line-height: 1.3em;
font-size: 14px;
}
.widefat th input {
margin: 0 0 0 8px;
padding: 0;
vertical-align: text-top;
}
.widefat .check-column {
width: 2.2em;
padding: 6px 0 25px;
vertical-align: top;
}
.widefat th input[type=checkbox] {
margin-top: -1px;
}
.widefat tbody th.check-column {
padding: 9px 0 22px;
}
.widefat.media .check-column {
padding-top: 8px;
}
.widefat thead th.check-column,
.widefat tbody th.check-column,
.widefat tfoot th.check-column {
padding: 11px 0 0 3px;
}
.widefat thead th.check-column {
padding-top: 10px;
}
.update-php div.updated,
.update-php div.error {
margin-left: 0;
}
.no-js .widefat thead .check-column input,
.no-js .widefat tfoot .check-column input {
display: none;
}
.widefat .num,
.column-comments,
.column-links,
.column-posts {
text-align: center;
}
.widefat th#comments {
vertical-align: middle;
}
.wrap {
margin: 10px 20px 0 2px;
}
div.updated,
div.error {
padding: 0 0.6em;
margin: 5px 15px 2px;
}
div.updated p,
div.error p {
margin: 0.5em 0;
padding: 2px;
}
.wrap div.updated,
.wrap div.error,
.media-upload-form div.error {
margin: 5px 0 15px;
}
div.updated {
border-left: 4px solid #7ad03a;
padding: 1px 12px;
background-color: #fff;
-webkit-box-shadow: 0 1px 1px 0 rgba(0,0,0,0.1);
box-shadow: 0 1px 1px 0 rgba(0,0,0,0.1);
}
div.error {
border-left: 4px solid #dd3d36;
background: #fff;
-webkit-box-shadow: 0 1px 1px 0 rgba(0,0,0,0.1);
box-shadow: 0 1px 1px 0 rgba(0,0,0,0.1);
padding: 1px 12px;
}
.attention {
color: #2ea2cc;
}
.wrap h2,
.subtitle {
font-weight: normal;
margin: 0;
}
.wrap h2 {
font-size: 23px;
font-weight: 400;
padding: 9px 15px 4px 0;
line-height: 29px;
}
.subtitle {
color: #777;
font-size: 14px;
padding-left: 25px;
}
.wrap .add-new-h2,
.wrap .add-new-h2:active {
margin-left: 4px;
padding: 4px 8px;
position: relative;
top: -3px;
text-decoration: none;
border: none;
-webkit-border-radius: 2px;
border-radius: 2px;
background: #e0e0e0;
text-shadow: none;
font-weight: 600;
font-size: 13px;
}
.wrap .add-new-h2:hover {
background: #2ea2cc;
color: #fff;
}
.wrap h2.long-header {
padding-right: 0;
}
.wp-dialog {
background-color: #fff;
}
.widgets-chooser ul,
#widgets-left .widget-in-question .widget-top,
#available-widgets .widget-top:hover,
div#widgets-right .widget-top:hover,
#widgets-left .widget-top:hover {
border-color: #999;
-webkit-box-shadow: 0 1px 2px rgba(0,0,0,0.1);
box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
.sorthelper {
background-color: #ccf3fa;
}
.ac_match,
.subsubsub a.current {
color: #000;
}
.alternate,
.alt {
background-color: #f9f9f9;
}
.bar {
background-color: #e8e8e8;
border-right-color: #99d;
}
.media-upload-form label.form-help,
td.help {
color: #9a9a9a;
}
/* Helper classes for plugins to leverage the active WordPress color scheme */
.highlight {
background-color: #e4f2fd;
color: #000;
}
.wp-ui-primary {
color: #fff;
background-color: #333;
}
.wp-ui-text-primary {
color: #333;
}
.wp-ui-highlight {
color: white;
background-color: #1e8cbe;
}
.wp-ui-text-highlight {
color: #1e8cbe;
}
.wp-ui-notification {
color: #fff;
background-color: #d54e21;
}
.wp-ui-text-notification {
color: #d54e21;
}
.wp-ui-text-icon {
color: #999;
}
/*------------------------------------------------------------------------------
1.0 - Text Styles
------------------------------------------------------------------------------*/
.widget .widget-top,
.postbox h3,
.stuffbox h3,
.control-section .accordion-section-title,
h3.dashboard-widget-title,
h3.dashboard-widget-title span,
h3.dashboard-widget-title small,
.sidebar-name,
#nav-menu-header,
#nav-menu-footer,
.menu-item-handle,
.checkbox,
.side-info,
#your-profile #rich_editing,
.widefat thead th,
.widefat tfoot th {
line-height: 1.4em;
}
.widget .widget-top,
.menu-item-handle {
background: #fafafa;
color: #222;
}
.postbox h3,
#namediv h3,
#submitdiv h3 {
border-bottom: 1px solid #eee;
}
.quicktags,
.search {
background-color: #ccc;
color: #000;
font-size: 12px;
}
.icon32 {
display: none;
}
/* @todo can we combine these into a class or use an existing dashicon one? */
#welcome-panel.welcome-panel .welcome-panel-close::before,
.tagchecklist span a:before,
#bulk-titles div a:before {
background: none;
color: #bbb;
content: '\f153';
display: block !important;
font: normal 16px/1 'dashicons';
speak: none;
height: 20px;
margin: 2px 0;
text-align: center;
width: 20px;
-webkit-font-smoothing: antialiased !important;
}
#welcome-panel.welcome-panel .welcome-panel-close:hover:before,
.tagchecklist span a:hover:before,
#bulk-titles div a:hover:before {
color: #c00;
}
.key-labels label {
line-height: 24px;
}
strong, b {
font-weight: 600;
}
.pre {
/* https://developer.mozilla.org/en-US/docs/CSS/white-space */
white-space: pre-wrap; /* css-3 */
word-wrap: break-word; /* IE 5.5 - 7 */
}
.howto {
color: #666;
font-style: italic;
display: block;
}
p.install-help {
margin: 8px 0;
font-style: italic;
}
.no-break {
white-space: nowrap;
}
hr {
border: 0;
border-top: 1px solid #ddd;
border-bottom: 1px solid #fafafa;
}
.row-actions span.delete a,
.row-actions span.trash a,
.row-actions span.spam a,
.plugins a.delete,
#all-plugins-table .plugins a.delete,
#search-plugins-table .plugins a.delete,
.submitbox .submitdelete,
#media-items a.delete,
#media-items a.delete-permanently,
#nav-menu-footer .menu-delete {
color: #a00;
}
abbr.required,
.file-error,
.widget-control-remove:hover,
.row-actions .delete a:hover,
.row-actions .trash a:hover,
.row-actions .spam a:hover,
.plugins a.delete:hover,
#all-plugins-table .plugins a.delete:hover,
#search-plugins-table .plugins a.delete:hover,
.submitbox .submitdelete:hover,
#media-items a.delete:hover,
#media-items a.delete-permanently:hover,
#nav-menu-footer .menu-delete:hover {
color: #f00;
text-decoration: none;
border: none;
}
/*------------------------------------------------------------------------------
3.0 - Actions
------------------------------------------------------------------------------*/
#major-publishing-actions {
padding: 10px;
clear: both;
border-top: 1px solid #ddd;
background: #f5f5f5;
}
#delete-action {
line-height: 28px;
vertical-align: middle;
text-align: left;
float: left;
}
#publishing-action {
text-align: right;
float: right;
line-height: 23px;
}
#publishing-action .spinner {
float: left;
}
#misc-publishing-actions {
padding: 6px 0 0;
}
.misc-pub-section {
padding: 6px 10px 8px;
}
#minor-publishing-actions {
padding: 10px 10px 0 10px;
text-align: right;
}
#save-post {
float: left;
}
.preview {
float: right;
}
#sticky-span {
margin-left: 18px;
}
.side-info {
margin: 0;
padding: 4px;
font-size: 11px;
}
.side-info h5 {
padding-bottom: 7px;
font-size: 14px;
margin: 12px 2px 5px;
border-bottom: 1px solid #dadada;
}
.side-info ul {
margin: 0;
padding-left: 18px;
list-style: square;
color: #666;
}
.approve,
.unapproved .unapprove {
display: none;
}
.unapproved .approve,
.spam .approve,
.trash .approve {
display: inline;
}
td.action-links,
th.action-links {
text-align: right;
}
/*------------------------------------------------------------------------------
4.0 - Notifications
------------------------------------------------------------------------------*/
#update-nag,
.update-nag {
display: inline-block;
line-height: 19px;
padding: 11px 15px;
font-size: 14px;
text-align: left;
margin: 25px 20px 0 2px;
background-color: #fff;
border-left: 4px solid #ffba00;
-webkit-box-shadow: 0 1px 1px 0 rgba(0,0,0,0.1);
box-shadow: 0 1px 1px 0 rgba(0,0,0,0.1);
}
.update-message {
color: #000;
}
ul#dismissed-updates {
display: none;
}
form.upgrade {
margin-top: 8px;
}
form.upgrade .hint {
font-style: italic;
font-size: 85%;
margin: -0.5em 0 2em 0;
}
.update-php .spinner {
float: none;
margin: -4px 0;
}
#ajax-loading,
.ajax-loading,
.ajax-feedback,
.imgedit-wait-spin,
.list-ajax-loading { /* deprecated */
visibility: hidden;
}
#ajax-response.alignleft {
margin-left: 2em;
}
/* @todo: this does not need its own section anymore */
/*------------------------------------------------------------------------------
6.0 - Admin Header
------------------------------------------------------------------------------*/
#adminmenu a,
#sidemenu a,
#taglist a,
#catlist a {
text-decoration: none;
}
/*------------------------------------------------------------------------------
6.1 - Screen Options Tabs
------------------------------------------------------------------------------*/
#screen-options-wrap,
#contextual-help-wrap {
margin: 0;
padding: 8px 20px 12px;
position: relative;
}
#contextual-help-wrap {
overflow: auto;
margin-left: 0 !important;
}
#screen-meta .screen-reader-text {
visibility: hidden;
}
#screen-meta-links {
margin: 0 20px 0 0;
}
#screen-meta-links a {
padding: 3px 6px 3px 16px;
}
#screen-meta-links a:focus {
outline: none;
}
/* screen options and help tabs revert */
#screen-meta {
display: none;
margin: 0 20px -1px 0px;
position: relative;
background-color: #fff;
border: 1px solid #ddd;
border-top: none;
-webkit-box-shadow: 0 1px 0 rgba(0,0,0,.025);
box-shadow: 0 1px 0 rgba(0,0,0,.025);
}
#screen-options-link-wrap,
#contextual-help-link-wrap {
float: right;
height: 28px;
margin: 0 0 0 6px;
border: 1px solid #ddd;
border-top: none;
background: #fff;
-webkit-box-shadow: 0 1px 1px -1px rgba(0,0,0,0.1);
box-shadow: 0 1px 1px -1px rgba(0,0,0,0.1);
}
#screen-meta-links .screen-meta-toggle {
position: relative;
top: 0;
}
#screen-meta-links a {
color: #777;
}
#screen-meta-links a:hover,
#screen-meta-links a:active,
#screen-meta-links a:focus {
color: #333;
}
#screen-meta-links a:focus {
border-color: #aaa;
-webkit-box-shadow: 0 2px 3px rgba(0,0,0,0.15);
box-shadow: 0 2px 3px rgba(0,0,0,0.15);
}
#screen-meta-links a.show-settings {
display: block;
font-size: 13px;
height: 22px;
line-height: 22px;
text-decoration: none;
z-index: 1;
}
#screen-meta-links a:after {
right: 0;
content: '\f140';
font: normal 20px/1 'dashicons';
speak: none;
display: inline-block;
padding: 0 5px 0 0;
bottom: 2px;
position: relative;
vertical-align: bottom;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-decoration: none !important;
color: #bbb;
}
#screen-meta-links a.screen-meta-active:after {
content: '\f142';
}
#screen-meta-links a.show-settings:hover {
text-decoration: none;
}
/* end screen options and help tabs */
.toggle-arrow {
background-repeat: no-repeat;
background-position: top left;
background-color: transparent;
height: 22px;
line-height: 22px;
display: block;
}
.toggle-arrow-active {
background-position: bottom left;
}
#screen-options-wrap h5,
#contextual-help-wrap h5 {
margin: 8px 0;
font-size: 13px;
}
.metabox-prefs label {
display: inline-block;
padding-right: 15px;
line-height: 30px;
}
.metabox-prefs label input[type=checkbox] {
margin-top: -4px;
margin-right: 6px;
}
.metabox-prefs label input {
margin: 0 5px 0 2px;
}
.metabox-prefs .columns-prefs label input {
margin: 0 2px;
}
.metabox-prefs label a {
display: none;
}
/*------------------------------------------------------------------------------
6.2 - Help Menu
------------------------------------------------------------------------------*/
#contextual-help-wrap {
padding: 0;
}
#contextual-help-columns {
position: relative;
}
#contextual-help-back {
position: absolute;
top: 0;
bottom: 0;
left: 150px;
right: 170px;
border: 1px solid #e1e1e1;
border-top: none;
border-bottom: none;
background: #f6fbfd;
}
#contextual-help-wrap.no-sidebar #contextual-help-back {
right: 0;
border-right-width: 0;
-webkit-border-bottom-right-radius: 2px;
border-bottom-right-radius: 2px;
}
.contextual-help-tabs {
float: left;
width: 150px;
margin: 0;
}
.contextual-help-tabs ul {
margin: 1em 0;
}
.contextual-help-tabs li {
margin-bottom: 0;
list-style-type: none;
border-style: solid;
border-width: 0 0 0 2px;
border-color: transparent;
}
.contextual-help-tabs a {
display: block;
padding: 5px 5px 5px 12px;
line-height: 18px;
text-decoration: none;
border: 1px solid transparent;
border-right: none;
border-left: none;
}
.contextual-help-tabs a:hover {
color: #333;
}
.contextual-help-tabs .active {
padding: 0;
margin: 0 -1px 0 0;
border-left: 2px solid #2ea2cc;
background: #f6fbfd;
-webkit-box-shadow: 0 2px 0 rgba(0,0,0,0.02), 0 1px 0 rgba(0,0,0,0.02);
box-shadow: 0 2px 0 rgba(0,0,0,0.02), 0 1px 0 rgba(0,0,0,0.02);
}
.contextual-help-tabs .active a {
border-color: #e1e1e1;
color: #333;
}
.contextual-help-tabs-wrap {
padding: 0 20px;
overflow: auto;
}
.help-tab-content {
display: none;
margin: 0 22px 12px 0;
line-height: 1.6em;
}
.help-tab-content.active {
display: block;
}
.help-tab-content ul li {
list-style-type: disc;
margin-left: 18px;
}
.contextual-help-sidebar {
width: 150px;
float: right;
padding: 0 8px 0 12px;
overflow: auto;
}
/*------------------------------------------------------------------------------
8.0 - Layout Blocks
------------------------------------------------------------------------------*/
html.wp-toolbar {
padding-top: 32px;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.narrow {
width: 70%;
margin-bottom: 40px;
}
.narrow p {
line-height: 150%;
}
.widefat th,
.widefat td {
overflow: hidden;
color: #555;
}
.widefat th {
font-weight: normal;
}
.widefat thead tr th,
.widefat tfoot tr th {
color: #333;
}
.widefat td p {
margin: 2px 0 0.8em;
}
.widefat p,
.widefat ol,
.widefat ul {
color: #333;
}
.widefat .column-comment p {
margin: 0.6em 0;
}
/* Screens with postboxes */
.postbox-container {
float: left;
}
.postbox-container .meta-box-sortables {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
#wpbody-content .metabox-holder {
padding-top: 10px;
}
.metabox-holder .postbox-container .empty-container {
border: 3px dashed #bbb;
height: 250px;
}
.metabox-holder.columns-1 .postbox-container .empty-container,
.columns-2 #postbox-container-3 .empty-container,
.columns-2 #postbox-container-4 .empty-container,
.columns-3 #postbox-container-4 .empty-container {
border: 0 none;
height: 0;
min-height: 0;
}
#post-body-content {
width: 100%;
min-width: 463px;
float: left;
}
#post-body.columns-2 #postbox-container-1 {
float: right;
margin-right: -300px;
width: 280px;
}
#post-body.columns-2 #side-sortables {
min-height: 250px;
}
/* one column on the dash */
@media only screen and (max-width: 799px) {
#wpbody-content .metabox-holder .postbox-container .empty-container {
border: 0 none;
height: 0;
min-height: 0;
}
}
.js .postbox .hndle {
cursor: move;
}
.hndle a {
font-size: 11px;
font-weight: normal;
}
.postbox .handlediv {
float: right;
width: 27px;
height: 30px;
}
.js .postbox .handlediv {
cursor: pointer;
}
.sortable-placeholder {
border: 1px dashed #bbb;
margin-bottom: 20px;
}
.postbox,
.stuffbox {
margin-bottom: 20px;
padding: 0;
line-height: 1;
}
.postbox h3,
.stuffbox h3 {
margin-top: 1px;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.js .widget .widget-top,
.js .postbox h3 {
cursor: move;
}
.postbox .inside,
.stuffbox .inside {
padding: 0 12px 12px;
line-height: 1.4em;
font-size: 13px;
}
.postbox .inside {
margin: 11px 0;
position: relative;
}
.postbox .inside > p:last-child,
.rss-widget ul li:last-child {
margin-bottom: 1px !important;
}
.postbox.closed h3 {
border: none;
-webkit-box-shadow: none;
box-shadow: none;
}
.postbox table.form-table {
margin-bottom: 0;
}
.postbox table.widefat {
-webkit-box-shadow: none;
box-shadow: none;
}
.temp-border {
border: 1px dotted #ccc;
}
.columns-prefs label {
padding: 0 5px;
}
/* @todo: what is this doing here */
#dashboard_right_now .versions .b,
#post-status-display,
#post-visibility-display,
#adminmenu .wp-submenu li.current,
#adminmenu .wp-submenu li.current a,
#adminmenu .wp-submenu li.current a:hover,
.media-item .percent,
.plugins .name,
#pass-strength-result.strong,
#pass-strength-result.short,
#ed_reply_toolbar #ed_reply_strong,
.item-controls .item-order a,
.feature-filter .feature-name {
font-weight: 600;
}
/*------------------------------------------------------------------------------
21.0 - Admin Footer
------------------------------------------------------------------------------*/
#wpfooter {
position: absolute;
bottom: 0;
left: 0;
right: 0;
padding: 10px 0;
margin-right: 20px;
color: #777;
}
#wpfooter p {
font-size: 13px;
margin: 0;
line-height: 20px;
}
#footer-thankyou {
font-style: italic;
}
#wpfooter a {
text-decoration: none;
}
#wpfooter a:hover {
text-decoration: underline;
}
/*------------------------------------------------------------------------------
25.0 - Tabbed Admin Screen Interface (Experimental)
------------------------------------------------------------------------------*/
.nav-tab {
border: 1px solid #ccc;
border-bottom: none;
background: #e4e4e4;
color: #555;
font-size: 12px;
line-height: 16px;
display: inline-block;
padding: 4px 14px 6px;
text-decoration: none;
margin: -4px 4px -1px 0;
}
.nav-tab:hover {
background-color: #fff;
color: #464646;
}
.nav-tab-active {
color: #464646;
}
.nav-tab-active,
.nav-tab-active:hover {
border-bottom: 1px solid #f1f1f1;
background: #f1f1f1;
color: #000;
}
h2.nav-tab-wrapper,
h3.nav-tab-wrapper {
border-bottom: 1px solid #ccc;
padding-bottom: 0;
padding-left: 10px;
}
h2 .nav-tab {
padding: 6px 10px;
font-weight: bold;
font-size: 15px;
line-height: 24px;
}
/*------------------------------------------------------------------------------
26.0 - Misc
------------------------------------------------------------------------------*/
.spinner {
background: url(../images/spinner.gif) no-repeat;
-webkit-background-size: 20px 20px;
background-size: 20px 20px;
display: none;
float: right;
opacity: 0.7;
filter: alpha(opacity=70);
width: 20px;
height: 20px;
margin: 2px 5px 0;
}
#template div {
margin-right: 190px;
}
.metabox-holder h3 {
font-size: 14px;
padding: 8px 12px;
margin: 0;
line-height: 1.4;
}
#templateside ul li a {
text-decoration: none;
}
#sidemenu {
margin: -30px 15px 0 315px;
list-style: none;
position: relative;
float: right;
padding-left: 10px;
font-size: 12px;
}
#sidemenu a {
padding: 0 7px;
display: block;
float: left;
line-height: 28px;
border-top: 1px solid #f9f9f9;
border-bottom: 1px solid #dfdfdf;
background-color: #f9f9f9;
-webkit-transition: none;
transition: none;
}
#sidemenu li {
display: inline;
line-height: 200%;
list-style: none;
text-align: center;
white-space: nowrap;
margin: 0;
padding: 0;
}
/* @todo: remove border radius */
#sidemenu a.current {
font-weight: normal;
padding-left: 6px;
padding-right: 6px;
-webkit-border-top-left-radius: 3px;
border-top-left-radius: 3px;
-webkit-border-top-right-radius: 3px;
border-top-right-radius: 3px;
border: 1px solid #dfdfdf;
border-bottom-color: #f1f1f1;
background-color: #f1f1f1;
color: #000;
}
#sidemenu li a .count-0 {
display: none;
}
.plugin-install #description,
.plugin-install-network #description {
width: 60%;
}
table .vers,
table .column-visible,
table .column-rating {
text-align: left;
}
.error-message {
color: red;
font-weight: 600;
}
/* Scrollbar fix for bulk upgrade iframe */
body.iframe {
height: 98%;
}
/* Upgrader styles, Specific to Language Packs */
.lp-show-latest p {
display: none;
}
.lp-show-latest p:last-child,
.lp-show-latest .lp-error p {
display: block;
}
/* - Only used once or twice in all of WP - deprecate for global style
------------------------------------------------------------------------------*/
td.media-icon {
text-align: center;
width: 80px;
padding-top: 8px;
padding-bottom: 8px;
}
td.media-icon img {
max-width: 80px;
max-height: 60px;
}
#howto {
font-size: 11px;
margin: 0 5px;
display: block;
}
.importers td {
padding-right: 14px;
}
.importers {
font-size: 16px;
width: auto;
}
#post-body #post-body-content #namediv h3 {
margin-top: 0;
}
#namediv h3 label {
vertical-align: baseline;
}
#namediv table {
width: 100%;
}
#namediv td.first {
width: 10px;
white-space: nowrap;
}
#namediv input {
width: 98%;
}
#namediv p {
margin: 10px 0;
}
#submitdiv h3 {
margin-bottom: 0 !important;
}
/* - Used - but could/should be deprecated with a CSS reset
------------------------------------------------------------------------------*/
.zerosize {
height: 0;
width: 0;
margin: 0;
border: 0;
padding: 0;
overflow: hidden;
position: absolute;
}
br.clear {
height: 2px;
line-height: 2px;
}
.checkbox {
border: none;
margin: 0;
padding: 0;
}
fieldset {
border: 0;
padding: 0;
margin: 0;
}
.post-categories {
display: inline;
margin: 0;
padding: 0;
}
.post-categories li {
display: inline;
}
/* Star Ratings - Back-compat for pre-3.8 */
div.star-holder {
position: relative;
height: 17px;
width: 100px;
background: url(../images/stars.png?ver=20121108) repeat-x bottom left;
}
div.star-holder .star-rating {
background: url(../images/stars.png?ver=20121108) repeat-x top left;
height: 17px;
float: left;
}
/* Star Ratings */
.star-rating {
white-space: nowrap;
}
.star-rating .star {
display: inline-block;
width: 20px;
height: 20px;
-webkit-font-smoothing: antialiased;
font-size: 20px;
line-height: 1;
font-family: 'dashicons';
text-decoration: inherit;
font-weight: normal;
font-style: normal;
vertical-align: top;
-webkit-transition: color .1s ease-in 0;
transition: color .1s ease-in 0;
text-align: center;
color: #0074a2;
}
.star-rating .star-full:before {
content:'\f155';
}
.star-rating .star-half:before {
content:'\f459';
}
.rtl .star-rating .star-half {
-webkit-transform: rotateY(180deg);
-ms-transform: rotateY(180deg);
transform: rotateY(180deg);
}
.star-rating .star-empty:before {
content:'\f154';
}
div.action-links {
font-weight: normal;
margin: 6px 0 0;
}
/* Plugin install thickbox */
#plugin-information {
background: #fcfcfc;
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
height: auto;
padding: 0;
}
#plugin-information-title {
padding: 0 76px 0 20px;
font-size: 22px;
font-weight: 600;
line-height: 56px;
top: 0;
right: 0;
left: 0;
height: 56px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
#plugin-information-tabs {
padding: 0 16px;
position: absolute;
top: 56px;
right: 0;
left: 0;
height: 36px;
z-index: 1;
}
#plugin-information-tabs a {
position: relative;
float: left;
padding: 8px 10px 9px;
margin: 0;
height: 18px;
line-height: 18px;
font-size: 14px;
text-decoration: none;
-webkit-transition: none;
transition: none;
}
#plugin-information-tabs a.current {
margin: -1px -1px 0;
background: #fff;
border: 1px solid #ddd;
border-bottom: none;
color: #333;
}
#plugin-information-tabs a:active,
#plugin-information-tabs a:focus {
outline: none;
}
#plugin-information-content {
background: #fff;
border-top: 1px solid #ddd;
border-bottom: 1px solid #ddd;
position: absolute;
top: 90px;
right: 0;
bottom: 58px;
left: 0;
}
#section-holder {
margin: 0;
padding: 10px 26px;
position: absolute;
top: 0;
right: 250px;
bottom: 0;
left: 0;
overflow: auto;
}
#section-holder .updated {
margin: 16px 0;
}
#plugin-information .fyi {
background: #f3f3f3;
border-left: 1px solid #ddd;
color: #666;
padding: 16px;
position: absolute;
top: 0;
right: 0;
bottom: 0;
width: 217px;
overflow: auto;
}
#plugin-information .fyi strong {
color: #464646;
}
#plugin-information .fyi h3 {
font-weight: bold;
text-transform: uppercase;
font-size: 12px;
color: #666;
margin: 24px 0 8px;
}
#plugin-information .fyi h2 {
font-size: 0.9em;
margin-bottom: 0;
margin-right: 0;
}
#plugin-information .fyi ul {
padding: 0;
margin: 0;
list-style: none;
}
#plugin-information .fyi li {
margin: 0 0 10px;
}
#plugin-information-footer {
padding: 15px 16px;
position: absolute;
right: 0;
bottom: 0;
left: 0;
height: 28px;
}
#plugin-information .section ul,
#plugin-information .section ol {
list-style-type: disc;
margin-left: 24px;
}
#plugin-information .section,
#plugin-information .section p {
font-size: 14px;
line-height: 1.7;
}
#plugin-information #section-screenshots ol {
list-style: none;
margin: 0;
}
#plugin-information #section-screenshots li img {
vertical-align: text-top;
margin-top: 16px;
max-width: 100%;
width: auto;
height: auto;
-webkit-box-shadow: 0 1px 2px rgba( 0, 0, 0, 0.3 );
box-shadow: 0 1px 2px rgba( 0, 0, 0, 0.3 );
}
#plugin-information #section-screenshots li p {
font-style: italic;
padding-left: 20px;
}
#plugin-information pre {
padding: 7px;
overflow: auto;
border: 1px solid #ccc;
}
.plugin-version-author-uri {
font-size: 13px;
}
@media screen and ( max-width: 782px ) {
#plugin-information-content {
overflow: auto;
bottom: 58px;
}
#plugin-information .fyi {
border: 1px solid #ddd;
position: static;
width: auto;
margin: 26px 26px 16px;
}
#section-holder {
position: static;
}
#plugin-information .fyi h3,
#plugin-information .fyi small {
display: none;
}
#plugin-information-footer {
padding: 12px 16px 0;
height: 46px;
}
}
/* Thickbox for Plugin Install screen */
body.plugin-install-php #TB_window,
body.import-php #TB_window,
body.plugins-php #TB_window,
body.update-core-php #TB_window,
body.index-php #TB_window {
background: #fcfcfc url( ../images/spinner.gif ) no-repeat center;
}
@media print,
(-o-min-device-pixel-ratio: 5/4),
(-webkit-min-device-pixel-ratio: 1.25),
(min-resolution: 120dpi) {
body.plugin-install-php #TB_window,
body.import-php #TB_window,
body.plugins-php #TB_window,
body.update-core-php #TB_window,
body.index-php #TB_window {
background: #fcfcfc url( ../images/spinner-2x.gif ) no-repeat center;
-webkit-background-size: 20px 20px;
background-size: 20px 20px;
}
}
body.plugin-install-php #TB_title,
body.import-php #TB_title,
body.plugins-php #TB_title,
body.update-core-php #TB_title,
body.index-php #TB_title {
float: left;
height: 1px;
}
body.plugin-install-php #TB_ajaxWindowTitle,
body.import-php #TB_ajaxWindowTitle,
body.plugins-php #TB_ajaxWindowTitle,
body.update-core-php #TB_ajaxWindowTitle,
body.index-php #TB_ajaxWindowTitle {
display: none;
}
body.plugin-install-php .tb-close-icon,
body.import-php .tb-close-icon,
body.plugins-php .tb-close-icon,
body.update-core-php .tb-close-icon,
body.index-php .tb-close-icon {
line-height: 48px;
width: 48px;
height: 48px;
}
body.plugin-install-php .tb-close-icon:before,
body.import-php .tb-close-icon:before,
body.plugins-php .tb-close-icon:before,
body.update-core-php .tb-close-icon:before,
body.index-php .tb-close-icon:before {
line-height: 48px;
}
/* @todo: move this. */
img {
border: none;
}
/* Header */
/* @todo: are these also specific to Press This? */
#wphead {
border-bottom: 1px solid #dfdfdf;
}
#wphead h1 a {
color: #464646;
}
/* @todo: these seem misplaced */
.js .meta-box-sortables .postbox:hover .handlediv {
margin-right: 0 !important;
}
/* Metabox collapse arrow indicators */
.js .sidebar-name .sidebar-name-arrow:before,
.js .meta-box-sortables .postbox .handlediv:before {
right: 12px;
font: normal 20px/1 'dashicons';
speak: none;
display: inline-block;
padding: 8px 10px;
top: 0;
position: relative;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-decoration: none !important;
}
.js #widgets-left .sidebar-name .sidebar-name-arrow {
display: none;
}
.js #widgets-left .widgets-holder-wrap.closed .sidebar-name .sidebar-name-arrow,
.js #widgets-left .sidebar-name:hover .sidebar-name-arrow {
display: block;
}
/* Show the arrow only on hover */
.js .sidebar-name .sidebar-name-arrow:before,
.js .meta-box-sortables .postbox .handlediv:before {
content: '\f142';
}
.js .widgets-holder-wrap.closed .sidebar-name-arrow:before,
.js .meta-box-sortables .postbox.closed .handlediv:before {
content: '\f140';
}
.error a {
text-decoration: underline;
}
.updated a {
text-decoration: none;
padding-bottom: 2px;
}
/* @todo: appears to be Press This only and overridden */
#photo-add-url-div input[type="text"] {
width: 300px;
}
/* Theme/Plugin Editor */
.alignleft h3 {
margin: 0;
}
#template textarea {
font-family: Consolas, Monaco, monospace;
font-size: 13px;
width: 97%;
background: #f9f9f9;
outline: none;
}
/* @noflip */
#template textarea,
#docs-list {
direction: ltr;
}
#template p {
width: 97%;
}
#templateside {
float: right;
width: 190px;
word-wrap: break-word;
}
#templateside h3,
#postcustomstuff p.submit {
margin: 0;
}
#templateside h4 {
margin: 1em 0 0;
}
#templateside ol,
#templateside ul {
margin: .5em 0;
padding: 0;
}
#templateside li {
margin: 4px 0;
}
#templateside a,
.theme-editor-php .highlight {
display: block;
padding: 3px 3px 3px 12px;
text-decoration: none;
}
.theme-editor-php .highlight {
margin: -3px 3px -3px -12px;
}
#templateside .highlight {
border: none;
font-weight: bold;
}
.nonessential {
color: #666;
font-size: 11px;
font-style: italic;
padding-left: 12px;
}
#documentation {
margin-top: 10px;
}
#documentation label {
line-height: 22px;
vertical-align: baseline;
font-weight: 600;
}
.fileedit-sub {
padding: 10px 0 8px;
line-height: 180%;
}
/* @todo: can we use a common class for these? */
.nav-menus-php .item-edit:before,
.widget-top a.widget-action:after,
.control-section .accordion-section-title:after,
.accordion-section-title:after {
right: 0;
content: '\f140';
border: none;
background: none;
font: normal 20px/1 'dashicons';
speak: none;
display: block;
padding: 0;
text-indent: 0;
text-align: center;
position: relative;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-decoration: none !important;
}
.widget-action,
.handlediv,
.item-edit,
.sidebar-name-arrow,
.accordion-section-title:after {
color: #aaa;
}
.widget-action:hover,
.handlediv:hover,
.item-edit:hover,
.sidebar-name:hover .sidebar-name-arrow,
.accordion-section-title:hover:after {
color: #777;
}
.widget-top a.widget-action:after {
padding: 12px 12px 0;
}
.nav-menus-php .item-edit:before {
line-height: 2.1;
}
.control-section .accordion-section-title:after,
.accordion-section-title:after {
float: right;
right: 20px;
top: -2px;
}
.control-section.open .accordion-section-title:after,
#customize-info.open .accordion-section-title:after,
.nav-menus-php .menu-item-edit-active .item-edit:before {
content: '\f142';
}
/* Enable draggable on IE10 touch events until it's rolled into jQuery UI core */
.ui-sortable,
.ui-draggable {
-ms-touch-action: none;
touch-action: none;
}
.meta-box-sortables.ui-sortable,
.widgets-holder-wrap .ui-draggable,
.widgets-holder-wrap .ui-sortable,
.menu.ui-sortable {
-ms-touch-action: auto;
touch-action: auto;
}
.meta-box-sortables.ui-sortable .hndle,
.menu.ui-sortable .menu-item-handle {
-ms-touch-action: none;
touch-action: none;
}
/* Accordion */
.accordion-section {
border-bottom: 1px solid #dfdfdf;
margin: 0;
}
.accordion-section.open .accordion-section-content,
.no-js .accordion-section .accordion-section-content {
display: block;
}
.accordion-section.open:hover {
border-bottom-color: #dfdfdf;
}
.accordion-section-content {
display: none;
padding: 10px 20px 15px;
overflow: hidden;
background: #fff;
}
.accordion-section-title {
margin: 0;
padding: 12px 15px 15px;
position: relative;
border-left: 1px solid #dfdfdf;
border-right: 1px solid #dfdfdf;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.js .accordion-section-title {
cursor: pointer;
}
.js .accordion-section-title:after {
position: absolute;
top: 12px;
right: 10px;
z-index: 1;
}
.accordion-section-title:focus {
outline: none;
}
.accordion-section-title:hover:after,
.accordion-section-title:focus:after {
border-color: #aaa transparent;
}
.cannot-expand .accordion-section-title {
cursor: auto;
}
.cannot-expand .accordion-section-title:after {
display: none;
}
.control-section .accordion-section-title {
border-left: none;
border-right: none;
padding: 10px 10px 11px 14px;
line-height: 21px;
background: #fff;
}
.control-section .accordion-section-title:after {
top: 11px;
}
.js .control-section:hover .accordion-section-title,
.js .control-section .accordion-section-title:hover,
.js .control-section.open .accordion-section-title,
.js .control-section .accordion-section-title:focus {
color: #222;
background: #f5f5f5;
}
.control-section.open .accordion-section-title {
/* When expanded */
border-bottom: 1px solid #dfdfdf;
}
/* =Media Queries
-------------------------------------------------------------- */
/* @todo: de-duplication */
@media only screen and (min-width: 769px) {
/* categories */
#col-left {
width: 35%;
}
#col-right {
width: 65%;
}
}
@media only screen and (max-width: 860px) {
/* categories */
#col-left {
width: 35%;
}
#col-right {
width: 65%;
}
}
@media only screen and (min-width: 980px) {
/* categories */
#col-left {
width: 35%;
}
#col-right {
width: 65%;
}
}
@media only screen and (max-width: 768px) {
/* categories */
#col-left {
width: 100%;
}
#col-right {
width: 100%;
}
}
/**
* HiDPI Displays
*/
@media print,
(-o-min-device-pixel-ratio: 5/4),
(-webkit-min-device-pixel-ratio: 1.25),
(min-resolution: 120dpi) {
/* Back-compat for pre-3.8 */
div.star-holder,
div.star-holder .star-rating {
background: url(../images/stars-2x.png?ver=20121108) repeat-x bottom left;
-webkit-background-size: 21px 37px;
background-size: 21px 37px;
}
.spinner {
background-image: url(../images/spinner-2x.gif);
}
/* @todo: evaluate - most of these were likely replaced by dashicons */
.curtime #timestamp,
#screen-meta-links a.show-settings,
.widget-top a.widget-action,
.widget-top a.widget-action:hover,
.sidebar-name-arrow,
.sidebar-name:hover .sidebar-name-arrow,
.meta-box-sortables .postbox:hover .handlediv,
.tagchecklist span a,
#bulk-titles div a,
.tagchecklist span a:hover,
#bulk-titles div a:hover {
background: none !important;
}
}
@-ms-viewport {
width: device-width;
}
@media screen and ( max-width: 782px ) {
html.wp-toolbar {
padding-top: 46px;
}
body {
min-width: 240px;
overflow-x: hidden;
}
body * {
-webkit-tap-highlight-color: rgba(0, 0, 0, 0) !important;
}
#wpwrap {
background: #f0f0f0;
}
#wpcontent {
position: relative;
margin-left: 0;
padding-left: 10px;
}
#wpbody-content {
padding-bottom: 100px;
}
.wrap {
margin-right: 12px;
margin-left: 0;
}
.col-wrap {
padding: 0;
}
/* Hidden Elements */
#screen-meta,
#screen-meta-links,
#collapse-menu,
.post-format-select {
display: none !important;
}
.wrap .add-new-h2, .wrap .add-new-h2:active {
padding: 10px 15px;
font-size: 14px;
}
.wp-color-result {
height: auto;
padding-left: 45px;
}
.wp-color-result:after {
font-size: 14px;
height: auto;
padding: 6px 14px;
}
/* Feedback Messages */
.wrap div.updated, .wrap div.error, .media-upload-form div.error {
margin: 20px 0 10px 0;
padding: 5px 10px;
font-size: 14px;
line-height: 175%;
}
.wrap .icon32 + h2 {
margin-top: -2px;
}
.wp-responsive-open #wpbody {
right: -190px;
}
/* General Metabox */
.postbox {
font-size: 14px;
}
.metabox-holder h3 {
padding: 12px;
}
.postbox .handlediv {
margin-top: 3px;
}
/* Subsubsub Nav */
.subsubsub {
font-size: 16px;
text-align: center;
margin-bottom: 15px;
}
/* Theme/Plugin File Editor */
#templateside {
float: none;
width: auto;
}
#templateside li {
margin: 0;
}
#templateside li a {
display: block;
padding: 5px;
}
#templateside .highlight {
padding: 5px;
margin-left: -5px;
margin-top: -5px;
}
#template div {
float: none;
margin: 0;
width: auto;
}
#template textarea {
width: 100%;
}
.fileedit-sub .alignright {
margin-top: 15px;
}
#wpfooter {
display: none;
}
#comments-form .checkforspam {
display: none;
}
}
/* Smartphone */
@media screen and (max-width: 600px) {
/* Disable horizontal scroll when responsive menu is open
since we push the main content off to the right. */
#wpwrap.wp-responsive-open {
overflow-x: hidden;
}
html.wp-toolbar {
padding-top: 0;
}
#wpbody {
padding-top: 46px;
}
/* Keep full-width boxes on Edit Post page from causing horizontal scroll */
div#post-body.metabox-holder.columns-1 {
overflow-x: hidden;
}
}
| 01-wordpress-paypal | trunk/wp-admin/css/common.css | CSS | gpl3 | 42,998 |
body {
overflow: hidden;
}
#customize-controls a {
text-decoration: none;
}
#customize-controls h3 {
font-size: 14px;
}
#customize-controls .submit {
text-align: center;
}
#customize-controls .description {
color: #666666;
}
#customize-header-actions .button-primary {
float: left;
margin-top: 9px;
}
#customize-header-actions .spinner {
margin-top: 16px;
margin-left: 4px;
}
.saving #customize-header-actions .spinner {
display: block;
}
#customize-info {
border: none;
border-top: 1px solid #ddd;
}
#customize-info .accordion-section-title {
background-color: #fff;
color: #666666;
border-right: none;
border-left: none;
border-bottom: 1px solid #eeeeee;
}
#customize-info.open .accordion-section-title,
#customize-info .accordion-section-title:hover,
#customize-info .accordion-section-title:focus {
color: #555555;
}
#customize-info.open .accordion-section-title:after,
#customize-info .accordion-section-title:hover:after,
#customize-info .accordion-section-title:focus:after {
color: #555555;
}
#customize-info.open .accordion-section-title {
border-color: transparent;
}
#customize-info .preview-notice {
font-size: 13px;
line-height: 24px;
}
#customize-info .theme-name {
font-size: 20px;
font-weight: 200;
line-height: 24px;
display: block;
}
#customize-info .theme-screenshot {
width: 258px;
}
#customize-info .theme-description {
margin-top: 1em;
color: #666666;
line-height: 20px;
}
#customize-theme-controls {
-webkit-box-shadow: 0 1px 1px -1px rgba(0, 0, 0, 0.1);
box-shadow: 0 1px 1px -1px rgba(0, 0, 0, 0.1);
}
#customize-theme-controls .control-section {
border: none;
}
#customize-theme-controls .accordion-section-title {
color: #555555;
background-color: #fff;
border-bottom: 1px solid #eeeeee;
}
#customize-theme-controls .accordion-section-content {
color: #555555;
background: white;
}
#customize-theme-controls .control-section:hover .accordion-section-title,
#customize-theme-controls .control-section .accordion-section-title:hover,
#customize-theme-controls .control-section.open .accordion-section-title,
#customize-theme-controls .control-section .accordion-section-title:focus {
color: #555555;
background: #f5f5f5;
}
.js .control-section:hover .accordion-section-title,
.js .control-section .accordion-section-title:hover,
.js .control-section.open .accordion-section-title,
.js .control-section .accordion-section-title:focus {
background: #f5f5f5;
}
#customize-theme-controls .control-section:hover .accordion-section-title::after,
#customize-theme-controls .control-section .accordion-section-title:hover::after,
#customize-theme-controls .control-section.open .accordion-section-title::after,
#customize-theme-controls .control-section .accordion-section-title:focus::after {
color: #555555;
}
#customize-theme-controls .control-section.open {
border-bottom: 1px solid #eeeeee;
}
#customize-theme-controls .control-section.open .accordion-section-title {
border-bottom-color: #eeeeee !important;
}
#customize-theme-controls .control-section:last-of-type.open,
#customize-theme-controls .control-section:last-of-type .accordion-section-title {
border-bottom-color: #ddd;
}
#customize-theme-controls > ul,
#customize-theme-controls .accordion-section-content {
margin: 0;
}
.customize-control {
width: 100%;
float: right;
clear: both;
margin-bottom: 8px;
}
.customize-control select,
.customize-control input[type="text"],
.customize-control input[type="radio"],
.customize-control input[type="checkbox"] {
line-height: 28px;
}
.customize-control input[type="text"] {
width: 98%;
line-height: 18px;
margin: 0;
}
.customize-control select {
min-width: 50%;
max-width: 100%;
height: 28px;
line-height: 28px;
}
.customize-control select[multiple] {
height: auto;
}
.customize-control-title {
display: block;
font-size: 14px;
line-height: 24px;
font-weight: 600;
margin-bottom: 5px;
}
.customize-control-color .color-picker,
.customize-control-checkbox label,
.customize-control-upload div {
line-height: 28px;
}
.customize-control-checkbox input {
margin-left: 5px;
}
.customize-control-radio {
padding: 5px 0 10px;
}
.customize-control-radio .customize-control-title {
margin-bottom: 0;
line-height: 22px;
}
.customize-control-radio label {
line-height: 32px;
}
.customize-control-radio input {
margin-left: 5px;
}
#customize-preview iframe {
width: 100%;
height: 100%;
}
.wp-full-overlay-sidebar {
background: #eeeeee;
border-left: 1px solid #ddd;
}
.collapse-sidebar {
background-color: transparent !important;
border: none !important;
-webkit-box-shadow: none !important;
box-shadow: none !important;
-webkit-border-radius: !important 0;
border-radius: !important 0;
}
.collapse-sidebar:active,
.collapse-sidebar:active .collapse-sidebar-label,
.collapse-sidebar:active .collapse-sidebar-arrow:before {
text-shadow: none;
}
.collapsed .collapse-sidebar-arrow:before {
color: #888;
}
/* Style for custom settings */
/*
* Dropdowns
*/
.accordion-section .dropdown {
float: right;
display: block;
position: relative;
cursor: pointer;
}
.accordion-section .dropdown-content {
overflow: hidden;
float: right;
min-width: 30px;
height: 16px;
line-height: 16px;
margin-left: 16px;
padding: 4px 5px;
border: 2px solid #eeeeee;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.customize-control .dropdown-arrow {
position: absolute;
top: 0;
bottom: 0;
left: 0;
width: 20px;
background: #eeeeee;
}
.customize-control .dropdown-arrow:after {
content: "\f140";
font: normal 20px/1 'dashicons';
speak: none;
display: block;
padding: 0;
text-indent: 0;
text-align: center;
position: relative;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-decoration: none !important;
color: #333;
}
.customize-control .dropdown-status {
color: #333;
background: #eeeeee;
display: none;
max-width: 112px;
}
/* Color Picker */
.customize-control-color .color-picker-hex {
display: none;
}
.customize-control-color.open .color-picker-hex {
display: block;
}
.customize-control-color .dropdown {
margin-left: 5px;
margin-bottom: 5px;
}
.customize-control-color .dropdown .dropdown-content {
background-color: #555555;
border: 1px solid rgba(0, 0, 0, 0.15);
}
.customize-control-color .dropdown:hover .dropdown-content {
border-color: rgba(0, 0, 0, 0.25);
}
/*
* Image Picker
*/
.customize-control-image .library,
.customize-control-image .actions {
display: none;
float: right;
width: 100%;
}
.customize-control-image.open .library,
.customize-control-image.open .actions {
display: block;
}
.accordion-section .customize-control-image .dropdown-content {
height: auto;
min-height: 24px;
min-width: 40px;
padding: 0;
}
.accordion-section .customize-control-image .dropdown-status {
padding: 4px 5px;
}
.accordion-section .customize-control-image .preview-thumbnail img {
display: block;
width: 100%;
max-width: 122px;
max-height: 98px;
margin: 0 auto;
}
.accordion-section .customize-control-image .actions {
text-align: left;
}
.accordion-section .customize-control-image .library ul {
border-bottom: 1px solid #ddd;
float: right;
width: 100%;
margin: 10px 0 0;
}
.accordion-section .customize-control-image .library li {
color: #ccc;
float: right;
padding: 3px 15px;
margin: 0;
border: 1px solid transparent;
}
.accordion-section .customize-control-image .library li.library-selected {
margin-bottom: -1px;
padding-bottom: 4px;
color: #666666;
border-color: #ddd;
border-bottom-color: #fff;
}
.accordion-section .customize-control-image .library .thumbnail {
display: block;
width: 100%;
}
.accordion-section .customize-control-image .library .thumbnail img {
display: block;
max-width: 90%;
max-height: 80px;
margin: 5px auto;
padding: 2px;
background: #666666;
}
.accordion-section .customize-control-image .library .thumbnail:hover img {
background-color: #2ea2cc;
}
.accordion-section .customize-control-image .library-content {
display: none;
width: 100%;
float: right;
padding: 10px 0;
}
.accordion-section .customize-control-image .library-content.library-selected {
display: block;
}
.accordion-section .customize-control-upload .upload-fallback,
.accordion-section .customize-control-image .upload-fallback {
display: none;
}
.accordion-section .customize-control-upload .upload-dropzone,
.accordion-section .customize-control-image .upload-dropzone {
display: none;
padding: 15px 10px;
border: 3px dashed #dfdfdf;
margin: 5px auto;
text-align: center;
position: relative;
cursor: default;
}
.accordion-section .customize-control-upload .upload-dropzone.supports-drag-drop,
.accordion-section .customize-control-image .upload-dropzone.supports-drag-drop {
display: block;
-webkit-transition: border-color 0.1s;
transition: border-color 0.1s;
}
.accordion-section .customize-control-upload .library ul li,
.accordion-section .customize-control-image .library ul li {
cursor: pointer;
}
.accordion-section .customize-control-upload .upload-dropzone.supports-drag-drop.drag-over,
.accordion-section .customize-control-image .upload-dropzone.supports-drag-drop.drag-over {
border-color: #83b4d8;
}
/**
* iOS can't scroll iframes,
* instead it expands the iframe size to match the size of the content
*/
.ios .wp-full-overlay {
position: relative;
}
.ios #customize-preview {
position: relative;
}
.ios #customize-controls .wp-full-overlay-sidebar-content {
-webkit-overflow-scrolling: touch;
}
/** Header control **/
#customize-control-header_image .current {
margin-bottom: 8px;
}
#customize-control-header_image .uploaded {
margin-bottom: 18px;
}
#customize-control-header_image .uploaded button:not(.random),
#customize-control-header_image .default button:not(.random) {
width: 100%;
padding: 0;
margin: 0;
background: none;
border: none;
color: inherit;
cursor: pointer;
}
#customize-control-header_image button img {
display: block;
}
#customize-control-header_image button.new,
#customize-control-header_image button.remove {
white-space: normal;
width: 48%;
height: auto;
}
/* Header control: current image container */
#customize-control-header_image .current .container {
overflow: hidden;
-webkit-border-radius: 2px;
border: 1px solid #eee;
-webkit-border-radius: 2px;
border-radius: 2px;
}
#customize-control-header_image .placeholder {
width: 100%;
position: relative;
text-align: center;
cursor: default;
}
#customize-control-header_image .inner {
display: none;
position: absolute;
width: 100%;
color: #555;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
#customize-control-header_image .inner,
#customize-control-header_image .inner .dashicons {
line-height: 20px;
top: 10px;
}
#customize-control-header_image .list .inner,
#customize-control-header_image .list .inner .dashicons {
top: 9px;
}
#customize-control-header_image .header-view {
position: relative;
width: 100%;
margin-bottom: 5px;
}
#customize-control-header_image .header-view:last-child {
margin-bottom: 0px;
}
/* Convoluted, but 'outline' support isn't good enough yet */
#customize-control-header_image .header-view:after {
border: 0;
}
#customize-control-header_image .header-view.selected:after {
content: '';
position: absolute;
height: auto;
top: 0; right: 0; bottom: 0; left: 0;
border: 4px solid #2ea2cc;
-webkit-border-radius: 2px;
border-radius: 2px;
}
#customize-control-header_image .header-view.button.selected {
border: 0;
}
/* Header control: overlay "close" button */
#customize-control-header_image .uploaded .header-view .close {
font-size: 2em;
color: grey;
position: absolute;
visibility: hidden;
top: 10px;
left: 10px;
z-index: 1;
width: 20px;
height: 20px;
cursor: pointer;
}
#customize-control-header_image .uploaded .header-view .close:hover {
color: black;
text-shadow:
-1px -1px 0 #fff,
1px -1px 0 #fff,
-1px 1px 0 #fff,
1px 1px 0 #fff;
}
#customize-control-header_image .header-view:hover .close {
visibility: visible;
}
/* Header control: randomiz(s)er */
#customize-control-header_image .random.placeholder {
cursor: pointer;
-webkit-border-radius: 2px;
border-radius: 2px;
height: 40px;
}
#customize-control-header_image button.random {
width: 100%;
height: auto;
min-height: 40px;
white-space: normal;
}
#customize-control-header_image button.random .dice {
margin-top: 4px;
}
#customize-control-header_image .placeholder:hover .dice,
#customize-control-header_image .header-view:hover > button.random .dice {
-webkit-animation: dice-color-change 3s infinite;
-ms-animation: dice-color-change 3s infinite;
animation: dice-color-change 3s infinite;
}
@-webkit-keyframes dice-color-change {
0% { color: #d4b146; }
50% { color: #ef54b0; }
75% { color: #7190d3; }
100% { color: #d4b146; }
}
@-ms-keyframes dice-color-change {
0% { color: #d4b146; }
50% { color: #ef54b0; }
75% { color: #7190d3; }
100% { color: #d4b146; }
}
@keyframes dice-color-change {
0% { color: #d4b146; }
50% { color: #ef54b0; }
75% { color: #7190d3; }
100% { color: #d4b146; }
}
/* Header control: actions and choices */
#customize-control-header_image .actions {
margin-bottom: 32px;
}
#customize-control-header_image .choice {
position: relative;
display: block;
margin-bottom: 9px;
}
#customize-control-header_image .uploaded div:last-child > .choice {
margin-bottom: 0;
}
#customize-control-header_image img {
width: 100%;
-webkit-border-radius: 2px;
border-radius: 2px;
}
#customize-control-header_image .remove {
float: right;
margin-left: 3px;
}
#customize-control-header_image .new {
float: left;
}
/** Handle cheaters. */
body.cheatin {
font-size: medium;
height: auto;
background: #fff;
margin: 50px auto 2em;
padding: 1em 2em;
max-width: 700px;
min-width: 0;
-webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.13);
box-shadow: 0 1px 3px rgba(0,0,0,0.13);
}
body.cheatin p {
font-size: 14px;
line-height: 1.5;
margin: 25px 0 20px;
}
| 01-wordpress-paypal | trunk/wp-admin/css/customize-controls-rtl.css | CSS | gpl3 | 14,051 |
/*------------------------------------------------------------------------------
27.0 - Localization
------------------------------------------------------------------------------*/
/* RTL except Hebrew (see below): Tahoma as the first font; */
body.rtl,
body.rtl .press-this a.wp-switch-editor {
font-family: Tahoma, Arial, sans-serif;
}
/* he_IL: Remove Tahoma from the font stack. Arial is best for Hebrew. */
body.locale-he-il,
body.locale-he-il .press-this a.wp-switch-editor {
font-family: Arial, sans-serif;
}
/* he_IL: Have <em> be bold rather than italic. */
.locale-he-il em {
font-style: normal;
font-weight: bold;
}
/* zh_CN: Remove italic properties. */
.locale-zh-cn .howto,
.locale-zh-cn .tablenav .displaying-num,
.locale-zh-cn .js .input-with-default-title,
.locale-zh-cn .link-to-original,
.locale-zh-cn .inline-edit-row fieldset span.title,
.locale-zh-cn .inline-edit-row fieldset span.checkbox-title,
.locale-zh-cn #utc-time,
.locale-zh-cn #local-time,
.locale-zh-cn p.install-help,
.locale-zh-cn p.help,
.locale-zh-cn p.description,
.locale-zh-cn span.description,
.locale-zh-cn .form-wrap p {
font-style: normal;
}
/* zh_CN: Enlarge dashboard widget 'Configure' link */
.locale-zh-cn .hdnle a { font-size: 12px; }
/* zn_CH: Enlarge font size, set font-size: normal */
.locale-zh-cn form.upgrade .hint { font-style: normal; font-size: 100%; }
/* Zn_CH: Distraction free writing.
* More beautiful font for "Just write."
* Larger text for HTML/Visual mode.
*/
.locale-zh-cn #wp-fullscreen-tagline { font-family: KaiTi, "楷体", sans-serif; }
.locale-zh-cn #wp-fullscreen-modes a { font-size: 12px; }
/* zh_CN: Enlarge font-size. */
.locale-zh-cn #sort-buttons { font-size: 1em !important; }
/* de_DE: Text needs more space for translation */
.locale-de-de .inline-edit-row fieldset label span.title {
width: 7em; /* default 5em */
}
.locale-de-de .inline-edit-row fieldset label span.input-text-wrap {
margin-right: 7em; /* default 5em */
}
.locale-de-de #customize-header-actions .button {
padding: 0 5px 1px; /* default 0 10px 1px */
}
.locale-de-de #customize-header-actions .spinner {
margin: 16px 3px 0; /* default 16px 4px 0 5px */
}
/* ru_RU: Text needs more room to breathe. */
.locale-ru-ru .inline-edit-row fieldset label span.title {
width: 8em; /* default 5em */
}
.locale-ru-ru .inline-edit-row fieldset label span.input-text-wrap {
margin-right: 8em; /* default 5em */
}
.locale-ru-ru.post-php .tagsdiv .newtag {
width: 165px; /* default 180px - 15px */
}
.locale-ru-ru.press-this .posting {
margin-left: 277px; /* default 252px + 25px */
}
.locale-ru-ru .press-this-sidebar {
width: 265px; /* default 240px + 25px */
}
.locale-ru-ru #customize-header-actions .button {
padding: 0 5px 1px; /* default 0 10px 1px */
}
.locale-ru-ru #customize-header-actions .spinner {
margin: 16px 3px 0; /* default 16px 4px 0 5px */
}
/* lt_LT: QuickEdit */
.locale-lt-lt .inline-edit-row fieldset label span.title {
width: 8em;
}
.locale-lt-lt .inline-edit-row fieldset label span.input-text-wrap {
margin-right: 8em;
}
| 01-wordpress-paypal | trunk/wp-admin/css/l10n-rtl.css | CSS | gpl3 | 3,076 |
/* Fixes for IE 7 bugs */
#dashboard-widgets form .input-text-wrap input,
#dashboard-widgets form .textarea-wrap textarea {
width: 99%;
}
#dashboard-widgets form #title {
width: 98%;
}
#wpbody-content #dashboard-widgets .postbox-container {
width: 49.5%;
}
#wpbody-content #dashboard-widgets #postbox-container-2,
#wpbody-content #dashboard-widgets #postbox-container-3,
#wpbody-content #dashboard-widgets #postbox-container-4 {
float: right;
width: 50.5%;
}
#dashboard-widgets #postbox-container-3 .empty-container,
#dashboard-widgets #postbox-container-4 .empty-container {
border: 0 none;
height: 0;
min-height: 0;
}
.wp-editor-wrap .wp-editor-tools,
.wp-editor-wrap .wp-switch-editor,
.wp-editor-wrap .wp-editor-tabs,
.wp-editor-wrap .wp-editor-container {
zoom: 100%;
}
.wp-editor-wrap .wp-editor-container textarea.wp-editor-area {
width: 97%;
}
#post-body.columns-2 #postbox-container-1 {
padding-left: 19px;
}
.welcome-panel .wp-badge {
position: absolute;
}
.welcome-panel .welcome-panel-column:first-child {
width: 35%;
}
.wp-fullscreen-title {
width: 97%;
}
#wp_mce_fullscreen_ifr {
background-color: #f9f9f9;
}
#wp-fullscreen-tagline {
color: #888;
font-size: 14px;
}
#adminmenuback {
left: 0;
background-image: none;
}
#adminmenuwrap {
position: static;
}
#adminmenu {
position: relative;
}
#adminmenu,
#adminmenu a {
cursor: pointer;
}
#adminmenu li.wp-menu-separator,
#adminmenu li.wp-menu-separator-last {
font-size: 1px;
line-height: 1;
}
#adminmenu a.menu-top {
border-bottom: 0 none;
border-top: 1px solid #ddd;
}
#adminmenu .separator {
font-size: 1px;
line-height: 1px;
}
#adminmenu .wp-submenu {
left: 110px;
}
#adminmenu .wp-submenu ul {
margin: 0;
}
.folded #wpcontent,
.folded #wpfooter {
margin-left: 170px;
}
.folded #adminmenuback,
.folded #adminmenuwrap,
.folded #adminmenu,
.folded #adminmenu li.menu-top {
width: 150px;
}
.folded #adminmenu .wp-submenu {
border-top-color: transparent;
}
.folded #adminmenu .wp-menu-name {
display: block;
}
.folded #adminmenu .wp-submenu.sub-open,
.folded #adminmenu .opensub .wp-submenu {
left: 110px;
}
.folded #adminmenu a.wp-has-current-submenu:focus + .wp-submenu,
.folded #adminmenu .wp-has-current-submenu .wp-submenu {
top: -1px;
position: relative;
}
.folded #adminmenu .wp-has-current-submenu .wp-submenu .wp-submenu-head {
background-color: transparent;
}
#adminmenu .wp-submenu .wp-submenu-head {
border-top-color: #ddd;
}
.folded #adminmenu .wp-submenu ul {
margin-left: 5px;
}
#adminmenu li.menu-top {
margin-bottom: -2px;
}
#adminmenu .wp-menu-arrow {
display: none !important;
}
.js.folded #adminmenu li.menu-top {
display: block;
zoom: 100%;
}
ul#adminmenu {
z-index: 99;
}
#adminmenu li.menu-top a.menu-top {
min-width: auto;
width: auto;
}
#wpcontent #adminmenu li.wp-has-current-submenu a.wp-has-submenu {
font-style: normal;
}
#wpcontent #adminmenu .wp-submenu li {
padding: 0;
}
#adminmenu li.wp-has-current-submenu .wp-submenu {
left: -40px;
}
#adminmenu .wp-menu-image {
display: none !important;
}
#adminmenu a.menu-top .wp-menu-name {
padding-left: 8px;
}
#collapse-menu {
line-height: 23px;
}
#wpadminbar .ab-comments-icon {
padding-top: 7px;
}
.theme-browser .theme {
width: 30%;
margin: 0 3% 4% 0;
cursor: auto;
}
.theme-browser .theme:hover,
.theme-browser .theme:focus {
cursor: auto;
}
.theme-browser .theme .theme-screenshot {
height: 180px;
}
.theme-browser .theme .theme-actions {
position: static;
background-color: #e8e8e8;
}
.theme-browser .theme .more-details {
display: none;
}
.plugins td,
.plugins th {
border-top: 1px solid #ddd;
}
table.fixed th,
table.fixed td {
border-top: 1px solid #ddd;
}
#wpbody-content input.button,
#wpbody-content input.button-primary,
#wpbody-content input.button-secondary {
overflow: visible;
}
#dashboard-widgets h3 a {
height: 14px;
line-height: 14px;
}
#dashboard_browser_nag {
color: #fff;
}
#dashboard_browser_nag .browser-icon {
position: relative;
}
.tablenav-pages .current-page {
vertical-align: middle;
}
#wpbody-content .postbox {
border: 1px solid #dfdfdf;
}
#wpbody-content .postbox h3 {
margin-bottom: -1px;
}
.major-publishing-actions,
.wp-submenu,
.wp-submenu li,
#template,
#template div,
#editcat,
#addcat {
zoom: 100%;
}
.wp-menu-arrow {
height: 28px;
}
.submitbox {
margin-top: 10px;
}
/* Inline Editor */
#wpbody-content .quick-edit-row-post .inline-edit-col-left {
width: 39%;
}
#wpbody-content .inline-edit-row-post .inline-edit-col-center {
width: 19%;
}
#wpbody-content .quick-edit-row-page .inline-edit-col-left {
width: 49%;
}
#wpbody-content .bulk-edit-row .inline-edit-col-left {
width: 29%;
}
.inline-edit-row p.submit {
zoom: 100%;
}
.inline-edit-row fieldset label span.title {
display: block;
float: left;
width: 5em;
}
.inline-edit-row fieldset label span.input-text-wrap {
margin-left: 0;
zoom: 100%;
}
#wpbody-content .inline-edit-row fieldset label span.input-text-wrap input {
line-height: 130%;
}
#wpbody-content .inline-edit-row .input-text-wrap input {
width: 95%;
}
#wpbody-content .inline-edit-row .input-text-wrap input.inline-edit-password-input {
width: 8em;
}
/* end Inline Editor */
#titlediv #title {
width: 98%;
}
.button,
input[type="reset"],
input[type="button"],
input[type="submit"] {
padding: 0 8px;
line-height: 20px;
height: auto;
}
.button.button-large,
input[type="reset"].button-large,
input[type="button"].button-large,
input[type="submit"].button-large {
padding: 0 10px;
line-height: 24px;
height: auto;
}
.button.button-small,
input[type="reset"].button-small,
input[type="button"].button-small,
input[type="submit"].button-small {
padding: 0 6px;
line-height: 16px;
height: auto;
}
a.button {
margin: 1px;
padding: 1px 9px 2px;
}
a.button.button-large {
padding: 1px 11px 2px;
}
a.button.button-small {
padding: 1px 7px 2px;
}
#screen-options-wrap {
overflow: hidden;
}
#the-comment-list .comment-item,
#post-status-info,
#wpwrap,
#wrap,
#postdivrich,
#postdiv,
#poststuff,
.metabox-holder,
#titlediv,
#post-body,
#editorcontainer,
.tablenav,
.widget-liquid-left,
.widget-liquid-right,
#widgets-left,
.widgets-sortables,
#dragHelper,
.widget .widget-top,
.widget-control-actions,
.tagchecklist,
#col-container,
#col-left,
#col-right,
.fileedit-sub {
display: block;
zoom: 100%;
}
p.search-box {
position: static;
float: right;
margin: -3px 0 4px;
}
#widget-list .widget,
.feature-filter .feature-group li {
display: inline;
}
.feature-filter .feature-group li input {
vertical-align: middle;
}
#editorcontainer #content {
overflow: auto;
margin: auto;
width: 98%;
}
form#template div {
width: 100%;
}
.wp-editor-container .quicktags-toolbar input {
overflow: visible;
padding: 0 4px;
}
#poststuff h2 {
font-size: 1.6em;
}
#poststuff .inside #parent_id,
#poststuff .inside #page_template,
.inline-edit-row #post_parent,
.inline-edit-row select[name="page_template"] {
width: 250px;
}
#submitdiv input,
#submitdiv select,
#submitdiv a.button {
position: relative;
}
#bh {
margin: 7px 10px 0 0;
float: right;
}
/* without this dashboard widgets appear in one column for some screen widths */
div#dashboard-widgets {
padding-right: 1px;
}
.tagchecklist span, .tagchecklist span a {
display: inline-block;
display: block;
}
.tablenav .button-secondary,
.nav .button-secondary {
padding-top: 2px;
padding-bottom: 2px;
}
.tablenav select {
font-size: 13px;
display: inline-block;
vertical-align: top;
margin-top: 2px;
}
.tablenav .actions select {
width: 155px;
}
.subsubsub li {
display: inline;
}
a.post-state-format {
text-indent: 0;
line-height: 0;
font-size: 0;
}
table.ie-fixed {
table-layout: fixed;
}
.widefat tr,
.widefat th {
margin-bottom: 0;
border-spacing: 0;
}
.widefat th input {
margin: 0 0 0 5px;
}
.widefat thead .check-column,
.widefat tfoot .check-column {
padding-top: 6px;
}
.widefat tbody th.check-column,
.media.widefat tbody th.check-column {
padding: 4px 0 0;
}
.widefat {
empty-cells: show;
border-collapse: collapse;
}
.tablenav a.button-secondary {
display: inline-block;
padding: 2px 5px;
}
.inactive-sidebar .widgets-sortables {
padding-bottom: 8px;
}
#available-widgets .widget-holder {
padding-bottom: 65px;
}
#widgets-left .inactive {
padding-bottom: 10px;
}
.widget-liquid-right .widget,
.inactive-sidebar .widget {
position: relative;
}
.inactive-sidebar .widget {
display: block;
float: left;
}
#wpcontent .button-primary-disabled {
color: #9FD0D5;
background: #298CBA;
}
#the-comment-list .unapproved tr,
#the-comment-list .unapproved td {
background-color: #ffffe0;
}
.imgedit-submit {
width: 300px;
}
#nav-menus-frame,
#wpbody,
.menu li {
zoom: 100%;
}
#update-nav-menu #post-body {
overflow:hidden;
}
.menu li {
min-width: 100%;
}
.menu li.sortable-placeholder {
min-width: 400px;
}
.available-theme {
display: inline;
}
.available-theme ul {
margin: 0;
}
.available-theme .action-links li {
padding-right: 7px;
margin-right: 7px;
}
.about-wrap .three-col.about-updates .col-2 {
width: 15%;
}
.about-wrap .about-password-meter input {
width: 98%;
}
.revisions-tickmarks,
.revisions-tooltip {
display: none !important;
}
.revisions.pinned .revisions-controls {
position: relative;
}
input[type="password"],
.login form .input {
font-family: sans-serif;
}
/* TinyMCE icons */
.mce-btn i.mce-i-bold,
.mce-btn i.mce-i-italic,
.mce-btn i.mce-i-bullist,
.mce-btn i.mce-i-numlist,
.mce-btn i.mce-i-blockquote,
.mce-btn i.mce-i-alignleft,
.mce-btn i.mce-i-aligncenter,
.mce-btn i.mce-i-alignright,
.mce-btn i.mce-i-link,
.mce-btn i.mce-i-unlink,
.mce-btn i.mce-i-wp_more,
.mce-btn i.mce-i-strikethrough,
.mce-btn i.mce-i-spellchecker,
.mce-btn i.mce-i-fullscreen,
.mce-btn i.mce-i-wp_fullscreen,
.mce-btn i.mce-i-wp_adv,
.mce-btn i.mce-i-underline,
.mce-btn i.mce-i-alignjustify,
.mce-btn i.mce-i-forecolor,
.mce-btn i.mce-i-pastetext,
.mce-btn i.mce-i-pasteword,
.mce-btn i.mce-i-removeformat,
.mce-btn i.mce-i-charmap,
.mce-btn i.mce-i-outdent,
.mce-btn i.mce-i-indent,
.mce-btn i.mce-i-undo,
.mce-btn i.mce-i-redo,
.mce-btn i.mce-i-help,
.mce-btn i.mce-i-wp_help,
.mce-btn i.mce-i-wp-media-library,
.mce-btn i.mce-i-ltr,
.mce-btn i.mce-i-wp_page,
.mce-btn i.mce-i-hr,
.mce-close {
font-family: 'tinymce', Arial;
font-style: normal;
font-weight: normal;
font-variant: normal;
font-size: 16px;
margin-left: 0;
padding-right: 0;
}
.mce-btn i.mce-i-wp_fullscreen,
.qt-fullscreen {
-ie7-icon: '\e023';
}
.mce-btn i.mce-i-wp_more,
.mce-btn i.mce-i-wp_page {
-ie7-icon: '\e027';
}
.mce-btn i.mce-i-wp_adv {
background-color: #aaa;
}
.mce-btn i.mce-i-help,
.mce-btn i.mce-i-wp_help {
-ie7-icon: '\e016';
}
/* IE6 leftovers */
* html .row-actions {
visibility: visible;
}
* html div.widget-liquid-left,
* html div.widget-liquid-right {
display: block;
position: relative;
}
* html #editorcontainer {
padding: 0;
}
* html #poststuff h2 {
margin-left: 0;
}
* html .stuffbox,
* html .stuffbox input,
* html .stuffbox textarea {
border: 1px solid #DFDFDF;
}
* html .feature-filter .feature-group li {
width: 145px;
}
* html div.widget-liquid-left {
width: 99%;
}
* html .widgets-sortables {
height: 50px;
}
* html a#content_resize {
right: -2px;
}
* html .widget-title h4 {
width: 205px;
}
* html #removing-widget .in-widget-title {
display: none;
}
* html .media-item .pinkynail {
height: 32px;
width: 40px;
}
* html .describe .field input.text,
* html .describe .field textarea {
width: 440px;
}
* html input {
border: 1px solid #dfdfdf;
}
* html .edit-box {
display: inline;
}
* html .postbox-container .meta-box-sortables {
height: 300px;
}
* html #wpbody-content #screen-options-link-wrap {
display: inline-block;
width: 150px;
text-align: center;
}
* html #wpbody-content #contextual-help-link-wrap {
display: inline-block;
width: 100px;
text-align: center;
}
* html #adminmenu {
margin-left: -80px;
}
* html .folded #adminmenu {
margin-left: -22px;
}
* html #wpcontent #adminmenu li.menu-top {
display: inline;
padding: 0;
margin: 0;
}
* html #wpfooter {
margin: 0;
}
* html #adminmenu div.wp-menu-image {
height: 29px;
}
| 01-wordpress-paypal | trunk/wp-admin/css/ie.css | CSS | gpl3 | 12,211 |
<?php
/**
* Parse OPML XML files and store in globals.
*
* @package WordPress
* @subpackage Administration
*/
if ( ! defined('ABSPATH') )
die();
global $opml, $map;
// columns we wish to find are: link_url, link_name, link_target, link_description
// we need to map XML attribute names to our columns
$opml_map = array('URL' => 'link_url',
'HTMLURL' => 'link_url',
'TEXT' => 'link_name',
'TITLE' => 'link_name',
'TARGET' => 'link_target',
'DESCRIPTION' => 'link_description',
'XMLURL' => 'link_rss'
);
$map = $opml_map;
/**
* XML callback function for the start of a new XML tag.
*
* @since 0.71
* @access private
*
* @uses $updated_timestamp Not used inside function.
* @uses $all_links Not used inside function.
* @uses $map Stores names of attributes to use.
* @global array $names
* @global array $urls
* @global array $targets
* @global array $descriptions
* @global array $feeds
*
* @param mixed $parser XML Parser resource.
* @param string $tagName XML element name.
* @param array $attrs XML element attributes.
*/
function startElement($parser, $tagName, $attrs) {
global $updated_timestamp, $all_links, $map;
global $names, $urls, $targets, $descriptions, $feeds;
if ($tagName == 'OUTLINE') {
foreach (array_keys($map) as $key) {
if (isset($attrs[$key])) {
$$map[$key] = $attrs[$key];
}
}
//echo("got data: link_url = [$link_url], link_name = [$link_name], link_target = [$link_target], link_description = [$link_description]<br />\n");
// save the data away.
$names[] = $link_name;
$urls[] = $link_url;
$targets[] = $link_target;
$feeds[] = $link_rss;
$descriptions[] = $link_description;
} // end if outline
}
/**
* XML callback function that is called at the end of a XML tag.
*
* @since 0.71
* @access private
*
* @param mixed $parser XML Parser resource.
* @param string $tagName XML tag name.
*/
function endElement($parser, $tagName) {
// nothing to do.
}
// Create an XML parser
$xml_parser = xml_parser_create();
// Set the functions to handle opening and closing tags
xml_set_element_handler($xml_parser, "startElement", "endElement");
if (!xml_parse($xml_parser, $opml, true)) {
echo(sprintf(__('XML error: %1$s at line %2$s'),
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
}
// Free up memory used by the XML parser
xml_parser_free($xml_parser);
| 01-wordpress-paypal | trunk/wp-admin/link-parse-opml.php | PHP | gpl3 | 2,439 |
<?php
/**
* Update/Install Plugin/Theme administration panel.
*
* @package WordPress
* @subpackage Administration
*/
if ( ! defined( 'IFRAME_REQUEST' ) && isset( $_GET['action'] ) && in_array( $_GET['action'], array( 'update-selected', 'activate-plugin', 'update-selected-themes' ) ) )
define( 'IFRAME_REQUEST', true );
/** WordPress Administration Bootstrap */
require_once( dirname( __FILE__ ) . '/admin.php' );
include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
if ( isset($_GET['action']) ) {
$plugin = isset($_REQUEST['plugin']) ? trim($_REQUEST['plugin']) : '';
$theme = isset($_REQUEST['theme']) ? urldecode($_REQUEST['theme']) : '';
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
if ( 'update-selected' == $action ) {
if ( ! current_user_can( 'update_plugins' ) )
wp_die( __( 'You do not have sufficient permissions to update plugins for this site.' ) );
check_admin_referer( 'bulk-update-plugins' );
if ( isset( $_GET['plugins'] ) )
$plugins = explode( ',', stripslashes($_GET['plugins']) );
elseif ( isset( $_POST['checked'] ) )
$plugins = (array) $_POST['checked'];
else
$plugins = array();
$plugins = array_map('urldecode', $plugins);
$url = 'update.php?action=update-selected&plugins=' . urlencode(implode(',', $plugins));
$nonce = 'bulk-update-plugins';
wp_enqueue_script( 'updates' );
iframe_header();
$upgrader = new Plugin_Upgrader( new Bulk_Plugin_Upgrader_Skin( compact( 'nonce', 'url' ) ) );
$upgrader->bulk_upgrade( $plugins );
iframe_footer();
} elseif ( 'upgrade-plugin' == $action ) {
if ( ! current_user_can('update_plugins') )
wp_die(__('You do not have sufficient permissions to update plugins for this site.'));
check_admin_referer('upgrade-plugin_' . $plugin);
$title = __('Update Plugin');
$parent_file = 'plugins.php';
$submenu_file = 'plugins.php';
wp_enqueue_script( 'updates' );
require_once(ABSPATH . 'wp-admin/admin-header.php');
$nonce = 'upgrade-plugin_' . $plugin;
$url = 'update.php?action=upgrade-plugin&plugin=' . urlencode( $plugin );
$upgrader = new Plugin_Upgrader( new Plugin_Upgrader_Skin( compact('title', 'nonce', 'url', 'plugin') ) );
$upgrader->upgrade($plugin);
include(ABSPATH . 'wp-admin/admin-footer.php');
} elseif ('activate-plugin' == $action ) {
if ( ! current_user_can('update_plugins') )
wp_die(__('You do not have sufficient permissions to update plugins for this site.'));
check_admin_referer('activate-plugin_' . $plugin);
if ( ! isset($_GET['failure']) && ! isset($_GET['success']) ) {
wp_redirect( admin_url('update.php?action=activate-plugin&failure=true&plugin=' . urlencode( $plugin ) . '&_wpnonce=' . $_GET['_wpnonce']) );
activate_plugin( $plugin, '', ! empty( $_GET['networkwide'] ), true );
wp_redirect( admin_url('update.php?action=activate-plugin&success=true&plugin=' . urlencode( $plugin ) . '&_wpnonce=' . $_GET['_wpnonce']) );
die();
}
iframe_header( __('Plugin Reactivation'), true );
if ( isset($_GET['success']) )
echo '<p>' . __('Plugin reactivated successfully.') . '</p>';
if ( isset($_GET['failure']) ){
echo '<p>' . __('Plugin failed to reactivate due to a fatal error.') . '</p>';
error_reporting( E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR );
@ini_set('display_errors', true); //Ensure that Fatal errors are displayed.
wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $plugin );
include( WP_PLUGIN_DIR . '/' . $plugin );
}
iframe_footer();
} elseif ( 'install-plugin' == $action ) {
if ( ! current_user_can('install_plugins') )
wp_die( __( 'You do not have sufficient permissions to install plugins on this site.' ) );
include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; //for plugins_api..
check_admin_referer('install-plugin_' . $plugin);
$api = plugins_api('plugin_information', array('slug' => $plugin, 'fields' => array('sections' => false) ) ); //Save on a bit of bandwidth.
if ( is_wp_error($api) )
wp_die($api);
$title = __('Plugin Install');
$parent_file = 'plugins.php';
$submenu_file = 'plugin-install.php';
require_once(ABSPATH . 'wp-admin/admin-header.php');
$title = sprintf( __('Installing Plugin: %s'), $api->name . ' ' . $api->version );
$nonce = 'install-plugin_' . $plugin;
$url = 'update.php?action=install-plugin&plugin=' . urlencode( $plugin );
if ( isset($_GET['from']) )
$url .= '&from=' . urlencode(stripslashes($_GET['from']));
$type = 'web'; //Install plugin type, From Web or an Upload.
$upgrader = new Plugin_Upgrader( new Plugin_Installer_Skin( compact('title', 'url', 'nonce', 'plugin', 'api') ) );
$upgrader->install($api->download_link);
include(ABSPATH . 'wp-admin/admin-footer.php');
} elseif ( 'upload-plugin' == $action ) {
if ( ! current_user_can('install_plugins') )
wp_die( __( 'You do not have sufficient permissions to install plugins on this site.' ) );
check_admin_referer('plugin-upload');
$file_upload = new File_Upload_Upgrader('pluginzip', 'package');
$title = __('Upload Plugin');
$parent_file = 'plugins.php';
$submenu_file = 'plugin-install.php';
require_once(ABSPATH . 'wp-admin/admin-header.php');
$title = sprintf( __('Installing Plugin from uploaded file: %s'), esc_html( basename( $file_upload->filename ) ) );
$nonce = 'plugin-upload';
$url = add_query_arg(array('package' => $file_upload->id), 'update.php?action=upload-plugin');
$type = 'upload'; //Install plugin type, From Web or an Upload.
$upgrader = new Plugin_Upgrader( new Plugin_Installer_Skin( compact('type', 'title', 'nonce', 'url') ) );
$result = $upgrader->install( $file_upload->package );
if ( $result || is_wp_error($result) )
$file_upload->cleanup();
include(ABSPATH . 'wp-admin/admin-footer.php');
} elseif ( 'upgrade-theme' == $action ) {
if ( ! current_user_can('update_themes') )
wp_die(__('You do not have sufficient permissions to update themes for this site.'));
check_admin_referer('upgrade-theme_' . $theme);
wp_enqueue_script( 'customize-loader' );
wp_enqueue_script( 'updates' );
$title = __('Update Theme');
$parent_file = 'themes.php';
$submenu_file = 'themes.php';
require_once(ABSPATH . 'wp-admin/admin-header.php');
$nonce = 'upgrade-theme_' . $theme;
$url = 'update.php?action=upgrade-theme&theme=' . urlencode( $theme );
$upgrader = new Theme_Upgrader( new Theme_Upgrader_Skin( compact('title', 'nonce', 'url', 'theme') ) );
$upgrader->upgrade($theme);
include(ABSPATH . 'wp-admin/admin-footer.php');
} elseif ( 'update-selected-themes' == $action ) {
if ( ! current_user_can( 'update_themes' ) )
wp_die( __( 'You do not have sufficient permissions to update themes for this site.' ) );
check_admin_referer( 'bulk-update-themes' );
if ( isset( $_GET['themes'] ) )
$themes = explode( ',', stripslashes($_GET['themes']) );
elseif ( isset( $_POST['checked'] ) )
$themes = (array) $_POST['checked'];
else
$themes = array();
$themes = array_map('urldecode', $themes);
$url = 'update.php?action=update-selected-themes&themes=' . urlencode(implode(',', $themes));
$nonce = 'bulk-update-themes';
wp_enqueue_script( 'updates' );
iframe_header();
$upgrader = new Theme_Upgrader( new Bulk_Theme_Upgrader_Skin( compact( 'nonce', 'url' ) ) );
$upgrader->bulk_upgrade( $themes );
iframe_footer();
} elseif ( 'install-theme' == $action ) {
if ( ! current_user_can('install_themes') )
wp_die( __( 'You do not have sufficient permissions to install themes on this site.' ) );
include_once ABSPATH . 'wp-admin/includes/theme-install.php'; //for themes_api..
check_admin_referer( 'install-theme_' . $theme );
$api = themes_api('theme_information', array('slug' => $theme, 'fields' => array('sections' => false, 'tags' => false) ) ); //Save on a bit of bandwidth.
if ( is_wp_error($api) )
wp_die($api);
wp_enqueue_script( 'customize-loader' );
$title = __('Install Themes');
$parent_file = 'themes.php';
$submenu_file = 'themes.php';
require_once(ABSPATH . 'wp-admin/admin-header.php');
$title = sprintf( __('Installing Theme: %s'), $api->name . ' ' . $api->version );
$nonce = 'install-theme_' . $theme;
$url = 'update.php?action=install-theme&theme=' . urlencode( $theme );
$type = 'web'; //Install theme type, From Web or an Upload.
$upgrader = new Theme_Upgrader( new Theme_Installer_Skin( compact('title', 'url', 'nonce', 'plugin', 'api') ) );
$upgrader->install($api->download_link);
include(ABSPATH . 'wp-admin/admin-footer.php');
} elseif ( 'upload-theme' == $action ) {
if ( ! current_user_can('install_themes') )
wp_die( __( 'You do not have sufficient permissions to install themes on this site.' ) );
check_admin_referer('theme-upload');
$file_upload = new File_Upload_Upgrader('themezip', 'package');
wp_enqueue_script( 'customize-loader' );
$title = __('Upload Theme');
$parent_file = 'themes.php';
$submenu_file = 'theme-install.php';
require_once(ABSPATH . 'wp-admin/admin-header.php');
$title = sprintf( __('Installing Theme from uploaded file: %s'), esc_html( basename( $file_upload->filename ) ) );
$nonce = 'theme-upload';
$url = add_query_arg(array('package' => $file_upload->id), 'update.php?action=upload-theme');
$type = 'upload'; //Install plugin type, From Web or an Upload.
$upgrader = new Theme_Upgrader( new Theme_Installer_Skin( compact('type', 'title', 'nonce', 'url') ) );
$result = $upgrader->install( $file_upload->package );
if ( $result || is_wp_error($result) )
$file_upload->cleanup();
include(ABSPATH . 'wp-admin/admin-footer.php');
} else {
/**
* Fires when a custom plugin or theme update request is received.
*
* The dynamic portion of the hook name, $action, refers to the action
* provided in the request for wp-admin/update.php. Can be used to
* provide custom update functionality for themes and plugins.
*
* @since 2.8.0
*/
do_action( "update-custom_{$action}" );
}
}
| 01-wordpress-paypal | trunk/wp-admin/update.php | PHP | gpl3 | 10,140 |
<?php
/**
* Disable error reporting
*
* Set this to error_reporting( E_ALL ) or error_reporting( E_ALL | E_STRICT ) for debugging
*/
error_reporting(0);
/** Set ABSPATH for execution */
define( 'ABSPATH', dirname(dirname(__FILE__)) . '/' );
define( 'WPINC', 'wp-includes' );
/**
* @ignore
*/
function __() {}
/**
* @ignore
*/
function _x() {}
/**
* @ignore
*/
function add_filter() {}
/**
* @ignore
*/
function esc_attr() {}
/**
* @ignore
*/
function apply_filters() {}
/**
* @ignore
*/
function get_option() {}
/**
* @ignore
*/
function is_lighttpd_before_150() {}
/**
* @ignore
*/
function add_action() {}
/**
* @ignore
*/
function did_action() {}
/**
* @ignore
*/
function do_action_ref_array() {}
/**
* @ignore
*/
function get_bloginfo() {}
/**
* @ignore
*/
function is_admin() {return true;}
/**
* @ignore
*/
function site_url() {}
/**
* @ignore
*/
function admin_url() {}
/**
* @ignore
*/
function home_url() {}
/**
* @ignore
*/
function includes_url() {}
/**
* @ignore
*/
function wp_guess_url() {}
if ( ! function_exists( 'json_encode' ) ) :
/**
* @ignore
*/
function json_encode() {}
endif;
function get_file($path) {
if ( function_exists('realpath') )
$path = realpath($path);
if ( ! $path || ! @is_file($path) )
return '';
return @file_get_contents($path);
}
$load = $_GET['load'];
if ( is_array( $load ) )
$load = implode( '', $load );
$load = preg_replace( '/[^a-z0-9,_-]+/i', '', $load );
$load = array_unique( explode( ',', $load ) );
if ( empty($load) )
exit;
require(ABSPATH . WPINC . '/script-loader.php');
require(ABSPATH . WPINC . '/version.php');
$compress = ( isset($_GET['c']) && $_GET['c'] );
$force_gzip = ( $compress && 'gzip' == $_GET['c'] );
$expires_offset = 31536000; // 1 year
$out = '';
$wp_scripts = new WP_Scripts();
wp_default_scripts($wp_scripts);
foreach( $load as $handle ) {
if ( !array_key_exists($handle, $wp_scripts->registered) )
continue;
$path = ABSPATH . $wp_scripts->registered[$handle]->src;
$out .= get_file($path) . "\n";
}
header('Content-Type: application/x-javascript; charset=UTF-8');
header('Expires: ' . gmdate( "D, d M Y H:i:s", time() + $expires_offset ) . ' GMT');
header("Cache-Control: public, max-age=$expires_offset");
if ( $compress && ! ini_get('zlib.output_compression') && 'ob_gzhandler' != ini_get('output_handler') && isset($_SERVER['HTTP_ACCEPT_ENCODING']) ) {
header('Vary: Accept-Encoding'); // Handle proxies
if ( false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate') && function_exists('gzdeflate') && ! $force_gzip ) {
header('Content-Encoding: deflate');
$out = gzdeflate( $out, 3 );
} elseif ( false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') && function_exists('gzencode') ) {
header('Content-Encoding: gzip');
$out = gzencode( $out, 3 );
}
}
echo $out;
exit;
| 01-wordpress-paypal | trunk/wp-admin/load-scripts.php | PHP | gpl3 | 2,859 |
<?php
/**
* Multisite users administration panel.
*
* @package WordPress
* @subpackage Multisite
* @since 3.0.0
*/
require_once( dirname( __FILE__ ) . '/admin.php' );
wp_redirect( network_admin_url('users.php') );
exit;
| 01-wordpress-paypal | trunk/wp-admin/ms-users.php | PHP | gpl3 | 228 |
<?php
/**
* Edit Posts Administration Screen.
*
* @package WordPress
* @subpackage Administration
*/
/** WordPress Administration Bootstrap */
require_once( dirname( __FILE__ ) . '/admin.php' );
if ( ! $typenow )
wp_die( __( 'Invalid post type' ) );
$post_type = $typenow;
$post_type_object = get_post_type_object( $post_type );
if ( ! $post_type_object )
wp_die( __( 'Invalid 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
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";
$submenu_file = "edit.php?post_type=$post_type";
$post_new_file = "post-new.php?post_type=$post_type";
} else {
$parent_file = 'edit.php';
$submenu_file = 'edit.php';
$post_new_file = 'post-new.php';
}
$doaction = $wp_list_table->current_action();
if ( $doaction ) {
check_admin_referer('bulk-posts');
$sendback = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'locked', 'ids'), wp_get_referer() );
if ( ! $sendback )
$sendback = admin_url( $parent_file );
$sendback = add_query_arg( 'paged', $pagenum, $sendback );
if ( strpos($sendback, 'post.php') !== false )
$sendback = admin_url($post_new_file);
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 ( 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 ) {
case 'trash':
$trashed = $locked = 0;
foreach( (array) $post_ids as $post_id ) {
if ( !current_user_can( 'delete_post', $post_id) )
wp_die( __('You are not allowed to move this item to the Trash.') );
if ( wp_check_post_lock( $post_id ) ) {
$locked++;
continue;
}
if ( !wp_trash_post($post_id) )
wp_die( __('Error in moving to Trash.') );
$trashed++;
}
$sendback = add_query_arg( array('trashed' => $trashed, 'ids' => join(',', $post_ids), 'locked' => $locked ), $sendback );
break;
case 'untrash':
$untrashed = 0;
foreach( (array) $post_ids as $post_id ) {
if ( !current_user_can( 'delete_post', $post_id) )
wp_die( __('You are not allowed to restore this item from the Trash.') );
if ( !wp_untrash_post($post_id) )
wp_die( __('Error in restoring from Trash.') );
$untrashed++;
}
$sendback = add_query_arg('untrashed', $untrashed, $sendback);
break;
case 'delete':
$deleted = 0;
foreach( (array) $post_ids as $post_id ) {
$post_del = get_post($post_id);
if ( !current_user_can( 'delete_post', $post_id ) )
wp_die( __('You are not allowed to delete this item.') );
if ( $post_del->post_type == 'attachment' ) {
if ( ! wp_delete_attachment($post_id) )
wp_die( __('Error in deleting.') );
} else {
if ( !wp_delete_post($post_id) )
wp_die( __('Error in deleting.') );
}
$deleted++;
}
$sendback = add_query_arg('deleted', $deleted, $sendback);
break;
case 'edit':
if ( isset($_REQUEST['bulk_edit']) ) {
$done = bulk_edit_posts($_REQUEST);
if ( is_array($done) ) {
$done['updated'] = count( $done['updated'] );
$done['skipped'] = count( $done['skipped'] );
$done['locked'] = count( $done['locked'] );
$sendback = add_query_arg( $done, $sendback );
}
}
break;
}
$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($_REQUEST['_wp_http_referer']) ) {
wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), wp_unslash($_SERVER['REQUEST_URI']) ) );
exit;
}
$wp_list_table->prepare_items();
wp_enqueue_script('inline-edit-post');
$title = $post_type_object->labels->name;
if ( 'post' == $post_type ) {
get_current_screen()->add_help_tab( array(
'id' => 'overview',
'title' => __('Overview'),
'content' =>
'<p>' . __('This screen provides access to all of your posts. You can customize the display of this screen to suit your workflow.') . '</p>'
) );
get_current_screen()->add_help_tab( array(
'id' => 'screen-content',
'title' => __('Screen Content'),
'content' =>
'<p>' . __('You can customize the display of this screen’s contents in a number of ways:') . '</p>' .
'<ul>' .
'<li>' . __('You can hide/display columns based on your needs and decide how many posts to list per screen using the Screen Options tab.') . '</li>' .
'<li>' . __('You can filter the list of posts by post status using the text links in the upper left to show All, Published, Draft, or Trashed posts. The default view is to show all posts.') . '</li>' .
'<li>' . __('You can view posts in a simple title list or with an excerpt. Choose the view you prefer by clicking on the icons at the top of the list on the right.') . '</li>' .
'<li>' . __('You can refine the list to show only posts in a specific category or from a specific month by using the dropdown menus above the posts list. Click the Filter button after making your selection. You also can refine the list by clicking on the post author, category or tag in the posts list.') . '</li>' .
'</ul>'
) );
get_current_screen()->add_help_tab( array(
'id' => 'action-links',
'title' => __('Available Actions'),
'content' =>
'<p>' . __('Hovering over a row in the posts list will display action links that allow you to manage your post. You can perform the following actions:') . '</p>' .
'<ul>' .
'<li>' . __('<strong>Edit</strong> takes you to the editing screen for that post. You can also reach that screen by clicking on the post title.') . '</li>' .
'<li>' . __('<strong>Quick Edit</strong> provides inline access to the metadata of your post, allowing you to update post details without leaving this screen.') . '</li>' .
'<li>' . __('<strong>Trash</strong> removes your post from this list and places it in the trash, from which you can permanently delete it.') . '</li>' .
'<li>' . __('<strong>Preview</strong> will show you what your draft post will look like if you publish it. View will take you to your live site to view the post. Which link is available depends on your post’s status.') . '</li>' .
'</ul>'
) );
get_current_screen()->add_help_tab( array(
'id' => 'bulk-actions',
'title' => __('Bulk Actions'),
'content' =>
'<p>' . __('You can also edit or move multiple posts to the trash at once. Select the posts you want to act on using the checkboxes, then select the action you want to take from the Bulk Actions menu and click Apply.') . '</p>' .
'<p>' . __('When using Bulk Edit, you can 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.') . '</p>'
) );
get_current_screen()->set_help_sidebar(
'<p><strong>' . __('For more information:') . '</strong></p>' .
'<p>' . __('<a href="http://codex.wordpress.org/Posts_Screen" target="_blank">Documentation on Managing Posts</a>') . '</p>' .
'<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
);
} elseif ( 'page' == $post_type ) {
get_current_screen()->add_help_tab( array(
'id' => 'overview',
'title' => __('Overview'),
'content' =>
'<p>' . __('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.') . '</p>'
) );
get_current_screen()->add_help_tab( array(
'id' => 'managing-pages',
'title' => __('Managing Pages'),
'content' =>
'<p>' . __('Managing pages is very similar to managing posts, and the screens can be customized in the same way.') . '</p>' .
'<p>' . __('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.') . '</p>'
) );
get_current_screen()->set_help_sidebar(
'<p><strong>' . __('For more information:') . '</strong></p>' .
'<p>' . __('<a href="http://codex.wordpress.org/Pages_Screen" target="_blank">Documentation on Managing Pages</a>') . '</p>' .
'<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
);
}
add_screen_option( 'per_page', array( 'label' => $title, 'default' => 20, 'option' => 'edit_' . $post_type . '_per_page' ) );
$bulk_counts = array(
'updated' => isset( $_REQUEST['updated'] ) ? absint( $_REQUEST['updated'] ) : 0,
'locked' => isset( $_REQUEST['locked'] ) ? absint( $_REQUEST['locked'] ) : 0,
'deleted' => isset( $_REQUEST['deleted'] ) ? absint( $_REQUEST['deleted'] ) : 0,
'trashed' => isset( $_REQUEST['trashed'] ) ? absint( $_REQUEST['trashed'] ) : 0,
'untrashed' => isset( $_REQUEST['untrashed'] ) ? absint( $_REQUEST['untrashed'] ) : 0,
);
$bulk_messages = array();
$bulk_messages['post'] = array(
'updated' => _n( '%s post updated.', '%s posts updated.', $bulk_counts['updated'] ),
'locked' => _n( '%s post not updated, somebody is editing it.', '%s posts not updated, somebody is editing them.', $bulk_counts['locked'] ),
'deleted' => _n( '%s post permanently deleted.', '%s posts permanently deleted.', $bulk_counts['deleted'] ),
'trashed' => _n( '%s post moved to the Trash.', '%s posts moved to the Trash.', $bulk_counts['trashed'] ),
'untrashed' => _n( '%s post restored from the Trash.', '%s posts restored from the Trash.', $bulk_counts['untrashed'] ),
);
$bulk_messages['page'] = array(
'updated' => _n( '%s page updated.', '%s pages updated.', $bulk_counts['updated'] ),
'locked' => _n( '%s page not updated, somebody is editing it.', '%s pages not updated, somebody is editing them.', $bulk_counts['locked'] ),
'deleted' => _n( '%s page permanently deleted.', '%s pages permanently deleted.', $bulk_counts['deleted'] ),
'trashed' => _n( '%s page moved to the Trash.', '%s pages moved to the Trash.', $bulk_counts['trashed'] ),
'untrashed' => _n( '%s page restored from the Trash.', '%s pages restored from the Trash.', $bulk_counts['untrashed'] ),
);
/**
* Filter the bulk action updated messages.
*
* By default, custom post types use the messages for the 'post' post type.
*
* @since 3.7.0
*
* @param array $bulk_messages Arrays of messages, each keyed by the corresponding post type. Messages are
* keyed with 'updated', 'locked', 'deleted', 'trashed', and 'untrashed'.
* @param array $bulk_counts Array of item counts for each message, used to build internationalized strings.
*/
$bulk_messages = apply_filters( 'bulk_post_updated_messages', $bulk_messages, $bulk_counts );
$bulk_counts = array_filter( $bulk_counts );
require_once( ABSPATH . 'wp-admin/admin-header.php' );
?>
<div class="wrap">
<h2><?php
echo esc_html( $post_type_object->labels->name );
if ( current_user_can( $post_type_object->cap->create_posts ) )
echo ' <a href="' . esc_url( admin_url( $post_new_file ) ) . '" class="add-new-h2">' . esc_html( $post_type_object->labels->add_new ) . '</a>';
if ( ! empty( $_REQUEST['s'] ) )
printf( ' <span class="subtitle">' . __('Search results for “%s”') . '</span>', get_search_query() );
?></h2>
<?php
// If we have a bulk message to issue:
$messages = array();
foreach ( $bulk_counts as $message => $count ) {
if ( isset( $bulk_messages[ $post_type ][ $message ] ) )
$messages[] = sprintf( $bulk_messages[ $post_type ][ $message ], number_format_i18n( $count ) );
elseif ( isset( $bulk_messages['post'][ $message ] ) )
$messages[] = sprintf( $bulk_messages['post'][ $message ], number_format_i18n( $count ) );
if ( $message == 'trashed' && isset( $_REQUEST['ids'] ) ) {
$ids = preg_replace( '/[^0-9,]/', '', $_REQUEST['ids'] );
$messages[] = '<a href="' . esc_url( wp_nonce_url( "edit.php?post_type=$post_type&doaction=undo&action=untrash&ids=$ids", "bulk-posts" ) ) . '">' . __('Undo') . '</a>';
}
}
if ( $messages )
echo '<div id="message" class="updated"><p>' . join( ' ', $messages ) . '</p></div>';
unset( $messages );
$_SERVER['REQUEST_URI'] = remove_query_arg( array( 'locked', 'skipped', 'updated', 'deleted', 'trashed', 'untrashed' ), $_SERVER['REQUEST_URI'] );
?>
<?php $wp_list_table->views(); ?>
<form id="posts-filter" action="" method="get">
<?php $wp_list_table->search_box( $post_type_object->labels->search_items, 'post' ); ?>
<input type="hidden" name="post_status" class="post_status_page" value="<?php echo !empty($_REQUEST['post_status']) ? esc_attr($_REQUEST['post_status']) : 'all'; ?>" />
<input type="hidden" name="post_type" class="post_type_page" value="<?php echo $post_type; ?>" />
<?php if ( ! empty( $_REQUEST['show_sticky'] ) ) { ?>
<input type="hidden" name="show_sticky" value="1" />
<?php } ?>
<?php $wp_list_table->display(); ?>
</form>
<?php
if ( $wp_list_table->has_items() )
$wp_list_table->inline_edit();
?>
<div id="ajax-response"></div>
<br class="clear" />
</div>
<?php
include( ABSPATH . 'wp-admin/admin-footer.php' );
| 01-wordpress-paypal | trunk/wp-admin/edit.php | PHP | gpl3 | 14,311 |
<?php
/**
* WordPress AJAX Process Execution.
*
* @package WordPress
* @subpackage Administration
*
* @link http://codex.wordpress.org/AJAX_in_Plugins
*/
/**
* Executing AJAX process.
*
* @since 2.1.0
*/
define( 'DOING_AJAX', true );
define( 'WP_ADMIN', true );
/** Load WordPress Bootstrap */
require_once( dirname( dirname( __FILE__ ) ) . '/wp-load.php' );
/** Allow for cross-domain requests (from the frontend). */
send_origin_headers();
// Require an action parameter
if ( empty( $_REQUEST['action'] ) )
die( '0' );
/** Load WordPress Administration APIs */
require_once( ABSPATH . 'wp-admin/includes/admin.php' );
/** Load Ajax Handlers for WordPress Core */
require_once( ABSPATH . 'wp-admin/includes/ajax-actions.php' );
@header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
@header( 'X-Robots-Tag: noindex' );
send_nosniff_header();
nocache_headers();
/** This action is documented in wp-admin/admin.php */
do_action( 'admin_init' );
$core_actions_get = array(
'fetch-list', 'ajax-tag-search', 'wp-compression-test', 'imgedit-preview', 'oembed-cache',
'autocomplete-user', 'dashboard-widgets', 'logged-in',
);
$core_actions_post = array(
'oembed-cache', 'image-editor', 'delete-comment', 'delete-tag', 'delete-link',
'delete-meta', 'delete-post', 'trash-post', 'untrash-post', 'delete-page', 'dim-comment',
'add-link-category', 'add-tag', 'get-tagcloud', 'get-comments', 'replyto-comment',
'edit-comment', 'add-menu-item', 'add-meta', 'add-user', 'closed-postboxes',
'hidden-columns', 'update-welcome-panel', 'menu-get-metabox', 'wp-link-ajax',
'menu-locations-save', 'menu-quick-search', 'meta-box-order', 'get-permalink',
'sample-permalink', 'inline-save', 'inline-save-tax', 'find_posts', 'widgets-order',
'save-widget', 'set-post-thumbnail', 'date_format', 'time_format', 'wp-fullscreen-save-post',
'wp-remove-post-lock', 'dismiss-wp-pointer', 'upload-attachment', 'get-attachment',
'query-attachments', 'save-attachment', 'save-attachment-compat', 'send-link-to-editor',
'send-attachment-to-editor', 'save-attachment-order', 'heartbeat', 'get-revision-diffs',
'save-user-color-scheme', 'update-widget', 'query-themes',
);
// Register core Ajax calls.
if ( ! empty( $_GET['action'] ) && in_array( $_GET['action'], $core_actions_get ) )
add_action( 'wp_ajax_' . $_GET['action'], 'wp_ajax_' . str_replace( '-', '_', $_GET['action'] ), 1 );
if ( ! empty( $_POST['action'] ) && in_array( $_POST['action'], $core_actions_post ) )
add_action( 'wp_ajax_' . $_POST['action'], 'wp_ajax_' . str_replace( '-', '_', $_POST['action'] ), 1 );
add_action( 'wp_ajax_nopriv_heartbeat', 'wp_ajax_nopriv_heartbeat', 1 );
if ( is_user_logged_in() ) {
/**
* Fires authenticated AJAX actions for logged-in users.
*
* The dynamic portion of the hook name, $_REQUEST['action'],
* refers to the name of the AJAX action callback being fired.
*
* @since 2.1.0
*/
do_action( 'wp_ajax_' . $_REQUEST['action'] );
} else {
/**
* Fires non-authenticated AJAX actions for logged-out users.
*
* The dynamic portion of the hook name, $_REQUEST['action'],
* refers to the name of the AJAX action callback being fired.
*
* @since 2.8.0
*/
do_action( 'wp_ajax_nopriv_' . $_REQUEST['action'] );
}
// Default status
die( '0' );
| 01-wordpress-paypal | trunk/wp-admin/admin-ajax.php | PHP | gpl3 | 3,301 |
<?php
/**
* Theme Customize Screen.
*
* @package WordPress
* @subpackage Customize
* @since 3.4.0
*/
define( 'IFRAME_REQUEST', true );
/** Load WordPress Administration Bootstrap */
require_once( dirname( __FILE__ ) . '/admin.php' );
if ( ! current_user_can( 'edit_theme_options' ) )
wp_die( __( 'Cheatin’ uh?' ) );
wp_reset_vars( array( 'url', 'return' ) );
$url = urldecode( $url );
$url = wp_validate_redirect( $url, home_url( '/' ) );
if ( $return )
$return = wp_validate_redirect( urldecode( $return ) );
if ( ! $return )
$return = $url;
global $wp_scripts, $wp_customize;
$registered = $wp_scripts->registered;
$wp_scripts = new WP_Scripts;
$wp_scripts->registered = $registered;
add_action( 'customize_controls_print_scripts', 'print_head_scripts', 20 );
add_action( 'customize_controls_print_footer_scripts', '_wp_footer_scripts' );
add_action( 'customize_controls_print_styles', 'print_admin_styles', 20 );
/**
* Fires when Customizer controls are initialized, before scripts are enqueued.
*
* @since 3.4.0
*/
do_action( 'customize_controls_init' );
wp_enqueue_script( 'customize-controls' );
wp_enqueue_style( 'customize-controls' );
wp_enqueue_script( 'accordion' );
/**
* Enqueue Customizer control scripts.
*
* @since 3.4.0
*/
do_action( 'customize_controls_enqueue_scripts' );
// Let's roll.
@header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
wp_user_settings();
_wp_admin_html_begin();
$body_class = 'wp-core-ui wp-customizer js';
if ( wp_is_mobile() ) :
$body_class .= ' mobile';
?><meta name="viewport" id="viewport-meta" content="width=device-width, initial-scale=0.8, minimum-scale=0.5, maximum-scale=1.2"><?php
endif;
$is_ios = wp_is_mobile() && preg_match( '/iPad|iPod|iPhone/', $_SERVER['HTTP_USER_AGENT'] );
if ( $is_ios )
$body_class .= ' ios';
if ( is_rtl() )
$body_class .= ' rtl';
$body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) );
$admin_title = sprintf( __( '%1$s — WordPress' ), strip_tags( sprintf( __( 'Customize %s' ), $wp_customize->theme()->display('Name') ) ) );
?><title><?php echo $admin_title; ?></title>
<script type="text/javascript">
var ajaxurl = '<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>';
</script>
<?php
/**
* Fires when Customizer control styles are printed.
*
* @since 3.4.0
*/
do_action( 'customize_controls_print_styles' );
/**
* Fires when Customizer control scripts are printed.
*
* @since 3.4.0
*/
do_action( 'customize_controls_print_scripts' );
?>
</head>
<body class="<?php echo esc_attr( $body_class ); ?>">
<div class="wp-full-overlay expanded">
<form id="customize-controls" class="wrap wp-full-overlay-sidebar">
<div id="customize-header-actions" class="wp-full-overlay-header">
<?php
$save_text = $wp_customize->is_theme_active() ? __( 'Save & Publish' ) : __( 'Save & Activate' );
submit_button( $save_text, 'primary save', 'save', false );
?>
<span class="spinner"></span>
<a class="back button" href="<?php echo esc_url( $return ? $return : admin_url( 'themes.php' ) ); ?>">
<?php _e( 'Cancel' ); ?>
</a>
</div>
<?php
$screenshot = $wp_customize->theme()->get_screenshot();
$cannot_expand = ! ( $screenshot || $wp_customize->theme()->get('Description') );
?>
<div id="widgets-right"><!-- For Widget Customizer, many widgets try to look for instances under div#widgets-right, so we have to add that ID to a container div in the customizer for compat -->
<div class="wp-full-overlay-sidebar-content accordion-container" tabindex="-1">
<div id="customize-info" class="accordion-section <?php if ( $cannot_expand ) echo ' cannot-expand'; ?>">
<div class="accordion-section-title" aria-label="<?php esc_attr_e( 'Theme Customizer Options' ); ?>" tabindex="0">
<span class="preview-notice"><?php
/* translators: %s is the theme name in the Customize/Live Preview pane */
echo sprintf( __( 'You are previewing %s' ), '<strong class="theme-name">' . $wp_customize->theme()->display('Name') . '</strong>' );
?></span>
</div>
<?php if ( ! $cannot_expand ) : ?>
<div class="accordion-section-content">
<?php if ( $screenshot ) : ?>
<img class="theme-screenshot" src="<?php echo esc_url( $screenshot ); ?>" />
<?php endif; ?>
<?php if ( $wp_customize->theme()->get('Description') ): ?>
<div class="theme-description"><?php echo $wp_customize->theme()->display('Description'); ?></div>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
<div id="customize-theme-controls"><ul>
<?php
foreach ( $wp_customize->sections() as $section )
$section->maybe_render();
?>
</ul></div>
</div>
</div>
<div id="customize-footer-actions" class="wp-full-overlay-footer">
<a href="#" class="collapse-sidebar button-secondary" title="<?php esc_attr_e('Collapse Sidebar'); ?>">
<span class="collapse-sidebar-arrow"></span>
<span class="collapse-sidebar-label"><?php _e('Collapse'); ?></span>
</a>
</div>
</form>
<div id="customize-preview" class="wp-full-overlay-main"></div>
<?php
/**
* Print Customizer control scripts in the footer.
*
* @since 3.4.0
*/
do_action( 'customize_controls_print_footer_scripts' );
// If the frontend and the admin are served from the same domain, load the
// preview over ssl if the customizer is being loaded over ssl. This avoids
// insecure content warnings. This is not attempted if the admin and frontend
// are on different domains to avoid the case where the frontend doesn't have
// ssl certs. Domain mapping plugins can allow other urls in these conditions
// using the customize_allowed_urls filter.
$allowed_urls = array( home_url('/') );
$admin_origin = parse_url( admin_url() );
$home_origin = parse_url( home_url() );
$cross_domain = ( strtolower( $admin_origin[ 'host' ] ) != strtolower( $home_origin[ 'host' ] ) );
if ( is_ssl() && ! $cross_domain )
$allowed_urls[] = home_url( '/', 'https' );
/**
* Filter the list of URLs allowed to be clicked and followed in the Customizer preview.
*
* @since 3.4.0
*
* @param array $allowed_urls An array of allowed URLs.
*/
$allowed_urls = array_unique( apply_filters( 'customize_allowed_urls', $allowed_urls ) );
$fallback_url = add_query_arg( array(
'preview' => 1,
'template' => $wp_customize->get_template(),
'stylesheet' => $wp_customize->get_stylesheet(),
'preview_iframe' => true,
'TB_iframe' => 'true'
), home_url( '/' ) );
$login_url = add_query_arg( array(
'interim-login' => 1,
'customize-login' => 1
), wp_login_url() );
// Prepare customizer settings to pass to Javascript.
$settings = array(
'theme' => array(
'stylesheet' => $wp_customize->get_stylesheet(),
'active' => $wp_customize->is_theme_active(),
),
'url' => array(
'preview' => esc_url_raw( $url ? $url : home_url( '/' ) ),
'parent' => esc_url_raw( admin_url() ),
'activated' => esc_url_raw( admin_url( 'themes.php?activated=true&previewed' ) ),
'ajax' => esc_url_raw( admin_url( 'admin-ajax.php', 'relative' ) ),
'allowed' => array_map( 'esc_url_raw', $allowed_urls ),
'isCrossDomain' => $cross_domain,
'fallback' => esc_url_raw( $fallback_url ),
'home' => esc_url_raw( home_url( '/' ) ),
'login' => esc_url_raw( $login_url ),
),
'browser' => array(
'mobile' => wp_is_mobile(),
'ios' => $is_ios,
),
'settings' => array(),
'controls' => array(),
'nonce' => array(
'save' => wp_create_nonce( 'save-customize_' . $wp_customize->get_stylesheet() ),
'preview' => wp_create_nonce( 'preview-customize_' . $wp_customize->get_stylesheet() )
),
);
// Prepare Customize Setting objects to pass to Javascript.
foreach ( $wp_customize->settings() as $id => $setting ) {
$settings['settings'][ $id ] = array(
'value' => $setting->js_value(),
'transport' => $setting->transport,
);
}
// Prepare Customize Control objects to pass to Javascript.
foreach ( $wp_customize->controls() as $id => $control ) {
$control->to_json();
$settings['controls'][ $id ] = $control->json;
}
?>
<script type="text/javascript">
var _wpCustomizeSettings = <?php echo json_encode( $settings ); ?>;
</script>
</div>
</body>
</html>
| 01-wordpress-paypal | trunk/wp-admin/customize.php | PHP | gpl3 | 8,433 |
<?php
/**
* WordPress Installer
*
* @package WordPress
* @subpackage Administration
*/
// Sanity check.
if ( false ) {
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Error: PHP is not running</title>
</head>
<body class="wp-core-ui">
<h1 id="logo"><a href="https://wordpress.org/">WordPress</a></h1>
<h2>Error: PHP is not running</h2>
<p>WordPress requires that your web server is running PHP. Your server does not have PHP installed, or PHP is turned off.</p>
</body>
</html>
<?php
}
/**
* We are installing WordPress.
*
* @since 1.5.1
* @var bool
*/
define( 'WP_INSTALLING', true );
/** Load WordPress Bootstrap */
require_once( dirname( dirname( __FILE__ ) ) . '/wp-load.php' );
/** Load WordPress Administration Upgrade API */
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
/** Load wpdb */
require_once( ABSPATH . 'wp-includes/wp-db.php' );
$step = isset( $_GET['step'] ) ? (int) $_GET['step'] : 0;
/**
* Display install header.
*
* @since 2.5.0
*/
function display_header() {
header( 'Content-Type: text/html; charset=utf-8' );
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
<head>
<meta name="viewport" content="width=device-width" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php _e( 'WordPress › Installation' ); ?></title>
<?php
wp_admin_css( 'install', true );
?>
</head>
<body class="wp-core-ui<?php if ( is_rtl() ) echo ' rtl'; ?>">
<h1 id="logo"><a href="<?php echo esc_url( __( 'https://wordpress.org/' ) ); ?>"><?php _e( 'WordPress' ); ?></a></h1>
<?php
} // end display_header()
/**
* Display installer setup form.
*
* @since 2.8.0
*/
function display_setup_form( $error = null ) {
global $wpdb;
$user_table = ( $wpdb->get_var("SHOW TABLES LIKE '$wpdb->users'") != null );
// Ensure that Blogs appear in search engines by default
$blog_public = 1;
if ( ! empty( $_POST ) )
$blog_public = isset( $_POST['blog_public'] );
$weblog_title = isset( $_POST['weblog_title'] ) ? trim( wp_unslash( $_POST['weblog_title'] ) ) : '';
$user_name = isset($_POST['user_name']) ? trim( wp_unslash( $_POST['user_name'] ) ) : '';
$admin_password = isset($_POST['admin_password']) ? trim( wp_unslash( $_POST['admin_password'] ) ) : '';
$admin_email = isset( $_POST['admin_email'] ) ? trim( wp_unslash( $_POST['admin_email'] ) ) : '';
if ( ! is_null( $error ) ) {
?>
<p class="message"><?php echo $error; ?></p>
<?php } ?>
<form id="setup" method="post" action="install.php?step=2">
<table class="form-table">
<tr>
<th scope="row"><label for="weblog_title"><?php _e( 'Site Title' ); ?></label></th>
<td><input name="weblog_title" type="text" id="weblog_title" size="25" value="<?php echo esc_attr( $weblog_title ); ?>" /></td>
</tr>
<tr>
<th scope="row"><label for="user_login"><?php _e('Username'); ?></label></th>
<td>
<?php
if ( $user_table ) {
_e('User(s) already exists.');
echo '<input name="user_name" type="hidden" value="admin" />';
} else {
?><input name="user_name" type="text" id="user_login" size="25" value="<?php echo esc_attr( sanitize_user( $user_name, true ) ); ?>" />
<p><?php _e( 'Usernames can have only alphanumeric characters, spaces, underscores, hyphens, periods and the @ symbol.' ); ?></p>
<?php
} ?>
</td>
</tr>
<?php if ( ! $user_table ) : ?>
<tr>
<th scope="row">
<label for="admin_password"><?php _e('Password, twice'); ?></label>
<p><?php _e('A password will be automatically generated for you if you leave this blank.'); ?></p>
</th>
<td>
<input name="admin_password" type="password" id="pass1" size="25" value="" />
<p><input name="admin_password2" type="password" id="pass2" size="25" value="" /></p>
<div id="pass-strength-result"><?php _e('Strength indicator'); ?></div>
<p><?php _e('Hint: The password should be at least seven characters long. To make it stronger, use upper and lower case letters, numbers, and symbols like ! " ? $ % ^ & ).'); ?></p>
</td>
</tr>
<?php endif; ?>
<tr>
<th scope="row"><label for="admin_email"><?php _e( 'Your E-mail' ); ?></label></th>
<td><input name="admin_email" type="text" id="admin_email" size="25" value="<?php echo esc_attr( $admin_email ); ?>" />
<p><?php _e( 'Double-check your email address before continuing.' ); ?></p></td>
</tr>
<tr>
<th scope="row"><label for="blog_public"><?php _e( 'Privacy' ); ?></label></th>
<td colspan="2"><label><input type="checkbox" name="blog_public" value="1" <?php checked( $blog_public ); ?> /> <?php _e( 'Allow search engines to index this site.' ); ?></label></td>
</tr>
</table>
<p class="step"><input type="submit" name="Submit" value="<?php esc_attr_e( 'Install WordPress' ); ?>" class="button button-large" /></p>
</form>
<?php
} // end display_setup_form()
// Let's check to make sure WP isn't already installed.
if ( is_blog_installed() ) {
display_header();
die( '<h1>' . __( 'Already Installed' ) . '</h1><p>' . __( 'You appear to have already installed WordPress. To reinstall please clear your old database tables first.' ) . '</p><p class="step"><a href="../wp-login.php" class="button button-large">' . __( 'Log In' ) . '</a></p></body></html>' );
}
$php_version = phpversion();
$mysql_version = $wpdb->db_version();
$php_compat = version_compare( $php_version, $required_php_version, '>=' );
$mysql_compat = version_compare( $mysql_version, $required_mysql_version, '>=' ) || file_exists( WP_CONTENT_DIR . '/db.php' );
if ( !$mysql_compat && !$php_compat )
$compat = sprintf( __( 'You cannot install because <a href="http://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> requires PHP version %2$s or higher and MySQL version %3$s or higher. You are running PHP version %4$s and MySQL version %5$s.' ), $wp_version, $required_php_version, $required_mysql_version, $php_version, $mysql_version );
elseif ( !$php_compat )
$compat = sprintf( __( 'You cannot install because <a href="http://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> requires PHP version %2$s or higher. You are running version %3$s.' ), $wp_version, $required_php_version, $php_version );
elseif ( !$mysql_compat )
$compat = sprintf( __( 'You cannot install because <a href="http://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> requires MySQL version %2$s or higher. You are running version %3$s.' ), $wp_version, $required_mysql_version, $mysql_version );
if ( !$mysql_compat || !$php_compat ) {
display_header();
die( '<h1>' . __( 'Insufficient Requirements' ) . '</h1><p>' . $compat . '</p></body></html>' );
}
if ( ! is_string( $wpdb->base_prefix ) || '' === $wpdb->base_prefix ) {
display_header();
die( '<h1>' . __( 'Configuration Error' ) . '</h1><p>' . __( 'Your <code>wp-config.php</code> file has an empty database table prefix, which is not supported.' ) . '</p></body></html>' );
}
switch($step) {
case 0: // Step 1
case 1: // Step 1, direct link.
display_header();
?>
<h1><?php _ex( 'Welcome', 'Howdy' ); ?></h1>
<p><?php printf( __( 'Welcome to the famous five minute WordPress installation process! You may want to browse the <a href="%s">ReadMe documentation</a> at your leisure. Otherwise, just fill in the information below and you’ll be on your way to using the most extendable and powerful personal publishing platform in the world.' ), '../readme.html' ); ?></p>
<h1><?php _e( 'Information needed' ); ?></h1>
<p><?php _e( 'Please provide the following information. Don’t worry, you can always change these settings later.' ); ?></p>
<?php
display_setup_form();
break;
case 2:
if ( ! empty( $wpdb->error ) )
wp_die( $wpdb->error->get_error_message() );
display_header();
// Fill in the data we gathered
$weblog_title = isset( $_POST['weblog_title'] ) ? trim( wp_unslash( $_POST['weblog_title'] ) ) : '';
$user_name = isset($_POST['user_name']) ? trim( wp_unslash( $_POST['user_name'] ) ) : '';
$admin_password = isset($_POST['admin_password']) ? wp_unslash( $_POST['admin_password'] ) : '';
$admin_password_check = isset($_POST['admin_password2']) ? wp_unslash( $_POST['admin_password2'] ) : '';
$admin_email = isset( $_POST['admin_email'] ) ?trim( wp_unslash( $_POST['admin_email'] ) ) : '';
$public = isset( $_POST['blog_public'] ) ? (int) $_POST['blog_public'] : 0;
// check e-mail address
$error = false;
if ( empty( $user_name ) ) {
// TODO: poka-yoke
display_setup_form( __( 'Please provide a valid username.' ) );
$error = true;
} elseif ( $user_name != sanitize_user( $user_name, true ) ) {
display_setup_form( __( 'The username you provided has invalid characters.' ) );
$error = true;
} elseif ( $admin_password != $admin_password_check ) {
// TODO: poka-yoke
display_setup_form( __( 'Your passwords do not match. Please try again.' ) );
$error = true;
} else if ( empty( $admin_email ) ) {
// TODO: poka-yoke
display_setup_form( __( 'You must provide an email address.' ) );
$error = true;
} elseif ( ! is_email( $admin_email ) ) {
// TODO: poka-yoke
display_setup_form( __( 'Sorry, that isn’t a valid email address. Email addresses look like <code>username@example.com</code>.' ) );
$error = true;
}
if ( $error === false ) {
$wpdb->show_errors();
$result = wp_install($weblog_title, $user_name, $admin_email, $public, '', wp_slash( $admin_password ) );
extract( $result, EXTR_SKIP );
?>
<h1><?php _e( 'Success!' ); ?></h1>
<p><?php _e( 'WordPress has been installed. Were you expecting more steps? Sorry to disappoint.' ); ?></p>
<table class="form-table install-success">
<tr>
<th><?php _e( 'Username' ); ?></th>
<td><?php echo esc_html( sanitize_user( $user_name, true ) ); ?></td>
</tr>
<tr>
<th><?php _e( 'Password' ); ?></th>
<td><?php
if ( ! empty( $password ) && empty($admin_password_check) )
echo '<code>'. esc_html($password) .'</code><br />';
echo "<p>$password_message</p>"; ?>
</td>
</tr>
</table>
<p class="step"><a href="../wp-login.php" class="button button-large"><?php _e( 'Log In' ); ?></a></p>
<?php
}
break;
}
if ( !wp_is_mobile() ) {
?>
<script type="text/javascript">var t = document.getElementById('weblog_title'); if (t){ t.focus(); }</script>
<?php } ?>
<?php wp_print_scripts( 'user-profile' ); ?>
</body>
</html>
| 01-wordpress-paypal | trunk/wp-admin/install.php | PHP | gpl3 | 10,461 |
<?php
/**
* Upgrade WordPress Page.
*
* @package WordPress
* @subpackage Administration
*/
/**
* We are upgrading WordPress.
*
* @since 1.5.1
* @var bool
*/
define( 'WP_INSTALLING', true );
/** Load WordPress Bootstrap */
require( dirname( dirname( __FILE__ ) ) . '/wp-load.php' );
nocache_headers();
timer_start();
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
delete_site_transient('update_core');
if ( isset( $_GET['step'] ) )
$step = $_GET['step'];
else
$step = 0;
// Do it. No output.
if ( 'upgrade_db' === $step ) {
wp_upgrade();
die( '0' );
}
$step = (int) $step;
$php_version = phpversion();
$mysql_version = $wpdb->db_version();
$php_compat = version_compare( $php_version, $required_php_version, '>=' );
if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && empty( $wpdb->is_mysql ) )
$mysql_compat = true;
else
$mysql_compat = version_compare( $mysql_version, $required_mysql_version, '>=' );
@header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) );
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
<head>
<meta name="viewport" content="width=device-width" />
<meta http-equiv="Content-Type" content="<?php bloginfo( 'html_type' ); ?>; charset=<?php echo get_option( 'blog_charset' ); ?>" />
<title><?php _e( 'WordPress › Update' ); ?></title>
<?php
wp_admin_css( 'install', true );
wp_admin_css( 'ie', true );
?>
</head>
<body class="wp-core-ui">
<h1 id="logo"><a href="<?php echo esc_url( __( 'https://wordpress.org/' ) ); ?>"><?php _e( 'WordPress' ); ?></a></h1>
<?php if ( get_option( 'db_version' ) == $wp_db_version || !is_blog_installed() ) : ?>
<h2><?php _e( 'No Update Required' ); ?></h2>
<p><?php _e( 'Your WordPress database is already up-to-date!' ); ?></p>
<p class="step"><a class="button button-large" href="<?php echo get_option( 'home' ); ?>/"><?php _e( 'Continue' ); ?></a></p>
<?php elseif ( !$php_compat || !$mysql_compat ) :
if ( !$mysql_compat && !$php_compat )
printf( __('You cannot update because <a href="http://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> requires PHP version %2$s or higher and MySQL version %3$s or higher. You are running PHP version %4$s and MySQL version %5$s.'), $wp_version, $required_php_version, $required_mysql_version, $php_version, $mysql_version );
elseif ( !$php_compat )
printf( __('You cannot update because <a href="http://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> requires PHP version %2$s or higher. You are running version %3$s.'), $wp_version, $required_php_version, $php_version );
elseif ( !$mysql_compat )
printf( __('You cannot update because <a href="http://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> requires MySQL version %2$s or higher. You are running version %3$s.'), $wp_version, $required_mysql_version, $mysql_version );
?>
<?php else :
switch ( $step ) :
case 0:
$goback = wp_get_referer();
$goback = esc_url_raw( $goback );
$goback = urlencode( $goback );
?>
<h2><?php _e( 'Database Update Required' ); ?></h2>
<p><?php _e( 'WordPress has been updated! Before we send you on your way, we have to update your database to the newest version.' ); ?></p>
<p><?php _e( 'The update process may take a little while, so please be patient.' ); ?></p>
<p class="step"><a class="button button-large" href="upgrade.php?step=1&backto=<?php echo $goback; ?>"><?php _e( 'Update WordPress Database' ); ?></a></p>
<?php
break;
case 1:
wp_upgrade();
$backto = !empty($_GET['backto']) ? wp_unslash( urldecode( $_GET['backto'] ) ) : __get_option( 'home' ) . '/';
$backto = esc_url( $backto );
$backto = wp_validate_redirect($backto, __get_option( 'home' ) . '/');
?>
<h2><?php _e( 'Update Complete' ); ?></h2>
<p><?php _e( 'Your WordPress database has been successfully updated!' ); ?></p>
<p class="step"><a class="button button-large" href="<?php echo $backto; ?>"><?php _e( 'Continue' ); ?></a></p>
<!--
<pre>
<?php printf( __( '%s queries' ), $wpdb->num_queries ); ?>
<?php printf( __( '%s seconds' ), timer_stop( 0 ) ); ?>
</pre>
-->
<?php
break;
endswitch;
endif;
?>
</body>
</html>
| 01-wordpress-paypal | trunk/wp-admin/upgrade.php | PHP | gpl3 | 4,184 |
<?php
/**
* WordPress Translation API
*
* @package WordPress
* @subpackage i18n
*/
/**
* Get the current locale.
*
* If the locale is set, then it will filter the locale in the 'locale' filter
* hook and return the value.
*
* If the locale is not set already, then the WPLANG constant is used if it is
* defined. Then it is filtered through the 'locale' filter hook and the value
* for the locale global set and the locale is returned.
*
* The process to get the locale should only be done once, but the locale will
* always be filtered using the 'locale' hook.
*
* @since 1.5.0
*
* @return string The locale of the blog or from the 'locale' hook.
*/
function get_locale() {
global $locale;
if ( isset( $locale ) )
/**
* Filter WordPress install's locale ID.
*
* @since 1.5.0
*
* @param string $locale The locale ID.
*/
return apply_filters( 'locale', $locale );
// WPLANG is defined in wp-config.
if ( defined( 'WPLANG' ) )
$locale = WPLANG;
// If multisite, check options.
if ( is_multisite() ) {
// Don't check blog option when installing.
if ( defined( 'WP_INSTALLING' ) || ( false === $ms_locale = get_option( 'WPLANG' ) ) )
$ms_locale = get_site_option('WPLANG');
if ( $ms_locale !== false )
$locale = $ms_locale;
}
if ( empty( $locale ) )
$locale = 'en_US';
/** This filter is documented in wp-includes/l10n.php */
return apply_filters( 'locale', $locale );
}
/**
* Retrieve the translation of $text.
*
* If there is no translation, or the text domain isn't loaded, the original text is returned.
*
* <strong>Note:</strong> Don't use translate() directly, use __() or related functions.
*
* @since 2.2.0
*
* @param string $text Text to translate.
* @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
* @return string Translated text
*/
function translate( $text, $domain = 'default' ) {
$translations = get_translations_for_domain( $domain );
$translations = $translations->translate( $text );
/**
* Filter text with its translation.
*
* @since 2.0.11
*
* @param string $translations Translated text.
* @param string $text Text to translate.
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
*/
return apply_filters( 'gettext', $translations, $text, $domain );
}
/**
* Remove last item on a pipe-delimited string.
*
* Meant for removing the last item in a string, such as 'Role name|User role'. The original
* string will be returned if no pipe '|' characters are found in the string.
*
* @since 2.8.0
*
* @param string $string A pipe-delimited string.
* @return string Either $string or everything before the last pipe.
*/
function before_last_bar( $string ) {
$last_bar = strrpos( $string, '|' );
if ( false == $last_bar )
return $string;
else
return substr( $string, 0, $last_bar );
}
/**
* Retrieve the translation of $text in the context defined in $context.
*
* If there is no translation, or the text domain isn't loaded the original
* text is returned.
*
* @since 2.8.0
*
* @param string $text Text to translate.
* @param string $context Context information for the translators.
* @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
* @return string Translated text on success, original text on failure.
*/
function translate_with_gettext_context( $text, $context, $domain = 'default' ) {
$translations = get_translations_for_domain( $domain );
$translations = $translations->translate( $text, $context );
/**
* Filter text with its translation based on context information.
*
* @since 2.8.0
*
* @param string $translations Translated text.
* @param string $text Text to translate.
* @param string $context Context information for the translators.
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
*/
return apply_filters( 'gettext_with_context', $translations, $text, $context, $domain );
}
/**
* Retrieve the translation of $text. If there is no translation,
* or the text domain isn't loaded, the original text is returned.
*
* @since 2.1.0
*
* @param string $text Text to translate.
* @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
* @return string Translated text.
*/
function __( $text, $domain = 'default' ) {
return translate( $text, $domain );
}
/**
* Retrieve the translation of $text and escapes it for safe use in an attribute.
*
* If there is no translation, or the text domain isn't loaded, the original text is returned.
*
* @since 2.8.0
*
* @param string $text Text to translate.
* @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
* @return string Translated text on success, original text on failure.
*/
function esc_attr__( $text, $domain = 'default' ) {
return esc_attr( translate( $text, $domain ) );
}
/**
* Retrieve the translation of $text and escapes it for safe use in HTML output.
*
* If there is no translation, or the text domain isn't loaded, the original text is returned.
*
* @since 2.8.0
*
* @param string $text Text to translate.
* @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
* @return string Translated text
*/
function esc_html__( $text, $domain = 'default' ) {
return esc_html( translate( $text, $domain ) );
}
/**
* Display translated text.
*
* @since 1.2.0
*
* @param string $text Text to translate.
* @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
*/
function _e( $text, $domain = 'default' ) {
echo translate( $text, $domain );
}
/**
* Display translated text that has been escaped for safe use in an attribute.
*
* @since 2.8.0
*
* @param string $text Text to translate.
* @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
*/
function esc_attr_e( $text, $domain = 'default' ) {
echo esc_attr( translate( $text, $domain ) );
}
/**
* Display translated text that has been escaped for safe use in HTML output.
*
* @since 2.8.0
*
* @param string $text Text to translate.
* @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
*/
function esc_html_e( $text, $domain = 'default' ) {
echo esc_html( translate( $text, $domain ) );
}
/**
* Retrieve translated string with gettext context.
*
* Quite a few times, there will be collisions with similar translatable text
* found in more than two places, but with different translated context.
*
* By including the context in the pot file, translators can translate the two
* strings differently.
*
* @since 2.8.0
*
* @param string $text Text to translate.
* @param string $context Context information for the translators.
* @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
* @return string Translated context string without pipe.
*/
function _x( $text, $context, $domain = 'default' ) {
return translate_with_gettext_context( $text, $context, $domain );
}
/**
* Display translated string with gettext context.
*
* @since 3.0.0
*
* @param string $text Text to translate.
* @param string $context Context information for the translators.
* @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
* @return string Translated context string without pipe.
*/
function _ex( $text, $context, $domain = 'default' ) {
echo _x( $text, $context, $domain );
}
/**
* Translate string with gettext context, and escapes it for safe use in an attribute.
*
* @since 2.8.0
*
* @param string $text Text to translate.
* @param string $context Context information for the translators.
* @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
* @return string Translated text
*/
function esc_attr_x( $text, $context, $domain = 'default' ) {
return esc_attr( translate_with_gettext_context( $text, $context, $domain ) );
}
/**
* Translate string with gettext context, and escapes it for safe use in HTML output.
*
* @since 2.9.0
*
* @param string $text Text to translate.
* @param string $context Context information for the translators.
* @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
* @return string Translated text.
*/
function esc_html_x( $text, $context, $domain = 'default' ) {
return esc_html( translate_with_gettext_context( $text, $context, $domain ) );
}
/**
* Retrieve the plural or single form based on the supplied amount.
*
* If the text domain is not set in the $l10n list, then a comparison will be made
* and either $plural or $single parameters returned.
*
* If the text domain does exist, then the parameters $single, $plural, and $number
* will first be passed to the text domain's ngettext method. Then it will be passed
* to the 'ngettext' filter hook along with the same parameters. The expected
* type will be a string.
*
* @since 2.8.0
*
* @param string $single The text that will be used if $number is 1.
* @param string $plural The text that will be used if $number is not 1.
* @param int $number The number to compare against to use either $single or $plural.
* @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
* @return string Either $single or $plural translated text.
*/
function _n( $single, $plural, $number, $domain = 'default' ) {
$translations = get_translations_for_domain( $domain );
$translation = $translations->translate_plural( $single, $plural, $number );
/**
* Filter text with its translation when plural option is available.
*
* @since 2.2.0
*
* @param string $translation Translated text.
* @param string $single The text that will be used if $number is 1.
* @param string $plural The text that will be used if $number is not 1.
* @param string $number The number to compare against to use either $single or $plural.
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
*/
return apply_filters( 'ngettext', $translation, $single, $plural, $number, $domain );
}
/**
* Retrieve the plural or single form based on the supplied amount with gettext context.
*
* This is a hybrid of _n() and _x(). It supports contexts and plurals.
*
* @since 2.8.0
*
* @param string $single The text that will be used if $number is 1.
* @param string $plural The text that will be used if $number is not 1.
* @param int $number The number to compare against to use either $single or $plural.
* @param string $context Context information for the translators.
* @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
* @return string Either $single or $plural translated text with context.
*/
function _nx($single, $plural, $number, $context, $domain = 'default') {
$translations = get_translations_for_domain( $domain );
$translation = $translations->translate_plural( $single, $plural, $number, $context );
/**
* Filter text with its translation while plural option and context are available.
*
* @since 2.8.0
*
* @param string $translation Translated text.
* @param string $single The text that will be used if $number is 1.
* @param string $plural The text that will be used if $number is not 1.
* @param string $number The number to compare against to use either $single or $plural.
* @param string $context Context information for the translators.
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
*/
return apply_filters( 'ngettext_with_context', $translation, $single, $plural, $number, $context, $domain );
}
/**
* Register plural strings in POT file, but don't translate them.
*
* Used when you want to keep structures with translatable plural
* strings and use them later.
*
* Example:
* <code>
* $messages = array(
* 'post' => _n_noop('%s post', '%s posts'),
* 'page' => _n_noop('%s pages', '%s pages')
* );
* ...
* $message = $messages[$type];
* $usable_text = sprintf( translate_nooped_plural( $message, $count ), $count );
* </code>
*
* @since 2.5.0
*
* @param string $singular Single form to be i18ned.
* @param string $plural Plural form to be i18ned.
* @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
* @return array array($singular, $plural)
*/
function _n_noop( $singular, $plural, $domain = null ) {
return array( 0 => $singular, 1 => $plural, 'singular' => $singular, 'plural' => $plural, 'context' => null, 'domain' => $domain );
}
/**
* Register plural strings with context in POT file, but don't translate them.
*
* @since 2.8.0
*/
function _nx_noop( $singular, $plural, $context, $domain = null ) {
return array( 0 => $singular, 1 => $plural, 2 => $context, 'singular' => $singular, 'plural' => $plural, 'context' => $context, 'domain' => $domain );
}
/**
* Translate the result of _n_noop() or _nx_noop().
*
* @since 3.1.0
*
* @param array $nooped_plural Array with singular, plural and context keys, usually the result of _n_noop() or _nx_noop()
* @param int $count Number of objects
* @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings. If $nooped_plural contains
* a text domain passed to _n_noop() or _nx_noop(), it will override this value.
* @return string Either $single or $plural translated text.
*/
function translate_nooped_plural( $nooped_plural, $count, $domain = 'default' ) {
if ( $nooped_plural['domain'] )
$domain = $nooped_plural['domain'];
if ( $nooped_plural['context'] )
return _nx( $nooped_plural['singular'], $nooped_plural['plural'], $count, $nooped_plural['context'], $domain );
else
return _n( $nooped_plural['singular'], $nooped_plural['plural'], $count, $domain );
}
/**
* Load a .mo file into the text domain $domain.
*
* If the text domain already exists, the translations will be merged. If both
* sets have the same string, the translation from the original value will be taken.
*
* On success, the .mo file will be placed in the $l10n global by $domain
* and will be a MO object.
*
* @since 1.5.0
*
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
* @param string $mofile Path to the .mo file.
* @return bool True on success, false on failure.
*/
function load_textdomain( $domain, $mofile ) {
global $l10n;
/**
* Filter text domain and/or MO file path for loading translations.
*
* @since 2.9.0
*
* @param bool $override Whether to override the text domain. Default false.
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
* @param string $mofile Path to the MO file.
*/
$plugin_override = apply_filters( 'override_load_textdomain', false, $domain, $mofile );
if ( true == $plugin_override ) {
return true;
}
/**
* Fires before the MO translation file is loaded.
*
* @since 2.9.0
*
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
* @param string $mofile Path to the .mo file.
*/
do_action( 'load_textdomain', $domain, $mofile );
/**
* Filter MO file path for loading translations for a specific text domain.
*
* @since 2.9.0
*
* @param string $mofile Path to the MO file.
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
*/
$mofile = apply_filters( 'load_textdomain_mofile', $mofile, $domain );
if ( !is_readable( $mofile ) ) return false;
$mo = new MO();
if ( !$mo->import_from_file( $mofile ) ) return false;
if ( isset( $l10n[$domain] ) )
$mo->merge_with( $l10n[$domain] );
$l10n[$domain] = &$mo;
return true;
}
/**
* Unload translations for a text domain.
*
* @since 3.0.0
*
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
* @return bool Whether textdomain was unloaded.
*/
function unload_textdomain( $domain ) {
global $l10n;
/**
* Filter the text domain for loading translation.
*
* @since 3.0.0
*
* @param bool $override Whether to override unloading the text domain. Default false.
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
*/
$plugin_override = apply_filters( 'override_unload_textdomain', false, $domain );
if ( $plugin_override )
return true;
/**
* Fires before the text domain is unloaded.
*
* @since 3.0.0
*
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
*/
do_action( 'unload_textdomain', $domain );
if ( isset( $l10n[$domain] ) ) {
unset( $l10n[$domain] );
return true;
}
return false;
}
/**
* Load default translated strings based on locale.
*
* Loads the .mo file in WP_LANG_DIR constant path from WordPress root.
* The translated (.mo) file is named based on the locale.
*
* @see load_textdomain()
*
* @since 1.5.0
*/
function load_default_textdomain() {
$locale = get_locale();
load_textdomain( 'default', WP_LANG_DIR . "/$locale.mo" );
if ( ( is_multisite() || ( defined( 'WP_INSTALLING_NETWORK' ) && WP_INSTALLING_NETWORK ) ) && ! file_exists( WP_LANG_DIR . "/admin-$locale.mo" ) ) {
load_textdomain( 'default', WP_LANG_DIR . "/ms-$locale.mo" );
return;
}
if ( is_admin() || ( defined( 'WP_REPAIRING' ) && WP_REPAIRING ) )
load_textdomain( 'default', WP_LANG_DIR . "/admin-$locale.mo" );
if ( is_network_admin() || ( defined( 'WP_INSTALLING_NETWORK' ) && WP_INSTALLING_NETWORK ) )
load_textdomain( 'default', WP_LANG_DIR . "/admin-network-$locale.mo" );
}
/**
* Load a plugin's translated strings.
*
* If the path is not given then it will be the root of the plugin directory.
*
* The .mo file should be named based on the text domain with a dash, and then the locale exactly.
*
* @since 1.5.0
*
* @param string $domain Unique identifier for retrieving translated strings
* @param string $deprecated Use the $plugin_rel_path parameter instead.
* @param string $plugin_rel_path Optional. Relative path to WP_PLUGIN_DIR where the .mo file resides.
*/
function load_plugin_textdomain( $domain, $deprecated = false, $plugin_rel_path = false ) {
$locale = get_locale();
/**
* Filter a plugin's locale.
*
* @since 3.0.0
*
* @param string $locale The plugin's current locale.
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
*/
$locale = apply_filters( 'plugin_locale', $locale, $domain );
if ( false !== $plugin_rel_path ) {
$path = WP_PLUGIN_DIR . '/' . trim( $plugin_rel_path, '/' );
} else if ( false !== $deprecated ) {
_deprecated_argument( __FUNCTION__, '2.7' );
$path = ABSPATH . trim( $deprecated, '/' );
} else {
$path = WP_PLUGIN_DIR;
}
// Load the textdomain according to the plugin first
$mofile = $domain . '-' . $locale . '.mo';
if ( $loaded = load_textdomain( $domain, $path . '/'. $mofile ) )
return $loaded;
// Otherwise, load from the languages directory
$mofile = WP_LANG_DIR . '/plugins/' . $mofile;
return load_textdomain( $domain, $mofile );
}
/**
* Load the translated strings for a plugin residing in the mu-plugins directory.
*
* @since 3.0.0
*
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
* @param string $mu_plugin_rel_path Relative to WPMU_PLUGIN_DIR directory in which the .mo file resides.
* Default empty string.
* @return bool True when textdomain is successfully loaded, false otherwise.
*/
function load_muplugin_textdomain( $domain, $mu_plugin_rel_path = '' ) {
/** This filter is documented in wp-includes/l10n.php */
$locale = apply_filters( 'plugin_locale', get_locale(), $domain );
$path = trailingslashit( WPMU_PLUGIN_DIR . '/' . ltrim( $mu_plugin_rel_path, '/' ) );
// Load the textdomain according to the plugin first
$mofile = $domain . '-' . $locale . '.mo';
if ( $loaded = load_textdomain( $domain, $path . $mofile ) )
return $loaded;
// Otherwise, load from the languages directory
$mofile = WP_LANG_DIR . '/plugins/' . $mofile;
return load_textdomain( $domain, $mofile );
}
/**
* Load the theme's translated strings.
*
* If the current locale exists as a .mo file in the theme's root directory, it
* will be included in the translated strings by the $domain.
*
* The .mo files must be named based on the locale exactly.
*
* @since 1.5.0
*
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
* @param string $path Optional. Path to the directory containing the .mo file.
* Default false.
* @return bool True when textdomain is successfully loaded, false otherwise.
*/
function load_theme_textdomain( $domain, $path = false ) {
$locale = get_locale();
/**
* Filter a theme's locale.
*
* @since 3.0.0
*
* @param string $locale The theme's current locale.
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
*/
$locale = apply_filters( 'theme_locale', $locale, $domain );
if ( ! $path )
$path = get_template_directory();
// Load the textdomain according to the theme
$mofile = "{$path}/{$locale}.mo";
if ( $loaded = load_textdomain( $domain, $mofile ) )
return $loaded;
// Otherwise, load from the languages directory
$mofile = WP_LANG_DIR . "/themes/{$domain}-{$locale}.mo";
return load_textdomain( $domain, $mofile );
}
/**
* Load the child themes translated strings.
*
* If the current locale exists as a .mo file in the child themes
* root directory, it will be included in the translated strings by the $domain.
*
* The .mo files must be named based on the locale exactly.
*
* @since 2.9.0
*
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
* @return bool True when the theme textdomain is successfully loaded, false otherwise.
*/
function load_child_theme_textdomain( $domain, $path = false ) {
if ( ! $path )
$path = get_stylesheet_directory();
return load_theme_textdomain( $domain, $path );
}
/**
* Return the Translations instance for a text domain.
*
* If there isn't one, returns empty Translations instance.
*
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
* @return Translations A Translations instance.
*/
function get_translations_for_domain( $domain ) {
global $l10n;
if ( !isset( $l10n[$domain] ) ) {
$l10n[$domain] = new NOOP_Translations;
}
return $l10n[$domain];
}
/**
* Whether there are translations for the text domain.
*
* @since 3.0.0
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
* @return bool Whether there are translations.
*/
function is_textdomain_loaded( $domain ) {
global $l10n;
return isset( $l10n[$domain] );
}
/**
* Translates role name.
*
* Since the role names are in the database and not in the source there
* are dummy gettext calls to get them into the POT file and this function
* properly translates them back.
*
* The before_last_bar() call is needed, because older installs keep the roles
* using the old context format: 'Role name|User role' and just skipping the
* content after the last bar is easier than fixing them in the DB. New installs
* won't suffer from that problem.
*
* @since 2.8.0
*
* @param string $name The role name.
* @return string Translated role name on success, original name on failure.
*/
function translate_user_role( $name ) {
return translate_with_gettext_context( before_last_bar($name), 'User role' );
}
/**
* Get all available languages based on the presence of *.mo files in a given directory.
*
* The default directory is WP_LANG_DIR.
*
* @since 3.0.0
*
* @param string $dir A directory to search for language files.
* Default WP_LANG_DIR.
* @return array An array of language codes or an empty array if no languages are present. Language codes are formed by stripping the .mo extension from the language file names.
*/
function get_available_languages( $dir = null ) {
$languages = array();
foreach( (array)glob( ( is_null( $dir) ? WP_LANG_DIR : $dir ) . '/*.mo' ) as $lang_file ) {
$lang_file = basename($lang_file, '.mo');
if ( 0 !== strpos( $lang_file, 'continents-cities' ) && 0 !== strpos( $lang_file, 'ms-' ) &&
0 !== strpos( $lang_file, 'admin-' ))
$languages[] = $lang_file;
}
return $languages;
}
/**
* Get installed translations.
*
* Looks in the wp-content/languages directory for translations of
* plugins or themes.
*
* @since 3.7.0
*
* @param string $type What to search for. Accepts 'plugins', 'themes', 'core'.
* @return array Array of language data.
*/
function wp_get_installed_translations( $type ) {
if ( $type !== 'themes' && $type !== 'plugins' && $type !== 'core' )
return array();
$dir = 'core' === $type ? '' : "/$type";
if ( ! is_dir( WP_LANG_DIR ) )
return array();
if ( $dir && ! is_dir( WP_LANG_DIR . $dir ) )
return array();
$files = scandir( WP_LANG_DIR . $dir );
if ( ! $files )
return array();
$language_data = array();
foreach ( $files as $file ) {
if ( '.' === $file[0] || is_dir( $file ) )
continue;
if ( substr( $file, -3 ) !== '.po' )
continue;
if ( ! preg_match( '/(?:(.+)-)?([A-Za-z_]{2,6}).po/', $file, $match ) )
continue;
list( , $textdomain, $language ) = $match;
if ( '' === $textdomain )
$textdomain = 'default';
$language_data[ $textdomain ][ $language ] = wp_get_pomo_file_data( WP_LANG_DIR . "$dir/$file" );
}
return $language_data;
}
/**
* Extract headers from a PO file.
*
* @since 3.7.0
*
* @param string $po_file Path to PO file.
* @return array PO file headers.
*/
function wp_get_pomo_file_data( $po_file ) {
$headers = get_file_data( $po_file, array(
'POT-Creation-Date' => '"POT-Creation-Date',
'PO-Revision-Date' => '"PO-Revision-Date',
'Project-Id-Version' => '"Project-Id-Version',
'X-Generator' => '"X-Generator',
) );
foreach ( $headers as $header => $value ) {
// Remove possible contextual '\n' and closing double quote.
$headers[ $header ] = preg_replace( '~(\\\n)?"$~', '', $value );
}
return $headers;
}
| 01-wordpress-paypal | trunk/wp-includes/l10n.php | PHP | gpl3 | 26,648 |
<?php
/**
* RSS 1 RDF Feed Template for displaying RSS 1 Posts feed.
*
* @package WordPress
*/
header('Content-Type: ' . feed_content_type('rdf') . '; charset=' . get_option('blog_charset'), true);
$more = 1;
echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>
<rdf:RDF
xmlns="http://purl.org/rss/1.0/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:admin="http://webns.net/mvcb/"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
<?php
/**
* Fires at the end of the feed root to add namespaces.
*
* @since 2.0.0
*/
do_action( 'rdf_ns' );
?>
>
<channel rdf:about="<?php bloginfo_rss("url") ?>">
<title><?php bloginfo_rss('name'); wp_title_rss(); ?></title>
<link><?php bloginfo_rss('url') ?></link>
<description><?php bloginfo_rss('description') ?></description>
<dc:date><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastpostmodified('GMT'), false); ?></dc:date>
<?php /** This filter is documented in wp-includes/feed-rss2.php */ ?>
<sy:updatePeriod><?php echo apply_filters( 'rss_update_period', 'hourly' ); ?></sy:updatePeriod>
<?php /** This filter is documented in wp-includes/feed-rss2.php */ ?>
<sy:updateFrequency><?php echo apply_filters( 'rss_update_frequency', '1' ); ?></sy:updateFrequency>
<sy:updateBase>2000-01-01T12:00+00:00</sy:updateBase>
<?php
/**
* Fires at the end of the RDF feed header.
*
* @since 2.0.0
*/
do_action( 'rdf_header' );
?>
<items>
<rdf:Seq>
<?php while (have_posts()): the_post(); ?>
<rdf:li rdf:resource="<?php the_permalink_rss() ?>"/>
<?php endwhile; ?>
</rdf:Seq>
</items>
</channel>
<?php rewind_posts(); while (have_posts()): the_post(); ?>
<item rdf:about="<?php the_permalink_rss() ?>">
<title><?php the_title_rss() ?></title>
<link><?php the_permalink_rss() ?></link>
<dc:date><?php echo mysql2date('Y-m-d\TH:i:s\Z', $post->post_date_gmt, false); ?></dc:date>
<dc:creator><![CDATA[<?php the_author() ?>]]></dc:creator>
<?php the_category_rss('rdf') ?>
<?php if (get_option('rss_use_excerpt')) : ?>
<description><![CDATA[<?php the_excerpt_rss() ?>]]></description>
<?php else : ?>
<description><![CDATA[<?php the_excerpt_rss() ?>]]></description>
<content:encoded><![CDATA[<?php the_content_feed('rdf') ?>]]></content:encoded>
<?php endif; ?>
<?php
/**
* Fires at the end of each RDF feed item.
*
* @since 2.0.0
*/
do_action( 'rdf_item' );
?>
</item>
<?php endwhile; ?>
</rdf:RDF>
| 01-wordpress-paypal | trunk/wp-includes/feed-rdf.php | PHP | gpl3 | 2,552 |
<?php
/**
* Portable PHP password hashing framework.
* @package phpass
* @since 2.5.0
* @version 0.3 / WordPress
* @link http://www.openwall.com/phpass/
*/
#
# Written by Solar Designer <solar at openwall.com> in 2004-2006 and placed in
# the public domain. Revised in subsequent years, still public domain.
#
# There's absolutely no warranty.
#
# Please be sure to update the Version line if you edit this file in any way.
# It is suggested that you leave the main version number intact, but indicate
# your project name (after the slash) and add your own revision information.
#
# Please do not change the "private" password hashing method implemented in
# here, thereby making your hashes incompatible. However, if you must, please
# change the hash type identifier (the "$P$") to something different.
#
# Obviously, since this code is in the public domain, the above are not
# requirements (there can be none), but merely suggestions.
#
/**
* Portable PHP password hashing framework.
*
* @package phpass
* @version 0.3 / WordPress
* @link http://www.openwall.com/phpass/
* @since 2.5.0
*/
class PasswordHash {
var $itoa64;
var $iteration_count_log2;
var $portable_hashes;
var $random_state;
function PasswordHash($iteration_count_log2, $portable_hashes)
{
$this->itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
if ($iteration_count_log2 < 4 || $iteration_count_log2 > 31)
$iteration_count_log2 = 8;
$this->iteration_count_log2 = $iteration_count_log2;
$this->portable_hashes = $portable_hashes;
$this->random_state = microtime() . uniqid(rand(), TRUE); // removed getmypid() for compatibility reasons
}
function get_random_bytes($count)
{
$output = '';
if ( @is_readable('/dev/urandom') &&
($fh = @fopen('/dev/urandom', 'rb'))) {
$output = fread($fh, $count);
fclose($fh);
}
if (strlen($output) < $count) {
$output = '';
for ($i = 0; $i < $count; $i += 16) {
$this->random_state =
md5(microtime() . $this->random_state);
$output .=
pack('H*', md5($this->random_state));
}
$output = substr($output, 0, $count);
}
return $output;
}
function encode64($input, $count)
{
$output = '';
$i = 0;
do {
$value = ord($input[$i++]);
$output .= $this->itoa64[$value & 0x3f];
if ($i < $count)
$value |= ord($input[$i]) << 8;
$output .= $this->itoa64[($value >> 6) & 0x3f];
if ($i++ >= $count)
break;
if ($i < $count)
$value |= ord($input[$i]) << 16;
$output .= $this->itoa64[($value >> 12) & 0x3f];
if ($i++ >= $count)
break;
$output .= $this->itoa64[($value >> 18) & 0x3f];
} while ($i < $count);
return $output;
}
function gensalt_private($input)
{
$output = '$P$';
$output .= $this->itoa64[min($this->iteration_count_log2 +
((PHP_VERSION >= '5') ? 5 : 3), 30)];
$output .= $this->encode64($input, 6);
return $output;
}
function crypt_private($password, $setting)
{
$output = '*0';
if (substr($setting, 0, 2) == $output)
$output = '*1';
$id = substr($setting, 0, 3);
# We use "$P$", phpBB3 uses "$H$" for the same thing
if ($id != '$P$' && $id != '$H$')
return $output;
$count_log2 = strpos($this->itoa64, $setting[3]);
if ($count_log2 < 7 || $count_log2 > 30)
return $output;
$count = 1 << $count_log2;
$salt = substr($setting, 4, 8);
if (strlen($salt) != 8)
return $output;
# We're kind of forced to use MD5 here since it's the only
# cryptographic primitive available in all versions of PHP
# currently in use. To implement our own low-level crypto
# in PHP would result in much worse performance and
# consequently in lower iteration counts and hashes that are
# quicker to crack (by non-PHP code).
if (PHP_VERSION >= '5') {
$hash = md5($salt . $password, TRUE);
do {
$hash = md5($hash . $password, TRUE);
} while (--$count);
} else {
$hash = pack('H*', md5($salt . $password));
do {
$hash = pack('H*', md5($hash . $password));
} while (--$count);
}
$output = substr($setting, 0, 12);
$output .= $this->encode64($hash, 16);
return $output;
}
function gensalt_extended($input)
{
$count_log2 = min($this->iteration_count_log2 + 8, 24);
# This should be odd to not reveal weak DES keys, and the
# maximum valid value is (2**24 - 1) which is odd anyway.
$count = (1 << $count_log2) - 1;
$output = '_';
$output .= $this->itoa64[$count & 0x3f];
$output .= $this->itoa64[($count >> 6) & 0x3f];
$output .= $this->itoa64[($count >> 12) & 0x3f];
$output .= $this->itoa64[($count >> 18) & 0x3f];
$output .= $this->encode64($input, 3);
return $output;
}
function gensalt_blowfish($input)
{
# This one needs to use a different order of characters and a
# different encoding scheme from the one in encode64() above.
# We care because the last character in our encoded string will
# only represent 2 bits. While two known implementations of
# bcrypt will happily accept and correct a salt string which
# has the 4 unused bits set to non-zero, we do not want to take
# chances and we also do not want to waste an additional byte
# of entropy.
$itoa64 = './ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
$output = '$2a$';
$output .= chr(ord('0') + $this->iteration_count_log2 / 10);
$output .= chr(ord('0') + $this->iteration_count_log2 % 10);
$output .= '$';
$i = 0;
do {
$c1 = ord($input[$i++]);
$output .= $itoa64[$c1 >> 2];
$c1 = ($c1 & 0x03) << 4;
if ($i >= 16) {
$output .= $itoa64[$c1];
break;
}
$c2 = ord($input[$i++]);
$c1 |= $c2 >> 4;
$output .= $itoa64[$c1];
$c1 = ($c2 & 0x0f) << 2;
$c2 = ord($input[$i++]);
$c1 |= $c2 >> 6;
$output .= $itoa64[$c1];
$output .= $itoa64[$c2 & 0x3f];
} while (1);
return $output;
}
function HashPassword($password)
{
$random = '';
if (CRYPT_BLOWFISH == 1 && !$this->portable_hashes) {
$random = $this->get_random_bytes(16);
$hash =
crypt($password, $this->gensalt_blowfish($random));
if (strlen($hash) == 60)
return $hash;
}
if (CRYPT_EXT_DES == 1 && !$this->portable_hashes) {
if (strlen($random) < 3)
$random = $this->get_random_bytes(3);
$hash =
crypt($password, $this->gensalt_extended($random));
if (strlen($hash) == 20)
return $hash;
}
if (strlen($random) < 6)
$random = $this->get_random_bytes(6);
$hash =
$this->crypt_private($password,
$this->gensalt_private($random));
if (strlen($hash) == 34)
return $hash;
# Returning '*' on error is safe here, but would _not_ be safe
# in a crypt(3)-like function used _both_ for generating new
# hashes and for validating passwords against existing hashes.
return '*';
}
function CheckPassword($password, $stored_hash)
{
$hash = $this->crypt_private($password, $stored_hash);
if ($hash[0] == '*')
$hash = crypt($password, $stored_hash);
return $hash === $stored_hash;
}
}
?>
| 01-wordpress-paypal | trunk/wp-includes/class-phpass.php | PHP | gpl3 | 6,996 |
<?php
/**
* Sets up the default filters and actions for Multisite.
*
* If you need to remove a default hook, this file will give you the priority
* for which to use to remove the hook.
*
* Not all of the Multisite default hooks are found in ms-default-filters.php
*
* @package WordPress
* @subpackage Multisite
* @see default-filters.php
* @since 3.0.0
*/
// Users
add_filter( 'wpmu_validate_user_signup', 'signup_nonce_check' );
add_action( 'init', 'maybe_add_existing_user_to_blog' );
add_action( 'wpmu_new_user', 'newuser_notify_siteadmin' );
add_action( 'wpmu_activate_user', 'add_new_user_to_blog', 10, 3 );
add_filter( 'sanitize_user', 'strtolower' );
// Blogs
add_filter( 'wpmu_validate_blog_signup', 'signup_nonce_check' );
add_action( 'wpmu_new_blog', 'wpmu_log_new_registrations', 10, 2 );
add_action( 'wpmu_new_blog', 'newblog_notify_siteadmin', 10, 2 );
// Register Nonce
add_action( 'signup_hidden_fields', 'signup_nonce_fields' );
// Template
add_action( 'template_redirect', 'maybe_redirect_404' );
add_filter( 'allowed_redirect_hosts', 'redirect_this_site' );
// Administration
add_filter( 'term_id_filter', 'global_terms', 10, 2 );
add_action( 'publish_post', 'update_posts_count' );
add_action( 'delete_post', '_update_blog_date_on_post_delete' );
add_action( 'transition_post_status', '_update_blog_date_on_post_publish', 10, 3 );
// Counts
add_action( 'admin_init', 'wp_schedule_update_network_counts');
add_action( 'update_network_counts', 'wp_update_network_counts');
foreach ( array( 'user_register', 'deleted_user', 'wpmu_new_user', 'make_spam_user', 'make_ham_user' ) as $action )
add_action( $action, 'wp_maybe_update_network_user_counts' );
foreach ( array( 'make_spam_blog', 'make_ham_blog', 'archive_blog', 'unarchive_blog', 'make_delete_blog', 'make_undelete_blog' ) as $action )
add_action( $action, 'wp_maybe_update_network_site_counts' );
unset( $action );
// Files
add_filter( 'wp_upload_bits', 'upload_is_file_too_big' );
add_filter( 'import_upload_size_limit', 'fix_import_form_size' );
add_filter( 'upload_mimes', 'check_upload_mimes' );
add_filter( 'upload_size_limit', 'upload_size_limit_filter' );
add_action( 'upload_ui_over_quota', 'multisite_over_quota_message' );
// Mail
add_action( 'phpmailer_init', 'fix_phpmailer_messageid' );
// Disable somethings by default for multisite
add_filter( 'enable_update_services_configuration', '__return_false' );
if ( ! defined('POST_BY_EMAIL') || ! POST_BY_EMAIL ) // back compat constant.
add_filter( 'enable_post_by_email_configuration', '__return_false' );
if ( ! defined('EDIT_ANY_USER') || ! EDIT_ANY_USER ) // back compat constant.
add_filter( 'enable_edit_any_user_configuration', '__return_false' );
add_filter( 'force_filtered_html_on_import', '__return_true' );
// WP_HOME and WP_SITEURL should not have any effect in MS
remove_filter( 'option_siteurl', '_config_wp_siteurl' );
remove_filter( 'option_home', '_config_wp_home' );
// If the network upgrade hasn't run yet, assume ms-files.php rewriting is used.
add_filter( 'default_site_option_ms_files_rewriting', '__return_true' );
// Whitelist multisite domains for HTTP requests
add_filter( 'http_request_host_is_external', 'ms_allowed_http_request_hosts', 20, 2 );
| 01-wordpress-paypal | trunk/wp-includes/ms-default-filters.php | PHP | gpl3 | 3,245 |
<?php
/**
* Navigation Menu template functions
*
* @package WordPress
* @subpackage Nav_Menus
* @since 3.0.0
*/
/**
* Create HTML list of nav menu items.
*
* @since 3.0.0
* @uses Walker
*/
class Walker_Nav_Menu extends Walker {
/**
* What the class handles.
*
* @see Walker::$tree_type
* @since 3.0.0
* @var string
*/
var $tree_type = array( 'post_type', 'taxonomy', 'custom' );
/**
* Database fields to use.
*
* @see Walker::$db_fields
* @since 3.0.0
* @todo Decouple this.
* @var array
*/
var $db_fields = array( 'parent' => 'menu_item_parent', 'id' => 'db_id' );
/**
* Starts the list before the elements are added.
*
* @see Walker::start_lvl()
*
* @since 3.0.0
*
* @param string $output Passed by reference. Used to append additional content.
* @param int $depth Depth of menu item. Used for padding.
* @param array $args An array of arguments. @see wp_nav_menu()
*/
function start_lvl( &$output, $depth = 0, $args = array() ) {
$indent = str_repeat("\t", $depth);
$output .= "\n$indent<ul class=\"sub-menu\">\n";
}
/**
* Ends the list of after the elements are added.
*
* @see Walker::end_lvl()
*
* @since 3.0.0
*
* @param string $output Passed by reference. Used to append additional content.
* @param int $depth Depth of menu item. Used for padding.
* @param array $args An array of arguments. @see wp_nav_menu()
*/
function end_lvl( &$output, $depth = 0, $args = array() ) {
$indent = str_repeat("\t", $depth);
$output .= "$indent</ul>\n";
}
/**
* Start the element output.
*
* @see Walker::start_el()
*
* @since 3.0.0
*
* @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 array $args An array of arguments. @see wp_nav_menu()
* @param int $id Current item ID.
*/
function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
$class_names = '';
$classes = empty( $item->classes ) ? array() : (array) $item->classes;
$classes[] = 'menu-item-' . $item->ID;
/**
* Filter the CSS class(es) applied to a menu item's <li>.
*
* @since 3.0.0
*
* @see wp_nav_menu()
*
* @param array $classes The CSS classes that are applied to the menu item's <li>.
* @param object $item The current menu item.
* @param array $args An array of wp_nav_menu() arguments.
*/
$class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args ) );
$class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';
/**
* Filter the ID applied to a menu item's <li>.
*
* @since 3.0.1
*
* @see wp_nav_menu()
*
* @param string $menu_id The ID that is applied to the menu item's <li>.
* @param object $item The current menu item.
* @param array $args An array of wp_nav_menu() arguments.
*/
$id = apply_filters( 'nav_menu_item_id', 'menu-item-'. $item->ID, $item, $args );
$id = $id ? ' id="' . esc_attr( $id ) . '"' : '';
$output .= $indent . '<li' . $id . $class_names .'>';
$atts = array();
$atts['title'] = ! empty( $item->attr_title ) ? $item->attr_title : '';
$atts['target'] = ! empty( $item->target ) ? $item->target : '';
$atts['rel'] = ! empty( $item->xfn ) ? $item->xfn : '';
$atts['href'] = ! empty( $item->url ) ? $item->url : '';
/**
* Filter the HTML attributes applied to a menu item's <a>.
*
* @since 3.6.0
*
* @see wp_nav_menu()
*
* @param array $atts {
* The HTML attributes applied to the menu item's <a>, empty strings are ignored.
*
* @type string $title Title attribute.
* @type string $target Target attribute.
* @type string $rel The rel attribute.
* @type string $href The href attribute.
* }
* @param object $item The current menu item.
* @param array $args An array of wp_nav_menu() arguments.
*/
$atts = apply_filters( 'nav_menu_link_attributes', $atts, $item, $args );
$attributes = '';
foreach ( $atts as $attr => $value ) {
if ( ! empty( $value ) ) {
$value = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value );
$attributes .= ' ' . $attr . '="' . $value . '"';
}
}
$item_output = $args->before;
$item_output .= '<a'. $attributes .'>';
/** This filter is documented in wp-includes/post-template.php */
$item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;
$item_output .= '</a>';
$item_output .= $args->after;
/**
* Filter a menu item's starting output.
*
* The menu item's starting output only includes $args->before, the opening <a>,
* the menu item's title, the closing </a>, and $args->after. Currently, there is
* no filter for modifying the opening and closing <li> for a menu item.
*
* @since 3.0.0
*
* @see wp_nav_menu()
*
* @param string $item_output The menu item's starting HTML output.
* @param object $item Menu item data object.
* @param int $depth Depth of menu item. Used for padding.
* @param array $args An array of wp_nav_menu() arguments.
*/
$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
}
/**
* Ends the element output, if needed.
*
* @see Walker::end_el()
*
* @since 3.0.0
*
* @param string $output Passed by reference. Used to append additional content.
* @param object $item Page data object. Not used.
* @param int $depth Depth of page. Not Used.
* @param array $args An array of arguments. @see wp_nav_menu()
*/
function end_el( &$output, $item, $depth = 0, $args = array() ) {
$output .= "</li>\n";
}
} // Walker_Nav_Menu
/**
* Displays a navigation menu.
*
* @since 3.0.0
*
* @param array $args {
* Optional. Array of nav menu arguments.
*
* @type string $menu Desired menu. Accepts (matching in order) id, slug, name. Default empty.
* @type string $menu_class CSS class to use for the ul element which forms the menu. Default 'menu'.
* @type string $menu_id The ID that is applied to the ul element which forms the menu.
* Default is the menu slug, incremented.
* @type string $container Whether to wrap the ul, and what to wrap it with. Default 'div'.
* @type string $container_class Class that is applied to the container. Default 'menu-{menu slug}-container'.
* @type string $container_id The ID that is applied to the container. Default empty.
* @type callback|bool $fallback_cb If the menu doesn't exists, a callback function will fire.
* Default is 'wp_page_menu'. Set to false for no fallback.
* @type string $before Text before the link text. Default empty.
* @type string $after Text after the link text. Default empty.
* @type string $link_before Text before the link. Default empty.
* @type string $link_after Text after the link. Default empty.
* @type bool $echo Whether to echo the menu or return it. Default true.
* @type int $depth How many levels of the hierarchy are to be included. 0 means all. Default 0.
* @type string $walker Allows a custom walker class to be specified. Default empty.
* @type string $theme_location Theme location to be used. Must be registered with register_nav_menu()
* in order to be selectable by the user.
* @type string $items_wrap How the list items should be wrapped. Default is a ul with an id and class.
* Uses printf() format with numbered placeholders.
* }
* @return mixed Menu output if $echo is false, false if there are no items or no menu was found.
*/
function wp_nav_menu( $args = array() ) {
static $menu_id_slugs = array();
$defaults = array( 'menu' => '', 'container' => 'div', 'container_class' => '', 'container_id' => '', 'menu_class' => 'menu', 'menu_id' => '',
'echo' => true, 'fallback_cb' => 'wp_page_menu', 'before' => '', 'after' => '', 'link_before' => '', 'link_after' => '', 'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s</ul>',
'depth' => 0, 'walker' => '', 'theme_location' => '' );
$args = wp_parse_args( $args, $defaults );
/**
* Filter the arguments used to display a navigation menu.
*
* @since 3.0.0
*
* @see wp_nav_menu()
*
* @param array $args Array of wp_nav_menu() arguments.
*/
$args = apply_filters( 'wp_nav_menu_args', $args );
$args = (object) $args;
/**
* Filter whether to short-circuit the wp_nav_menu() output.
*
* Returning a non-null value to the filter will short-circuit
* wp_nav_menu(), echoing that value if $args->echo is true,
* returning that value otherwise.
*
* @since 3.9.0
*
* @see wp_nav_menu()
*
* @param string|null $output Nav menu output to short-circuit with. Default null.
* @param object $args An object containing wp_nav_menu() arguments.
*/
$nav_menu = apply_filters( 'pre_wp_nav_menu', null, $args );
if ( null !== $nav_menu ) {
if ( $args->echo ) {
echo $nav_menu;
return;
}
return $nav_menu;
}
// Get the nav menu based on the requested menu
$menu = wp_get_nav_menu_object( $args->menu );
// Get the nav menu based on the theme_location
if ( ! $menu && $args->theme_location && ( $locations = get_nav_menu_locations() ) && isset( $locations[ $args->theme_location ] ) )
$menu = wp_get_nav_menu_object( $locations[ $args->theme_location ] );
// get the first menu that has items if we still can't find a menu
if ( ! $menu && !$args->theme_location ) {
$menus = wp_get_nav_menus();
foreach ( $menus as $menu_maybe ) {
if ( $menu_items = wp_get_nav_menu_items( $menu_maybe->term_id, array( 'update_post_term_cache' => false ) ) ) {
$menu = $menu_maybe;
break;
}
}
}
// If the menu exists, get its items.
if ( $menu && ! is_wp_error($menu) && !isset($menu_items) )
$menu_items = wp_get_nav_menu_items( $menu->term_id, array( 'update_post_term_cache' => false ) );
/*
* If no menu was found:
* - Fall back (if one was specified), or bail.
*
* If no menu items were found:
* - Fall back, but only if no theme location was specified.
* - Otherwise, bail.
*/
if ( ( !$menu || is_wp_error($menu) || ( isset($menu_items) && empty($menu_items) && !$args->theme_location ) )
&& $args->fallback_cb && is_callable( $args->fallback_cb ) )
return call_user_func( $args->fallback_cb, (array) $args );
if ( ! $menu || is_wp_error( $menu ) )
return false;
$nav_menu = $items = '';
$show_container = false;
if ( $args->container ) {
/**
* Filter the list of HTML tags that are valid for use as menu containers.
*
* @since 3.0.0
*
* @param array $tags The acceptable HTML tags for use as menu containers.
* Default is array containing 'div' and 'nav'.
*/
$allowed_tags = apply_filters( 'wp_nav_menu_container_allowedtags', array( 'div', 'nav' ) );
if ( in_array( $args->container, $allowed_tags ) ) {
$show_container = true;
$class = $args->container_class ? ' class="' . esc_attr( $args->container_class ) . '"' : ' class="menu-'. $menu->slug .'-container"';
$id = $args->container_id ? ' id="' . esc_attr( $args->container_id ) . '"' : '';
$nav_menu .= '<'. $args->container . $id . $class . '>';
}
}
// Set up the $menu_item variables
_wp_menu_item_classes_by_context( $menu_items );
$sorted_menu_items = $menu_items_with_children = array();
foreach ( (array) $menu_items as $menu_item ) {
$sorted_menu_items[ $menu_item->menu_order ] = $menu_item;
if ( $menu_item->menu_item_parent )
$menu_items_with_children[ $menu_item->menu_item_parent ] = true;
}
// Add the menu-item-has-children class where applicable
if ( $menu_items_with_children ) {
foreach ( $sorted_menu_items as &$menu_item ) {
if ( isset( $menu_items_with_children[ $menu_item->ID ] ) )
$menu_item->classes[] = 'menu-item-has-children';
}
}
unset( $menu_items, $menu_item );
/**
* Filter the sorted list of menu item objects before generating the menu's HTML.
*
* @since 3.1.0
*
* @param array $sorted_menu_items The menu items, sorted by each menu item's menu order.
*/
$sorted_menu_items = apply_filters( 'wp_nav_menu_objects', $sorted_menu_items, $args );
$items .= walk_nav_menu_tree( $sorted_menu_items, $args->depth, $args );
unset($sorted_menu_items);
// Attributes
if ( ! empty( $args->menu_id ) ) {
$wrap_id = $args->menu_id;
} else {
$wrap_id = 'menu-' . $menu->slug;
while ( in_array( $wrap_id, $menu_id_slugs ) ) {
if ( preg_match( '#-(\d+)$#', $wrap_id, $matches ) )
$wrap_id = preg_replace('#-(\d+)$#', '-' . ++$matches[1], $wrap_id );
else
$wrap_id = $wrap_id . '-1';
}
}
$menu_id_slugs[] = $wrap_id;
$wrap_class = $args->menu_class ? $args->menu_class : '';
/**
* Filter the HTML list content for navigation menus.
*
* @since 3.0.0
*
* @see wp_nav_menu()
*
* @param string $items The HTML list content for the menu items.
* @param array $args Array of wp_nav_menu() arguments.
*/
$items = apply_filters( 'wp_nav_menu_items', $items, $args );
/**
* Filter the HTML list content for a specific navigation menu.
*
* @since 3.0.0
*
* @see wp_nav_menu()
*
* @param string $items The HTML list content for the menu items.
* @param array $args Array of wp_nav_menu() arguments.
*/
$items = apply_filters( "wp_nav_menu_{$menu->slug}_items", $items, $args );
// Don't print any markup if there are no items at this point.
if ( empty( $items ) )
return false;
$nav_menu .= sprintf( $args->items_wrap, esc_attr( $wrap_id ), esc_attr( $wrap_class ), $items );
unset( $items );
if ( $show_container )
$nav_menu .= '</' . $args->container . '>';
/**
* Filter the HTML content for navigation menus.
*
* @since 3.0.0
*
* @see wp_nav_menu()
*
* @param string $nav_menu The HTML content for the navigation menu.
* @param array $args Array of wp_nav_menu() arguments.
*/
$nav_menu = apply_filters( 'wp_nav_menu', $nav_menu, $args );
if ( $args->echo )
echo $nav_menu;
else
return $nav_menu;
}
/**
* Add the class property classes for the current context, if applicable.
*
* @access private
* @since 3.0.0
*
* @param array $menu_items The current menu item objects to which to add the class property information.
*/
function _wp_menu_item_classes_by_context( &$menu_items ) {
global $wp_query, $wp_rewrite;
$queried_object = $wp_query->get_queried_object();
$queried_object_id = (int) $wp_query->queried_object_id;
$active_object = '';
$active_ancestor_item_ids = array();
$active_parent_item_ids = array();
$active_parent_object_ids = array();
$possible_taxonomy_ancestors = array();
$possible_object_parents = array();
$home_page_id = (int) get_option( 'page_for_posts' );
if ( $wp_query->is_singular && ! empty( $queried_object->post_type ) && ! is_post_type_hierarchical( $queried_object->post_type ) ) {
foreach ( (array) get_object_taxonomies( $queried_object->post_type ) as $taxonomy ) {
if ( is_taxonomy_hierarchical( $taxonomy ) ) {
$term_hierarchy = _get_term_hierarchy( $taxonomy );
$terms = wp_get_object_terms( $queried_object_id, $taxonomy, array( 'fields' => 'ids' ) );
if ( is_array( $terms ) ) {
$possible_object_parents = array_merge( $possible_object_parents, $terms );
$term_to_ancestor = array();
foreach ( (array) $term_hierarchy as $anc => $descs ) {
foreach ( (array) $descs as $desc )
$term_to_ancestor[ $desc ] = $anc;
}
foreach ( $terms as $desc ) {
do {
$possible_taxonomy_ancestors[ $taxonomy ][] = $desc;
if ( isset( $term_to_ancestor[ $desc ] ) ) {
$_desc = $term_to_ancestor[ $desc ];
unset( $term_to_ancestor[ $desc ] );
$desc = $_desc;
} else {
$desc = 0;
}
} while ( ! empty( $desc ) );
}
}
}
}
} elseif ( ! empty( $queried_object->taxonomy ) && is_taxonomy_hierarchical( $queried_object->taxonomy ) ) {
$term_hierarchy = _get_term_hierarchy( $queried_object->taxonomy );
$term_to_ancestor = array();
foreach ( (array) $term_hierarchy as $anc => $descs ) {
foreach ( (array) $descs as $desc )
$term_to_ancestor[ $desc ] = $anc;
}
$desc = $queried_object->term_id;
do {
$possible_taxonomy_ancestors[ $queried_object->taxonomy ][] = $desc;
if ( isset( $term_to_ancestor[ $desc ] ) ) {
$_desc = $term_to_ancestor[ $desc ];
unset( $term_to_ancestor[ $desc ] );
$desc = $_desc;
} else {
$desc = 0;
}
} while ( ! empty( $desc ) );
}
$possible_object_parents = array_filter( $possible_object_parents );
$front_page_url = home_url();
foreach ( (array) $menu_items as $key => $menu_item ) {
$menu_items[$key]->current = false;
$classes = (array) $menu_item->classes;
$classes[] = 'menu-item';
$classes[] = 'menu-item-type-' . $menu_item->type;
$classes[] = 'menu-item-object-' . $menu_item->object;
// if the menu item corresponds to a taxonomy term for the currently-queried non-hierarchical post object
if ( $wp_query->is_singular && 'taxonomy' == $menu_item->type && in_array( $menu_item->object_id, $possible_object_parents ) ) {
$active_parent_object_ids[] = (int) $menu_item->object_id;
$active_parent_item_ids[] = (int) $menu_item->db_id;
$active_object = $queried_object->post_type;
// if the menu item corresponds to the currently-queried post or taxonomy object
} elseif (
$menu_item->object_id == $queried_object_id &&
(
( ! empty( $home_page_id ) && 'post_type' == $menu_item->type && $wp_query->is_home && $home_page_id == $menu_item->object_id ) ||
( 'post_type' == $menu_item->type && $wp_query->is_singular ) ||
( 'taxonomy' == $menu_item->type && ( $wp_query->is_category || $wp_query->is_tag || $wp_query->is_tax ) && $queried_object->taxonomy == $menu_item->object )
)
) {
$classes[] = 'current-menu-item';
$menu_items[$key]->current = true;
$_anc_id = (int) $menu_item->db_id;
while(
( $_anc_id = get_post_meta( $_anc_id, '_menu_item_menu_item_parent', true ) ) &&
! in_array( $_anc_id, $active_ancestor_item_ids )
) {
$active_ancestor_item_ids[] = $_anc_id;
}
if ( 'post_type' == $menu_item->type && 'page' == $menu_item->object ) {
// Back compat classes for pages to match wp_page_menu()
$classes[] = 'page_item';
$classes[] = 'page-item-' . $menu_item->object_id;
$classes[] = 'current_page_item';
}
$active_parent_item_ids[] = (int) $menu_item->menu_item_parent;
$active_parent_object_ids[] = (int) $menu_item->post_parent;
$active_object = $menu_item->object;
// if the menu item corresponds to the currently-requested URL
} elseif ( 'custom' == $menu_item->object ) {
$_root_relative_current = untrailingslashit( $_SERVER['REQUEST_URI'] );
$current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_root_relative_current );
$raw_item_url = strpos( $menu_item->url, '#' ) ? substr( $menu_item->url, 0, strpos( $menu_item->url, '#' ) ) : $menu_item->url;
$item_url = untrailingslashit( $raw_item_url );
$_indexless_current = untrailingslashit( preg_replace( '/' . preg_quote( $wp_rewrite->index, '/' ) . '$/', '', $current_url ) );
if ( $raw_item_url && in_array( $item_url, array( $current_url, $_indexless_current, $_root_relative_current ) ) ) {
$classes[] = 'current-menu-item';
$menu_items[$key]->current = true;
$_anc_id = (int) $menu_item->db_id;
while(
( $_anc_id = get_post_meta( $_anc_id, '_menu_item_menu_item_parent', true ) ) &&
! in_array( $_anc_id, $active_ancestor_item_ids )
) {
$active_ancestor_item_ids[] = $_anc_id;
}
if ( in_array( home_url(), array( untrailingslashit( $current_url ), untrailingslashit( $_indexless_current ) ) ) ) {
// Back compat for home link to match wp_page_menu()
$classes[] = 'current_page_item';
}
$active_parent_item_ids[] = (int) $menu_item->menu_item_parent;
$active_parent_object_ids[] = (int) $menu_item->post_parent;
$active_object = $menu_item->object;
// give front page item current-menu-item class when extra query arguments involved
} elseif ( $item_url == $front_page_url && is_front_page() ) {
$classes[] = 'current-menu-item';
}
if ( untrailingslashit($item_url) == home_url() )
$classes[] = 'menu-item-home';
}
// back-compat with wp_page_menu: add "current_page_parent" to static home page link for any non-page query
if ( ! empty( $home_page_id ) && 'post_type' == $menu_item->type && empty( $wp_query->is_page ) && $home_page_id == $menu_item->object_id )
$classes[] = 'current_page_parent';
$menu_items[$key]->classes = array_unique( $classes );
}
$active_ancestor_item_ids = array_filter( array_unique( $active_ancestor_item_ids ) );
$active_parent_item_ids = array_filter( array_unique( $active_parent_item_ids ) );
$active_parent_object_ids = array_filter( array_unique( $active_parent_object_ids ) );
// set parent's class
foreach ( (array) $menu_items as $key => $parent_item ) {
$classes = (array) $parent_item->classes;
$menu_items[$key]->current_item_ancestor = false;
$menu_items[$key]->current_item_parent = false;
if (
isset( $parent_item->type ) &&
(
// ancestral post object
(
'post_type' == $parent_item->type &&
! empty( $queried_object->post_type ) &&
is_post_type_hierarchical( $queried_object->post_type ) &&
in_array( $parent_item->object_id, $queried_object->ancestors ) &&
$parent_item->object != $queried_object->ID
) ||
// ancestral term
(
'taxonomy' == $parent_item->type &&
isset( $possible_taxonomy_ancestors[ $parent_item->object ] ) &&
in_array( $parent_item->object_id, $possible_taxonomy_ancestors[ $parent_item->object ] ) &&
(
! isset( $queried_object->term_id ) ||
$parent_item->object_id != $queried_object->term_id
)
)
)
) {
$classes[] = empty( $queried_object->taxonomy ) ? 'current-' . $queried_object->post_type . '-ancestor' : 'current-' . $queried_object->taxonomy . '-ancestor';
}
if ( in_array( intval( $parent_item->db_id ), $active_ancestor_item_ids ) ) {
$classes[] = 'current-menu-ancestor';
$menu_items[$key]->current_item_ancestor = true;
}
if ( in_array( $parent_item->db_id, $active_parent_item_ids ) ) {
$classes[] = 'current-menu-parent';
$menu_items[$key]->current_item_parent = true;
}
if ( in_array( $parent_item->object_id, $active_parent_object_ids ) )
$classes[] = 'current-' . $active_object . '-parent';
if ( 'post_type' == $parent_item->type && 'page' == $parent_item->object ) {
// Back compat classes for pages to match wp_page_menu()
if ( in_array('current-menu-parent', $classes) )
$classes[] = 'current_page_parent';
if ( in_array('current-menu-ancestor', $classes) )
$classes[] = 'current_page_ancestor';
}
$menu_items[$key]->classes = array_unique( $classes );
}
}
/**
* Retrieve the HTML list content for nav menu items.
*
* @uses Walker_Nav_Menu to create HTML list content.
* @since 3.0.0
* @see Walker::walk() for parameters and return description.
*/
function walk_nav_menu_tree( $items, $depth, $r ) {
$walker = ( empty($r->walker) ) ? new Walker_Nav_Menu : $r->walker;
$args = array( $items, $depth, $r );
return call_user_func_array( array($walker, 'walk'), $args );
}
/**
* Prevents a menu item ID from being used more than once.
*
* @since 3.0.1
* @access private
*/
function _nav_menu_item_id_use_once( $id, $item ) {
static $_used_ids = array();
if ( in_array( $item->ID, $_used_ids ) )
return '';
$_used_ids[] = $item->ID;
return $id;
}
add_filter( 'nav_menu_item_id', '_nav_menu_item_id_use_once', 10, 2 );
| 01-wordpress-paypal | trunk/wp-includes/nav-menu-template.php | PHP | gpl3 | 24,349 |
<?php
/**
* General API for generating and formatting diffs - the differences between
* two sequences of strings.
*
* The original PHP version of this code was written by Geoffrey T. Dairiki
* <dairiki@dairiki.org>, and is used/adapted with his permission.
*
* Copyright 2004 Geoffrey T. Dairiki <dairiki@dairiki.org>
* Copyright 2004-2010 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you did
* not receive this file, see http://opensource.org/licenses/lgpl-license.php.
*
* @package Text_Diff
* @author Geoffrey T. Dairiki <dairiki@dairiki.org>
*/
class Text_Diff {
/**
* Array of changes.
*
* @var array
*/
var $_edits;
/**
* Computes diffs between sequences of strings.
*
* @param string $engine Name of the diffing engine to use. 'auto'
* will automatically select the best.
* @param array $params Parameters to pass to the diffing engine.
* Normally an array of two arrays, each
* containing the lines from a file.
*/
function Text_Diff($engine, $params)
{
// Backward compatibility workaround.
if (!is_string($engine)) {
$params = array($engine, $params);
$engine = 'auto';
}
if ($engine == 'auto') {
$engine = extension_loaded('xdiff') ? 'xdiff' : 'native';
} else {
$engine = basename($engine);
}
// WP #7391
require_once dirname(__FILE__).'/Diff/Engine/' . $engine . '.php';
$class = 'Text_Diff_Engine_' . $engine;
$diff_engine = new $class();
$this->_edits = call_user_func_array(array($diff_engine, 'diff'), $params);
}
/**
* Returns the array of differences.
*/
function getDiff()
{
return $this->_edits;
}
/**
* returns the number of new (added) lines in a given diff.
*
* @since Text_Diff 1.1.0
*
* @return integer The number of new lines
*/
function countAddedLines()
{
$count = 0;
foreach ($this->_edits as $edit) {
if (is_a($edit, 'Text_Diff_Op_add') ||
is_a($edit, 'Text_Diff_Op_change')) {
$count += $edit->nfinal();
}
}
return $count;
}
/**
* Returns the number of deleted (removed) lines in a given diff.
*
* @since Text_Diff 1.1.0
*
* @return integer The number of deleted lines
*/
function countDeletedLines()
{
$count = 0;
foreach ($this->_edits as $edit) {
if (is_a($edit, 'Text_Diff_Op_delete') ||
is_a($edit, 'Text_Diff_Op_change')) {
$count += $edit->norig();
}
}
return $count;
}
/**
* Computes a reversed diff.
*
* Example:
* <code>
* $diff = new Text_Diff($lines1, $lines2);
* $rev = $diff->reverse();
* </code>
*
* @return Text_Diff A Diff object representing the inverse of the
* original diff. Note that we purposely don't return a
* reference here, since this essentially is a clone()
* method.
*/
function reverse()
{
if (version_compare(zend_version(), '2', '>')) {
$rev = clone($this);
} else {
$rev = $this;
}
$rev->_edits = array();
foreach ($this->_edits as $edit) {
$rev->_edits[] = $edit->reverse();
}
return $rev;
}
/**
* Checks for an empty diff.
*
* @return boolean True if two sequences were identical.
*/
function isEmpty()
{
foreach ($this->_edits as $edit) {
if (!is_a($edit, 'Text_Diff_Op_copy')) {
return false;
}
}
return true;
}
/**
* Computes the length of the Longest Common Subsequence (LCS).
*
* This is mostly for diagnostic purposes.
*
* @return integer The length of the LCS.
*/
function lcs()
{
$lcs = 0;
foreach ($this->_edits as $edit) {
if (is_a($edit, 'Text_Diff_Op_copy')) {
$lcs += count($edit->orig);
}
}
return $lcs;
}
/**
* Gets the original set of lines.
*
* This reconstructs the $from_lines parameter passed to the constructor.
*
* @return array The original sequence of strings.
*/
function getOriginal()
{
$lines = array();
foreach ($this->_edits as $edit) {
if ($edit->orig) {
array_splice($lines, count($lines), 0, $edit->orig);
}
}
return $lines;
}
/**
* Gets the final set of lines.
*
* This reconstructs the $to_lines parameter passed to the constructor.
*
* @return array The sequence of strings.
*/
function getFinal()
{
$lines = array();
foreach ($this->_edits as $edit) {
if ($edit->final) {
array_splice($lines, count($lines), 0, $edit->final);
}
}
return $lines;
}
/**
* Removes trailing newlines from a line of text. This is meant to be used
* with array_walk().
*
* @param string $line The line to trim.
* @param integer $key The index of the line in the array. Not used.
*/
static function trimNewlines(&$line, $key)
{
$line = str_replace(array("\n", "\r"), '', $line);
}
/**
* Determines the location of the system temporary directory.
*
* @static
*
* @access protected
*
* @return string A directory name which can be used for temp files.
* Returns false if one could not be found.
*/
function _getTempDir()
{
$tmp_locations = array('/tmp', '/var/tmp', 'c:\WUTemp', 'c:\temp',
'c:\windows\temp', 'c:\winnt\temp');
/* Try PHP's upload_tmp_dir directive. */
$tmp = ini_get('upload_tmp_dir');
/* Otherwise, try to determine the TMPDIR environment variable. */
if (!strlen($tmp)) {
$tmp = getenv('TMPDIR');
}
/* If we still cannot determine a value, then cycle through a list of
* preset possibilities. */
while (!strlen($tmp) && count($tmp_locations)) {
$tmp_check = array_shift($tmp_locations);
if (@is_dir($tmp_check)) {
$tmp = $tmp_check;
}
}
/* If it is still empty, we have failed, so return false; otherwise
* return the directory determined. */
return strlen($tmp) ? $tmp : false;
}
/**
* Checks a diff for validity.
*
* This is here only for debugging purposes.
*/
function _check($from_lines, $to_lines)
{
if (serialize($from_lines) != serialize($this->getOriginal())) {
trigger_error("Reconstructed original doesn't match", E_USER_ERROR);
}
if (serialize($to_lines) != serialize($this->getFinal())) {
trigger_error("Reconstructed final doesn't match", E_USER_ERROR);
}
$rev = $this->reverse();
if (serialize($to_lines) != serialize($rev->getOriginal())) {
trigger_error("Reversed original doesn't match", E_USER_ERROR);
}
if (serialize($from_lines) != serialize($rev->getFinal())) {
trigger_error("Reversed final doesn't match", E_USER_ERROR);
}
$prevtype = null;
foreach ($this->_edits as $edit) {
if ($prevtype == get_class($edit)) {
trigger_error("Edit sequence is non-optimal", E_USER_ERROR);
}
$prevtype = get_class($edit);
}
return true;
}
}
/**
* @package Text_Diff
* @author Geoffrey T. Dairiki <dairiki@dairiki.org>
*/
class Text_MappedDiff extends Text_Diff {
/**
* Computes a diff between sequences of strings.
*
* This can be used to compute things like case-insensitve diffs, or diffs
* which ignore changes in white-space.
*
* @param array $from_lines An array of strings.
* @param array $to_lines An array of strings.
* @param array $mapped_from_lines This array should have the same size
* number of elements as $from_lines. The
* elements in $mapped_from_lines and
* $mapped_to_lines are what is actually
* compared when computing the diff.
* @param array $mapped_to_lines This array should have the same number
* of elements as $to_lines.
*/
function Text_MappedDiff($from_lines, $to_lines,
$mapped_from_lines, $mapped_to_lines)
{
assert(count($from_lines) == count($mapped_from_lines));
assert(count($to_lines) == count($mapped_to_lines));
parent::Text_Diff($mapped_from_lines, $mapped_to_lines);
$xi = $yi = 0;
for ($i = 0; $i < count($this->_edits); $i++) {
$orig = &$this->_edits[$i]->orig;
if (is_array($orig)) {
$orig = array_slice($from_lines, $xi, count($orig));
$xi += count($orig);
}
$final = &$this->_edits[$i]->final;
if (is_array($final)) {
$final = array_slice($to_lines, $yi, count($final));
$yi += count($final);
}
}
}
}
/**
* @package Text_Diff
* @author Geoffrey T. Dairiki <dairiki@dairiki.org>
*
* @access private
*/
class Text_Diff_Op {
var $orig;
var $final;
function &reverse()
{
trigger_error('Abstract method', E_USER_ERROR);
}
function norig()
{
return $this->orig ? count($this->orig) : 0;
}
function nfinal()
{
return $this->final ? count($this->final) : 0;
}
}
/**
* @package Text_Diff
* @author Geoffrey T. Dairiki <dairiki@dairiki.org>
*
* @access private
*/
class Text_Diff_Op_copy extends Text_Diff_Op {
function Text_Diff_Op_copy($orig, $final = false)
{
if (!is_array($final)) {
$final = $orig;
}
$this->orig = $orig;
$this->final = $final;
}
function &reverse()
{
$reverse = new Text_Diff_Op_copy($this->final, $this->orig);
return $reverse;
}
}
/**
* @package Text_Diff
* @author Geoffrey T. Dairiki <dairiki@dairiki.org>
*
* @access private
*/
class Text_Diff_Op_delete extends Text_Diff_Op {
function Text_Diff_Op_delete($lines)
{
$this->orig = $lines;
$this->final = false;
}
function &reverse()
{
$reverse = new Text_Diff_Op_add($this->orig);
return $reverse;
}
}
/**
* @package Text_Diff
* @author Geoffrey T. Dairiki <dairiki@dairiki.org>
*
* @access private
*/
class Text_Diff_Op_add extends Text_Diff_Op {
function Text_Diff_Op_add($lines)
{
$this->final = $lines;
$this->orig = false;
}
function &reverse()
{
$reverse = new Text_Diff_Op_delete($this->final);
return $reverse;
}
}
/**
* @package Text_Diff
* @author Geoffrey T. Dairiki <dairiki@dairiki.org>
*
* @access private
*/
class Text_Diff_Op_change extends Text_Diff_Op {
function Text_Diff_Op_change($orig, $final)
{
$this->orig = $orig;
$this->final = $final;
}
function &reverse()
{
$reverse = new Text_Diff_Op_change($this->final, $this->orig);
return $reverse;
}
}
| 01-wordpress-paypal | trunk/wp-includes/Text/Diff.php | PHP | gpl3 | 11,945 |
<?php
/**
* A class to render Diffs in different formats.
*
* This class renders the diff in classic diff format. It is intended that
* this class be customized via inheritance, to obtain fancier outputs.
*
* Copyright 2004-2010 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you did
* not receive this file, see http://opensource.org/licenses/lgpl-license.php.
*
* @package Text_Diff
*/
class Text_Diff_Renderer {
/**
* Number of leading context "lines" to preserve.
*
* This should be left at zero for this class, but subclasses may want to
* set this to other values.
*/
var $_leading_context_lines = 0;
/**
* Number of trailing context "lines" to preserve.
*
* This should be left at zero for this class, but subclasses may want to
* set this to other values.
*/
var $_trailing_context_lines = 0;
/**
* Constructor.
*/
function Text_Diff_Renderer($params = array())
{
foreach ($params as $param => $value) {
$v = '_' . $param;
if (isset($this->$v)) {
$this->$v = $value;
}
}
}
/**
* Get any renderer parameters.
*
* @return array All parameters of this renderer object.
*/
function getParams()
{
$params = array();
foreach (get_object_vars($this) as $k => $v) {
if ($k[0] == '_') {
$params[substr($k, 1)] = $v;
}
}
return $params;
}
/**
* Renders a diff.
*
* @param Text_Diff $diff A Text_Diff object.
*
* @return string The formatted output.
*/
function render($diff)
{
$xi = $yi = 1;
$block = false;
$context = array();
$nlead = $this->_leading_context_lines;
$ntrail = $this->_trailing_context_lines;
$output = $this->_startDiff();
$diffs = $diff->getDiff();
foreach ($diffs as $i => $edit) {
/* If these are unchanged (copied) lines, and we want to keep
* leading or trailing context lines, extract them from the copy
* block. */
if (is_a($edit, 'Text_Diff_Op_copy')) {
/* Do we have any diff blocks yet? */
if (is_array($block)) {
/* How many lines to keep as context from the copy
* block. */
$keep = $i == count($diffs) - 1 ? $ntrail : $nlead + $ntrail;
if (count($edit->orig) <= $keep) {
/* We have less lines in the block than we want for
* context => keep the whole block. */
$block[] = $edit;
} else {
if ($ntrail) {
/* Create a new block with as many lines as we need
* for the trailing context. */
$context = array_slice($edit->orig, 0, $ntrail);
$block[] = new Text_Diff_Op_copy($context);
}
/* @todo */
$output .= $this->_block($x0, $ntrail + $xi - $x0,
$y0, $ntrail + $yi - $y0,
$block);
$block = false;
}
}
/* Keep the copy block as the context for the next block. */
$context = $edit->orig;
} else {
/* Don't we have any diff blocks yet? */
if (!is_array($block)) {
/* Extract context lines from the preceding copy block. */
$context = array_slice($context, count($context) - $nlead);
$x0 = $xi - count($context);
$y0 = $yi - count($context);
$block = array();
if ($context) {
$block[] = new Text_Diff_Op_copy($context);
}
}
$block[] = $edit;
}
if ($edit->orig) {
$xi += count($edit->orig);
}
if ($edit->final) {
$yi += count($edit->final);
}
}
if (is_array($block)) {
$output .= $this->_block($x0, $xi - $x0,
$y0, $yi - $y0,
$block);
}
return $output . $this->_endDiff();
}
function _block($xbeg, $xlen, $ybeg, $ylen, &$edits)
{
$output = $this->_startBlock($this->_blockHeader($xbeg, $xlen, $ybeg, $ylen));
foreach ($edits as $edit) {
switch (strtolower(get_class($edit))) {
case 'text_diff_op_copy':
$output .= $this->_context($edit->orig);
break;
case 'text_diff_op_add':
$output .= $this->_added($edit->final);
break;
case 'text_diff_op_delete':
$output .= $this->_deleted($edit->orig);
break;
case 'text_diff_op_change':
$output .= $this->_changed($edit->orig, $edit->final);
break;
}
}
return $output . $this->_endBlock();
}
function _startDiff()
{
return '';
}
function _endDiff()
{
return '';
}
function _blockHeader($xbeg, $xlen, $ybeg, $ylen)
{
if ($xlen > 1) {
$xbeg .= ',' . ($xbeg + $xlen - 1);
}
if ($ylen > 1) {
$ybeg .= ',' . ($ybeg + $ylen - 1);
}
// this matches the GNU Diff behaviour
if ($xlen && !$ylen) {
$ybeg--;
} elseif (!$xlen) {
$xbeg--;
}
return $xbeg . ($xlen ? ($ylen ? 'c' : 'd') : 'a') . $ybeg;
}
function _startBlock($header)
{
return $header . "\n";
}
function _endBlock()
{
return '';
}
function _lines($lines, $prefix = ' ')
{
return $prefix . implode("\n$prefix", $lines) . "\n";
}
function _context($lines)
{
return $this->_lines($lines, ' ');
}
function _added($lines)
{
return $this->_lines($lines, '> ');
}
function _deleted($lines)
{
return $this->_lines($lines, '< ');
}
function _changed($orig, $final)
{
return $this->_deleted($orig) . "---\n" . $this->_added($final);
}
}
| 01-wordpress-paypal | trunk/wp-includes/Text/Diff/Renderer.php | PHP | gpl3 | 6,691 |
<?php
/**
* Class used internally by Text_Diff to actually compute the diffs.
*
* This class is implemented using native PHP code.
*
* The algorithm used here is mostly lifted from the perl module
* Algorithm::Diff (version 1.06) by Ned Konz, which is available at:
* http://www.perl.com/CPAN/authors/id/N/NE/NEDKONZ/Algorithm-Diff-1.06.zip
*
* More ideas are taken from: http://www.ics.uci.edu/~eppstein/161/960229.html
*
* Some ideas (and a bit of code) are taken from analyze.c, of GNU
* diffutils-2.7, which can be found at:
* ftp://gnudist.gnu.org/pub/gnu/diffutils/diffutils-2.7.tar.gz
*
* Some ideas (subdivision by NCHUNKS > 2, and some optimizations) are from
* Geoffrey T. Dairiki <dairiki@dairiki.org>. The original PHP version of this
* code was written by him, and is used/adapted with his permission.
*
* Copyright 2004-2010 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you did
* not receive this file, see http://opensource.org/licenses/lgpl-license.php.
*
* @author Geoffrey T. Dairiki <dairiki@dairiki.org>
* @package Text_Diff
*/
class Text_Diff_Engine_native {
function diff($from_lines, $to_lines)
{
array_walk($from_lines, array('Text_Diff', 'trimNewlines'));
array_walk($to_lines, array('Text_Diff', 'trimNewlines'));
$n_from = count($from_lines);
$n_to = count($to_lines);
$this->xchanged = $this->ychanged = array();
$this->xv = $this->yv = array();
$this->xind = $this->yind = array();
unset($this->seq);
unset($this->in_seq);
unset($this->lcs);
// Skip leading common lines.
for ($skip = 0; $skip < $n_from && $skip < $n_to; $skip++) {
if ($from_lines[$skip] !== $to_lines[$skip]) {
break;
}
$this->xchanged[$skip] = $this->ychanged[$skip] = false;
}
// Skip trailing common lines.
$xi = $n_from; $yi = $n_to;
for ($endskip = 0; --$xi > $skip && --$yi > $skip; $endskip++) {
if ($from_lines[$xi] !== $to_lines[$yi]) {
break;
}
$this->xchanged[$xi] = $this->ychanged[$yi] = false;
}
// Ignore lines which do not exist in both files.
for ($xi = $skip; $xi < $n_from - $endskip; $xi++) {
$xhash[$from_lines[$xi]] = 1;
}
for ($yi = $skip; $yi < $n_to - $endskip; $yi++) {
$line = $to_lines[$yi];
if (($this->ychanged[$yi] = empty($xhash[$line]))) {
continue;
}
$yhash[$line] = 1;
$this->yv[] = $line;
$this->yind[] = $yi;
}
for ($xi = $skip; $xi < $n_from - $endskip; $xi++) {
$line = $from_lines[$xi];
if (($this->xchanged[$xi] = empty($yhash[$line]))) {
continue;
}
$this->xv[] = $line;
$this->xind[] = $xi;
}
// Find the LCS.
$this->_compareseq(0, count($this->xv), 0, count($this->yv));
// Merge edits when possible.
$this->_shiftBoundaries($from_lines, $this->xchanged, $this->ychanged);
$this->_shiftBoundaries($to_lines, $this->ychanged, $this->xchanged);
// Compute the edit operations.
$edits = array();
$xi = $yi = 0;
while ($xi < $n_from || $yi < $n_to) {
assert($yi < $n_to || $this->xchanged[$xi]);
assert($xi < $n_from || $this->ychanged[$yi]);
// Skip matching "snake".
$copy = array();
while ($xi < $n_from && $yi < $n_to
&& !$this->xchanged[$xi] && !$this->ychanged[$yi]) {
$copy[] = $from_lines[$xi++];
++$yi;
}
if ($copy) {
$edits[] = new Text_Diff_Op_copy($copy);
}
// Find deletes & adds.
$delete = array();
while ($xi < $n_from && $this->xchanged[$xi]) {
$delete[] = $from_lines[$xi++];
}
$add = array();
while ($yi < $n_to && $this->ychanged[$yi]) {
$add[] = $to_lines[$yi++];
}
if ($delete && $add) {
$edits[] = new Text_Diff_Op_change($delete, $add);
} elseif ($delete) {
$edits[] = new Text_Diff_Op_delete($delete);
} elseif ($add) {
$edits[] = new Text_Diff_Op_add($add);
}
}
return $edits;
}
/**
* Divides the Largest Common Subsequence (LCS) of the sequences (XOFF,
* XLIM) and (YOFF, YLIM) into NCHUNKS approximately equally sized
* segments.
*
* Returns (LCS, PTS). LCS is the length of the LCS. PTS is an array of
* NCHUNKS+1 (X, Y) indexes giving the diving points between sub
* sequences. The first sub-sequence is contained in (X0, X1), (Y0, Y1),
* the second in (X1, X2), (Y1, Y2) and so on. Note that (X0, Y0) ==
* (XOFF, YOFF) and (X[NCHUNKS], Y[NCHUNKS]) == (XLIM, YLIM).
*
* This function assumes that the first lines of the specified portions of
* the two files do not match, and likewise that the last lines do not
* match. The caller must trim matching lines from the beginning and end
* of the portions it is going to specify.
*/
function _diag ($xoff, $xlim, $yoff, $ylim, $nchunks)
{
$flip = false;
if ($xlim - $xoff > $ylim - $yoff) {
/* Things seems faster (I'm not sure I understand why) when the
* shortest sequence is in X. */
$flip = true;
list ($xoff, $xlim, $yoff, $ylim)
= array($yoff, $ylim, $xoff, $xlim);
}
if ($flip) {
for ($i = $ylim - 1; $i >= $yoff; $i--) {
$ymatches[$this->xv[$i]][] = $i;
}
} else {
for ($i = $ylim - 1; $i >= $yoff; $i--) {
$ymatches[$this->yv[$i]][] = $i;
}
}
$this->lcs = 0;
$this->seq[0]= $yoff - 1;
$this->in_seq = array();
$ymids[0] = array();
$numer = $xlim - $xoff + $nchunks - 1;
$x = $xoff;
for ($chunk = 0; $chunk < $nchunks; $chunk++) {
if ($chunk > 0) {
for ($i = 0; $i <= $this->lcs; $i++) {
$ymids[$i][$chunk - 1] = $this->seq[$i];
}
}
$x1 = $xoff + (int)(($numer + ($xlim - $xoff) * $chunk) / $nchunks);
for (; $x < $x1; $x++) {
$line = $flip ? $this->yv[$x] : $this->xv[$x];
if (empty($ymatches[$line])) {
continue;
}
$matches = $ymatches[$line];
reset($matches);
while (list(, $y) = each($matches)) {
if (empty($this->in_seq[$y])) {
$k = $this->_lcsPos($y);
assert($k > 0);
$ymids[$k] = $ymids[$k - 1];
break;
}
}
while (list(, $y) = each($matches)) {
if ($y > $this->seq[$k - 1]) {
assert($y <= $this->seq[$k]);
/* Optimization: this is a common case: next match is
* just replacing previous match. */
$this->in_seq[$this->seq[$k]] = false;
$this->seq[$k] = $y;
$this->in_seq[$y] = 1;
} elseif (empty($this->in_seq[$y])) {
$k = $this->_lcsPos($y);
assert($k > 0);
$ymids[$k] = $ymids[$k - 1];
}
}
}
}
$seps[] = $flip ? array($yoff, $xoff) : array($xoff, $yoff);
$ymid = $ymids[$this->lcs];
for ($n = 0; $n < $nchunks - 1; $n++) {
$x1 = $xoff + (int)(($numer + ($xlim - $xoff) * $n) / $nchunks);
$y1 = $ymid[$n] + 1;
$seps[] = $flip ? array($y1, $x1) : array($x1, $y1);
}
$seps[] = $flip ? array($ylim, $xlim) : array($xlim, $ylim);
return array($this->lcs, $seps);
}
function _lcsPos($ypos)
{
$end = $this->lcs;
if ($end == 0 || $ypos > $this->seq[$end]) {
$this->seq[++$this->lcs] = $ypos;
$this->in_seq[$ypos] = 1;
return $this->lcs;
}
$beg = 1;
while ($beg < $end) {
$mid = (int)(($beg + $end) / 2);
if ($ypos > $this->seq[$mid]) {
$beg = $mid + 1;
} else {
$end = $mid;
}
}
assert($ypos != $this->seq[$end]);
$this->in_seq[$this->seq[$end]] = false;
$this->seq[$end] = $ypos;
$this->in_seq[$ypos] = 1;
return $end;
}
/**
* Finds LCS of two sequences.
*
* The results are recorded in the vectors $this->{x,y}changed[], by
* storing a 1 in the element for each line that is an insertion or
* deletion (ie. is not in the LCS).
*
* The subsequence of file 0 is (XOFF, XLIM) and likewise for file 1.
*
* Note that XLIM, YLIM are exclusive bounds. All line numbers are
* origin-0 and discarded lines are not counted.
*/
function _compareseq ($xoff, $xlim, $yoff, $ylim)
{
/* Slide down the bottom initial diagonal. */
while ($xoff < $xlim && $yoff < $ylim
&& $this->xv[$xoff] == $this->yv[$yoff]) {
++$xoff;
++$yoff;
}
/* Slide up the top initial diagonal. */
while ($xlim > $xoff && $ylim > $yoff
&& $this->xv[$xlim - 1] == $this->yv[$ylim - 1]) {
--$xlim;
--$ylim;
}
if ($xoff == $xlim || $yoff == $ylim) {
$lcs = 0;
} else {
/* This is ad hoc but seems to work well. $nchunks =
* sqrt(min($xlim - $xoff, $ylim - $yoff) / 2.5); $nchunks =
* max(2,min(8,(int)$nchunks)); */
$nchunks = min(7, $xlim - $xoff, $ylim - $yoff) + 1;
list($lcs, $seps)
= $this->_diag($xoff, $xlim, $yoff, $ylim, $nchunks);
}
if ($lcs == 0) {
/* X and Y sequences have no common subsequence: mark all
* changed. */
while ($yoff < $ylim) {
$this->ychanged[$this->yind[$yoff++]] = 1;
}
while ($xoff < $xlim) {
$this->xchanged[$this->xind[$xoff++]] = 1;
}
} else {
/* Use the partitions to split this problem into subproblems. */
reset($seps);
$pt1 = $seps[0];
while ($pt2 = next($seps)) {
$this->_compareseq ($pt1[0], $pt2[0], $pt1[1], $pt2[1]);
$pt1 = $pt2;
}
}
}
/**
* Adjusts inserts/deletes of identical lines to join changes as much as
* possible.
*
* We do something when a run of changed lines include a line at one end
* and has an excluded, identical line at the other. We are free to
* choose which identical line is included. `compareseq' usually chooses
* the one at the beginning, but usually it is cleaner to consider the
* following identical line to be the "change".
*
* This is extracted verbatim from analyze.c (GNU diffutils-2.7).
*/
function _shiftBoundaries($lines, &$changed, $other_changed)
{
$i = 0;
$j = 0;
assert('count($lines) == count($changed)');
$len = count($lines);
$other_len = count($other_changed);
while (1) {
/* Scan forward to find the beginning of another run of
* changes. Also keep track of the corresponding point in the
* other file.
*
* Throughout this code, $i and $j are adjusted together so that
* the first $i elements of $changed and the first $j elements of
* $other_changed both contain the same number of zeros (unchanged
* lines).
*
* Furthermore, $j is always kept so that $j == $other_len or
* $other_changed[$j] == false. */
while ($j < $other_len && $other_changed[$j]) {
$j++;
}
while ($i < $len && ! $changed[$i]) {
assert('$j < $other_len && ! $other_changed[$j]');
$i++; $j++;
while ($j < $other_len && $other_changed[$j]) {
$j++;
}
}
if ($i == $len) {
break;
}
$start = $i;
/* Find the end of this run of changes. */
while (++$i < $len && $changed[$i]) {
continue;
}
do {
/* Record the length of this run of changes, so that we can
* later determine whether the run has grown. */
$runlength = $i - $start;
/* Move the changed region back, so long as the previous
* unchanged line matches the last changed one. This merges
* with previous changed regions. */
while ($start > 0 && $lines[$start - 1] == $lines[$i - 1]) {
$changed[--$start] = 1;
$changed[--$i] = false;
while ($start > 0 && $changed[$start - 1]) {
$start--;
}
assert('$j > 0');
while ($other_changed[--$j]) {
continue;
}
assert('$j >= 0 && !$other_changed[$j]');
}
/* Set CORRESPONDING to the end of the changed run, at the
* last point where it corresponds to a changed run in the
* other file. CORRESPONDING == LEN means no such point has
* been found. */
$corresponding = $j < $other_len ? $i : $len;
/* Move the changed region forward, so long as the first
* changed line matches the following unchanged one. This
* merges with following changed regions. Do this second, so
* that if there are no merges, the changed region is moved
* forward as far as possible. */
while ($i < $len && $lines[$start] == $lines[$i]) {
$changed[$start++] = false;
$changed[$i++] = 1;
while ($i < $len && $changed[$i]) {
$i++;
}
assert('$j < $other_len && ! $other_changed[$j]');
$j++;
if ($j < $other_len && $other_changed[$j]) {
$corresponding = $i;
while ($j < $other_len && $other_changed[$j]) {
$j++;
}
}
}
} while ($runlength != $i - $start);
/* If possible, move the fully-merged run of changes back to a
* corresponding run in the other file. */
while ($corresponding < $i) {
$changed[--$start] = 1;
$changed[--$i] = 0;
assert('$j > 0');
while ($other_changed[--$j]) {
continue;
}
assert('$j >= 0 && !$other_changed[$j]');
}
}
}
}
| 01-wordpress-paypal | trunk/wp-includes/Text/Diff/Engine/native.php | PHP | gpl3 | 15,840 |
<?php
/**
* Class used internally by Diff to actually compute the diffs.
*
* This class uses the Unix `diff` program via shell_exec to compute the
* differences between the two input arrays.
*
* Copyright 2007-2010 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you did
* not receive this file, see http://opensource.org/licenses/lgpl-license.php.
*
* @author Milian Wolff <mail@milianw.de>
* @package Text_Diff
* @since 0.3.0
*/
class Text_Diff_Engine_shell {
/**
* Path to the diff executable
*
* @var string
*/
var $_diffCommand = 'diff';
/**
* Returns the array of differences.
*
* @param array $from_lines lines of text from old file
* @param array $to_lines lines of text from new file
*
* @return array all changes made (array with Text_Diff_Op_* objects)
*/
function diff($from_lines, $to_lines)
{
array_walk($from_lines, array('Text_Diff', 'trimNewlines'));
array_walk($to_lines, array('Text_Diff', 'trimNewlines'));
$temp_dir = Text_Diff::_getTempDir();
// Execute gnu diff or similar to get a standard diff file.
$from_file = tempnam($temp_dir, 'Text_Diff');
$to_file = tempnam($temp_dir, 'Text_Diff');
$fp = fopen($from_file, 'w');
fwrite($fp, implode("\n", $from_lines));
fclose($fp);
$fp = fopen($to_file, 'w');
fwrite($fp, implode("\n", $to_lines));
fclose($fp);
$diff = shell_exec($this->_diffCommand . ' ' . $from_file . ' ' . $to_file);
unlink($from_file);
unlink($to_file);
if (is_null($diff)) {
// No changes were made
return array(new Text_Diff_Op_copy($from_lines));
}
$from_line_no = 1;
$to_line_no = 1;
$edits = array();
// Get changed lines by parsing something like:
// 0a1,2
// 1,2c4,6
// 1,5d6
preg_match_all('#^(\d+)(?:,(\d+))?([adc])(\d+)(?:,(\d+))?$#m', $diff,
$matches, PREG_SET_ORDER);
foreach ($matches as $match) {
if (!isset($match[5])) {
// This paren is not set every time (see regex).
$match[5] = false;
}
if ($match[3] == 'a') {
$from_line_no--;
}
if ($match[3] == 'd') {
$to_line_no--;
}
if ($from_line_no < $match[1] || $to_line_no < $match[4]) {
// copied lines
assert('$match[1] - $from_line_no == $match[4] - $to_line_no');
array_push($edits,
new Text_Diff_Op_copy(
$this->_getLines($from_lines, $from_line_no, $match[1] - 1),
$this->_getLines($to_lines, $to_line_no, $match[4] - 1)));
}
switch ($match[3]) {
case 'd':
// deleted lines
array_push($edits,
new Text_Diff_Op_delete(
$this->_getLines($from_lines, $from_line_no, $match[2])));
$to_line_no++;
break;
case 'c':
// changed lines
array_push($edits,
new Text_Diff_Op_change(
$this->_getLines($from_lines, $from_line_no, $match[2]),
$this->_getLines($to_lines, $to_line_no, $match[5])));
break;
case 'a':
// added lines
array_push($edits,
new Text_Diff_Op_add(
$this->_getLines($to_lines, $to_line_no, $match[5])));
$from_line_no++;
break;
}
}
if (!empty($from_lines)) {
// Some lines might still be pending. Add them as copied
array_push($edits,
new Text_Diff_Op_copy(
$this->_getLines($from_lines, $from_line_no,
$from_line_no + count($from_lines) - 1),
$this->_getLines($to_lines, $to_line_no,
$to_line_no + count($to_lines) - 1)));
}
return $edits;
}
/**
* Get lines from either the old or new text
*
* @access private
*
* @param array &$text_lines Either $from_lines or $to_lines
* @param int &$line_no Current line number
* @param int $end Optional end line, when we want to chop more
* than one line.
*
* @return array The chopped lines
*/
function _getLines(&$text_lines, &$line_no, $end = false)
{
if (!empty($end)) {
$lines = array();
// We can shift even more
while ($line_no <= $end) {
array_push($lines, array_shift($text_lines));
$line_no++;
}
} else {
$lines = array(array_shift($text_lines));
$line_no++;
}
return $lines;
}
}
| 01-wordpress-paypal | trunk/wp-includes/Text/Diff/Engine/shell.php | PHP | gpl3 | 5,170 |
<?php
/**
* Class used internally by Diff to actually compute the diffs.
*
* This class uses the xdiff PECL package (http://pecl.php.net/package/xdiff)
* to compute the differences between the two input arrays.
*
* Copyright 2004-2010 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you did
* not receive this file, see http://opensource.org/licenses/lgpl-license.php.
*
* @author Jon Parise <jon@horde.org>
* @package Text_Diff
*/
class Text_Diff_Engine_xdiff {
/**
*/
function diff($from_lines, $to_lines)
{
array_walk($from_lines, array('Text_Diff', 'trimNewlines'));
array_walk($to_lines, array('Text_Diff', 'trimNewlines'));
/* Convert the two input arrays into strings for xdiff processing. */
$from_string = implode("\n", $from_lines);
$to_string = implode("\n", $to_lines);
/* Diff the two strings and convert the result to an array. */
$diff = xdiff_string_diff($from_string, $to_string, count($to_lines));
$diff = explode("\n", $diff);
/* Walk through the diff one line at a time. We build the $edits
* array of diff operations by reading the first character of the
* xdiff output (which is in the "unified diff" format).
*
* Note that we don't have enough information to detect "changed"
* lines using this approach, so we can't add Text_Diff_Op_changed
* instances to the $edits array. The result is still perfectly
* valid, albeit a little less descriptive and efficient. */
$edits = array();
foreach ($diff as $line) {
if (!strlen($line)) {
continue;
}
switch ($line[0]) {
case ' ':
$edits[] = new Text_Diff_Op_copy(array(substr($line, 1)));
break;
case '+':
$edits[] = new Text_Diff_Op_add(array(substr($line, 1)));
break;
case '-':
$edits[] = new Text_Diff_Op_delete(array(substr($line, 1)));
break;
}
}
return $edits;
}
}
| 01-wordpress-paypal | trunk/wp-includes/Text/Diff/Engine/xdiff.php | PHP | gpl3 | 2,210 |
<?php
/**
* "Inline" diff renderer.
*
* Copyright 2004-2010 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you did
* not receive this file, see http://opensource.org/licenses/lgpl-license.php.
*
* @author Ciprian Popovici
* @package Text_Diff
*/
/** Text_Diff_Renderer */
// WP #7391
require_once dirname(dirname(__FILE__)) . '/Renderer.php';
/**
* "Inline" diff renderer.
*
* This class renders diffs in the Wiki-style "inline" format.
*
* @author Ciprian Popovici
* @package Text_Diff
*/
class Text_Diff_Renderer_inline extends Text_Diff_Renderer {
/**
* Number of leading context "lines" to preserve.
*
* @var integer
*/
var $_leading_context_lines = 10000;
/**
* Number of trailing context "lines" to preserve.
*
* @var integer
*/
var $_trailing_context_lines = 10000;
/**
* Prefix for inserted text.
*
* @var string
*/
var $_ins_prefix = '<ins>';
/**
* Suffix for inserted text.
*
* @var string
*/
var $_ins_suffix = '</ins>';
/**
* Prefix for deleted text.
*
* @var string
*/
var $_del_prefix = '<del>';
/**
* Suffix for deleted text.
*
* @var string
*/
var $_del_suffix = '</del>';
/**
* Header for each change block.
*
* @var string
*/
var $_block_header = '';
/**
* Whether to split down to character-level.
*
* @var boolean
*/
var $_split_characters = false;
/**
* What are we currently splitting on? Used to recurse to show word-level
* or character-level changes.
*
* @var string
*/
var $_split_level = 'lines';
function _blockHeader($xbeg, $xlen, $ybeg, $ylen)
{
return $this->_block_header;
}
function _startBlock($header)
{
return $header;
}
function _lines($lines, $prefix = ' ', $encode = true)
{
if ($encode) {
array_walk($lines, array(&$this, '_encode'));
}
if ($this->_split_level == 'lines') {
return implode("\n", $lines) . "\n";
} else {
return implode('', $lines);
}
}
function _added($lines)
{
array_walk($lines, array(&$this, '_encode'));
$lines[0] = $this->_ins_prefix . $lines[0];
$lines[count($lines) - 1] .= $this->_ins_suffix;
return $this->_lines($lines, ' ', false);
}
function _deleted($lines, $words = false)
{
array_walk($lines, array(&$this, '_encode'));
$lines[0] = $this->_del_prefix . $lines[0];
$lines[count($lines) - 1] .= $this->_del_suffix;
return $this->_lines($lines, ' ', false);
}
function _changed($orig, $final)
{
/* If we've already split on characters, just display. */
if ($this->_split_level == 'characters') {
return $this->_deleted($orig)
. $this->_added($final);
}
/* If we've already split on words, just display. */
if ($this->_split_level == 'words') {
$prefix = '';
while ($orig[0] !== false && $final[0] !== false &&
substr($orig[0], 0, 1) == ' ' &&
substr($final[0], 0, 1) == ' ') {
$prefix .= substr($orig[0], 0, 1);
$orig[0] = substr($orig[0], 1);
$final[0] = substr($final[0], 1);
}
return $prefix . $this->_deleted($orig) . $this->_added($final);
}
$text1 = implode("\n", $orig);
$text2 = implode("\n", $final);
/* Non-printing newline marker. */
$nl = "\0";
if ($this->_split_characters) {
$diff = new Text_Diff('native',
array(preg_split('//', $text1),
preg_split('//', $text2)));
} else {
/* We want to split on word boundaries, but we need to preserve
* whitespace as well. Therefore we split on words, but include
* all blocks of whitespace in the wordlist. */
$diff = new Text_Diff('native',
array($this->_splitOnWords($text1, $nl),
$this->_splitOnWords($text2, $nl)));
}
/* Get the diff in inline format. */
$renderer = new Text_Diff_Renderer_inline
(array_merge($this->getParams(),
array('split_level' => $this->_split_characters ? 'characters' : 'words')));
/* Run the diff and get the output. */
return str_replace($nl, "\n", $renderer->render($diff)) . "\n";
}
function _splitOnWords($string, $newlineEscape = "\n")
{
// Ignore \0; otherwise the while loop will never finish.
$string = str_replace("\0", '', $string);
$words = array();
$length = strlen($string);
$pos = 0;
while ($pos < $length) {
// Eat a word with any preceding whitespace.
$spaces = strspn(substr($string, $pos), " \n");
$nextpos = strcspn(substr($string, $pos + $spaces), " \n");
$words[] = str_replace("\n", $newlineEscape, substr($string, $pos, $spaces + $nextpos));
$pos += $spaces + $nextpos;
}
return $words;
}
function _encode(&$string)
{
$string = htmlspecialchars($string);
}
}
| 01-wordpress-paypal | trunk/wp-includes/Text/Diff/Renderer/inline.php | PHP | gpl3 | 5,535 |
<?php
/**
* XML-RPC protocol support for WordPress
*
* @package WordPress
* @subpackage Publishing
*/
/**
* WordPress XMLRPC server implementation.
*
* Implements compatibility for Blogger API, MetaWeblog API, MovableType, and
* pingback. Additional WordPress API for managing comments, pages, posts,
* options, etc.
*
* As of WordPress 3.5.0, XML-RPC is enabled by default. It can be disabled
* via the xmlrpc_enabled filter found in wp_xmlrpc_server::login().
*
* @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.
*
* 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 __construct() {
$this->methods = array(
// WordPress API
'wp.getUsersBlogs' => 'this:wp_getUsersBlogs',
'wp.newPost' => 'this:wp_newPost',
'wp.editPost' => 'this:wp_editPost',
'wp.deletePost' => 'this:wp_deletePost',
'wp.getPost' => 'this:wp_getPost',
'wp.getPosts' => 'this:wp_getPosts',
'wp.newTerm' => 'this:wp_newTerm',
'wp.editTerm' => 'this:wp_editTerm',
'wp.deleteTerm' => 'this:wp_deleteTerm',
'wp.getTerm' => 'this:wp_getTerm',
'wp.getTerms' => 'this:wp_getTerms',
'wp.getTaxonomy' => 'this:wp_getTaxonomy',
'wp.getTaxonomies' => 'this:wp_getTaxonomies',
'wp.getUser' => 'this:wp_getUser',
'wp.getUsers' => 'this:wp_getUsers',
'wp.getProfile' => 'this:wp_getProfile',
'wp.editProfile' => 'this:wp_editProfile',
'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',
'wp.getPostType' => 'this:wp_getPostType',
'wp.getPostTypes' => 'this:wp_getPostTypes',
'wp.getRevisions' => 'this:wp_getRevisions',
'wp.restoreRevision' => 'this:wp_restoreRevision',
// Blogger API
'blogger.getUsersBlogs' => 'this:blogger_getUsersBlogs',
'blogger.getUserInfo' => 'this:blogger_getUserInfo',
'blogger.getPost' => 'this:blogger_getPost',
'blogger.getRecentPosts' => 'this:blogger_getRecentPosts',
'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.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();
/**
* Filter the methods exposed by the XML-RPC server.
*
* This filter can be used to add new methods, and remove built-in methods.
*
* @since 1.5.0
*
* @param array $methods An array of XML-RPC methods.
*/
$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;
}
/**
* Log user in.
*
* @since 2.8.0
*
* @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 ) {
/*
* Respect old get_option() filters left for back-compat when the 'enable_xmlrpc'
* option was deprecated in 3.5.0. Use the 'xmlrpc_enabled' hook instead.
*/
$enabled = apply_filters( 'pre_option_enable_xmlrpc', false );
if ( false === $enabled ) {
$enabled = apply_filters( 'option_enable_xmlrpc', true );
}
/**
* Filter whether XML-RPC is enabled.
*
* This is the proper filter for turning off XML-RPC.
*
* @since 3.5.0
*
* @param bool $enabled Whether XML-RPC is enabled. Default true.
*/
$enabled = apply_filters( 'xmlrpc_enabled', $enabled );
if ( ! $enabled ) {
$this->error = new IXR_Error( 405, sprintf( __( 'XML-RPC services are disabled on this site.' ) ) );
return false;
}
$user = wp_authenticate($username, $password);
if (is_wp_error($user)) {
$this->error = new IXR_Error( 403, __( 'Incorrect username or password.' ) );
/**
* Filter the XML-RPC user login error message.
*
* @since 3.5.0
*
* @param string $error The XML-RPC error message.
* @param WP_User $user WP_User object.
*/
$this->error = apply_filters( 'xmlrpc_login_error', $this->error, $user );
return false;
}
wp_set_current_user( $user->ID );
return $user;
}
/**
* Check user's credentials. Deprecated.
*
* @since 1.5.0
* @deprecated 2.8.0
* @deprecated use wp_xmlrpc_server::login
* @see wp_xmlrpc_server::login
*
* @param string $username User's username.
* @param string $password User's password.
* @return bool Whether authentication passed.
*/
function login_pass_ok( $username, $password ) {
return (bool) $this->login( $username, $password );
}
/**
* Escape string or array of strings for database.
*
* @since 1.5.2
*
* @param string|array $data Escape single string or array of strings.
* @return string|array Type matches $data and sanitized for the database.
*/
function escape( &$data ) {
if ( ! is_array( $data ) )
return wp_slash( $data );
foreach ( $data as &$v ) {
if ( is_array( $v ) )
$this->escape( $v );
elseif ( ! is_object( $v ) )
$v = wp_slash( $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 ( ! current_user_can( 'edit_post_meta', $post_id , $meta['meta_key'] ) )
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'];
$pmeta = get_metadata_by_mid( 'post', $meta['id'] );
if ( isset($meta['key']) ) {
$meta['key'] = wp_unslash( $meta['key'] );
if ( $meta['key'] !== $pmeta->meta_key )
continue;
$meta['value'] = wp_unslash( $meta['value'] );
if ( current_user_can( 'edit_post_meta', $post_id, $meta['key'] ) )
update_metadata_by_mid( 'post', $meta['id'], $meta['value'] );
} elseif ( current_user_can( 'delete_post_meta', $post_id, $pmeta->meta_key ) ) {
delete_metadata_by_mid( 'post', $meta['id'] );
}
} elseif ( current_user_can( 'add_post_meta', $post_id, wp_unslash( $meta['key'] ) ) ) {
add_post_meta( $post_id, $meta['key'], $meta['value'] );
}
}
}
/**
* 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' => __( 'WordPress Address (URL)' ),
'readonly' => true,
'option' => 'siteurl'
),
'home_url' => array(
'desc' => __( 'Site Address (URL)' ),
'readonly' => true,
'option' => 'home'
),
'login_url' => array(
'desc' => __( 'Login Address (URL)' ),
'readonly' => true,
'value' => wp_login_url( )
),
'admin_url' => array(
'desc' => __( 'The URL to the admin area' ),
'readonly' => true,
'value' => get_admin_url( )
),
'image_default_link_type' => array(
'desc' => __( 'Image default link type' ),
'readonly' => true,
'option' => 'image_default_link_type'
),
'image_default_size' => array(
'desc' => __( 'Image default size' ),
'readonly' => true,
'option' => 'image_default_size'
),
'image_default_align' => array(
'desc' => __( 'Image default align' ),
'readonly' => true,
'option' => 'image_default_align'
),
'template' => array(
'desc' => __( 'Template' ),
'readonly' => true,
'option' => 'template'
),
'stylesheet' => array(
'desc' => __( 'Stylesheet' ),
'readonly' => true,
'option' => 'stylesheet'
),
'post_thumbnail' => array(
'desc' => __('Post Thumbnail'),
'readonly' => true,
'value' => current_theme_supports( 'post-thumbnails' )
),
// 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'
),
'default_comment_status' => array(
'desc' => __( 'Allow people to post comments on new articles' ),
'readonly' => false,
'option' => 'default_comment_status'
),
'default_ping_status' => array(
'desc' => __( 'Allow link notifications from other blogs (pingbacks and trackbacks)' ),
'readonly' => false,
'option' => 'default_ping_status'
)
);
/**
* Filter the XML-RPC blog options property.
*
* @since 2.6.0
*
* @param array $blog_options An array of XML-RPC blog options.
*/
$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. Contains:
* - username
* - password
* @return array. Contains:
* - 'isAdmin'
* - 'url'
* - 'blogid'
* - 'blogName'
* - 'xmlrpc' - url of xmlrpc endpoint
*/
function wp_getUsersBlogs( $args ) {
// 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;
/**
* Fires after the XML-RPC user has been authenticated but before the rest of
* the method logic begins.
*
* All built-in XML-RPC methods use the action xmlrpc_call, with a parameter
* equal to the method's name, e.g., wp.getUsersBlogs, wp.newPost, etc.
*
* @since 2.5.0
*
* @param method $name The method name.
*/
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 != get_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' => home_url( '/' ),
'blogid' => (string) $blog_id,
'blogName' => get_option( 'blogname' ),
'xmlrpc' => site_url( 'xmlrpc.php', 'rpc' ),
);
restore_current_blog();
}
return $struct;
}
/**
* Checks if the method received at least the minimum number of arguments.
*
* @since 3.4.0
*
* @param string|array $args Sanitize single string or array of strings.
* @param int $count Minimum number of arguments.
* @return boolean if $args contains at least $count arguments.
*/
protected function minimum_args( $args, $count ) {
if ( count( $args ) < $count ) {
$this->error = new IXR_Error( 400, __( 'Insufficient arguments passed to this XML-RPC method.' ) );
return false;
}
return true;
}
/**
* Prepares taxonomy data for return in an XML-RPC object.
*
* @access protected
*
* @param object $taxonomy The unprepared taxonomy data
* @param array $fields The subset of taxonomy fields to return
* @return array The prepared taxonomy data
*/
protected function _prepare_taxonomy( $taxonomy, $fields ) {
$_taxonomy = array(
'name' => $taxonomy->name,
'label' => $taxonomy->label,
'hierarchical' => (bool) $taxonomy->hierarchical,
'public' => (bool) $taxonomy->public,
'show_ui' => (bool) $taxonomy->show_ui,
'_builtin' => (bool) $taxonomy->_builtin,
);
if ( in_array( 'labels', $fields ) )
$_taxonomy['labels'] = (array) $taxonomy->labels;
if ( in_array( 'cap', $fields ) )
$_taxonomy['cap'] = (array) $taxonomy->cap;
if ( in_array( 'menu', $fields ) )
$_taxonomy['show_in_menu'] = (bool) $_taxonomy->show_in_menu;
if ( in_array( 'object_type', $fields ) )
$_taxonomy['object_type'] = array_unique( (array) $taxonomy->object_type );
/**
* Filter XML-RPC-prepared data for the given taxonomy.
*
* @since 3.4.0
*
* @param array $_taxonomy An array of taxonomy data.
* @param object $taxonomy Taxonomy object.
* @param array $fields The subset of taxonomy fields to return.
*/
return apply_filters( 'xmlrpc_prepare_taxonomy', $_taxonomy, $taxonomy, $fields );
}
/**
* Prepares term data for return in an XML-RPC object.
*
* @access protected
*
* @param array|object $term The unprepared term data
* @return array The prepared term data
*/
protected function _prepare_term( $term ) {
$_term = $term;
if ( ! is_array( $_term) )
$_term = get_object_vars( $_term );
// For integers which may be larger than XML-RPC supports ensure we return strings.
$_term['term_id'] = strval( $_term['term_id'] );
$_term['term_group'] = strval( $_term['term_group'] );
$_term['term_taxonomy_id'] = strval( $_term['term_taxonomy_id'] );
$_term['parent'] = strval( $_term['parent'] );
// Count we are happy to return as an integer because people really shouldn't use terms that much.
$_term['count'] = intval( $_term['count'] );
/**
* Filter XML-RPC-prepared data for the given term.
*
* @since 3.4.0
*
* @param array $_term An array of term data.
* @param array|object $term Term object or array.
*/
return apply_filters( 'xmlrpc_prepare_term', $_term, $term );
}
/**
* Convert a WordPress date string to an IXR_Date object.
*
* @access protected
*
* @param string $date
* @return IXR_Date
*/
protected function _convert_date( $date ) {
if ( $date === '0000-00-00 00:00:00' ) {
return new IXR_Date( '00000000T00:00:00Z' );
}
return new IXR_Date( mysql2date( 'Ymd\TH:i:s', $date, false ) );
}
/**
* Convert a WordPress GMT date string to an IXR_Date object.
*
* @access protected
*
* @param string $date_gmt
* @param string $date
* @return IXR_Date
*/
protected function _convert_date_gmt( $date_gmt, $date ) {
if ( $date !== '0000-00-00 00:00:00' && $date_gmt === '0000-00-00 00:00:00' ) {
return new IXR_Date( get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $date, false ), 'Ymd\TH:i:s' ) );
}
return $this->_convert_date( $date_gmt );
}
/**
* Prepares post data for return in an XML-RPC object.
*
* @access protected
*
* @param array $post The unprepared post data
* @param array $fields The subset of post type fields to return
* @return array The prepared post data
*/
protected function _prepare_post( $post, $fields ) {
// holds the data for this post. built up based on $fields
$_post = array( 'post_id' => strval( $post['ID'] ) );
// prepare common post fields
$post_fields = array(
'post_title' => $post['post_title'],
'post_date' => $this->_convert_date( $post['post_date'] ),
'post_date_gmt' => $this->_convert_date_gmt( $post['post_date_gmt'], $post['post_date'] ),
'post_modified' => $this->_convert_date( $post['post_modified'] ),
'post_modified_gmt' => $this->_convert_date_gmt( $post['post_modified_gmt'], $post['post_modified'] ),
'post_status' => $post['post_status'],
'post_type' => $post['post_type'],
'post_name' => $post['post_name'],
'post_author' => $post['post_author'],
'post_password' => $post['post_password'],
'post_excerpt' => $post['post_excerpt'],
'post_content' => $post['post_content'],
'post_parent' => strval( $post['post_parent'] ),
'post_mime_type' => $post['post_mime_type'],
'link' => post_permalink( $post['ID'] ),
'guid' => $post['guid'],
'menu_order' => intval( $post['menu_order'] ),
'comment_status' => $post['comment_status'],
'ping_status' => $post['ping_status'],
'sticky' => ( $post['post_type'] === 'post' && is_sticky( $post['ID'] ) ),
);
// Thumbnail
$post_fields['post_thumbnail'] = array();
$thumbnail_id = get_post_thumbnail_id( $post['ID'] );
if ( $thumbnail_id ) {
$thumbnail_size = current_theme_supports('post-thumbnail') ? 'post-thumbnail' : 'thumbnail';
$post_fields['post_thumbnail'] = $this->_prepare_media_item( get_post( $thumbnail_id ), $thumbnail_size );
}
// Consider future posts as published
if ( $post_fields['post_status'] === 'future' )
$post_fields['post_status'] = 'publish';
// Fill in blank post format
$post_fields['post_format'] = get_post_format( $post['ID'] );
if ( empty( $post_fields['post_format'] ) )
$post_fields['post_format'] = 'standard';
// Merge requested $post_fields fields into $_post
if ( in_array( 'post', $fields ) ) {
$_post = array_merge( $_post, $post_fields );
} else {
$requested_fields = array_intersect_key( $post_fields, array_flip( $fields ) );
$_post = array_merge( $_post, $requested_fields );
}
$all_taxonomy_fields = in_array( 'taxonomies', $fields );
if ( $all_taxonomy_fields || in_array( 'terms', $fields ) ) {
$post_type_taxonomies = get_object_taxonomies( $post['post_type'], 'names' );
$terms = wp_get_object_terms( $post['ID'], $post_type_taxonomies );
$_post['terms'] = array();
foreach ( $terms as $term ) {
$_post['terms'][] = $this->_prepare_term( $term );
}
}
if ( in_array( 'custom_fields', $fields ) )
$_post['custom_fields'] = $this->get_custom_fields( $post['ID'] );
if ( in_array( 'enclosure', $fields ) ) {
$_post['enclosure'] = array();
$enclosures = (array) get_post_meta( $post['ID'], 'enclosure' );
if ( ! empty( $enclosures ) ) {
$encdata = explode( "\n", $enclosures[0] );
$_post['enclosure']['url'] = trim( htmlspecialchars( $encdata[0] ) );
$_post['enclosure']['length'] = (int) trim( $encdata[1] );
$_post['enclosure']['type'] = trim( $encdata[2] );
}
}
/**
* Filter XML-RPC-prepared date for the given post.
*
* @since 3.4.0
*
* @param array $_post An array of modified post data.
* @param array $post An array of post data.
* @param array $fields An array of post fields.
*/
return apply_filters( 'xmlrpc_prepare_post', $_post, $post, $fields );
}
/**
* Prepares post data for return in an XML-RPC object.
*
* @access protected
*
* @param object $post_type Post type object
* @param array $fields The subset of post fields to return
* @return array The prepared post type data
*/
protected function _prepare_post_type( $post_type, $fields ) {
$_post_type = array(
'name' => $post_type->name,
'label' => $post_type->label,
'hierarchical' => (bool) $post_type->hierarchical,
'public' => (bool) $post_type->public,
'show_ui' => (bool) $post_type->show_ui,
'_builtin' => (bool) $post_type->_builtin,
'has_archive' => (bool) $post_type->has_archive,
'supports' => get_all_post_type_supports( $post_type->name ),
);
if ( in_array( 'labels', $fields ) ) {
$_post_type['labels'] = (array) $post_type->labels;
}
if ( in_array( 'cap', $fields ) ) {
$_post_type['cap'] = (array) $post_type->cap;
$_post_type['map_meta_cap'] = (bool) $post_type->map_meta_cap;
}
if ( in_array( 'menu', $fields ) ) {
$_post_type['menu_position'] = (int) $post_type->menu_position;
$_post_type['menu_icon'] = $post_type->menu_icon;
$_post_type['show_in_menu'] = (bool) $post_type->show_in_menu;
}
if ( in_array( 'taxonomies', $fields ) )
$_post_type['taxonomies'] = get_object_taxonomies( $post_type->name, 'names' );
/**
* Filter XML-RPC-prepared date for the given post type.
*
* @since 3.4.0
*
* @param array $_post_type An array of post type data.
* @param object $post_type Post type object.
*/
return apply_filters( 'xmlrpc_prepare_post_type', $_post_type, $post_type );
}
/**
* Prepares media item data for return in an XML-RPC object.
*
* @access protected
*
* @param object $media_item The unprepared media item data
* @param string $thumbnail_size The image size to use for the thumbnail URL
* @return array The prepared media item data
*/
protected function _prepare_media_item( $media_item, $thumbnail_size = 'thumbnail' ) {
$_media_item = array(
'attachment_id' => strval( $media_item->ID ),
'date_created_gmt' => $this->_convert_date_gmt( $media_item->post_date_gmt, $media_item->post_date ),
'parent' => $media_item->post_parent,
'link' => wp_get_attachment_url( $media_item->ID ),
'title' => $media_item->post_title,
'caption' => $media_item->post_excerpt,
'description' => $media_item->post_content,
'metadata' => wp_get_attachment_metadata( $media_item->ID ),
);
$thumbnail_src = image_downsize( $media_item->ID, $thumbnail_size );
if ( $thumbnail_src )
$_media_item['thumbnail'] = $thumbnail_src[0];
else
$_media_item['thumbnail'] = $_media_item['link'];
/**
* Filter XML-RPC-prepared data for the given media item.
*
* @since 3.4.0
*
* @param array $_media_item An array of media item data.
* @param object $media_item Media item object.
* @param string $thumbnail_size Image size.
*/
return apply_filters( 'xmlrpc_prepare_media_item', $_media_item, $media_item, $thumbnail_size );
}
/**
* Prepares page data for return in an XML-RPC object.
*
* @access protected
*
* @param object $page The unprepared page data
* @return array The prepared page data
*/
protected function _prepare_page( $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_post( $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 = $this->_convert_date( $page->post_date );
$page_date_gmt = $this->_convert_date_gmt( $page->post_date_gmt, $page->post_date );
// 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_page_template_slug( $page->ID );
if ( empty( $page_template ) )
$page_template = 'default';
$_page = array(
'dateCreated' => $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' => (string) $author->ID,
'wp_author_display_name' => $author->display_name,
'date_created_gmt' => $page_date_gmt,
'custom_fields' => $this->get_custom_fields( $page->ID ),
'wp_page_template' => $page_template
);
/**
* Filter XML-RPC-prepared data for the given page.
*
* @since 3.4.0
*
* @param array $_page An array of page data.
* @param WP_Post $page Page object.
*/
return apply_filters( 'xmlrpc_prepare_page', $_page, $page );
}
/**
* Prepares comment data for return in an XML-RPC object.
*
* @access protected
*
* @param object $comment The unprepared comment data
* @return array The prepared comment data
*/
protected function _prepare_comment( $comment ) {
// Format page date.
$comment_date = $this->_convert_date( $comment->comment_date );
$comment_date_gmt = $this->_convert_date_gmt( $comment->comment_date_gmt, $comment->comment_date );
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;
$_comment = array(
'date_created_gmt' => $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' => get_comment_link($comment),
'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,
);
/**
* Filter XML-RPC-prepared data for the given comment.
*
* @since 3.4.0
*
* @param array $_comment An array of prepared comment data.
* @param object $comment Comment object.
*/
return apply_filters( 'xmlrpc_prepare_comment', $_comment, $comment );
}
/**
* Prepares user data for return in an XML-RPC object.
*
* @access protected
*
* @param WP_User $user The unprepared user object
* @param array $fields The subset of user fields to return
* @return array The prepared user data
*/
protected function _prepare_user( $user, $fields ) {
$_user = array( 'user_id' => strval( $user->ID ) );
$user_fields = array(
'username' => $user->user_login,
'first_name' => $user->user_firstname,
'last_name' => $user->user_lastname,
'registered' => $this->_convert_date( $user->user_registered ),
'bio' => $user->user_description,
'email' => $user->user_email,
'nickname' => $user->nickname,
'nicename' => $user->user_nicename,
'url' => $user->user_url,
'display_name' => $user->display_name,
'roles' => $user->roles,
);
if ( in_array( 'all', $fields ) ) {
$_user = array_merge( $_user, $user_fields );
} else {
if ( in_array( 'basic', $fields ) ) {
$basic_fields = array( 'username', 'email', 'registered', 'display_name', 'nicename' );
$fields = array_merge( $fields, $basic_fields );
}
$requested_fields = array_intersect_key( $user_fields, array_flip( $fields ) );
$_user = array_merge( $_user, $requested_fields );
}
/**
* Filter XML-RPC-prepared data for the given user.
*
* @since 3.5.0
*
* @param array $_user An array of user data.
* @param WP_User $user User object.
* @param array $fields An array of user fields.
*/
return apply_filters( 'xmlrpc_prepare_user', $_user, $user, $fields );
}
/**
* Create a new post for any registered post type.
*
* @since 3.4.0
*
* @param array $args Method parameters. Contains:
* - int $blog_id
* - string $username
* - string $password
* - array $content_struct
* $content_struct can contain:
* - post_type (default: 'post')
* - post_status (default: 'draft')
* - post_title
* - post_author
* - post_excerpt
* - post_content
* - post_date_gmt | post_date
* - post_format
* - post_password
* - comment_status - can be 'open' | 'closed'
* - ping_status - can be 'open' | 'closed'
* - sticky
* - post_thumbnail - ID of a media item to use as the post thumbnail/featured image
* - custom_fields - array, with each element containing 'key' and 'value'
* - terms - array, with taxonomy names as keys and arrays of term IDs as values
* - terms_names - array, with taxonomy names as keys and arrays of term names as values
* - enclosure
* - any other fields supported by wp_insert_post()
* @return string post_id
*/
function wp_newPost( $args ) {
if ( ! $this->minimum_args( $args, 4 ) )
return $this->error;
$this->escape( $args );
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
$content_struct = $args[3];
if ( ! $user = $this->login( $username, $password ) )
return $this->error;
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'wp.newPost' );
unset( $content_struct['ID'] );
return $this->_insert_post( $user, $content_struct );
}
/**
* Helper method for filtering out elements from an array.
*
* @since 3.4.0
*
* @param int $count Number to compare to one.
*/
private function _is_greater_than_one( $count ) {
return $count > 1;
}
/**
* Helper method for wp_newPost and wp_editPost, containing shared logic.
*
* @since 3.4.0
* @uses wp_insert_post()
*
* @param WP_User $user The post author if post_author isn't set in $content_struct.
* @param array $content_struct Post data to insert.
*/
protected function _insert_post( $user, $content_struct ) {
$defaults = array( 'post_status' => 'draft', 'post_type' => 'post', 'post_author' => 0,
'post_password' => '', 'post_excerpt' => '', 'post_content' => '', 'post_title' => '' );
$post_data = wp_parse_args( $content_struct, $defaults );
$post_type = get_post_type_object( $post_data['post_type'] );
if ( ! $post_type )
return new IXR_Error( 403, __( 'Invalid post type' ) );
$update = ! empty( $post_data['ID'] );
if ( $update ) {
if ( ! get_post( $post_data['ID'] ) )
return new IXR_Error( 401, __( 'Invalid post ID.' ) );
if ( ! current_user_can( 'edit_post', $post_data['ID'] ) )
return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
if ( $post_data['post_type'] != get_post_type( $post_data['ID'] ) )
return new IXR_Error( 401, __( 'The post type may not be changed.' ) );
} else {
if ( ! current_user_can( $post_type->cap->create_posts ) || ! current_user_can( $post_type->cap->edit_posts ) )
return new IXR_Error( 401, __( 'Sorry, you are not allowed to post on this site.' ) );
}
switch ( $post_data['post_status'] ) {
case 'draft':
case 'pending':
break;
case 'private':
if ( ! current_user_can( $post_type->cap->publish_posts ) )
return new IXR_Error( 401, __( 'Sorry, you are not allowed to create private posts in this post type' ) );
break;
case 'publish':
case 'future':
if ( ! current_user_can( $post_type->cap->publish_posts ) )
return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish posts in this post type' ) );
break;
default:
if ( ! get_post_status_object( $post_data['post_status'] ) )
$post_data['post_status'] = 'draft';
break;
}
if ( ! empty( $post_data['post_password'] ) && ! current_user_can( $post_type->cap->publish_posts ) )
return new IXR_Error( 401, __( 'Sorry, you are not allowed to create password protected posts in this post type' ) );
$post_data['post_author'] = absint( $post_data['post_author'] );
if ( ! empty( $post_data['post_author'] ) && $post_data['post_author'] != $user->ID ) {
if ( ! current_user_can( $post_type->cap->edit_others_posts ) )
return new IXR_Error( 401, __( 'You are not allowed to create posts as this user.' ) );
$author = get_userdata( $post_data['post_author'] );
if ( ! $author )
return new IXR_Error( 404, __( 'Invalid author ID.' ) );
} else {
$post_data['post_author'] = $user->ID;
}
if ( isset( $post_data['comment_status'] ) && $post_data['comment_status'] != 'open' && $post_data['comment_status'] != 'closed' )
unset( $post_data['comment_status'] );
if ( isset( $post_data['ping_status'] ) && $post_data['ping_status'] != 'open' && $post_data['ping_status'] != 'closed' )
unset( $post_data['ping_status'] );
// Do some timestamp voodoo
if ( ! empty( $post_data['post_date_gmt'] ) ) {
// We know this is supposed to be GMT, so we're going to slap that Z on there by force
$dateCreated = rtrim( $post_data['post_date_gmt']->getIso(), 'Z' ) . 'Z';
} elseif ( ! empty( $post_data['post_date'] ) ) {
$dateCreated = $post_data['post_date']->getIso();
}
if ( ! empty( $dateCreated ) ) {
$post_data['post_date'] = get_date_from_gmt( iso8601_to_datetime( $dateCreated ) );
$post_data['post_date_gmt'] = iso8601_to_datetime( $dateCreated, 'GMT' );
}
if ( ! isset( $post_data['ID'] ) )
$post_data['ID'] = get_default_post_to_edit( $post_data['post_type'], true )->ID;
$post_ID = $post_data['ID'];
if ( $post_data['post_type'] == 'post' ) {
// Private and password-protected posts cannot be stickied.
if ( $post_data['post_status'] == 'private' || ! empty( $post_data['post_password'] ) ) {
// Error if the client tried to stick the post, otherwise, silently unstick.
if ( ! empty( $post_data['sticky'] ) )
return new IXR_Error( 401, __( 'Sorry, you cannot stick a private post.' ) );
if ( $update )
unstick_post( $post_ID );
} elseif ( isset( $post_data['sticky'] ) ) {
if ( ! current_user_can( $post_type->cap->edit_others_posts ) )
return new IXR_Error( 401, __( 'Sorry, you are not allowed to stick this post.' ) );
if ( $post_data['sticky'] )
stick_post( $post_ID );
else
unstick_post( $post_ID );
}
}
if ( isset( $post_data['post_thumbnail'] ) ) {
// empty value deletes, non-empty value adds/updates
if ( ! $post_data['post_thumbnail'] )
delete_post_thumbnail( $post_ID );
elseif ( ! get_post( absint( $post_data['post_thumbnail'] ) ) )
return new IXR_Error( 404, __( 'Invalid attachment ID.' ) );
set_post_thumbnail( $post_ID, $post_data['post_thumbnail'] );
unset( $content_struct['post_thumbnail'] );
}
if ( isset( $post_data['custom_fields'] ) )
$this->set_custom_fields( $post_ID, $post_data['custom_fields'] );
if ( isset( $post_data['terms'] ) || isset( $post_data['terms_names'] ) ) {
$post_type_taxonomies = get_object_taxonomies( $post_data['post_type'], 'objects' );
// accumulate term IDs from terms and terms_names
$terms = array();
// first validate the terms specified by ID
if ( isset( $post_data['terms'] ) && is_array( $post_data['terms'] ) ) {
$taxonomies = array_keys( $post_data['terms'] );
// validating term ids
foreach ( $taxonomies as $taxonomy ) {
if ( ! array_key_exists( $taxonomy , $post_type_taxonomies ) )
return new IXR_Error( 401, __( 'Sorry, one of the given taxonomies is not supported by the post type.' ) );
if ( ! current_user_can( $post_type_taxonomies[$taxonomy]->cap->assign_terms ) )
return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign a term to one of the given taxonomies.' ) );
$term_ids = $post_data['terms'][$taxonomy];
$terms[ $taxonomy ] = array();
foreach ( $term_ids as $term_id ) {
$term = get_term_by( 'id', $term_id, $taxonomy );
if ( ! $term )
return new IXR_Error( 403, __( 'Invalid term ID' ) );
$terms[$taxonomy][] = (int) $term_id;
}
}
}
// now validate terms specified by name
if ( isset( $post_data['terms_names'] ) && is_array( $post_data['terms_names'] ) ) {
$taxonomies = array_keys( $post_data['terms_names'] );
foreach ( $taxonomies as $taxonomy ) {
if ( ! array_key_exists( $taxonomy , $post_type_taxonomies ) )
return new IXR_Error( 401, __( 'Sorry, one of the given taxonomies is not supported by the post type.' ) );
if ( ! current_user_can( $post_type_taxonomies[$taxonomy]->cap->assign_terms ) )
return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign a term to one of the given taxonomies.' ) );
// for hierarchical taxonomies, we can't assign a term when multiple terms in the hierarchy share the same name
$ambiguous_terms = array();
if ( is_taxonomy_hierarchical( $taxonomy ) ) {
$tax_term_names = get_terms( $taxonomy, array( 'fields' => 'names', 'hide_empty' => false ) );
// count the number of terms with the same name
$tax_term_names_count = array_count_values( $tax_term_names );
// filter out non-ambiguous term names
$ambiguous_tax_term_counts = array_filter( $tax_term_names_count, array( $this, '_is_greater_than_one') );
$ambiguous_terms = array_keys( $ambiguous_tax_term_counts );
}
$term_names = $post_data['terms_names'][$taxonomy];
foreach ( $term_names as $term_name ) {
if ( in_array( $term_name, $ambiguous_terms ) )
return new IXR_Error( 401, __( 'Ambiguous term name used in a hierarchical taxonomy. Please use term ID instead.' ) );
$term = get_term_by( 'name', $term_name, $taxonomy );
if ( ! $term ) {
// term doesn't exist, so check that the user is allowed to create new terms
if ( ! current_user_can( $post_type_taxonomies[$taxonomy]->cap->edit_terms ) )
return new IXR_Error( 401, __( 'Sorry, you are not allowed to add a term to one of the given taxonomies.' ) );
// create the new term
$term_info = wp_insert_term( $term_name, $taxonomy );
if ( is_wp_error( $term_info ) )
return new IXR_Error( 500, $term_info->get_error_message() );
$terms[$taxonomy][] = (int) $term_info['term_id'];
} else {
$terms[$taxonomy][] = (int) $term->term_id;
}
}
}
}
$post_data['tax_input'] = $terms;
unset( $post_data['terms'], $post_data['terms_names'] );
} else {
// do not allow direct submission of 'tax_input', clients must use 'terms' and/or 'terms_names'
unset( $post_data['tax_input'], $post_data['post_category'], $post_data['tags_input'] );
}
if ( isset( $post_data['post_format'] ) ) {
$format = set_post_format( $post_ID, $post_data['post_format'] );
if ( is_wp_error( $format ) )
return new IXR_Error( 500, $format->get_error_message() );
unset( $post_data['post_format'] );
}
// Handle enclosures
$enclosure = isset( $post_data['enclosure'] ) ? $post_data['enclosure'] : null;
$this->add_enclosure_if_new( $post_ID, $enclosure );
$this->attach_uploads( $post_ID, $post_data['post_content'] );
/**
* Filter post data array to be inserted via XML-RPC.
*
* @since 3.4.0
*
* @param array $post_data Parsed array of post data.
* @param array $content_struct Post data array.
*/
$post_data = apply_filters( 'xmlrpc_wp_insert_post_data', $post_data, $content_struct );
$post_ID = $update ? wp_update_post( $post_data, true ) : wp_insert_post( $post_data, true );
if ( is_wp_error( $post_ID ) )
return new IXR_Error( 500, $post_ID->get_error_message() );
if ( ! $post_ID )
return new IXR_Error( 401, __( 'Sorry, your entry could not be posted. Something wrong happened.' ) );
return strval( $post_ID );
}
/**
* Edit a post for any registered post type.
*
* The $content_struct parameter only needs to contain fields that
* should be changed. All other fields will retain their existing values.
*
* @since 3.4.0
*
* @param array $args Method parameters. Contains:
* - int $blog_id
* - string $username
* - string $password
* - int $post_id
* - array $content_struct
* @return true on success
*/
function wp_editPost( $args ) {
if ( ! $this->minimum_args( $args, 5 ) )
return $this->error;
$this->escape( $args );
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
$post_id = (int) $args[3];
$content_struct = $args[4];
if ( ! $user = $this->login( $username, $password ) )
return $this->error;
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'wp.editPost' );
$post = get_post( $post_id, ARRAY_A );
if ( empty( $post['ID'] ) )
return new IXR_Error( 404, __( 'Invalid post ID.' ) );
if ( isset( $content_struct['if_not_modified_since'] ) ) {
// If the post has been modified since the date provided, return an error.
if ( mysql2date( 'U', $post['post_modified_gmt'] ) > $content_struct['if_not_modified_since']->getTimestamp() ) {
return new IXR_Error( 409, __( 'There is a revision of this post that is more recent.' ) );
}
}
// convert the date field back to IXR form
$post['post_date'] = $this->_convert_date( $post['post_date'] );
// ignore the existing GMT date if it is empty or a non-GMT date was supplied in $content_struct,
// since _insert_post will ignore the non-GMT date if the GMT date is set
if ( $post['post_date_gmt'] == '0000-00-00 00:00:00' || isset( $content_struct['post_date'] ) )
unset( $post['post_date_gmt'] );
else
$post['post_date_gmt'] = $this->_convert_date( $post['post_date_gmt'] );
$this->escape( $post );
$merged_content_struct = array_merge( $post, $content_struct );
$retval = $this->_insert_post( $user, $merged_content_struct );
if ( $retval instanceof IXR_Error )
return $retval;
return true;
}
/**
* Delete a post for any registered post type.
*
* @since 3.4.0
*
* @uses wp_delete_post()
* @param array $args Method parameters. Contains:
* - int $blog_id
* - string $username
* - string $password
* - int $post_id
* @return true on success
*/
function wp_deletePost( $args ) {
if ( ! $this->minimum_args( $args, 4 ) )
return $this->error;
$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;
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'wp.deletePost' );
$post = get_post( $post_id, ARRAY_A );
if ( empty( $post['ID'] ) )
return new IXR_Error( 404, __( 'Invalid post ID.' ) );
if ( ! current_user_can( 'delete_post', $post_id ) )
return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) );
$result = wp_delete_post( $post_id );
if ( ! $result )
return new IXR_Error( 500, __( 'The post cannot be deleted.' ) );
return true;
}
/**
* Retrieve a post.
*
* @since 3.4.0
*
* The optional $fields parameter specifies what fields will be included
* in the response array. This should be a list of field names. 'post_id' will
* always be included in the response regardless of the value of $fields.
*
* Instead of, or in addition to, individual field names, conceptual group
* names can be used to specify multiple fields. The available conceptual
* groups are 'post' (all basic fields), 'taxonomies', 'custom_fields',
* and 'enclosure'.
*
* @uses get_post()
* @param array $args Method parameters. Contains:
* - int $post_id
* - string $username
* - string $password
* - array $fields optional
* @return array contains (based on $fields parameter):
* - 'post_id'
* - 'post_title'
* - 'post_date'
* - 'post_date_gmt'
* - 'post_modified'
* - 'post_modified_gmt'
* - 'post_status'
* - 'post_type'
* - 'post_name'
* - 'post_author'
* - 'post_password'
* - 'post_excerpt'
* - 'post_content'
* - 'link'
* - 'comment_status'
* - 'ping_status'
* - 'sticky'
* - 'custom_fields'
* - 'terms'
* - 'categories'
* - 'tags'
* - 'enclosure'
*/
function wp_getPost( $args ) {
if ( ! $this->minimum_args( $args, 4 ) )
return $this->error;
$this->escape( $args );
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
$post_id = (int) $args[3];
if ( isset( $args[4] ) ) {
$fields = $args[4];
} else {
/**
* Filter the list of post query fields used by the given XML-RPC method.
*
* @since 3.4.0
*
* @param array $fields Array of post fields.
* @param string $method Method name.
*/
$fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPost' );
}
if ( ! $user = $this->login( $username, $password ) )
return $this->error;
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'wp.getPost' );
$post = get_post( $post_id, ARRAY_A );
if ( empty( $post['ID'] ) )
return new IXR_Error( 404, __( 'Invalid post ID.' ) );
if ( ! current_user_can( 'edit_post', $post_id ) )
return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) );
return $this->_prepare_post( $post, $fields );
}
/**
* Retrieve posts.
*
* @since 3.4.0
*
* The optional $filter parameter modifies the query used to retrieve posts.
* Accepted keys are 'post_type', 'post_status', 'number', 'offset',
* 'orderby', and 'order'.
*
* The optional $fields parameter specifies what fields will be included
* in the response array.
*
* @uses wp_get_recent_posts()
* @see wp_getPost() for more on $fields
* @see get_posts() for more on $filter values
*
* @param array $args Method parameters. Contains:
* - int $blog_id
* - string $username
* - string $password
* - array $filter optional
* - array $fields optional
* @return array contains a collection of posts.
*/
function wp_getPosts( $args ) {
if ( ! $this->minimum_args( $args, 3 ) )
return $this->error;
$this->escape( $args );
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
$filter = isset( $args[3] ) ? $args[3] : array();
if ( isset( $args[4] ) ) {
$fields = $args[4];
} else {
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
$fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPosts' );
}
if ( ! $user = $this->login( $username, $password ) )
return $this->error;
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'wp.getPosts' );
$query = array();
if ( isset( $filter['post_type'] ) ) {
$post_type = get_post_type_object( $filter['post_type'] );
if ( ! ( (bool) $post_type ) )
return new IXR_Error( 403, __( 'The post type specified is not valid' ) );
} else {
$post_type = get_post_type_object( 'post' );
}
if ( ! current_user_can( $post_type->cap->edit_posts ) )
return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts in this post type' ));
$query['post_type'] = $post_type->name;
if ( isset( $filter['post_status'] ) )
$query['post_status'] = $filter['post_status'];
if ( isset( $filter['number'] ) )
$query['numberposts'] = absint( $filter['number'] );
if ( isset( $filter['offset'] ) )
$query['offset'] = absint( $filter['offset'] );
if ( isset( $filter['orderby'] ) ) {
$query['orderby'] = $filter['orderby'];
if ( isset( $filter['order'] ) )
$query['order'] = $filter['order'];
}
if ( isset( $filter['s'] ) ) {
$query['s'] = $filter['s'];
}
$posts_list = wp_get_recent_posts( $query );
if ( ! $posts_list )
return array();
// holds all the posts data
$struct = array();
foreach ( $posts_list as $post ) {
if ( ! current_user_can( 'edit_post', $post['ID'] ) )
continue;
$struct[] = $this->_prepare_post( $post, $fields );
}
return $struct;
}
/**
* Create a new term.
*
* @since 3.4.0
*
* @uses wp_insert_term()
* @param array $args Method parameters. Contains:
* - int $blog_id
* - string $username
* - string $password
* - array $content_struct
* The $content_struct must contain:
* - 'name'
* - 'taxonomy'
* Also, it can optionally contain:
* - 'parent'
* - 'description'
* - 'slug'
* @return string term_id
*/
function wp_newTerm( $args ) {
if ( ! $this->minimum_args( $args, 4 ) )
return $this->error;
$this->escape( $args );
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
$content_struct = $args[3];
if ( ! $user = $this->login( $username, $password ) )
return $this->error;
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'wp.newTerm' );
if ( ! taxonomy_exists( $content_struct['taxonomy'] ) )
return new IXR_Error( 403, __( 'Invalid taxonomy' ) );
$taxonomy = get_taxonomy( $content_struct['taxonomy'] );
if ( ! current_user_can( $taxonomy->cap->manage_terms ) )
return new IXR_Error( 401, __( 'You are not allowed to create terms in this taxonomy.' ) );
$taxonomy = (array) $taxonomy;
// hold the data of the term
$term_data = array();
$term_data['name'] = trim( $content_struct['name'] );
if ( empty( $term_data['name'] ) )
return new IXR_Error( 403, __( 'The term name cannot be empty.' ) );
if ( isset( $content_struct['parent'] ) ) {
if ( ! $taxonomy['hierarchical'] )
return new IXR_Error( 403, __( 'This taxonomy is not hierarchical.' ) );
$parent_term_id = (int) $content_struct['parent'];
$parent_term = get_term( $parent_term_id , $taxonomy['name'] );
if ( is_wp_error( $parent_term ) )
return new IXR_Error( 500, $parent_term->get_error_message() );
if ( ! $parent_term )
return new IXR_Error( 403, __( 'Parent term does not exist.' ) );
$term_data['parent'] = $content_struct['parent'];
}
if ( isset( $content_struct['description'] ) )
$term_data['description'] = $content_struct['description'];
if ( isset( $content_struct['slug'] ) )
$term_data['slug'] = $content_struct['slug'];
$term = wp_insert_term( $term_data['name'] , $taxonomy['name'] , $term_data );
if ( is_wp_error( $term ) )
return new IXR_Error( 500, $term->get_error_message() );
if ( ! $term )
return new IXR_Error( 500, __( 'Sorry, your term could not be created. Something wrong happened.' ) );
return strval( $term['term_id'] );
}
/**
* Edit a term.
*
* @since 3.4.0
*
* @uses wp_update_term()
* @param array $args Method parameters. Contains:
* - int $blog_id
* - string $username
* - string $password
* - string $term_id
* - array $content_struct
* The $content_struct must contain:
* - 'taxonomy'
* Also, it can optionally contain:
* - 'name'
* - 'parent'
* - 'description'
* - 'slug'
* @return bool True, on success.
*/
function wp_editTerm( $args ) {
if ( ! $this->minimum_args( $args, 5 ) )
return $this->error;
$this->escape( $args );
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
$term_id = (int) $args[3];
$content_struct = $args[4];
if ( ! $user = $this->login( $username, $password ) )
return $this->error;
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'wp.editTerm' );
if ( ! taxonomy_exists( $content_struct['taxonomy'] ) )
return new IXR_Error( 403, __( 'Invalid taxonomy' ) );
$taxonomy = get_taxonomy( $content_struct['taxonomy'] );
if ( ! current_user_can( $taxonomy->cap->edit_terms ) )
return new IXR_Error( 401, __( 'You are not allowed to edit terms in this taxonomy.' ) );
$taxonomy = (array) $taxonomy;
// hold the data of the term
$term_data = array();
$term = get_term( $term_id , $content_struct['taxonomy'] );
if ( is_wp_error( $term ) )
return new IXR_Error( 500, $term->get_error_message() );
if ( ! $term )
return new IXR_Error( 404, __( 'Invalid term ID' ) );
if ( isset( $content_struct['name'] ) ) {
$term_data['name'] = trim( $content_struct['name'] );
if ( empty( $term_data['name'] ) )
return new IXR_Error( 403, __( 'The term name cannot be empty.' ) );
}
if ( isset( $content_struct['parent'] ) ) {
if ( ! $taxonomy['hierarchical'] )
return new IXR_Error( 403, __( "This taxonomy is not hierarchical so you can't set a parent." ) );
$parent_term_id = (int) $content_struct['parent'];
$parent_term = get_term( $parent_term_id , $taxonomy['name'] );
if ( is_wp_error( $parent_term ) )
return new IXR_Error( 500, $parent_term->get_error_message() );
if ( ! $parent_term )
return new IXR_Error( 403, __( 'Parent term does not exist.' ) );
$term_data['parent'] = $content_struct['parent'];
}
if ( isset( $content_struct['description'] ) )
$term_data['description'] = $content_struct['description'];
if ( isset( $content_struct['slug'] ) )
$term_data['slug'] = $content_struct['slug'];
$term = wp_update_term( $term_id , $taxonomy['name'] , $term_data );
if ( is_wp_error( $term ) )
return new IXR_Error( 500, $term->get_error_message() );
if ( ! $term )
return new IXR_Error( 500, __( 'Sorry, editing the term failed.' ) );
return true;
}
/**
* Delete a term.
*
* @since 3.4.0
*
* @uses wp_delete_term()
* @param array $args Method parameters. Contains:
* - int $blog_id
* - string $username
* - string $password
* - string $taxnomy_name
* - string $term_id
* @return boolean|IXR_Error If it suceeded true else a reason why not
*/
function wp_deleteTerm( $args ) {
if ( ! $this->minimum_args( $args, 5 ) )
return $this->error;
$this->escape( $args );
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
$taxonomy = $args[3];
$term_id = (int) $args[4];
if ( ! $user = $this->login( $username, $password ) )
return $this->error;
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'wp.deleteTerm' );
if ( ! taxonomy_exists( $taxonomy ) )
return new IXR_Error( 403, __( 'Invalid taxonomy' ) );
$taxonomy = get_taxonomy( $taxonomy );
if ( ! current_user_can( $taxonomy->cap->delete_terms ) )
return new IXR_Error( 401, __( 'You are not allowed to delete terms in this taxonomy.' ) );
$term = get_term( $term_id, $taxonomy->name );
if ( is_wp_error( $term ) )
return new IXR_Error( 500, $term->get_error_message() );
if ( ! $term )
return new IXR_Error( 404, __( 'Invalid term ID' ) );
$result = wp_delete_term( $term_id, $taxonomy->name );
if ( is_wp_error( $result ) )
return new IXR_Error( 500, $term->get_error_message() );
if ( ! $result )
return new IXR_Error( 500, __( 'Sorry, deleting the term failed.' ) );
return $result;
}
/**
* Retrieve a term.
*
* @since 3.4.0
*
* @uses get_term()
* @param array $args Method parameters. Contains:
* - int $blog_id
* - string $username
* - string $password
* - string $taxonomy
* - string $term_id
* @return array contains:
* - 'term_id'
* - 'name'
* - 'slug'
* - 'term_group'
* - 'term_taxonomy_id'
* - 'taxonomy'
* - 'description'
* - 'parent'
* - 'count'
*/
function wp_getTerm( $args ) {
if ( ! $this->minimum_args( $args, 5 ) )
return $this->error;
$this->escape( $args );
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
$taxonomy = $args[3];
$term_id = (int) $args[4];
if ( ! $user = $this->login( $username, $password ) )
return $this->error;
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'wp.getTerm' );
if ( ! taxonomy_exists( $taxonomy ) )
return new IXR_Error( 403, __( 'Invalid taxonomy' ) );
$taxonomy = get_taxonomy( $taxonomy );
if ( ! current_user_can( $taxonomy->cap->assign_terms ) )
return new IXR_Error( 401, __( 'You are not allowed to assign terms in this taxonomy.' ) );
$term = get_term( $term_id , $taxonomy->name, ARRAY_A );
if ( is_wp_error( $term ) )
return new IXR_Error( 500, $term->get_error_message() );
if ( ! $term )
return new IXR_Error( 404, __( 'Invalid term ID' ) );
return $this->_prepare_term( $term );
}
/**
* Retrieve all terms for a taxonomy.
*
* @since 3.4.0
*
* The optional $filter parameter modifies the query used to retrieve terms.
* Accepted keys are 'number', 'offset', 'orderby', 'order', 'hide_empty', and 'search'.
*
* @uses get_terms()
* @param array $args Method parameters. Contains:
* - int $blog_id
* - string $username
* - string $password
* - string $taxonomy
* - array $filter optional
* @return array terms
*/
function wp_getTerms( $args ) {
if ( ! $this->minimum_args( $args, 4 ) )
return $this->error;
$this->escape( $args );
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
$taxonomy = $args[3];
$filter = isset( $args[4] ) ? $args[4] : array();
if ( ! $user = $this->login( $username, $password ) )
return $this->error;
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'wp.getTerms' );
if ( ! taxonomy_exists( $taxonomy ) )
return new IXR_Error( 403, __( 'Invalid taxonomy' ) );
$taxonomy = get_taxonomy( $taxonomy );
if ( ! current_user_can( $taxonomy->cap->assign_terms ) )
return new IXR_Error( 401, __( 'You are not allowed to assign terms in this taxonomy.' ) );
$query = array();
if ( isset( $filter['number'] ) )
$query['number'] = absint( $filter['number'] );
if ( isset( $filter['offset'] ) )
$query['offset'] = absint( $filter['offset'] );
if ( isset( $filter['orderby'] ) ) {
$query['orderby'] = $filter['orderby'];
if ( isset( $filter['order'] ) )
$query['order'] = $filter['order'];
}
if ( isset( $filter['hide_empty'] ) )
$query['hide_empty'] = $filter['hide_empty'];
else
$query['get'] = 'all';
if ( isset( $filter['search'] ) )
$query['search'] = $filter['search'];
$terms = get_terms( $taxonomy->name, $query );
if ( is_wp_error( $terms ) )
return new IXR_Error( 500, $terms->get_error_message() );
$struct = array();
foreach ( $terms as $term ) {
$struct[] = $this->_prepare_term( $term );
}
return $struct;
}
/**
* Retrieve a taxonomy.
*
* @since 3.4.0
*
* @uses get_taxonomy()
* @param array $args Method parameters. Contains:
* - int $blog_id
* - string $username
* - string $password
* - string $taxonomy
* @return array (@see get_taxonomy())
*/
function wp_getTaxonomy( $args ) {
if ( ! $this->minimum_args( $args, 4 ) )
return $this->error;
$this->escape( $args );
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
$taxonomy = $args[3];
if ( isset( $args[4] ) ) {
$fields = $args[4];
} else {
/**
* Filter the taxonomy query fields used by the given XML-RPC method.
*
* @since 3.4.0
*
* @param array $fields An array of taxonomy fields to retrieve.
* @param string $method The method name.
*/
$fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomy' );
}
if ( ! $user = $this->login( $username, $password ) )
return $this->error;
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'wp.getTaxonomy' );
if ( ! taxonomy_exists( $taxonomy ) )
return new IXR_Error( 403, __( 'Invalid taxonomy' ) );
$taxonomy = get_taxonomy( $taxonomy );
if ( ! current_user_can( $taxonomy->cap->assign_terms ) )
return new IXR_Error( 401, __( 'You are not allowed to assign terms in this taxonomy.' ) );
return $this->_prepare_taxonomy( $taxonomy, $fields );
}
/**
* Retrieve all taxonomies.
*
* @since 3.4.0
*
* @uses get_taxonomies()
* @param array $args Method parameters. Contains:
* - int $blog_id
* - string $username
* - string $password
* @return array taxonomies
*/
function wp_getTaxonomies( $args ) {
if ( ! $this->minimum_args( $args, 3 ) )
return $this->error;
$this->escape( $args );
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
$filter = isset( $args[3] ) ? $args[3] : array( 'public' => true );
if ( isset( $args[4] ) ) {
$fields = $args[4];
} else {
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
$fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomies' );
}
if ( ! $user = $this->login( $username, $password ) )
return $this->error;
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'wp.getTaxonomies' );
$taxonomies = get_taxonomies( $filter, 'objects' );
// holds all the taxonomy data
$struct = array();
foreach ( $taxonomies as $taxonomy ) {
// capability check for post_types
if ( ! current_user_can( $taxonomy->cap->assign_terms ) )
continue;
$struct[] = $this->_prepare_taxonomy( $taxonomy, $fields );
}
return $struct;
}
/**
* Retrieve a user.
*
* The optional $fields parameter specifies what fields will be included
* in the response array. This should be a list of field names. 'user_id' will
* always be included in the response regardless of the value of $fields.
*
* Instead of, or in addition to, individual field names, conceptual group
* names can be used to specify multiple fields. The available conceptual
* groups are 'basic' and 'all'.
*
* @uses get_userdata()
* @param array $args Method parameters. Contains:
* - int $blog_id
* - string $username
* - string $password
* - int $user_id
* - array $fields optional
* @return array contains (based on $fields parameter):
* - 'user_id'
* - 'username'
* - 'first_name'
* - 'last_name'
* - 'registered'
* - 'bio'
* - 'email'
* - 'nickname'
* - 'nicename'
* - 'url'
* - 'display_name'
* - 'roles'
*/
function wp_getUser( $args ) {
if ( ! $this->minimum_args( $args, 4 ) )
return $this->error;
$this->escape( $args );
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
$user_id = (int) $args[3];
if ( isset( $args[4] ) ) {
$fields = $args[4];
} else {
/**
* Filter the default user query fields used by the given XML-RPC method.
*
* @since 3.5.0
*
* @param array $fields User query fields for given method. Default 'all'.
* @param string $method The method name.
*/
$fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUser' );
}
if ( ! $user = $this->login( $username, $password ) )
return $this->error;
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'wp.getUser' );
if ( ! current_user_can( 'edit_user', $user_id ) )
return new IXR_Error( 401, __( 'Sorry, you cannot edit users.' ) );
$user_data = get_userdata( $user_id );
if ( ! $user_data )
return new IXR_Error( 404, __( 'Invalid user ID' ) );
return $this->_prepare_user( $user_data, $fields );
}
/**
* Retrieve users.
*
* The optional $filter parameter modifies the query used to retrieve users.
* Accepted keys are 'number' (default: 50), 'offset' (default: 0), 'role',
* 'who', 'orderby', and 'order'.
*
* The optional $fields parameter specifies what fields will be included
* in the response array.
*
* @uses get_users()
* @see wp_getUser() for more on $fields and return values
*
* @param array $args Method parameters. Contains:
* - int $blog_id
* - string $username
* - string $password
* - array $filter optional
* - array $fields optional
* @return array users data
*/
function wp_getUsers( $args ) {
if ( ! $this->minimum_args( $args, 3 ) )
return $this->error;
$this->escape( $args );
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
$filter = isset( $args[3] ) ? $args[3] : array();
if ( isset( $args[4] ) ) {
$fields = $args[4];
} else {
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
$fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUsers' );
}
if ( ! $user = $this->login( $username, $password ) )
return $this->error;
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'wp.getUsers' );
if ( ! current_user_can( 'list_users' ) )
return new IXR_Error( 401, __( 'Sorry, you cannot list users.' ) );
$query = array( 'fields' => 'all_with_meta' );
$query['number'] = ( isset( $filter['number'] ) ) ? absint( $filter['number'] ) : 50;
$query['offset'] = ( isset( $filter['offset'] ) ) ? absint( $filter['offset'] ) : 0;
if ( isset( $filter['orderby'] ) ) {
$query['orderby'] = $filter['orderby'];
if ( isset( $filter['order'] ) )
$query['order'] = $filter['order'];
}
if ( isset( $filter['role'] ) ) {
if ( get_role( $filter['role'] ) === null )
return new IXR_Error( 403, __( 'The role specified is not valid' ) );
$query['role'] = $filter['role'];
}
if ( isset( $filter['who'] ) ) {
$query['who'] = $filter['who'];
}
$users = get_users( $query );
$_users = array();
foreach ( $users as $user_data ) {
if ( current_user_can( 'edit_user', $user_data->ID ) )
$_users[] = $this->_prepare_user( $user_data, $fields );
}
return $_users;
}
/**
* Retrieve information about the requesting user.
*
* @uses get_userdata()
* @param array $args Method parameters. Contains:
* - int $blog_id
* - string $username
* - string $password
* - array $fields optional
* @return array (@see wp_getUser)
*/
function wp_getProfile( $args ) {
if ( ! $this->minimum_args( $args, 3 ) )
return $this->error;
$this->escape( $args );
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
if ( isset( $args[3] ) ) {
$fields = $args[3];
} else {
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
$fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getProfile' );
}
if ( ! $user = $this->login( $username, $password ) )
return $this->error;
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'wp.getProfile' );
if ( ! current_user_can( 'edit_user', $user->ID ) )
return new IXR_Error( 401, __( 'Sorry, you cannot edit your profile.' ) );
$user_data = get_userdata( $user->ID );
return $this->_prepare_user( $user_data, $fields );
}
/**
* Edit user's profile.
*
* @uses wp_update_user()
* @param array $args Method parameters. Contains:
* - int $blog_id
* - string $username
* - string $password
* - array $content_struct
* It can optionally contain:
* - 'first_name'
* - 'last_name'
* - 'website'
* - 'display_name'
* - 'nickname'
* - 'nicename'
* - 'bio'
* @return bool True, on success.
*/
function wp_editProfile( $args ) {
if ( ! $this->minimum_args( $args, 4 ) )
return $this->error;
$this->escape( $args );
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
$content_struct = $args[3];
if ( ! $user = $this->login( $username, $password ) )
return $this->error;
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'wp.editProfile' );
if ( ! current_user_can( 'edit_user', $user->ID ) )
return new IXR_Error( 401, __( 'Sorry, you cannot edit your profile.' ) );
// holds data of the user
$user_data = array();
$user_data['ID'] = $user->ID;
// only set the user details if it was given
if ( isset( $content_struct['first_name'] ) )
$user_data['first_name'] = $content_struct['first_name'];
if ( isset( $content_struct['last_name'] ) )
$user_data['last_name'] = $content_struct['last_name'];
if ( isset( $content_struct['url'] ) )
$user_data['user_url'] = $content_struct['url'];
if ( isset( $content_struct['display_name'] ) )
$user_data['display_name'] = $content_struct['display_name'];
if ( isset( $content_struct['nickname'] ) )
$user_data['nickname'] = $content_struct['nickname'];
if ( isset( $content_struct['nicename'] ) )
$user_data['user_nicename'] = $content_struct['nicename'];
if ( isset( $content_struct['bio'] ) )
$user_data['description'] = $content_struct['bio'];
$result = wp_update_user( $user_data );
if ( is_wp_error( $result ) )
return new IXR_Error( 500, $result->get_error_message() );
if ( ! $result )
return new IXR_Error( 500, __( 'Sorry, the user cannot be updated.' ) );
return true;
}
/**
* Retrieve page.
*
* @since 2.2.0
*
* @param array $args Method parameters. Contains:
* - blog_id
* - page_id
* - username
* - password
* @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;
}
$page = get_post($page_id);
if ( ! $page )
return new IXR_Error( 404, __( 'Invalid post ID.' ) );
if ( !current_user_can( 'edit_page', $page_id ) )
return new IXR_Error( 401, __( 'Sorry, you cannot edit this page.' ) );
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'wp.getPage' );
// If we found the page then format the data.
if ( $page->ID && ($page->post_type == 'page') ) {
return $this->_prepare_page( $page );
}
// 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. Contains:
* - blog_id
* - username
* - password
* - num_pages
* @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.' ) );
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
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();
foreach ($pages as $page) {
if ( current_user_can( 'edit_page', $page->ID ) )
$pages_struct[] = $this->_prepare_page( $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. See {@link wp_xmlrpc_server::mw_newPost()}
* @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;
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'wp.newPage' );
// 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;
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
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 = get_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.')));
/**
* Fires after a page has been successfully deleted via XML-RPC.
*
* @since 3.4.0
*
* @param int $page_id ID of the deleted page.
* @param array $args An array of arguments to delete the page.
*/
do_action( 'xmlrpc_call_success_wp_deletePage', $page_id, $args );
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;
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'wp.editPage' );
// Get the page data and make sure it is a page.
$actual_page = get_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.' ) );
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
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 formatted properly.
$num_pages = count($page_list);
for ( $i = 0; $i < $num_pages; $i++ ) {
$page_list[$i]->dateCreated = $this->_convert_date( $page_list[$i]->post_date );
$page_list[$i]->date_created_gmt = $this->_convert_date_gmt( $page_list[$i]->post_date_gmt, $page_list[$i]->post_date );
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.')));
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
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.0
*
* @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.' ) );
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
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;
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
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.')));
}
/**
* Fires after a new category has been successfully created via XML-RPC.
*
* @since 3.4.0
*
* @param int $cat_id ID of the new category.
* @param array $args An array of new category arguments.
*/
do_action( 'xmlrpc_call_success_wp_newCategory', $cat_id, $args );
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;
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
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.' ) );
$status = wp_delete_term( $category_id, 'category' );
if ( true == $status ) {
/**
* Fires after a category has been successfully deleted via XML-RPC.
*
* @since 3.4.0
*
* @param int $category_id ID of the deleted category.
* @param array $args An array of arguments to delete the category.
*/
do_action( 'xmlrpc_call_success_wp_deleteCategory', $category_id, $args );
}
return $status;
}
/**
* 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.' ) );
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
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.' ) );
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'wp.getComment' );
if ( ! $comment = get_comment($comment_id) )
return new IXR_Error( 404, __( 'Invalid comment ID.' ) );
return $this->_prepare_comment( $comment );
}
/**
* Retrieve comments.
*
* Besides the common blog_id, username, and password arguments, it takes a filter
* array as last argument.
*
* Accepted 'filter' keys are 'status', 'post_id', 'offset', and 'number'.
*
* The defaults are as follows:
* - 'status' - Default is ''. Filter by status (e.g., 'approve', 'hold')
* - 'post_id' - Default is ''. The post where the comment is posted. Empty string shows all comments.
* - 'number' - Default is 10. Total number of media items to retrieve.
* - 'offset' - Default is 0. See {@link WP_Query::query()} for more.
*
* @since 2.7.0
*
* @param array $args Method parameters.
* @return array. Contains a collection of comments. See {@link wp_xmlrpc_server::wp_getComment()} for a description of each item contents
*/
function wp_getComments($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( 'moderate_comments' ) )
return new IXR_Error( 401, __( 'Sorry, you cannot edit comments.' ) );
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
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 ) );
$comments_struct = array();
foreach ( $comments as $comment ) {
$comments_struct[] = $this->_prepare_comment( $comment );
}
return $comments_struct;
}
/**
* Delete a comment.
*
* By default, the comment will be moved to the trash instead of deleted.
* See {@link wp_delete_comment()} for more information on
* this behavior.
*
* @since 2.7.0
*
* @param array $args Method parameters. Contains:
* - blog_id
* - username
* - password
* - comment_id
* @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 ( ! get_comment($comment_ID) )
return new IXR_Error( 404, __( 'Invalid comment ID.' ) );
if ( !current_user_can( 'edit_comment', $comment_ID ) )
return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) );
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'wp.deleteComment' );
$status = wp_delete_comment( $comment_ID );
if ( true == $status ) {
/**
* Fires after a comment has been successfully deleted via XML-RPC.
*
* @since 3.4.0
*
* @param int $comment_ID ID of the deleted comment.
* @param array $args An array of arguments to delete the comment.
*/
do_action( 'xmlrpc_call_success_wp_deleteComment', $comment_ID, $args );
}
return $status;
}
/**
* Edit comment.
*
* Besides the common blog_id, username, and password arguments, it takes a
* comment_id integer and a content_struct array as last argument.
*
* The allowed keys in the content_struct array are:
* - 'author'
* - 'author_url'
* - 'author_email'
* - 'content'
* - 'date_created_gmt'
* - 'status'. Common statuses are 'approve', 'hold', 'spam'. See {@link get_comment_statuses()} for more details
*
* @since 2.7.0
*
* @param array $args. Contains:
* - blog_id
* - username
* - password
* - comment_id
* - content_struct
* @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 ( ! get_comment($comment_ID) )
return new IXR_Error( 404, __( 'Invalid comment ID.' ) );
if ( !current_user_can( 'edit_comment', $comment_ID ) )
return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) );
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
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'] ) ) {
// We know this is supposed to be GMT, so we're going to slap that Z on there by force
$dateCreated = rtrim( $content_struct['date_created_gmt']->getIso(), 'Z' ) . 'Z';
$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.'));
/**
* Fires after a comment has been successfully updated via XML-RPC.
*
* @since 3.4.0
*
* @param int $comment_ID ID of the updated comment.
* @param array $args An array of arguments to update the comment.
*/
do_action( 'xmlrpc_call_success_wp_editComment', $comment_ID, $args );
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];
/**
* Filter whether to allow anonymous comments over XML-RPC.
*
* @since 2.7.0
*
* @param bool $allow Whether to allow anonymous commenting via XML-RPC.
* Default false.
*/
$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'] = $this->escape( $user->display_name );
$comment['comment_author_email'] = $this->escape( $user->user_email );
$comment['comment_author_url'] = $this->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;
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'wp.newComment' );
$comment_ID = wp_new_comment( $comment );
/**
* Fires after a new comment has been successfully created via XML-RPC.
*
* @since 3.4.0
*
* @param int $comment_ID ID of the new comment.
* @param array $args An array of new comment arguments.
*/
do_action( 'xmlrpc_call_success_wp_newComment', $comment_ID, $args );
return $comment_ID;
}
/**
* 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.' ) );
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
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.' ) );
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
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.' ) );
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
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.' ) );
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
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();
$can_manage = current_user_can( 'manage_options' );
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']);
}
if ( ! $can_manage )
$data[$option]['readonly'] = true;
}
}
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'], wp_unslash( $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. Associative 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 do not have permission to upload files.' ) );
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'wp.getMediaItem' );
if ( ! $attachment = get_post($attachment_id) )
return new IXR_Error( 404, __( 'Invalid attachment ID.' ) );
return $this->_prepare_media_item( $attachment );
}
/**
* 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) {
$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, __( 'You do not have permission to upload files.' ) );
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
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 ) );
$attachments_struct = array();
foreach ($attachments as $attachment )
$attachments_struct[] = $this->_prepare_media_item( $attachment );
return $attachments_struct;
}
/**
* Retrieves a list of post formats used by the site
*
* @since 3.1.0
*
* @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;
if ( !current_user_can( 'edit_posts' ) )
return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) );
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'wp.getPostFormats' );
$formats = get_post_format_strings();
# find out if they want a list of currently supports formats
if ( isset( $args[3] ) && is_array( $args[3] ) ) {
if ( $args[3]['show-supported'] ) {
if ( current_theme_supports( 'post-formats' ) ) {
$supported = get_theme_support( 'post-formats' );
$data['all'] = $formats;
$data['supported'] = $supported[0];
$formats = $data;
}
}
}
return $formats;
}
/**
* Retrieves a post type
*
* @since 3.4.0
*
* @uses get_post_type_object()
* @param array $args Method parameters. Contains:
* - int $blog_id
* - string $username
* - string $password
* - string $post_type_name
* - array $fields
* @return array contains:
* - 'labels'
* - 'description'
* - 'capability_type'
* - 'cap'
* - 'map_meta_cap'
* - 'hierarchical'
* - 'menu_position'
* - 'taxonomies'
* - 'supports'
*/
function wp_getPostType( $args ) {
if ( ! $this->minimum_args( $args, 4 ) )
return $this->error;
$this->escape( $args );
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
$post_type_name = $args[3];
if ( isset( $args[4] ) ) {
$fields = $args[4];
} else {
/**
* Filter the default query fields used by the given XML-RPC method.
*
* @since 3.4.0
*
* @param array $fields An array of post type query fields for the given method.
* @param string $method The method name.
*/
$fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostType' );
}
if ( !$user = $this->login( $username, $password ) )
return $this->error;
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'wp.getPostType' );
if( ! post_type_exists( $post_type_name ) )
return new IXR_Error( 403, __( 'Invalid post type' ) );
$post_type = get_post_type_object( $post_type_name );
if( ! current_user_can( $post_type->cap->edit_posts ) )
return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post type.' ) );
return $this->_prepare_post_type( $post_type, $fields );
}
/**
* Retrieves a post types
*
* @since 3.4.0
*
* @uses get_post_types()
* @param array $args Method parameters. Contains:
* - int $blog_id
* - string $username
* - string $password
* - array $filter
* - array $fields
* @return array
*/
function wp_getPostTypes( $args ) {
if ( ! $this->minimum_args( $args, 3 ) )
return $this->error;
$this->escape( $args );
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
$filter = isset( $args[3] ) ? $args[3] : array( 'public' => true );
if ( isset( $args[4] ) ) {
$fields = $args[4];
} else {
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
$fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostTypes' );
}
if ( ! $user = $this->login( $username, $password ) )
return $this->error;
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'wp.getPostTypes' );
$post_types = get_post_types( $filter, 'objects' );
$struct = array();
foreach( $post_types as $post_type ) {
if( ! current_user_can( $post_type->cap->edit_posts ) )
continue;
$struct[$post_type->name] = $this->_prepare_post_type( $post_type, $fields );
}
return $struct;
}
/**
* Retrieve revisions for a specific post.
*
* @since 3.5.0
*
* The optional $fields parameter specifies what fields will be included
* in the response array.
*
* @uses wp_get_post_revisions()
* @see wp_getPost() for more on $fields
*
* @param array $args Method parameters. Contains:
* - int $blog_id
* - string $username
* - string $password
* - int $post_id
* - array $fields
* @return array contains a collection of posts.
*/
function wp_getRevisions( $args ) {
if ( ! $this->minimum_args( $args, 4 ) )
return $this->error;
$this->escape( $args );
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
$post_id = (int) $args[3];
if ( isset( $args[4] ) ) {
$fields = $args[4];
} else {
/**
* Filter the default revision query fields used by the given XML-RPC method.
*
* @since 3.5.0
*
* @param array $field An array of revision query fields.
* @param string $method The method name.
*/
$fields = apply_filters( 'xmlrpc_default_revision_fields', array( 'post_date', 'post_date_gmt' ), 'wp.getRevisions' );
}
if ( ! $user = $this->login( $username, $password ) )
return $this->error;
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'wp.getRevisions' );
if ( ! $post = get_post( $post_id ) )
return new IXR_Error( 404, __( 'Invalid post ID' ) );
if ( ! current_user_can( 'edit_post', $post_id ) )
return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) );
// Check if revisions are enabled.
if ( ! wp_revisions_enabled( $post ) )
return new IXR_Error( 401, __( 'Sorry, revisions are disabled.' ) );
$revisions = wp_get_post_revisions( $post_id );
if ( ! $revisions )
return array();
$struct = array();
foreach ( $revisions as $revision ) {
if ( ! current_user_can( 'read_post', $revision->ID ) )
continue;
// Skip autosaves
if ( wp_is_post_autosave( $revision ) )
continue;
$struct[] = $this->_prepare_post( get_object_vars( $revision ), $fields );
}
return $struct;
}
/**
* Restore a post revision
*
* @since 3.5.0
*
* @uses wp_restore_post_revision()
*
* @param array $args Method parameters. Contains:
* - int $blog_id
* - string $username
* - string $password
* - int $post_id
* @return bool false if there was an error restoring, true if success.
*/
function wp_restoreRevision( $args ) {
if ( ! $this->minimum_args( $args, 3 ) )
return $this->error;
$this->escape( $args );
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
$revision_id = (int) $args[3];
if ( ! $user = $this->login( $username, $password ) )
return $this->error;
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'wp.restoreRevision' );
if ( ! $revision = wp_get_post_revision( $revision_id ) )
return new IXR_Error( 404, __( 'Invalid post ID' ) );
if ( wp_is_post_autosave( $revision ) )
return new IXR_Error( 404, __( 'Invalid post ID' ) );
if ( ! $post = get_post( $revision->post_parent ) )
return new IXR_Error( 404, __( 'Invalid post ID' ) );
if ( ! current_user_can( 'edit_post', $revision->post_parent ) )
return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) );
// Check if revisions are disabled.
if ( ! wp_revisions_enabled( $post ) )
return new IXR_Error( 401, __( 'Sorry, revisions are disabled.' ) );
$post = wp_restore_post_revision( $revision_id );
return (bool) $post;
}
/* 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;
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
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', 'rpc' ),
);
return array($struct);
}
/**
* Private function for retrieving a users blogs for multisite setups
*
* @access protected
*/
function _multisite_getUsersBlogs($args) {
$current_blog = get_blog_details();
$domain = $current_blog->domain;
$path = $current_blog->path . 'xmlrpc.php';
$rpc = new IXR_Client( set_url_scheme( "http://{$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.' ) );
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
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;
$post_data = get_post($post_ID, ARRAY_A);
if ( ! $post_data )
return new IXR_Error( 404, __( 'Invalid post ID.' ) );
if ( !current_user_can( 'edit_post', $post_ID ) )
return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) );
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'blogger.getPost' );
$categories = implode(',', wp_get_post_categories($post_ID));
$content = '<title>'.wp_unslash($post_data['post_title']).'</title>';
$content .= '<category>'.$categories.'</category>';
$content .= wp_unslash($post_data['post_content']);
$struct = array(
'userid' => $post_data['post_author'],
'dateCreated' => $this->_convert_date( $post_data['post_date'] ),
'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;
if ( ! current_user_can( 'edit_posts' ) )
return new IXR_Error( 401, __( 'Sorry, you cannot edit posts on this site.' ) );
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
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 = $this->_convert_date( $entry['post_date'] );
$categories = implode(',', wp_get_post_categories($entry['ID']));
$content = '<title>'.wp_unslash($entry['post_title']).'</title>';
$content .= '<category>'.$categories.'</category>';
$content .= wp_unslash($entry['post_content']);
$struct[] = array(
'userid' => $entry['post_author'],
'dateCreated' => $post_date,
'content' => $content,
'postid' => (string) $entry['ID'],
);
}
$recent_posts = array();
for ( $j=0; $j<count($struct); $j++ ) {
array_push($recent_posts, $struct[$j]);
}
return $recent_posts;
}
/**
* Deprecated.
*
* @since 1.5.0
* @deprecated 3.5.0
*/
function blogger_getTemplate($args) {
return new IXR_Error( 403, __('Sorry, that file cannot be edited.' ) );
}
/**
* Deprecated.
*
* @since 1.5.0
* @deprecated 3.5.0
*/
function blogger_setTemplate($args) {
return new IXR_Error( 403, __('Sorry, that file cannot be edited.' ) );
}
/**
* 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;
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'blogger.newPost' );
$cap = ($publish) ? 'publish_posts' : 'edit_posts';
if ( ! current_user_can( get_post_type_object( 'post' )->cap->create_posts ) || !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 );
/**
* Fires after a new post has been successfully created via the XML-RPC Blogger API.
*
* @since 3.4.0
*
* @param int $post_ID ID of the new post.
* @param array $args An array of new post arguments.
*/
do_action( 'xmlrpc_call_success_blogger_newPost', $post_ID, $args );
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;
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'blogger.editPost' );
$actual_post = get_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 );
/**
* Fires after a post has been successfully updated via the XML-RPC Blogger API.
*
* @since 3.4.0
*
* @param int $post_ID ID of the updated post.
* @param array $args An array of arguments for the post to edit.
*/
do_action( 'xmlrpc_call_success_blogger_editPost', $post_ID, $args );
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;
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'blogger.deletePost' );
$actual_post = get_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.'));
/**
* Fires after a post has been successfully deleted via the XML-RPC Blogger API.
*
* @since 3.4.0
*
* @param int $post_ID ID of the deleted post.
* @param array $args An array of arguments to delete the post.
*/
do_action( 'xmlrpc_call_success_blogger_deletePost', $post_ID, $args );
return true;
}
/* MetaWeblog API functions
* specs on wherever Dave Winer wants them to be
*/
/**
* Create a new post.
*
* The 'content_struct' argument must contain:
* - title
* - description
* - mt_excerpt
* - mt_text_more
* - mt_keywords
* - mt_tb_ping_urls
* - categories
*
* Also, it can optionally contain:
* - wp_slug
* - wp_password
* - wp_page_parent_id
* - wp_page_order
* - wp_author_id
* - post_status | page_status - can be 'draft', 'private', 'publish', or 'pending'
* - mt_allow_comments - can be 'open' or 'closed'
* - mt_allow_pings - can be 'open' or 'closed'
* - date_created_gmt
* - dateCreated
* - wp_post_thumbnail
*
* @since 1.5.0
*
* @param array $args Method parameters. Contains:
* - blog_id
* - username
* - password
* - content_struct
* - publish
* @return int
*/
function mw_newPost($args) {
$this->escape($args);
$blog_ID = (int) $args[0];
$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;
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
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 ( isset( $content_struct['page_status'] ) && '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 ( isset( $content_struct['post_status'] ) && '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 ( isset( $content_struct['post_status'] ) && '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( get_post_type_object( $post_type )->cap->create_posts ) )
return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish posts on this site.' ) );
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 create posts 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;
}
$author = get_userdata( $content_struct['wp_author_id'] );
if ( ! $author )
return new IXR_Error( 404, __( 'Invalid author ID.' ) );
$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 'pending':
case 'private':
case 'publish':
$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 . '<!--more-->' . $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'] ) )
// We know this is supposed to be GMT, so we're going to slap that Z on there by force
$dateCreated = rtrim( $content_struct['date_created_gmt']->getIso(), 'Z' ) . 'Z';
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'];
if ( is_array($catnames) ) {
foreach ($catnames as $cat) {
$post_category[] = get_cat_ID($cat);
}
}
}
$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 = $postdata['ID'] = get_default_post_to_edit( $post_type, true )->ID;
// 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']);
if ( isset ( $content_struct['wp_post_thumbnail'] ) ) {
if ( set_post_thumbnail( $post_ID, $content_struct['wp_post_thumbnail'] ) === false )
return new IXR_Error( 404, __( 'Invalid attachment ID.' ) );
unset( $content_struct['wp_post_thumbnail'] );
}
// 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'] ) )
set_post_format( $post_ID, $content_struct['wp_post_format'] );
$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.'));
/**
* Fires after a new post has been successfully created via the XML-RPC MovableType API.
*
* @since 3.4.0
*
* @param int $post_ID ID of the new post.
* @param array $args An array of arguments to create the new post.
*/
do_action( 'xmlrpc_call_success_mw_newPost', $post_ID, $args );
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'] . "\n";
$found = false;
if ( $enclosures = get_post_meta( $post_ID, 'enclosure' ) ) {
foreach ( $enclosures as $enc ) {
// This method used to omit the trailing new line. #23219
if ( rtrim( $enc, "\n" ) == rtrim( $encstring, "\n" ) ) {
$found = true;
break;
}
}
}
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 ( ! empty( $file->guid ) && 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 = isset( $args[4] ) ? $args[4] : 0;
if ( ! $user = $this->login($username, $password) )
return $this->error;
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'metaWeblog.editPost' );
$postdata = get_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 ( ! $postdata || empty( $postdata[ 'ID' ] ) )
return new IXR_Error( 404, __( 'Invalid post ID.' ) );
if ( ! current_user_can( 'edit_post', $post_ID ) )
return new IXR_Error( 401, __( 'Sorry, you do not have the right to edit this post.' ) );
// Use wp.editPost to edit post types other than post and page.
if ( ! in_array( $postdata[ 'post_type' ], array( 'post', 'page' ) ) )
return new IXR_Error( 401, __( 'Invalid post type' ) );
// Thwart attempt to change the post type.
if ( ! empty( $content_struct[ 'post_type' ] ) && ( $content_struct['post_type'] != $postdata[ 'post_type' ] ) )
return new IXR_Error( 401, __( 'The post type may not be changed.' ) );
// 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' ) );
}
}
$this->escape($postdata);
extract($postdata, EXTR_SKIP);
// Let WordPress manage slug if none was provided.
$post_name = "";
$post_name = $postdata['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'];
if ( ! empty( $content_struct['wp_page_template'] ) && 'page' == $post_type )
$page_template = $content_struct['wp_page_template'];
$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;
}
}
}
if ( isset( $content_struct['title'] ) )
$post_title = $content_struct['title'];
if ( isset( $content_struct['description'] ) )
$post_content = $content_struct['description'];
$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);
}
}
}
if ( isset( $content_struct['mt_excerpt'] ) )
$post_excerpt = $content_struct['mt_excerpt'];
$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 'pending':
case 'private':
case 'publish':
$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 . "<!--more-->" . $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'] ) )
// We know this is supposed to be GMT, so we're going to slap that Z on there by force
$dateCreated = rtrim( $content_struct['date_created_gmt']->getIso(), 'Z' ) . 'Z';
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']);
if ( isset ( $content_struct['wp_post_thumbnail'] ) ) {
// empty value deletes, non-empty value adds/updates
if ( empty( $content_struct['wp_post_thumbnail'] ) ) {
delete_post_thumbnail( $post_ID );
} else {
if ( set_post_thumbnail( $post_ID, $content_struct['wp_post_thumbnail'] ) === false )
return new IXR_Error( 404, __( 'Invalid attachment ID.' ) );
}
unset( $content_struct['wp_post_thumbnail'] );
}
// 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'] ) )
set_post_format( $post_ID, $content_struct['wp_post_format'] );
/**
* Fires after a post has been successfully updated via the XML-RPC MovableType API.
*
* @since 3.4.0
*
* @param int $post_ID ID of the updated post.
* @param array $args An array of arguments to update the post.
*/
do_action( 'xmlrpc_call_success_mw_editPost', $post_ID, $args );
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;
$postdata = get_post($post_ID, ARRAY_A);
if ( ! $postdata )
return new IXR_Error( 404, __( 'Invalid post ID.' ) );
if ( !current_user_can( 'edit_post', $post_ID ) )
return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) );
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'metaWeblog.getPost' );
if ($postdata['post_date'] != '') {
$post_date = $this->_convert_date( $postdata['post_date'] );
$post_date_gmt = $this->_convert_date_gmt( $postdata['post_date_gmt'], $postdata['post_date'] );
$post_modified = $this->_convert_date( $postdata['post_modified'] );
$post_modified_gmt = $this->_convert_date_gmt( $postdata['post_modified_gmt'], $postdata['post_modified'] );
$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 = explode("\n", $enc);
$enclosure['url'] = trim(htmlspecialchars($encdata[0]));
$enclosure['length'] = (int) trim($encdata[1]);
$enclosure['type'] = trim($encdata[2]);
break 2;
}
}
}
$resp = array(
'dateCreated' => $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'],
'wp_more_text' => $post['more_text'],
'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' => (string) $author->ID,
'wp_author_display_name' => $author->display_name,
'date_created_gmt' => $post_date_gmt,
'post_status' => $postdata['post_status'],
'custom_fields' => $this->get_custom_fields($post_ID),
'wp_post_format' => $post_format,
'sticky' => $sticky,
'date_modified' => $post_modified,
'date_modified_gmt' => $post_modified_gmt
);
if ( !empty($enclosure) ) $resp['enclosure'] = $enclosure;
$resp['wp_post_thumbnail'] = get_post_thumbnail_id( $postdata['ID'] );
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;
if ( ! current_user_can( 'edit_posts' ) )
return new IXR_Error( 401, __( 'Sorry, you cannot edit posts on this site.' ) );
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'metaWeblog.getRecentPosts' );
$posts_list = wp_get_recent_posts( $query );
if ( !$posts_list )
return array();
$struct = array();
foreach ($posts_list as $entry) {
if ( !current_user_can( 'edit_post', $entry['ID'] ) )
continue;
$post_date = $this->_convert_date( $entry['post_date'] );
$post_date_gmt = $this->_convert_date_gmt( $entry['post_date_gmt'], $entry['post_date'] );
$post_modified = $this->_convert_date( $entry['post_modified'] );
$post_modified_gmt = $this->_convert_date_gmt( $entry['post_modified_gmt'], $entry['post_modified'] );
$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' => $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'],
'wp_more_text' => $post['more_text'],
'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' => (string) $author->ID,
'wp_author_display_name' => $author->display_name,
'date_created_gmt' => $post_date_gmt,
'post_status' => $entry['post_status'],
'custom_fields' => $this->get_custom_fields($entry['ID']),
'wp_post_format' => $post_format,
'date_modified' => $post_modified,
'date_modified_gmt' => $post_modified_gmt,
'sticky' => ( $entry['post_type'] === 'post' && is_sticky( $entry['ID'] ) ),
);
$entry_index = count( $struct ) - 1;
$struct[ $entry_index ][ 'wp_post_thumbnail' ] = get_post_thumbnail_id( $entry['ID'] );
}
$recent_posts = array();
for ( $j=0; $j<count($struct); $j++ ) {
array_push($recent_posts, $struct[$j]);
}
return $recent_posts;
}
/**
* Retrieve the list of categories on a given blog.
*
* @since 1.5.0
*
* @param array $args Method parameters.
* @return array
*/
function mw_getCategories($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 categories.' ) );
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
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 = $this->escape($args[1]);
$password = $this->escape($args[2]);
$data = $args[3];
$name = sanitize_file_name( $data['name'] );
$type = $data['type'];
$bits = $data['bits'];
if ( !$user = $this->login($username, $password) )
return $this->error;
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'metaWeblog.newMediaObject' );
if ( !current_user_can('upload_files') ) {
$this->error = new IXR_Error( 401, __( 'You do not have permission to upload files.' ) );
return $this->error;
}
/**
* Filter whether to preempt the XML-RPC media upload.
*
* Passing a truthy value will effectively short-circuit the media upload,
* returning that value as a 500 error instead.
*
* @since 2.1.0
*
* @param bool $error Whether to pre-empt the media upload. Default false.
*/
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']);
return new IXR_Error(500, $errorString);
}
// Construct the attachment array
$post_id = 0;
if ( ! empty( $data['post_id'] ) ) {
$post_id = (int) $data['post_id'];
if ( ! current_user_can( 'edit_post', $post_id ) )
return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) );
}
$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'] ) );
/**
* Fires after a new attachment has been added via the XML-RPC MovableType API.
*
* @since 3.4.0
*
* @param int $id ID of the new attachment.
* @param array $args An array of arguments to add the attachment.
*/
do_action( 'xmlrpc_call_success_mw_newMediaObject', $id, $args );
$struct = array(
'id' => strval( $id ),
'file' => $name,
'url' => $upload[ 'url' ],
'type' => $type
);
/** This filter is documented in wp-admin/includes/file.php */
return apply_filters( 'wp_handle_upload', $struct, '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;
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
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;
}
$struct = array();
foreach ($posts_list as $entry) {
if ( !current_user_can( 'edit_post', $entry['ID'] ) )
continue;
$post_date = $this->_convert_date( $entry['post_date'] );
$post_date_gmt = $this->_convert_date_gmt( $entry['post_date_gmt'], $entry['post_date'] );
$struct[] = array(
'dateCreated' => $post_date,
'userid' => $entry['post_author'],
'postid' => (string) $entry['ID'],
'title' => $entry['post_title'],
'post_status' => $entry['post_status'],
'date_created_gmt' => $post_date_gmt
);
}
$recent_posts = array();
for ( $j=0; $j<count($struct); $j++ ) {
array_push($recent_posts, $struct[$j]);
}
return $recent_posts;
}
/**
* Retrieve list of all categories on blog.
*
* @since 1.5.0
*
* @param array $args Method parameters.
* @return array
*/
function mt_getCategoryList($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 categories.' ) );
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
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 ( ! get_post( $post_ID ) )
return new IXR_Error( 404, __( 'Invalid post ID.' ) );
if ( !current_user_can( 'edit_post', $post_ID ) )
return new IXR_Error( 401, __( 'Sorry, you can not edit this post.' ) );
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
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;
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'mt.setPostCategories' );
if ( ! get_post( $post_ID ) )
return new IXR_Error( 404, __( 'Invalid post ID.' ) );
if ( !current_user_can('edit_post', $post_ID) )
return new IXR_Error(401, __('Sorry, you cannot edit this post.'));
$catids = array();
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) {
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
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) {
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'mt.supportedTextFilters' );
/**
* Filter the MoveableType text filters list for XML-RPC.
*
* @since 2.2.0
*
* @param array $filters An array of text filters.
*/
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);
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'mt.getTrackbackPings' );
$actual_post = get_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, '</strong>') - 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;
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
do_action( 'xmlrpc_call', 'mt.publishPost' );
$postdata = get_post($post_ID, ARRAY_A);
if ( ! $postdata )
return new IXR_Error( 404, __( 'Invalid post ID.' ) );
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['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;
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
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);
/**
* Filter the pingback source URI.
*
* @since 3.6.0
*
* @param string $pagelinkedfrom URI of the page linked from.
* @param string $pagelinkedto URI of the page linked to.
*/
$pagelinkedfrom = apply_filters( 'pingback_ping_source_uri', $pagelinkedfrom, $pagelinkedto );
if ( ! $pagelinkedfrom )
return $this->pingback_error( 0, __( 'A valid URL was not provided.' ) );
// 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 $this->pingback_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 ( isset( $urltest['query'] ) && 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 (simplest 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 $this->pingback_error( 0, '' );
}
$way = 'from the fragment (title)';
}
} else {
// TODO: Attempt to extract a post ID from the given URL
return $this->pingback_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;
$post = get_post($post_ID);
if ( !$post ) // Post_ID not found
return $this->pingback_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 $this->pingback_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 $this->pingback_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 $this->pingback_error( 48, __( 'The pingback has already been registered.' ) );
// very stupid, but gives time to the 'from' server to publish !
sleep(1);
$remote_ip = preg_replace( '/[^0-9a-fA-F:., ]/', '', $_SERVER['REMOTE_ADDR'] );
/** This filter is documented in wp-includes/class-http.php */
$user_agent = apply_filters( 'http_headers_useragent', 'WordPress/' . $GLOBALS['wp_version'] . '; ' . get_bloginfo( 'url' ) );
// Let's check the remote site
$http_api_args = array(
'timeout' => 10,
'redirection' => 0,
'limit_response_size' => 153600, // 150 KB
'user-agent' => "$user_agent; verifying pingback from $remote_ip",
'headers' => array(
'X-Pingback-Forwarded-For' => $remote_ip,
),
);
$request = wp_safe_remote_get( $pagelinkedfrom, $http_api_args );
$linea = wp_remote_retrieve_body( $request );
if ( !$linea )
return $this->pingback_error( 16, __( 'The source URL does not exist.' ) );
/**
* Filter the pingback remote source.
*
* @since 2.5.0
*
* @param string $linea Response object for the page linked from.
* @param string $pagelinkedto URL of the page linked to.
*/
$linea = apply_filters( 'pre_remote_source', $linea, $pagelinkedto );
// Work around bug in strip_tags():
$linea = str_replace('<!DOC', '<DOC', $linea);
$linea = preg_replace( '/[\r\n\t ]+/', ' ', $linea ); // normalize spaces
$linea = preg_replace( "/<\/*(h1|h2|h3|h4|h5|h6|p|th|td|li|dt|dd|pre|caption|input|textarea|button|body)[^>]*>/", "\n\n", $linea );
preg_match('|<title>([^<]*?)</title>|is', $linea, $matchtitle);
$title = $matchtitle[1];
if ( empty( $title ) )
return $this->pingback_error( 32, __('We cannot find a title on that page.' ) );
$linea = strip_tags( $linea, '<a>' ); // 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("|<a[^>]+?".$preg_target."[^>]*>([^>]+?)</a>|", $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('|\</?wpcontext\>|', '', $para);
// prevent really long link text
if ( strlen($context[1]) > 100 )
$context[1] = substr($context[1], 0, 100) . '…';
$marker = '<wpcontext>'.$context[1].'</wpcontext>'; // set up our marker
$excerpt= str_replace($context[0], $marker, $excerpt); // swap out the link for our marker
$excerpt = strip_tags($excerpt, '<wpcontext>'); // 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 $this->pingback_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 = $this->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);
/**
* Fires after a post pingback has been sent.
*
* @since 0.71
*
* @param int $comment_ID Comment ID.
*/
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;
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
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 $this->pingback_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 = get_post($post_ID, ARRAY_A);
if ( !$actual_post ) {
// No such post = resource not found
return $this->pingback_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;
}
protected function pingback_error( $code, $message ) {
/**
* Filter the XML-RPC pingback error return.
*
* @since 3.5.1
*
* @param IXR_Error $error An IXR_Error object containing the error code and message.
*/
return apply_filters( 'xmlrpc_pingback_error', new IXR_Error( $code, $message ) );
}
}
| 01-wordpress-paypal | trunk/wp-includes/class-wp-xmlrpc-server.php | PHP | gpl3 | 178,875 |
<?php
/**
* Multisite upload handler.
*
* @since 3.0.0
*
* @package WordPress
* @subpackage Multisite
*/
define( 'SHORTINIT', true );
require_once( dirname( dirname( __FILE__ ) ) . '/wp-load.php' );
if( !is_multisite() )
die( 'Multisite support not enabled' );
ms_file_constants();
error_reporting( 0 );
if ( $current_blog->archived == '1' || $current_blog->spam == '1' || $current_blog->deleted == '1' ) {
status_header( 404 );
die( '404 — File not found.' );
}
$file = rtrim( BLOGUPLOADDIR, '/' ) . '/' . str_replace( '..', '', $_GET[ 'file' ] );
if ( !is_file( $file ) ) {
status_header( 404 );
die( '404 — File not found.' );
}
$mime = wp_check_filetype( $file );
if( false === $mime[ 'type' ] && function_exists( 'mime_content_type' ) )
$mime[ 'type' ] = mime_content_type( $file );
if( $mime[ 'type' ] )
$mimetype = $mime[ 'type' ];
else
$mimetype = 'image/' . substr( $file, strrpos( $file, '.' ) + 1 );
header( 'Content-Type: ' . $mimetype ); // always send this
if ( false === strpos( $_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS' ) )
header( 'Content-Length: ' . filesize( $file ) );
// Optional support for X-Sendfile and X-Accel-Redirect
if ( WPMU_ACCEL_REDIRECT ) {
header( 'X-Accel-Redirect: ' . str_replace( WP_CONTENT_DIR, '', $file ) );
exit;
} elseif ( WPMU_SENDFILE ) {
header( 'X-Sendfile: ' . $file );
exit;
}
$last_modified = gmdate( 'D, d M Y H:i:s', filemtime( $file ) );
$etag = '"' . md5( $last_modified ) . '"';
header( "Last-Modified: $last_modified GMT" );
header( 'ETag: ' . $etag );
header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + 100000000 ) . ' GMT' );
// Support for Conditional GET - use stripslashes to avoid formatting.php dependency
$client_etag = isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) ? stripslashes( $_SERVER['HTTP_IF_NONE_MATCH'] ) : false;
if( ! isset( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) )
$_SERVER['HTTP_IF_MODIFIED_SINCE'] = false;
$client_last_modified = 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...
$modified_timestamp = strtotime($last_modified);
if ( ( $client_last_modified && $client_etag )
? ( ( $client_modified_timestamp >= $modified_timestamp) && ( $client_etag == $etag ) )
: ( ( $client_modified_timestamp >= $modified_timestamp) || ( $client_etag == $etag ) )
) {
status_header( 304 );
exit;
}
// If we made it this far, just serve the file
readfile( $file );
| 01-wordpress-paypal | trunk/wp-includes/ms-files.php | PHP | gpl3 | 2,607 |
<?php
/**
* Admin Bar
*
* This code handles the building and rendering of the press bar.
*/
/**
* Instantiate the admin bar object and set it up as a global for access elsewhere.
*
* UNHOOKING THIS FUNCTION WILL NOT PROPERLY REMOVE THE ADMIN BAR.
* For that, use show_admin_bar(false) or the 'show_admin_bar' filter.
*
* @since 3.1.0
* @access private
* @return bool Whether the admin bar was successfully initialized.
*/
function _wp_admin_bar_init() {
global $wp_admin_bar;
if ( ! is_admin_bar_showing() )
return false;
/* Load the admin bar class code ready for instantiation */
require( ABSPATH . WPINC . '/class-wp-admin-bar.php' );
/* Instantiate the admin bar */
/**
* Filter the admin bar class to instantiate.
*
* @since 3.1.0
*
* @param string $wp_admin_bar_class Admin bar class to use. Default 'WP_Admin_Bar'.
*/
$admin_bar_class = apply_filters( 'wp_admin_bar_class', 'WP_Admin_Bar' );
if ( class_exists( $admin_bar_class ) )
$wp_admin_bar = new $admin_bar_class;
else
return false;
$wp_admin_bar->initialize();
$wp_admin_bar->add_menus();
return true;
}
// Don't remove. Wrong way to disable.
add_action( 'template_redirect', '_wp_admin_bar_init', 0 );
add_action( 'admin_init', '_wp_admin_bar_init' );
/**
* 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;
/**
* Load all necessary admin bar items.
*
* This is the hook used to add, remove, or manipulate admin bar items.
*
* @since 3.1.0
*
* @param WP_Admin_Bar $wp_admin_bar WP_Admin_Bar instance, passed by reference
*/
do_action_ref_array( 'admin_bar_menu', array( &$wp_admin_bar ) );
/**
* Fires before the admin bar is rendered.
*
* @since 3.1.0
*/
do_action( 'wp_before_admin_bar_render' );
$wp_admin_bar->render();
/**
* Fires after the admin bar is rendered.
*
* @since 3.1.0
*/
do_action( 'wp_after_admin_bar_render' );
}
add_action( 'wp_footer', 'wp_admin_bar_render', 1000 );
add_action( 'in_admin_header', 'wp_admin_bar_render', 0 );
/**
* Add the WordPress logo menu.
*
* @since 3.3.0
*
* @param WP_Admin_Bar $wp_admin_bar
*/
function wp_admin_bar_wp_menu( $wp_admin_bar ) {
$wp_admin_bar->add_menu( array(
'id' => 'wp-logo',
'title' => '<span class="ab-icon"></span>',
'href' => self_admin_url( 'about.php' ),
'meta' => array(
'title' => __('About WordPress'),
),
) );
if ( is_user_logged_in() ) {
// Add "About WordPress" link
$wp_admin_bar->add_menu( array(
'parent' => 'wp-logo',
'id' => 'about',
'title' => __('About WordPress'),
'href' => self_admin_url( 'about.php' ),
) );
}
// Add WordPress.org link
$wp_admin_bar->add_menu( array(
'parent' => 'wp-logo-external',
'id' => 'wporg',
'title' => __('WordPress.org'),
'href' => __('https://wordpress.org/'),
) );
// Add codex link
$wp_admin_bar->add_menu( array(
'parent' => 'wp-logo-external',
'id' => 'documentation',
'title' => __('Documentation'),
'href' => __('http://codex.wordpress.org/'),
) );
// Add forums link
$wp_admin_bar->add_menu( array(
'parent' => 'wp-logo-external',
'id' => 'support-forums',
'title' => __('Support Forums'),
'href' => __('https://wordpress.org/support/'),
) );
// Add feedback link
$wp_admin_bar->add_menu( array(
'parent' => 'wp-logo-external',
'id' => 'feedback',
'title' => __('Feedback'),
'href' => __('https://wordpress.org/support/forum/requests-and-feedback'),
) );
}
/**
* Add the sidebar toggle button.
*
* @since 3.8.0
*
* @param WP_Admin_Bar $wp_admin_bar
*/
function wp_admin_bar_sidebar_toggle( $wp_admin_bar ) {
if ( is_admin() ) {
$wp_admin_bar->add_menu( array(
'id' => 'menu-toggle',
'title' => '<span class="ab-icon"></span><span class="screen-reader-text">' . __( 'Menu' ) . '</span>',
'href' => '#',
) );
}
}
/**
* Add the "My Account" item.
*
* @since 3.3.0
*
* @param WP_Admin_Bar $wp_admin_bar
*/
function wp_admin_bar_my_account_item( $wp_admin_bar ) {
$user_id = get_current_user_id();
$current_user = wp_get_current_user();
$profile_url = get_edit_profile_url( $user_id );
if ( ! $user_id )
return;
$avatar = get_avatar( $user_id, 26 );
$howdy = sprintf( __('Howdy, %1$s'), $current_user->display_name );
$class = empty( $avatar ) ? '' : 'with-avatar';
$wp_admin_bar->add_menu( array(
'id' => 'my-account',
'parent' => 'top-secondary',
'title' => $howdy . $avatar,
'href' => $profile_url,
'meta' => array(
'class' => $class,
'title' => __('My Account'),
),
) );
}
/**
* Add the "My Account" submenu items.
*
* @since 3.1.0
*
* @param WP_Admin_Bar $wp_admin_bar
*/
function wp_admin_bar_my_account_menu( $wp_admin_bar ) {
$user_id = get_current_user_id();
$current_user = wp_get_current_user();
$profile_url = get_edit_profile_url( $user_id );
if ( ! $user_id )
return;
$wp_admin_bar->add_group( array(
'parent' => 'my-account',
'id' => 'user-actions',
) );
$user_info = get_avatar( $user_id, 64 );
$user_info .= "<span class='display-name'>{$current_user->display_name}</span>";
if ( $current_user->display_name !== $current_user->user_login )
$user_info .= "<span class='username'>{$current_user->user_login}</span>";
$wp_admin_bar->add_menu( array(
'parent' => 'user-actions',
'id' => 'user-info',
'title' => $user_info,
'href' => $profile_url,
'meta' => array(
'tabindex' => -1,
),
) );
$wp_admin_bar->add_menu( array(
'parent' => 'user-actions',
'id' => 'edit-profile',
'title' => __( 'Edit My Profile' ),
'href' => $profile_url,
) );
$wp_admin_bar->add_menu( array(
'parent' => 'user-actions',
'id' => 'logout',
'title' => __( 'Log Out' ),
'href' => wp_logout_url(),
) );
}
/**
* Add the "Site Name" menu.
*
* @since 3.3.0
*
* @param WP_Admin_Bar $wp_admin_bar
*/
function wp_admin_bar_site_menu( $wp_admin_bar ) {
// Don't show for logged out users.
if ( ! is_user_logged_in() )
return;
// Show only when the user is a member of this site, or they're a super admin.
if ( ! is_user_member_of_blog() && ! is_super_admin() )
return;
$blogname = get_bloginfo('name');
if ( empty( $blogname ) )
$blogname = preg_replace( '#^(https?://)?(www.)?#', '', get_home_url() );
if ( is_network_admin() ) {
$blogname = sprintf( __('Network Admin: %s'), esc_html( get_current_site()->site_name ) );
} elseif ( is_user_admin() ) {
$blogname = sprintf( __('Global Dashboard: %s'), esc_html( get_current_site()->site_name ) );
}
$title = wp_html_excerpt( $blogname, 40, '…' );
$wp_admin_bar->add_menu( array(
'id' => 'site-name',
'title' => $title,
'href' => is_admin() ? home_url( '/' ) : admin_url(),
) );
// Create submenu items.
if ( is_admin() ) {
// Add an option to visit the site.
$wp_admin_bar->add_menu( array(
'parent' => 'site-name',
'id' => 'view-site',
'title' => __( 'Visit Site' ),
'href' => home_url( '/' ),
) );
if ( is_blog_admin() && is_multisite() && current_user_can( 'manage_sites' ) ) {
$wp_admin_bar->add_menu( array(
'parent' => 'site-name',
'id' => 'edit-site',
'title' => __( 'Edit Site' ),
'href' => network_admin_url( 'site-info.php?id=' . get_current_blog_id() ),
) );
}
} else {
// We're on the front end, link to the Dashboard.
$wp_admin_bar->add_menu( array(
'parent' => 'site-name',
'id' => 'dashboard',
'title' => __( 'Dashboard' ),
'href' => admin_url(),
) );
// Add the appearance submenu items.
wp_admin_bar_appearance_menu( $wp_admin_bar );
}
}
/**
* Add the "My Sites/[Site Name]" menu and all submenus.
*
* @since 3.1.0
*
* @param WP_Admin_Bar $wp_admin_bar
*/
function wp_admin_bar_my_sites_menu( $wp_admin_bar ) {
// Don't show for logged out users or single site mode.
if ( ! is_user_logged_in() || ! is_multisite() )
return;
// Show only when the user has at least one site, or they're a super admin.
if ( count( $wp_admin_bar->user->blogs ) < 1 && ! is_super_admin() )
return;
$wp_admin_bar->add_menu( array(
'id' => 'my-sites',
'title' => __( 'My Sites' ),
'href' => admin_url( 'my-sites.php' ),
) );
if ( is_super_admin() ) {
$wp_admin_bar->add_group( array(
'parent' => 'my-sites',
'id' => 'my-sites-super-admin',
) );
$wp_admin_bar->add_menu( array(
'parent' => 'my-sites-super-admin',
'id' => 'network-admin',
'title' => __('Network Admin'),
'href' => network_admin_url(),
) );
$wp_admin_bar->add_menu( array(
'parent' => 'network-admin',
'id' => 'network-admin-d',
'title' => __( 'Dashboard' ),
'href' => network_admin_url(),
) );
$wp_admin_bar->add_menu( array(
'parent' => 'network-admin',
'id' => 'network-admin-s',
'title' => __( 'Sites' ),
'href' => network_admin_url( 'sites.php' ),
) );
$wp_admin_bar->add_menu( array(
'parent' => 'network-admin',
'id' => 'network-admin-u',
'title' => __( 'Users' ),
'href' => network_admin_url( 'users.php' ),
) );
$wp_admin_bar->add_menu( array(
'parent' => 'network-admin',
'id' => 'network-admin-t',
'title' => __( 'Themes' ),
'href' => network_admin_url( 'themes.php' ),
) );
$wp_admin_bar->add_menu( array(
'parent' => 'network-admin',
'id' => 'network-admin-p',
'title' => __( 'Plugins' ),
'href' => network_admin_url( 'plugins.php' ),
) );
}
// Add site links
$wp_admin_bar->add_group( array(
'parent' => 'my-sites',
'id' => 'my-sites-list',
'meta' => array(
'class' => is_super_admin() ? 'ab-sub-secondary' : '',
),
) );
foreach ( (array) $wp_admin_bar->user->blogs as $blog ) {
switch_to_blog( $blog->userblog_id );
$blavatar = '<div class="blavatar"></div>';
$blogname = empty( $blog->blogname ) ? $blog->domain : $blog->blogname;
$menu_id = 'blog-' . $blog->userblog_id;
$wp_admin_bar->add_menu( array(
'parent' => 'my-sites-list',
'id' => $menu_id,
'title' => $blavatar . $blogname,
'href' => admin_url(),
) );
$wp_admin_bar->add_menu( array(
'parent' => $menu_id,
'id' => $menu_id . '-d',
'title' => __( 'Dashboard' ),
'href' => admin_url(),
) );
if ( current_user_can( get_post_type_object( 'post' )->cap->create_posts ) ) {
$wp_admin_bar->add_menu( array(
'parent' => $menu_id,
'id' => $menu_id . '-n',
'title' => __( 'New Post' ),
'href' => admin_url( 'post-new.php' ),
) );
}
if ( current_user_can( 'edit_posts' ) ) {
$wp_admin_bar->add_menu( array(
'parent' => $menu_id,
'id' => $menu_id . '-c',
'title' => __( 'Manage Comments' ),
'href' => admin_url( 'edit-comments.php' ),
) );
}
$wp_admin_bar->add_menu( array(
'parent' => $menu_id,
'id' => $menu_id . '-v',
'title' => __( 'Visit Site' ),
'href' => home_url( '/' ),
) );
restore_current_blog();
}
}
/**
* Provide a shortlink.
*
* @since 3.1.0
*
* @param WP_Admin_Bar $wp_admin_bar
*/
function wp_admin_bar_shortlink_menu( $wp_admin_bar ) {
$short = wp_get_shortlink( 0, 'query' );
$id = 'get-shortlink';
if ( empty( $short ) )
return;
$html = '<input class="shortlink-input" type="text" readonly="readonly" value="' . esc_attr( $short ) . '" />';
$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
*
* @param WP_Admin_Bar $wp_admin_bar
*/
function wp_admin_bar_edit_menu( $wp_admin_bar ) {
global $tag, $wp_the_query;
if ( is_admin() ) {
$current_screen = get_current_screen();
$post = get_post();
if ( 'post' == $current_screen->base
&& 'add' != $current_screen->action
&& ( $post_type_object = get_post_type_object( $post->post_type ) )
&& current_user_can( 'read_post', $post->ID )
&& ( $post_type_object->public )
&& ( $post_type_object->show_in_admin_bar ) )
{
$wp_admin_bar->add_menu( array(
'id' => 'view',
'title' => $post_type_object->labels->view_item,
'href' => get_permalink( $post->ID )
) );
} elseif ( 'edit-tags' == $current_screen->base
&& isset( $tag ) && is_object( $tag )
&& ( $tax = get_taxonomy( $tag->taxonomy ) )
&& $tax->public )
{
$wp_admin_bar->add_menu( array(
'id' => 'view',
'title' => $tax->labels->view_item,
'href' => get_term_link( $tag )
) );
}
} else {
$current_object = $wp_the_query->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( 'edit_post', $current_object->ID )
&& $post_type_object->show_ui && $post_type_object->show_in_admin_bar )
{
$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
*
* @param WP_Admin_Bar $wp_admin_bar
*/
function wp_admin_bar_new_content_menu( $wp_admin_bar ) {
$actions = array();
$cpts = (array) get_post_types( array( 'show_in_admin_bar' => true ), 'objects' );
if ( isset( $cpts['post'] ) && current_user_can( $cpts['post']->cap->create_posts ) )
$actions[ 'post-new.php' ] = array( $cpts['post']->labels->name_admin_bar, 'new-post' );
if ( isset( $cpts['attachment'] ) && current_user_can( 'upload_files' ) )
$actions[ 'media-new.php' ] = array( $cpts['attachment']->labels->name_admin_bar, 'new-media' );
if ( current_user_can( 'manage_links' ) )
$actions[ 'link-add.php' ] = array( _x( 'Link', 'add new from admin bar' ), 'new-link' );
if ( isset( $cpts['page'] ) && current_user_can( $cpts['page']->cap->create_posts ) )
$actions[ 'post-new.php?post_type=page' ] = array( $cpts['page']->labels->name_admin_bar, 'new-page' );
unset( $cpts['post'], $cpts['page'], $cpts['attachment'] );
// Add any additional custom post types.
foreach ( $cpts as $cpt ) {
if ( ! current_user_can( $cpt->cap->create_posts ) )
continue;
$key = 'post-new.php?post_type=' . $cpt->name;
$actions[ $key ] = array( $cpt->labels->name_admin_bar, 'new-' . $cpt->name );
}
// Avoid clash with parent node and a 'content' post type.
if ( isset( $actions['post-new.php?post_type=content'] ) )
$actions['post-new.php?post_type=content'][1] = 'add-new-content';
if ( current_user_can( 'create_users' ) || current_user_can( 'promote_users' ) )
$actions[ 'user-new.php' ] = array( _x( 'User', 'add new from admin bar' ), 'new-user' );
if ( ! $actions )
return;
$title = '<span class="ab-icon"></span><span class="ab-label">' . _x( 'New', 'admin bar menu group label' ) . '</span>';
$wp_admin_bar->add_menu( array(
'id' => 'new-content',
'title' => $title,
'href' => admin_url( current( array_keys( $actions ) ) ),
'meta' => array(
'title' => _x( 'Add New', 'admin bar menu group label' ),
),
) );
foreach ( $actions as $link => $action ) {
list( $title, $id ) = $action;
$wp_admin_bar->add_menu( array(
'parent' => 'new-content',
'id' => $id,
'title' => $title,
'href' => admin_url( $link )
) );
}
}
/**
* Add edit comments link with awaiting moderation count bubble.
*
* @since 3.1.0
*
* @param WP_Admin_Bar $wp_admin_bar
*/
function wp_admin_bar_comments_menu( $wp_admin_bar ) {
if ( !current_user_can('edit_posts') )
return;
$awaiting_mod = wp_count_comments();
$awaiting_mod = $awaiting_mod->moderated;
$awaiting_title = esc_attr( sprintf( _n( '%s comment awaiting moderation', '%s comments awaiting moderation', $awaiting_mod ), number_format_i18n( $awaiting_mod ) ) );
$icon = '<span class="ab-icon"></span>';
$title = '<span id="ab-awaiting-mod" class="ab-label awaiting-mod pending-count count-' . $awaiting_mod . '">' . number_format_i18n( $awaiting_mod ) . '</span>';
$wp_admin_bar->add_menu( array(
'id' => 'comments',
'title' => $icon . $title,
'href' => admin_url('edit-comments.php'),
'meta' => array( 'title' => $awaiting_title ),
) );
}
/**
* Add appearance submenu items to the "Site Name" menu.
*
* @since 3.1.0
*
* @param WP_Admin_Bar $wp_admin_bar
*/
function wp_admin_bar_appearance_menu( $wp_admin_bar ) {
$wp_admin_bar->add_group( array( 'parent' => 'site-name', 'id' => 'appearance' ) );
if ( current_user_can( 'switch_themes' ) || current_user_can( 'edit_theme_options' ) )
$wp_admin_bar->add_menu( array( 'parent' => 'appearance', 'id' => 'themes', 'title' => __('Themes'), 'href' => admin_url('themes.php') ) );
if ( ! current_user_can( 'edit_theme_options' ) )
return;
$current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$wp_admin_bar->add_menu( array(
'parent' => 'appearance',
'id' => 'customize',
'title' => __('Customize'),
'href' => add_query_arg( 'url', urlencode( $current_url ), wp_customize_url() ),
'meta' => array(
'class' => 'hide-if-no-customize',
),
) );
add_action( 'wp_before_admin_bar_render', 'wp_customize_support_script' );
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') ) );
if ( current_theme_supports( 'custom-background' ) )
$wp_admin_bar->add_menu( array( 'parent' => 'appearance', 'id' => 'background', 'title' => __('Background'), 'href' => admin_url('themes.php?page=custom-background') ) );
if ( current_theme_supports( 'custom-header' ) )
$wp_admin_bar->add_menu( array( 'parent' => 'appearance', 'id' => 'header', 'title' => __('Header'), 'href' => admin_url('themes.php?page=custom-header') ) );
}
/**
* Provide an update link if theme/plugin/core updates are available.
*
* @since 3.1.0
*
* @param WP_Admin_Bar $wp_admin_bar
*/
function wp_admin_bar_updates_menu( $wp_admin_bar ) {
$update_data = wp_get_update_data();
if ( !$update_data['counts']['total'] )
return;
$title = '<span class="ab-icon"></span><span class="ab-label">' . number_format_i18n( $update_data['counts']['total'] ) . '</span>';
$title .= '<span class="screen-reader-text">' . $update_data['title'] . '</span>';
$wp_admin_bar->add_menu( array(
'id' => 'updates',
'title' => $title,
'href' => network_admin_url( 'update-core.php' ),
'meta' => array(
'title' => $update_data['title'],
),
) );
}
/**
* Add search form.
*
* @since 3.3.0
*
* @param WP_Admin_Bar $wp_admin_bar
*/
function wp_admin_bar_search_menu( $wp_admin_bar ) {
if ( is_admin() )
return;
$form = '<form action="' . esc_url( home_url( '/' ) ) . '" method="get" id="adminbarsearch">';
$form .= '<input class="adminbar-input" name="s" id="adminbar-search" type="text" value="" maxlength="150" />';
$form .= '<input type="submit" class="adminbar-button" value="' . __('Search') . '"/>';
$form .= '</form>';
$wp_admin_bar->add_menu( array(
'parent' => 'top-secondary',
'id' => 'search',
'title' => $form,
'meta' => array(
'class' => 'admin-bar-search',
'tabindex' => -1,
)
) );
}
/**
* Add secondary menus.
*
* @since 3.3.0
*
* @param WP_Admin_Bar $wp_admin_bar
*/
function wp_admin_bar_add_secondary_groups( $wp_admin_bar ) {
$wp_admin_bar->add_group( array(
'id' => 'top-secondary',
'meta' => array(
'class' => 'ab-top-secondary',
),
) );
$wp_admin_bar->add_group( array(
'parent' => 'wp-logo',
'id' => 'wp-logo-external',
'meta' => array(
'class' => 'ab-sub-secondary',
),
) );
}
/**
* Style and scripts for the admin bar.
*
* @since 3.1.0
*/
function wp_admin_bar_header() { ?>
<style type="text/css" media="print">#wpadminbar { display:none; }</style>
<?php
}
/**
* Default admin bar callback.
*
* @since 3.1.0
*/
function _admin_bar_bump_cb() { ?>
<style type="text/css" media="screen">
html { margin-top: 32px !important; }
* html body { margin-top: 32px !important; }
@media screen and ( max-width: 782px ) {
html { margin-top: 46px !important; }
* html body { margin-top: 46px !important; }
}
</style>
<?php
}
/**
* Set the display status of the admin bar.
*
* This can be called immediately upon plugin load. It does not need to be called from a function hooked to the init action.
*
* @since 3.1.0
*
* @param bool $show Whether to allow the admin bar to show.
* @return void
*/
function show_admin_bar( $show ) {
global $show_admin_bar;
$show_admin_bar = (bool) $show;
}
/**
* Determine whether the admin bar should be showing.
*
* @since 3.1.0
*
* @return bool Whether the admin bar should be showing.
*/
function is_admin_bar_showing() {
global $show_admin_bar, $pagenow;
// For all these types of requests, we never want an admin bar.
if ( defined('XMLRPC_REQUEST') || defined('DOING_AJAX') || defined('IFRAME_REQUEST') )
return false;
// Integrated into the admin.
if ( is_admin() )
return true;
if ( ! isset( $show_admin_bar ) ) {
if ( ! is_user_logged_in() || 'wp-login.php' == $pagenow ) {
$show_admin_bar = false;
} else {
$show_admin_bar = _get_admin_bar_pref();
}
}
/**
* Filter whether to show the admin bar.
*
* Returning false to this hook is the recommended way to hide the admin bar.
* The user's display preference is used for logged in users.
*
* @since 3.1.0
*
* @param bool $show_admin_bar Whether the admin bar should be shown. Default false.
*/
$show_admin_bar = apply_filters( 'show_admin_bar', $show_admin_bar );
return $show_admin_bar;
}
/**
* Retrieve the admin bar display preference of a user.
*
* @since 3.1.0
* @access private
*
* @param string $context Context of this preference check. Defaults to 'front'. The 'admin'
* preference is no longer used.
* @param int $user Optional. ID of the user to check, defaults to 0 for current user.
* @return bool Whether the admin bar should be showing for this user.
*/
function _get_admin_bar_pref( $context = 'front', $user = 0 ) {
$pref = get_user_option( "show_admin_bar_{$context}", $user );
if ( false === $pref )
return true;
return 'true' === $pref;
}
| 01-wordpress-paypal | trunk/wp-includes/admin-bar.php | PHP | gpl3 | 23,564 |
<?php
/**
* WordPress Link Template Functions
*
* @package WordPress
* @subpackage Template
*/
/**
* Display the permalink for the current post.
*
* @since 1.2.0
*/
function the_permalink() {
/**
* Filter the display of the permalink for the current post.
*
* @since 1.5.0
*
* @param string $permalink The permalink for the current post.
*/
echo esc_url( apply_filters( 'the_permalink', get_permalink() ) );
}
/**
* Retrieve trailing slash string, if blog set for adding trailing slashes.
*
* Conditionally adds a trailing slash if the permalink structure has a trailing
* slash, strips the trailing slash if not. The string is passed through the
* 'user_trailingslashit' filter. Will remove trailing slash from string, if
* blog is not set to have them.
*
* @since 2.2.0
* @uses $wp_rewrite
*
* @param string $string URL with or without a trailing slash.
* @param string $type_of_url The type of URL being considered (e.g. single, category, etc) for use in the filter.
* @return string
*/
function user_trailingslashit($string, $type_of_url = '') {
global $wp_rewrite;
if ( $wp_rewrite->use_trailing_slashes )
$string = trailingslashit($string);
else
$string = untrailingslashit($string);
/**
* Filter the trailing slashed string, depending on whether the site is set
* to use training slashes.
*
* @since 2.2.0
*
* @param string $string URL with or without a trailing slash.
* @param string $type_of_url The type of URL being considered. Accepts 'single', 'single_trackback',
* 'single_feed', 'single_paged', 'feed', 'category', 'page', 'year',
* 'month', 'day', 'paged', 'post_type_archive'.
*/
$string = apply_filters( 'user_trailingslashit', $string, $type_of_url );
return $string;
}
/**
* Display permalink anchor for current post.
*
* The permalink mode title will use the post title for the 'a' element 'id'
* attribute. The id mode uses 'post-' with the post ID for the 'id' attribute.
*
* @since 0.71
*
* @param string $mode Permalink mode can be either 'title', 'id', or default, which is 'id'.
*/
function permalink_anchor( $mode = 'id' ) {
$post = get_post();
switch ( strtolower( $mode ) ) {
case 'title':
$title = sanitize_title( $post->post_title ) . '-' . $post->ID;
echo '<a id="'.$title.'"></a>';
break;
case 'id':
default:
echo '<a id="post-' . $post->ID . '"></a>';
break;
}
}
/**
* Retrieve full permalink for current post or post ID.
*
* This function is an alias for get_permalink().
*
* @since 3.9.0
*
* @see get_permalink()
*
* @param int|WP_Post $id Optional. Post ID or post object. Default is the current post.
* @param bool $leavename Optional. Whether to keep post name or page name. Default false.
* @return string|bool The permalink URL or false if post does not exist.
*/
function get_the_permalink( $id = 0, $leavename = false ) {
return get_permalink( $id, $leavename );
}
/**
* Retrieve full permalink for current post or post ID.
*
* @since 1.0.0
*
* @param int|WP_Post $id Optional. Post ID or post object. Default current post.
* @param bool $leavename Optional. Whether to keep post name or page name. Default false.
* @return string|bool The permalink URL or false if post does not exist.
*/
function get_permalink( $id = 0, $leavename = false ) {
$rewritecode = array(
'%year%',
'%monthnum%',
'%day%',
'%hour%',
'%minute%',
'%second%',
$leavename? '' : '%postname%',
'%post_id%',
'%category%',
'%author%',
$leavename? '' : '%pagename%',
);
if ( is_object($id) && isset($id->filter) && 'sample' == $id->filter ) {
$post = $id;
$sample = true;
} else {
$post = get_post($id);
$sample = false;
}
if ( empty($post->ID) )
return false;
if ( $post->post_type == 'page' )
return get_page_link($post->ID, $leavename, $sample);
elseif ( $post->post_type == 'attachment' )
return get_attachment_link( $post->ID, $leavename );
elseif ( in_array($post->post_type, get_post_types( array('_builtin' => false) ) ) )
return get_post_permalink($post->ID, $leavename, $sample);
$permalink = get_option('permalink_structure');
/**
* Filter the permalink structure for a post before token replacement occurs.
*
* Only applies to posts with post_type of 'post'.
*
* @since 3.0.0
*
* @param string $permalink The site's permalink structure.
* @param WP_Post $post The post in question.
* @param bool $leavename Whether to keep the post name.
*/
$permalink = apply_filters( 'pre_post_link', $permalink, $post, $leavename );
if ( '' != $permalink && !in_array($post->post_status, array('draft', 'pending', 'auto-draft')) ) {
$unixtime = strtotime($post->post_date);
$category = '';
if ( strpos($permalink, '%category%') !== false ) {
$cats = get_the_category($post->ID);
if ( $cats ) {
usort($cats, '_usort_terms_by_ID'); // order by ID
/**
* Filter the category that gets used in the %category% permalink token.
*
* @since 3.5.0
*
* @param stdClass $cat The category to use in the permalink.
* @param array $cats Array of all categories associated with the post.
* @param WP_Post $post The post in question.
*/
$category_object = apply_filters( 'post_link_category', $cats[0], $cats, $post );
$category_object = get_term( $category_object, 'category' );
$category = $category_object->slug;
if ( $parent = $category_object->parent )
$category = get_category_parents($parent, false, '/', true) . $category;
}
// show default category in permalinks, without
// having to assign it explicitly
if ( empty($category) ) {
$default_category = get_term( get_option( 'default_category' ), 'category' );
$category = is_wp_error( $default_category ) ? '' : $default_category->slug;
}
}
$author = '';
if ( strpos($permalink, '%author%') !== false ) {
$authordata = get_userdata($post->post_author);
$author = $authordata->user_nicename;
}
$date = explode(" ",date('Y m d H i s', $unixtime));
$rewritereplace =
array(
$date[0],
$date[1],
$date[2],
$date[3],
$date[4],
$date[5],
$post->post_name,
$post->ID,
$category,
$author,
$post->post_name,
);
$permalink = home_url( str_replace($rewritecode, $rewritereplace, $permalink) );
$permalink = user_trailingslashit($permalink, 'single');
} else { // if they're not using the fancy permalink option
$permalink = home_url('?p=' . $post->ID);
}
/**
* Filter the permalink for a post.
*
* Only applies to posts with post_type of 'post'.
*
* @since 1.5.0
*
* @param string $permalink The post's permalink.
* @param WP_Post $post The post in question.
* @param bool $leavename Whether to keep the post name.
*/
return apply_filters( 'post_link', $permalink, $post, $leavename );
}
/**
* Retrieve the permalink for a post with a custom post type.
*
* @since 3.0.0
*
* @param int $id Optional. Post ID.
* @param bool $leavename Optional, defaults to false. Whether to keep post name.
* @param bool $sample Optional, defaults to false. Is it a sample permalink.
* @return string
*/
function get_post_permalink( $id = 0, $leavename = false, $sample = false ) {
global $wp_rewrite;
$post = get_post($id);
if ( is_wp_error( $post ) )
return $post;
$post_link = $wp_rewrite->get_extra_permastruct($post->post_type);
$slug = $post->post_name;
$draft_or_pending = isset($post->post_status) && in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft' ) );
$post_type = get_post_type_object($post->post_type);
if ( !empty($post_link) && ( !$draft_or_pending || $sample ) ) {
if ( ! $leavename ) {
if ( $post_type->hierarchical )
$slug = get_page_uri($id);
$post_link = str_replace("%$post->post_type%", $slug, $post_link);
}
$post_link = home_url( user_trailingslashit($post_link) );
} else {
if ( $post_type->query_var && ( isset($post->post_status) && !$draft_or_pending ) )
$post_link = add_query_arg($post_type->query_var, $slug, '');
else
$post_link = add_query_arg(array('post_type' => $post->post_type, 'p' => $post->ID), '');
$post_link = home_url($post_link);
}
/**
* Filter the permalink for a post with a custom post type.
*
* @since 3.0.0
*
* @param string $post_link The post's permalink.
* @param WP_Post $post The post in question.
* @param bool $leavename Whether to keep the post name.
* @param bool $sample Is it a sample permalink.
*/
return apply_filters( 'post_type_link', $post_link, $post, $leavename, $sample );
}
/**
* Retrieve permalink from post ID.
*
* @since 1.0.0
*
* @param int $post_id Optional. Post ID.
* @param mixed $deprecated Not used.
* @return string
*/
function post_permalink( $post_id = 0, $deprecated = '' ) {
if ( !empty( $deprecated ) )
_deprecated_argument( __FUNCTION__, '1.3' );
return get_permalink($post_id);
}
/**
* Retrieve the permalink for current page or page ID.
*
* Respects page_on_front. Use this one.
*
* @since 1.5.0
*
* @param int|object $post Optional. Post ID or object.
* @param bool $leavename Optional, defaults to false. Whether to keep page name.
* @param bool $sample Optional, defaults to false. Is it a sample permalink.
* @return string
*/
function get_page_link( $post = false, $leavename = false, $sample = false ) {
$post = get_post( $post );
if ( 'page' == get_option( 'show_on_front' ) && $post->ID == get_option( 'page_on_front' ) )
$link = home_url('/');
else
$link = _get_page_link( $post, $leavename, $sample );
/**
* Filter the permalink for a page.
*
* @since 1.5.0
*
* @param string $link The page's permalink.
* @param int $post_id The ID of the page.
* @param bool $sample Is it a sample permalink.
*/
return apply_filters( 'page_link', $link, $post->ID, $sample );
}
/**
* Retrieve the page permalink.
*
* Ignores page_on_front. Internal use only.
*
* @since 2.1.0
* @access private
*
* @param int|object $post Optional. Post ID or object.
* @param bool $leavename Optional. Leave name.
* @param bool $sample Optional. Sample permalink.
* @return string
*/
function _get_page_link( $post = false, $leavename = false, $sample = false ) {
global $wp_rewrite;
$post = get_post( $post );
$draft_or_pending = in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft' ) );
$link = $wp_rewrite->get_page_permastruct();
if ( !empty($link) && ( ( isset($post->post_status) && !$draft_or_pending ) || $sample ) ) {
if ( ! $leavename ) {
$link = str_replace('%pagename%', get_page_uri( $post ), $link);
}
$link = home_url($link);
$link = user_trailingslashit($link, 'page');
} else {
$link = home_url( '?page_id=' . $post->ID );
}
/**
* Filter the permalink for a non-page_on_front page.
*
* @since 2.1.0
*
* @param string $link The page's permalink.
* @param int $post_id The ID of the page.
*/
return apply_filters( '_get_page_link', $link, $post->ID );
}
/**
* Retrieve permalink for attachment.
*
* This can be used in the WordPress Loop or outside of it.
*
* @since 2.0.0
*
* @param int|object $post Optional. Post ID or object.
* @param bool $leavename Optional. Leave name.
* @return string
*/
function get_attachment_link( $post = null, $leavename = false ) {
global $wp_rewrite;
$link = false;
$post = get_post( $post );
$parent = ( $post->post_parent > 0 && $post->post_parent != $post->ID ) ? get_post( $post->post_parent ) : false;
if ( $wp_rewrite->using_permalinks() && $parent ) {
if ( 'page' == $parent->post_type )
$parentlink = _get_page_link( $post->post_parent ); // Ignores page_on_front
else
$parentlink = get_permalink( $post->post_parent );
if ( is_numeric($post->post_name) || false !== strpos(get_option('permalink_structure'), '%category%') )
$name = 'attachment/' . $post->post_name; // <permalink>/<int>/ is paged so we use the explicit attachment marker
else
$name = $post->post_name;
if ( strpos($parentlink, '?') === false )
$link = user_trailingslashit( trailingslashit($parentlink) . '%postname%' );
if ( ! $leavename )
$link = str_replace( '%postname%', $name, $link );
}
if ( ! $link )
$link = home_url( '/?attachment_id=' . $post->ID );
/**
* Filter the permalink for an attachment.
*
* @since 2.0.0
*
* @param string $link The attachment's permalink.
* @param int $post_id Attachment ID.
*/
return apply_filters( 'attachment_link', $link, $post->ID );
}
/**
* Retrieve the permalink for the year archives.
*
* @since 1.5.0
*
* @param int|bool $year False for current year or year for permalink.
* @return string
*/
function get_year_link($year) {
global $wp_rewrite;
if ( !$year )
$year = gmdate('Y', current_time('timestamp'));
$yearlink = $wp_rewrite->get_year_permastruct();
if ( !empty($yearlink) ) {
$yearlink = str_replace('%year%', $year, $yearlink);
$yearlink = home_url( user_trailingslashit( $yearlink, 'year' ) );
} else {
$yearlink = home_url( '?m=' . $year );
}
/**
* Filter the year archive permalink.
*
* @since 1.5.0
*
* @param string $yearlink Permalink for the year archive.
* @param int $year Year for the archive.
*/
return apply_filters( 'year_link', $yearlink, $year );
}
/**
* Retrieve the permalink for the month archives with year.
*
* @since 1.0.0
*
* @param bool|int $year False for current year. Integer of year.
* @param bool|int $month False for current month. Integer of month.
* @return string
*/
function get_month_link($year, $month) {
global $wp_rewrite;
if ( !$year )
$year = gmdate('Y', current_time('timestamp'));
if ( !$month )
$month = gmdate('m', current_time('timestamp'));
$monthlink = $wp_rewrite->get_month_permastruct();
if ( !empty($monthlink) ) {
$monthlink = str_replace('%year%', $year, $monthlink);
$monthlink = str_replace('%monthnum%', zeroise(intval($month), 2), $monthlink);
$monthlink = home_url( user_trailingslashit( $monthlink, 'month' ) );
} else {
$monthlink = home_url( '?m=' . $year . zeroise( $month, 2 ) );
}
/**
* Filter the month archive permalink.
*
* @since 1.5.0
*
* @param string $monthlink Permalink for the month archive.
* @param int $year Year for the archive.
* @param int $month The month for the archive.
*/
return apply_filters( 'month_link', $monthlink, $year, $month );
}
/**
* Retrieve the permalink for the day archives with year and month.
*
* @since 1.0.0
*
* @param bool|int $year False for current year. Integer of year.
* @param bool|int $month False for current month. Integer of month.
* @param bool|int $day False for current day. Integer of day.
* @return string
*/
function get_day_link($year, $month, $day) {
global $wp_rewrite;
if ( !$year )
$year = gmdate('Y', current_time('timestamp'));
if ( !$month )
$month = gmdate('m', current_time('timestamp'));
if ( !$day )
$day = gmdate('j', current_time('timestamp'));
$daylink = $wp_rewrite->get_day_permastruct();
if ( !empty($daylink) ) {
$daylink = str_replace('%year%', $year, $daylink);
$daylink = str_replace('%monthnum%', zeroise(intval($month), 2), $daylink);
$daylink = str_replace('%day%', zeroise(intval($day), 2), $daylink);
$daylink = home_url( user_trailingslashit( $daylink, 'day' ) );
} else {
$daylink = home_url( '?m=' . $year . zeroise( $month, 2 ) . zeroise( $day, 2 ) );
}
/**
* Filter the day archive permalink.
*
* @since 1.5.0
*
* @param string $daylink Permalink for the day archive.
* @param int $year Year for the archive.
* @param int $month Month for the archive.
* @param int $day The day for the archive.
*/
return apply_filters( 'day_link', $daylink, $year, $month, $day );
}
/**
* Display the permalink for the feed type.
*
* @since 3.0.0
*
* @param string $anchor The link's anchor text.
* @param string $feed Optional, defaults to default feed. Feed type.
*/
function the_feed_link( $anchor, $feed = '' ) {
$link = '<a href="' . esc_url( get_feed_link( $feed ) ) . '">' . $anchor . '</a>';
/**
* Filter the feed link anchor tag.
*
* @since 3.0.0
*
* @param string $link The complete anchor tag for a feed link.
* @param string $feed The feed type, or an empty string for the
* default feed type.
*/
echo apply_filters( 'the_feed_link', $link, $feed );
}
/**
* Retrieve the permalink for the feed type.
*
* @since 1.5.0
*
* @param string $feed Optional, defaults to default feed. Feed type.
* @return string
*/
function get_feed_link($feed = '') {
global $wp_rewrite;
$permalink = $wp_rewrite->get_feed_permastruct();
if ( '' != $permalink ) {
if ( false !== strpos($feed, 'comments_') ) {
$feed = str_replace('comments_', '', $feed);
$permalink = $wp_rewrite->get_comment_feed_permastruct();
}
if ( get_default_feed() == $feed )
$feed = '';
$permalink = str_replace('%feed%', $feed, $permalink);
$permalink = preg_replace('#/+#', '/', "/$permalink");
$output = home_url( user_trailingslashit($permalink, 'feed') );
} else {
if ( empty($feed) )
$feed = get_default_feed();
if ( false !== strpos($feed, 'comments_') )
$feed = str_replace('comments_', 'comments-', $feed);
$output = home_url("?feed={$feed}");
}
/**
* Filter the feed type permalink.
*
* @since 1.5.0
*
* @param string $output The feed permalink.
* @param string $feed Feed type.
*/
return apply_filters( 'feed_link', $output, $feed );
}
/**
* Retrieve the permalink for the post comments feed.
*
* @since 2.2.0
*
* @param int $post_id Optional. Post ID.
* @param string $feed Optional. Feed type.
* @return string
*/
function get_post_comments_feed_link($post_id = 0, $feed = '') {
$post_id = absint( $post_id );
if ( ! $post_id )
$post_id = get_the_ID();
if ( empty( $feed ) )
$feed = get_default_feed();
if ( '' != get_option('permalink_structure') ) {
if ( 'page' == get_option('show_on_front') && $post_id == get_option('page_on_front') )
$url = _get_page_link( $post_id );
else
$url = get_permalink($post_id);
$url = trailingslashit($url) . 'feed';
if ( $feed != get_default_feed() )
$url .= "/$feed";
$url = user_trailingslashit($url, 'single_feed');
} else {
$type = get_post_field('post_type', $post_id);
if ( 'page' == $type )
$url = add_query_arg( array( 'feed' => $feed, 'page_id' => $post_id ), home_url( '/' ) );
else
$url = add_query_arg( array( 'feed' => $feed, 'p' => $post_id ), home_url( '/' ) );
}
/**
* Filter the post comments feed permalink.
*
* @since 1.5.1
*
* @param string $url Post comments feed permalink.
*/
return apply_filters( 'post_comments_feed_link', $url );
}
/**
* Display the comment feed link for a post.
*
* Prints out the comment feed link for a post. Link text is placed in the
* anchor. If no link text is specified, default text is used. If no post ID is
* specified, the current post is used.
*
* @since 2.5.0
*
* @param string $link_text Descriptive text.
* @param int $post_id Optional post ID. Default to current post.
* @param string $feed Optional. Feed format.
* @return string Link to the comment feed for the current post.
*/
function post_comments_feed_link( $link_text = '', $post_id = '', $feed = '' ) {
$url = esc_url( get_post_comments_feed_link( $post_id, $feed ) );
if ( empty($link_text) )
$link_text = __('Comments Feed');
/**
* Filter the post comment feed link anchor tag.
*
* @since 2.8.0
*
* @param string $link The complete anchor tag for the comment feed link.
* @param int $post_id Post ID.
* @param string $feed The feed type, or an empty string for the default feed type.
*/
echo apply_filters( 'post_comments_feed_link_html', "<a href='$url'>$link_text</a>", $post_id, $feed );
}
/**
* Retrieve the feed link for a given author.
*
* Returns a link to the feed for all posts by a given author. A specific feed
* can be requested or left blank to get the default feed.
*
* @since 2.5.0
*
* @param int $author_id ID of an author.
* @param string $feed Optional. Feed type.
* @return string Link to the feed for the author specified by $author_id.
*/
function get_author_feed_link( $author_id, $feed = '' ) {
$author_id = (int) $author_id;
$permalink_structure = get_option('permalink_structure');
if ( empty($feed) )
$feed = get_default_feed();
if ( '' == $permalink_structure ) {
$link = home_url("?feed=$feed&author=" . $author_id);
} else {
$link = get_author_posts_url($author_id);
if ( $feed == get_default_feed() )
$feed_link = 'feed';
else
$feed_link = "feed/$feed";
$link = trailingslashit($link) . user_trailingslashit($feed_link, 'feed');
}
/**
* Filter the feed link for a given author.
*
* @since 1.5.1
*
* @param string $link The author feed link.
* @param string $feed Feed type.
*/
$link = apply_filters( 'author_feed_link', $link, $feed );
return $link;
}
/**
* Retrieve the feed link for a category.
*
* Returns a link to the feed for all posts in a given category. A specific feed
* can be requested or left blank to get the default feed.
*
* @since 2.5.0
*
* @param int $cat_id ID of a category.
* @param string $feed Optional. Feed type.
* @return string Link to the feed for the category specified by $cat_id.
*/
function get_category_feed_link($cat_id, $feed = '') {
return get_term_feed_link($cat_id, 'category', $feed);
}
/**
* Retrieve the feed link for a term.
*
* Returns a link to the feed for all posts in a given term. A specific feed
* can be requested or left blank to get the default feed.
*
* @since 3.0.0
*
* @param int $term_id ID of a category.
* @param string $taxonomy Optional. Taxonomy of $term_id
* @param string $feed Optional. Feed type.
* @return string Link to the feed for the term specified by $term_id and $taxonomy.
*/
function get_term_feed_link( $term_id, $taxonomy = 'category', $feed = '' ) {
$term_id = ( int ) $term_id;
$term = get_term( $term_id, $taxonomy );
if ( empty( $term ) || is_wp_error( $term ) )
return false;
if ( empty( $feed ) )
$feed = get_default_feed();
$permalink_structure = get_option( 'permalink_structure' );
if ( '' == $permalink_structure ) {
if ( 'category' == $taxonomy ) {
$link = home_url("?feed=$feed&cat=$term_id");
}
elseif ( 'post_tag' == $taxonomy ) {
$link = home_url("?feed=$feed&tag=$term->slug");
} else {
$t = get_taxonomy( $taxonomy );
$link = home_url("?feed=$feed&$t->query_var=$term->slug");
}
} else {
$link = get_term_link( $term_id, $term->taxonomy );
if ( $feed == get_default_feed() )
$feed_link = 'feed';
else
$feed_link = "feed/$feed";
$link = trailingslashit( $link ) . user_trailingslashit( $feed_link, 'feed' );
}
if ( 'category' == $taxonomy ) {
/**
* Filter the category feed link.
*
* @since 1.5.1
*
* @param string $link The category feed link.
* @param string $feed Feed type.
*/
$link = apply_filters( 'category_feed_link', $link, $feed );
} elseif ( 'post_tag' == $taxonomy ) {
/**
* Filter the post tag feed link.
*
* @since 2.3.0
*
* @param string $link The tag feed link.
* @param string $feed Feed type.
*/
$link = apply_filters( 'tag_feed_link', $link, $feed );
} else {
/**
* Filter the feed link for a taxonomy other than 'category' or 'post_tag'.
*
* @since 3.0.0
*
* @param string $link The taxonomy feed link.
* @param string $feed Feed type.
* @param string $feed The taxonomy name.
*/
$link = apply_filters( 'taxonomy_feed_link', $link, $feed, $taxonomy );
}
return $link;
}
/**
* Retrieve permalink for feed of tag.
*
* @since 2.3.0
*
* @param int $tag_id Tag ID.
* @param string $feed Optional. Feed type.
* @return string
*/
function get_tag_feed_link($tag_id, $feed = '') {
return get_term_feed_link($tag_id, 'post_tag', $feed);
}
/**
* Retrieve edit tag link.
*
* @since 2.7.0
*
* @param int $tag_id Tag ID
* @param string $taxonomy Taxonomy
* @return string
*/
function get_edit_tag_link( $tag_id, $taxonomy = 'post_tag' ) {
/**
* Filter the edit link for a tag (or term in another taxonomy).
*
* @since 2.7.0
*
* @param string $link The term edit link.
*/
return apply_filters( 'get_edit_tag_link', get_edit_term_link( $tag_id, $taxonomy ) );
}
/**
* Display or retrieve edit tag link with formatting.
*
* @since 2.7.0
*
* @param string $link Optional. Anchor text.
* @param string $before Optional. Display before edit link.
* @param string $after Optional. Display after edit link.
* @param object $tag Tag object.
* @return string HTML content.
*/
function edit_tag_link( $link = '', $before = '', $after = '', $tag = null ) {
$link = edit_term_link( $link, '', '', $tag, false );
/**
* Filter the anchor tag for the edit link for a tag (or term in another taxonomy).
*
* @since 2.7.0
*
* @param string $link The anchor tag for the edit link.
*/
echo $before . apply_filters( 'edit_tag_link', $link ) . $after;
}
/**
* Retrieve edit term url.
*
* @since 3.1.0
*
* @param int $term_id Term ID
* @param string $taxonomy Taxonomy
* @param string $object_type The object type
* @return string
*/
function get_edit_term_link( $term_id, $taxonomy, $object_type = '' ) {
$tax = get_taxonomy( $taxonomy );
if ( !current_user_can( $tax->cap->edit_terms ) )
return;
$term = get_term( $term_id, $taxonomy );
$args = array(
'action' => 'edit',
'taxonomy' => $taxonomy,
'tag_ID' => $term->term_id,
);
if ( $object_type )
$args['post_type'] = $object_type;
$location = add_query_arg( $args, admin_url( 'edit-tags.php' ) );
/**
* Filter the edit link for a term.
*
* @since 3.1.0
*
* @param string $location The edit link.
* @param int $term_id Term ID.
* @param string $taxonomy Taxonomy name.
* @param string $object_type The object type (eg. the post type).
*/
return apply_filters( 'get_edit_term_link', $location, $term_id, $taxonomy, $object_type );
}
/**
* Display or retrieve edit term link with formatting.
*
* @since 3.1.0
*
* @param string $link Optional. Anchor text.
* @param string $before Optional. Display before edit link.
* @param string $after Optional. Display after edit link.
* @param object $term Term object.
* @return string HTML content.
*/
function edit_term_link( $link = '', $before = '', $after = '', $term = null, $echo = true ) {
if ( is_null( $term ) )
$term = get_queried_object();
if ( ! $term )
return;
$tax = get_taxonomy( $term->taxonomy );
if ( ! current_user_can( $tax->cap->edit_terms ) )
return;
if ( empty( $link ) )
$link = __('Edit This');
$link = '<a href="' . get_edit_term_link( $term->term_id, $term->taxonomy ) . '">' . $link . '</a>';
/**
* Filter the anchor tag for the edit link of a term.
*
* @since 3.1.0
*
* @param string $link The anchor tag for the edit link.
* @param int $term_id Term ID.
*/
$link = $before . apply_filters( 'edit_term_link', $link, $term->term_id ) . $after;
if ( $echo )
echo $link;
else
return $link;
}
/**
* Retrieve permalink for search.
*
* @since 3.0.0
*
* @param string $query Optional. The query string to use. If empty the current query is used.
* @return string
*/
function get_search_link( $query = '' ) {
global $wp_rewrite;
if ( empty($query) )
$search = get_search_query( false );
else
$search = stripslashes($query);
$permastruct = $wp_rewrite->get_search_permastruct();
if ( empty( $permastruct ) ) {
$link = home_url('?s=' . urlencode($search) );
} else {
$search = urlencode($search);
$search = str_replace('%2F', '/', $search); // %2F(/) is not valid within a URL, send it unencoded.
$link = str_replace( '%search%', $search, $permastruct );
$link = home_url( user_trailingslashit( $link, 'search' ) );
}
/**
* Filter the search permalink.
*
* @since 3.0.0
*
* @param string $link Search permalink.
* @param string $search The URL-encoded search term.
*/
return apply_filters( 'search_link', $link, $search );
}
/**
* Retrieve the permalink for the feed of the search results.
*
* @since 2.5.0
*
* @param string $search_query Optional. Search query.
* @param string $feed Optional. Feed type.
* @return string
*/
function get_search_feed_link($search_query = '', $feed = '') {
global $wp_rewrite;
$link = get_search_link($search_query);
if ( empty($feed) )
$feed = get_default_feed();
$permastruct = $wp_rewrite->get_search_permastruct();
if ( empty($permastruct) ) {
$link = add_query_arg('feed', $feed, $link);
} else {
$link = trailingslashit($link);
$link .= "feed/$feed/";
}
/**
* Filter the search feed link.
*
* @since 2.5.0
*
* @param string $link Search feed link.
* @param string $feed Feed type.
* @param string $type The search type. One of 'posts' or 'comments'.
*/
$link = apply_filters( 'search_feed_link', $link, $feed, 'posts' );
return $link;
}
/**
* Retrieve the permalink for the comments feed of the search results.
*
* @since 2.5.0
*
* @param string $search_query Optional. Search query.
* @param string $feed Optional. Feed type.
* @return string
*/
function get_search_comments_feed_link($search_query = '', $feed = '') {
global $wp_rewrite;
if ( empty($feed) )
$feed = get_default_feed();
$link = get_search_feed_link($search_query, $feed);
$permastruct = $wp_rewrite->get_search_permastruct();
if ( empty($permastruct) )
$link = add_query_arg('feed', 'comments-' . $feed, $link);
else
$link = add_query_arg('withcomments', 1, $link);
/** This filter is documented in wp-includes/link-template.php */
$link = apply_filters('search_feed_link', $link, $feed, 'comments');
return $link;
}
/**
* Retrieve the permalink for a post type archive.
*
* @since 3.1.0
*
* @param string $post_type Post type
* @return string
*/
function get_post_type_archive_link( $post_type ) {
global $wp_rewrite;
if ( ! $post_type_obj = get_post_type_object( $post_type ) )
return false;
if ( ! $post_type_obj->has_archive )
return false;
if ( get_option( 'permalink_structure' ) && is_array( $post_type_obj->rewrite ) ) {
$struct = ( true === $post_type_obj->has_archive ) ? $post_type_obj->rewrite['slug'] : $post_type_obj->has_archive;
if ( $post_type_obj->rewrite['with_front'] )
$struct = $wp_rewrite->front . $struct;
else
$struct = $wp_rewrite->root . $struct;
$link = home_url( user_trailingslashit( $struct, 'post_type_archive' ) );
} else {
$link = home_url( '?post_type=' . $post_type );
}
/**
* Filter the post type archive permalink.
*
* @since 3.1.0
*
* @param string $link The post type archive permalink.
* @param string $post_type Post type name.
*/
return apply_filters( 'post_type_archive_link', $link, $post_type );
}
/**
* Retrieve the permalink for a post type archive feed.
*
* @since 3.1.0
*
* @param string $post_type Post type
* @param string $feed Optional. Feed type
* @return string
*/
function get_post_type_archive_feed_link( $post_type, $feed = '' ) {
$default_feed = get_default_feed();
if ( empty( $feed ) )
$feed = $default_feed;
if ( ! $link = get_post_type_archive_link( $post_type ) )
return false;
$post_type_obj = get_post_type_object( $post_type );
if ( get_option( 'permalink_structure' ) && is_array( $post_type_obj->rewrite ) && $post_type_obj->rewrite['feeds'] ) {
$link = trailingslashit( $link );
$link .= 'feed/';
if ( $feed != $default_feed )
$link .= "$feed/";
} else {
$link = add_query_arg( 'feed', $feed, $link );
}
/**
* Filter the post type archive feed link.
*
* @since 3.1.0
*
* @param string $link The post type archive feed link.
* @param string $feed Feed type.
*/
return apply_filters( 'post_type_archive_feed_link', $link, $feed );
}
/**
* Retrieve edit posts link for post.
*
* Can be used within the WordPress loop or outside of it. Can be used with
* pages, posts, attachments, and revisions.
*
* @since 2.3.0
*
* @param int $id Optional. Post ID.
* @param string $context Optional, defaults to display. How to write the '&', defaults to '&'.
* @return string
*/
function get_edit_post_link( $id = 0, $context = 'display' ) {
if ( ! $post = get_post( $id ) )
return;
if ( 'revision' === $post->post_type )
$action = '';
elseif ( 'display' == $context )
$action = '&action=edit';
else
$action = '&action=edit';
$post_type_object = get_post_type_object( $post->post_type );
if ( !$post_type_object )
return;
if ( !current_user_can( 'edit_post', $post->ID ) )
return;
/**
* Filter the post edit link.
*
* @since 2.3.0
*
* @param string $link The edit link.
* @param int $post_id Post ID.
* @param string $context The link context. If set to 'display' then ampersands
* are encoded.
*/
return apply_filters( 'get_edit_post_link', admin_url( sprintf( $post_type_object->_edit_link . $action, $post->ID ) ), $post->ID, $context );
}
/**
* Display edit post link for post.
*
* @since 1.0.0
*
* @param string $link Optional. Anchor text.
* @param string $before Optional. Display before edit link.
* @param string $after Optional. Display after edit link.
* @param int $id Optional. Post ID.
*/
function edit_post_link( $link = null, $before = '', $after = '', $id = 0 ) {
if ( !$post = get_post( $id ) )
return;
if ( !$url = get_edit_post_link( $post->ID ) )
return;
if ( null === $link )
$link = __('Edit This');
$post_type_obj = get_post_type_object( $post->post_type );
$link = '<a class="post-edit-link" href="' . $url . '">' . $link . '</a>';
/**
* Filter the post edit link anchor tag.
*
* @since 2.3.0
*
* @param string $link Anchor tag for the edit link.
* @param int $post_id Post ID.
*/
echo $before . apply_filters( 'edit_post_link', $link, $post->ID ) . $after;
}
/**
* Retrieve delete posts link for post.
*
* Can be used within the WordPress loop or outside of it, with any post type.
*
* @since 2.9.0
*
* @param int $id Optional. Post ID.
* @param string $deprecated Not used.
* @param bool $force_delete Whether to bypass trash and force deletion. Default is false.
* @return string
*/
function get_delete_post_link( $id = 0, $deprecated = '', $force_delete = false ) {
if ( ! empty( $deprecated ) )
_deprecated_argument( __FUNCTION__, '3.0' );
if ( !$post = get_post( $id ) )
return;
$post_type_object = get_post_type_object( $post->post_type );
if ( !$post_type_object )
return;
if ( !current_user_can( 'delete_post', $post->ID ) )
return;
$action = ( $force_delete || !EMPTY_TRASH_DAYS ) ? 'delete' : 'trash';
$delete_link = add_query_arg( 'action', $action, admin_url( sprintf( $post_type_object->_edit_link, $post->ID ) ) );
/**
* Filter the post delete link.
*
* @since 2.9.0
*
* @param string $link The delete link.
* @param int $post_id Post ID.
* @param bool $force_delete Whether to bypass the trash and force deletion. Default false.
*/
return apply_filters( 'get_delete_post_link', wp_nonce_url( $delete_link, "$action-post_{$post->ID}" ), $post->ID, $force_delete );
}
/**
* Retrieve edit comment link.
*
* @since 2.3.0
*
* @param int $comment_id Optional. Comment ID.
* @return string
*/
function get_edit_comment_link( $comment_id = 0 ) {
$comment = get_comment( $comment_id );
if ( !current_user_can( 'edit_comment', $comment->comment_ID ) )
return;
$location = admin_url('comment.php?action=editcomment&c=') . $comment->comment_ID;
/**
* Filter the comment edit link.
*
* @since 2.3.0
*
* @param string $location The edit link.
*/
return apply_filters( 'get_edit_comment_link', $location );
}
/**
* Display edit comment link with formatting.
*
* @since 1.0.0
*
* @param string $link Optional. Anchor text.
* @param string $before Optional. Display before edit link.
* @param string $after Optional. Display after edit link.
*/
function edit_comment_link( $link = null, $before = '', $after = '' ) {
global $comment;
if ( !current_user_can( 'edit_comment', $comment->comment_ID ) )
return;
if ( null === $link )
$link = __('Edit This');
$link = '<a class="comment-edit-link" href="' . get_edit_comment_link( $comment->comment_ID ) . '">' . $link . '</a>';
/**
* Filter the comment edit link anchor tag.
*
* @since 2.3.0
*
* @param string $link Anchor tag for the edit link.
* @param int $comment_id Comment ID.
*/
echo $before . apply_filters( 'edit_comment_link', $link, $comment->comment_ID ) . $after;
}
/**
* Display edit bookmark (literally a URL external to blog) link.
*
* @since 2.7.0
*
* @param int $link Optional. Bookmark ID.
* @return string
*/
function get_edit_bookmark_link( $link = 0 ) {
$link = get_bookmark( $link );
if ( !current_user_can('manage_links') )
return;
$location = admin_url('link.php?action=edit&link_id=') . $link->link_id;
/**
* Filter the bookmark (link) edit link.
*
* @since 2.7.0
*
* @param string $location The edit link.
* @param int $link_id Bookmark ID.
*/
return apply_filters( 'get_edit_bookmark_link', $location, $link->link_id );
}
/**
* Display edit bookmark (literally a URL external to blog) link anchor content.
*
* @since 2.7.0
*
* @param string $link Optional. Anchor text.
* @param string $before Optional. Display before edit link.
* @param string $after Optional. Display after edit link.
* @param int $bookmark Optional. Bookmark ID.
*/
function edit_bookmark_link( $link = '', $before = '', $after = '', $bookmark = null ) {
$bookmark = get_bookmark($bookmark);
if ( !current_user_can('manage_links') )
return;
if ( empty($link) )
$link = __('Edit This');
$link = '<a href="' . get_edit_bookmark_link( $bookmark ) . '">' . $link . '</a>';
/**
* Filter the bookmark edit link anchor tag.
*
* @since 2.7.0
*
* @param string $link Anchor tag for the edit link.
* @param int $link_id Bookmark ID.
*/
echo $before . apply_filters( 'edit_bookmark_link', $link, $bookmark->link_id ) . $after;
}
/**
* Retrieve edit user link
*
* @since 3.5.0
*
* @param int $user_id Optional. User ID. Defaults to the current user.
* @return string URL to edit user page or empty string.
*/
function get_edit_user_link( $user_id = null ) {
if ( ! $user_id )
$user_id = get_current_user_id();
if ( empty( $user_id ) || ! current_user_can( 'edit_user', $user_id ) )
return '';
$user = get_userdata( $user_id );
if ( ! $user )
return '';
if ( get_current_user_id() == $user->ID )
$link = get_edit_profile_url( $user->ID );
else
$link = add_query_arg( 'user_id', $user->ID, self_admin_url( 'user-edit.php' ) );
/**
* Filter the user edit link.
*
* @since 3.5.0
*
* @param string $link The edit link.
* @param int $user_id User ID.
*/
return apply_filters( 'get_edit_user_link', $link, $user->ID );
}
// Navigation links
/**
* Retrieve previous post that is adjacent to current post.
*
* @since 1.5.0
*
* @param bool $in_same_term Optional. Whether post should be in a same taxonomy term.
* @param array|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs.
* @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'.
* @return mixed Post object if successful. Null if global $post is not set. Empty string if no corresponding post exists.
*/
function get_previous_post( $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) {
return get_adjacent_post( $in_same_term, $excluded_terms, true, $taxonomy );
}
/**
* Retrieve next post that is adjacent to current post.
*
* @since 1.5.0
*
* @param bool $in_same_term Optional. Whether post should be in a same taxonomy term.
* @param array|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs.
* @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'.
* @return mixed Post object if successful. Null if global $post is not set. Empty string if no corresponding post exists.
*/
function get_next_post( $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) {
return get_adjacent_post( $in_same_term, $excluded_terms, false, $taxonomy );
}
/**
* Retrieve adjacent post.
*
* Can either be next or previous post.
*
* @since 2.5.0
*
* @param bool $in_same_term Optional. Whether post should be in a same taxonomy term.
* @param array|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs.
* @param bool $previous Optional. Whether to retrieve previous post.
* @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'.
* @return mixed Post object if successful. Null if global $post is not set. Empty string if no corresponding post exists.
*/
function get_adjacent_post( $in_same_term = false, $excluded_terms = '', $previous = true, $taxonomy = 'category' ) {
global $wpdb;
if ( ( ! $post = get_post() ) || ! taxonomy_exists( $taxonomy ) )
return null;
$current_post_date = $post->post_date;
$join = '';
$posts_in_ex_terms_sql = '';
if ( $in_same_term || ! empty( $excluded_terms ) ) {
$join = " INNER JOIN $wpdb->term_relationships AS tr ON p.ID = tr.object_id INNER JOIN $wpdb->term_taxonomy tt ON tr.term_taxonomy_id = tt.term_taxonomy_id";
if ( $in_same_term ) {
if ( ! is_object_in_taxonomy( $post->post_type, $taxonomy ) )
return '';
$term_array = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) );
if ( ! $term_array || is_wp_error( $term_array ) )
return '';
$join .= $wpdb->prepare( " AND tt.taxonomy = %s AND tt.term_id IN (" . implode( ',', array_map( 'intval', $term_array ) ) . ")", $taxonomy );
}
$posts_in_ex_terms_sql = $wpdb->prepare( "AND tt.taxonomy = %s", $taxonomy );
if ( ! empty( $excluded_terms ) ) {
if ( ! is_array( $excluded_terms ) ) {
// back-compat, $excluded_terms used to be $excluded_terms with IDs separated by " and "
if ( false !== strpos( $excluded_terms, ' and ' ) ) {
_deprecated_argument( __FUNCTION__, '3.3', sprintf( __( 'Use commas instead of %s to separate excluded terms.' ), "'and'" ) );
$excluded_terms = explode( ' and ', $excluded_terms );
} else {
$excluded_terms = explode( ',', $excluded_terms );
}
}
$excluded_terms = array_map( 'intval', $excluded_terms );
if ( ! empty( $term_array ) ) {
$excluded_terms = array_diff( $excluded_terms, $term_array );
$posts_in_ex_terms_sql = '';
}
if ( ! empty( $excluded_terms ) ) {
$posts_in_ex_terms_sql = $wpdb->prepare( " AND tt.taxonomy = %s AND tt.term_id NOT IN (" . implode( $excluded_terms, ',' ) . ')', $taxonomy );
}
}
}
$adjacent = $previous ? 'previous' : 'next';
$op = $previous ? '<' : '>';
$order = $previous ? 'DESC' : 'ASC';
/**
* Filter the JOIN clause in the SQL for an adjacent post query.
*
* The dynamic portion of the hook name, $adjacent, refers to the type
* of adjacency, 'next' or 'previous'.
*
* @since 2.5.0
*
* @param string $join The JOIN clause in the SQL.
* @param bool $in_same_term Whether post should be in a same taxonomy term.
* @param array $excluded_terms Array of excluded term IDs.
*/
$join = apply_filters( "get_{$adjacent}_post_join", $join, $in_same_term, $excluded_terms );
/**
* Filter the WHERE clause in the SQL for an adjacent post query.
*
* The dynamic portion of the hook name, $adjacent, refers to the type
* of adjacency, 'next' or 'previous'.
*
* @since 2.5.0
*
* @param string $where The WHERE clause in the SQL.
* @param bool $in_same_term Whether post should be in a same taxonomy term.
* @param array $excluded_terms Array of excluded term IDs.
*/
$where = apply_filters( "get_{$adjacent}_post_where", $wpdb->prepare( "WHERE p.post_date $op %s AND p.post_type = %s AND p.post_status = 'publish' $posts_in_ex_terms_sql", $current_post_date, $post->post_type), $in_same_term, $excluded_terms );
/**
* Filter the ORDER BY clause in the SQL for an adjacent post query.
*
* The dynamic portion of the hook name, $adjacent, refers to the type
* of adjacency, 'next' or 'previous'.
*
* @since 2.5.0
*
* @param string $order_by The ORDER BY clause in the SQL.
*/
$sort = apply_filters( "get_{$adjacent}_post_sort", "ORDER BY p.post_date $order LIMIT 1" );
$query = "SELECT p.ID FROM $wpdb->posts AS p $join $where $sort";
$query_key = 'adjacent_post_' . md5( $query );
$result = wp_cache_get( $query_key, 'counts' );
if ( false !== $result ) {
if ( $result )
$result = get_post( $result );
return $result;
}
$result = $wpdb->get_var( $query );
if ( null === $result )
$result = '';
wp_cache_set( $query_key, $result, 'counts' );
if ( $result )
$result = get_post( $result );
return $result;
}
/**
* Get adjacent post relational link.
*
* Can either be next or previous post relational link.
*
* @since 2.8.0
*
* @param string $title Optional. Link title format.
* @param bool $in_same_term Optional. Whether link should be in a same taxonomy term.
* @param array|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs.
* @param bool $previous Optional. Whether to display link to previous or next post. Default true.
* @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'.
* @return string
*/
function get_adjacent_post_rel_link( $title = '%title', $in_same_term = false, $excluded_terms = '', $previous = true, $taxonomy = 'category' ) {
if ( $previous && is_attachment() && $post = get_post() )
$post = get_post( $post->post_parent );
else
$post = get_adjacent_post( $in_same_term, $excluded_terms, $previous, $taxonomy );
if ( empty( $post ) )
return;
$post_title = the_title_attribute( array( 'echo' => false, 'post' => $post ) );
if ( empty( $post_title ) )
$post_title = $previous ? __( 'Previous Post' ) : __( 'Next Post' );
$date = mysql2date( get_option( 'date_format' ), $post->post_date );
$title = str_replace( '%title', $post_title, $title );
$title = str_replace( '%date', $date, $title );
$link = $previous ? "<link rel='prev' title='" : "<link rel='next' title='";
$link .= esc_attr( $title );
$link .= "' href='" . get_permalink( $post ) . "' />\n";
$adjacent = $previous ? 'previous' : 'next';
/**
* Filter the adjacent post relational link.
*
* The dynamic portion of the hook name, $adjacent, refers to the type
* of adjacency, 'next' or 'previous'.
*
* @since 2.8.0
*
* @param string $link The relational link.
*/
return apply_filters( "{$adjacent}_post_rel_link", $link );
}
/**
* Display relational links for the posts adjacent to the current post.
*
* @since 2.8.0
*
* @param string $title Optional. Link title format.
* @param bool $in_same_term Optional. Whether link should be in a same taxonomy term.
* @param array|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs.
* @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'.
*/
function adjacent_posts_rel_link( $title = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) {
echo get_adjacent_post_rel_link( $title, $in_same_term, $excluded_terms, true, $taxonomy );
echo get_adjacent_post_rel_link( $title, $in_same_term, $excluded_terms, false, $taxonomy );
}
/**
* Display relational links for the posts adjacent to the current post for single post pages.
*
* This is meant to be attached to actions like 'wp_head'. Do not call this directly in plugins or theme templates.
* @since 3.0.0
*
*/
function adjacent_posts_rel_link_wp_head() {
if ( !is_singular() || is_attachment() )
return;
adjacent_posts_rel_link();
}
/**
* Display relational link for the next post adjacent to the current post.
*
* @since 2.8.0
*
* @param string $title Optional. Link title format.
* @param bool $in_same_term Optional. Whether link should be in a same taxonomy term.
* @param array|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs.
* @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'.
*/
function next_post_rel_link( $title = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) {
echo get_adjacent_post_rel_link( $title, $in_same_term, $excluded_terms, false, $taxonomy );
}
/**
* Display relational link for the previous post adjacent to the current post.
*
* @since 2.8.0
*
* @param string $title Optional. Link title format.
* @param bool $in_same_term Optional. Whether link should be in a same taxonomy term.
* @param array|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. Default true.
* @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'.
*/
function prev_post_rel_link( $title = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) {
echo get_adjacent_post_rel_link( $title, $in_same_term, $excluded_terms, true, $taxonomy );
}
/**
* Retrieve boundary post.
*
* Boundary being either the first or last post by publish date within the constraints specified
* by $in_same_term or $excluded_terms.
*
* @since 2.8.0
*
* @param bool $in_same_term Optional. Whether returned post should be in a same taxonomy term.
* @param array|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs.
* @param bool $start Optional. Whether to retrieve first or last post.
* @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'.
* @return mixed Array containing the boundary post object if successful, null otherwise.
*/
function get_boundary_post( $in_same_term = false, $excluded_terms = '', $start = true, $taxonomy = 'category' ) {
$post = get_post();
if ( ! $post || ! is_single() || is_attachment() || ! taxonomy_exists( $taxonomy ) )
return null;
$query_args = array(
'posts_per_page' => 1,
'order' => $start ? 'ASC' : 'DESC',
'update_post_term_cache' => false,
'update_post_meta_cache' => false
);
$term_array = array();
if ( ! is_array( $excluded_terms ) ) {
if ( ! empty( $excluded_terms ) )
$excluded_terms = explode( ',', $excluded_terms );
else
$excluded_terms = array();
}
if ( $in_same_term || ! empty( $excluded_terms ) ) {
if ( $in_same_term )
$term_array = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) );
if ( ! empty( $excluded_terms ) ) {
$excluded_terms = array_map( 'intval', $excluded_terms );
$excluded_terms = array_diff( $excluded_terms, $term_array );
$inverse_terms = array();
foreach ( $excluded_terms as $excluded_term )
$inverse_terms[] = $excluded_term * -1;
$excluded_terms = $inverse_terms;
}
$query_args[ 'tax_query' ] = array( array(
'taxonomy' => $taxonomy,
'terms' => array_merge( $term_array, $excluded_terms )
) );
}
return get_posts( $query_args );
}
/*
* Get previous post link that is adjacent to the current post.
*
* @since 3.7.0
*
* @param string $format Optional. Link anchor format.
* @param string $link Optional. Link permalink format.
* @param bool $in_same_term Optional. Whether link should be in a same taxonomy term.
* @param array|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs.
* @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'.
* @return string
*/
function get_previous_post_link( $format = '« %link', $link = '%title', $in_same_cat = false, $excluded_terms = '', $taxonomy = 'category' ) {
return get_adjacent_post_link( $format, $link, $in_same_cat, $excluded_terms, true, $taxonomy );
}
/**
* Display previous post link that is adjacent to the current post.
*
* @since 1.5.0
* @see get_previous_post_link()
*
* @param string $format Optional. Link anchor format.
* @param string $link Optional. Link permalink format.
* @param bool $in_same_term Optional. Whether link should be in a same taxonomy term.
* @param array|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs.
* @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'.
*/
function previous_post_link( $format = '« %link', $link = '%title', $in_same_cat = false, $excluded_terms = '', $taxonomy = 'category' ) {
echo get_previous_post_link( $format, $link, $in_same_cat, $excluded_terms, $taxonomy );
}
/**
* Get next post link that is adjacent to the current post.
*
* @since 3.7.0
*
* @param string $format Optional. Link anchor format.
* @param string $link Optional. Link permalink format.
* @param bool $in_same_term Optional. Whether link should be in a same taxonomy term.
* @param array|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs.
* @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'.
* @return string
*/
function get_next_post_link( $format = '%link »', $link = '%title', $in_same_cat = false, $excluded_terms = '', $taxonomy = 'category' ) {
return get_adjacent_post_link( $format, $link, $in_same_cat, $excluded_terms, false, $taxonomy );
}
/**
* Display next post link that is adjacent to the current post.
*
* @since 1.5.0
* @see get_next_post_link()
*
* @param string $format Optional. Link anchor format.
* @param string $link Optional. Link permalink format.
* @param bool $in_same_term Optional. Whether link should be in a same taxonomy term.
* @param array|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs.
* @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'.
*/
function next_post_link( $format = '%link »', $link = '%title', $in_same_cat = false, $excluded_terms = '', $taxonomy = 'category' ) {
echo get_next_post_link( $format, $link, $in_same_cat, $excluded_terms, $taxonomy );
}
/**
* Get adjacent post link.
*
* Can be either next post link or previous.
*
* @since 3.7.0
*
* @param string $format Link anchor format.
* @param string $link Link permalink format.
* @param bool $in_same_term Optional. Whether link should be in a same taxonomy term.
* @param array|string $excluded_terms Optional. Array or comma-separated list of excluded terms IDs.
* @param bool $previous Optional. Whether to display link to previous or next post. Default true.
* @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'.
* @return string
*/
function get_adjacent_post_link( $format, $link, $in_same_cat = false, $excluded_terms = '', $previous = true, $taxonomy = 'category' ) {
if ( $previous && is_attachment() )
$post = get_post( get_post()->post_parent );
else
$post = get_adjacent_post( $in_same_cat, $excluded_terms, $previous, $taxonomy );
if ( ! $post ) {
$output = '';
} else {
$title = $post->post_title;
if ( empty( $post->post_title ) )
$title = $previous ? __( 'Previous Post' ) : __( 'Next Post' );
/** This filter is documented in wp-includes/post-template.php */
$title = apply_filters( 'the_title', $title, $post->ID );
$date = mysql2date( get_option( 'date_format' ), $post->post_date );
$rel = $previous ? 'prev' : 'next';
$string = '<a href="' . get_permalink( $post ) . '" rel="'.$rel.'">';
$inlink = str_replace( '%title', $title, $link );
$inlink = str_replace( '%date', $date, $inlink );
$inlink = $string . $inlink . '</a>';
$output = str_replace( '%link', $inlink, $format );
}
$adjacent = $previous ? 'previous' : 'next';
/**
* Filter the adjacent post link.
*
* The dynamic portion of the hook name, $adjacent, refers to the type
* of adjacency, 'next' or 'previous'.
*
* @since 2.6.0
*
* @param string $output The adjacent post link.
* @param string $format Link anchor format.
* @param string $link Link permalink format.
* @param WP_Post $post The adjacent post.
*/
return apply_filters( "{$adjacent}_post_link", $output, $format, $link, $post );
}
/**
* Display adjacent post link.
*
* Can be either next post link or previous.
*
* @since 2.5.0
* @uses get_adjacent_post_link()
*
* @param string $format Link anchor format.
* @param string $link Link permalink format.
* @param bool $in_same_cat Optional. Whether link should be in a same category.
* @param array|string $excluded_terms Optional. Array or comma-separated list of excluded category IDs.
* @param bool $previous Optional. Whether to display link to previous or next post. Default true.
* @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'.
* @return string
*/
function adjacent_post_link( $format, $link, $in_same_cat = false, $excluded_terms = '', $previous = true, $taxonomy = 'category' ) {
echo get_adjacent_post_link( $format, $link, $in_same_cat, $excluded_terms, $previous, $taxonomy );
}
/**
* Retrieve links for page numbers.
*
* @since 1.5.0
*
* @param int $pagenum Optional. Page ID.
* @param bool $escape Optional. Whether to escape the URL for display, with esc_url(). Defaults to true.
* Otherwise, prepares the URL with esc_url_raw().
* @return string
*/
function get_pagenum_link($pagenum = 1, $escape = true ) {
global $wp_rewrite;
$pagenum = (int) $pagenum;
$request = remove_query_arg( 'paged' );
$home_root = parse_url(home_url());
$home_root = ( isset($home_root['path']) ) ? $home_root['path'] : '';
$home_root = preg_quote( $home_root, '|' );
$request = preg_replace('|^'. $home_root . '|i', '', $request);
$request = preg_replace('|^/+|', '', $request);
if ( !$wp_rewrite->using_permalinks() || is_admin() ) {
$base = trailingslashit( get_bloginfo( 'url' ) );
if ( $pagenum > 1 ) {
$result = add_query_arg( 'paged', $pagenum, $base . $request );
} else {
$result = $base . $request;
}
} else {
$qs_regex = '|\?.*?$|';
preg_match( $qs_regex, $request, $qs_match );
if ( !empty( $qs_match[0] ) ) {
$query_string = $qs_match[0];
$request = preg_replace( $qs_regex, '', $request );
} else {
$query_string = '';
}
$request = preg_replace( "|$wp_rewrite->pagination_base/\d+/?$|", '', $request);
$request = preg_replace( '|^' . preg_quote( $wp_rewrite->index, '|' ) . '|i', '', $request);
$request = ltrim($request, '/');
$base = trailingslashit( get_bloginfo( 'url' ) );
if ( $wp_rewrite->using_index_permalinks() && ( $pagenum > 1 || '' != $request ) )
$base .= $wp_rewrite->index . '/';
if ( $pagenum > 1 ) {
$request = ( ( !empty( $request ) ) ? trailingslashit( $request ) : $request ) . user_trailingslashit( $wp_rewrite->pagination_base . "/" . $pagenum, 'paged' );
}
$result = $base . $request . $query_string;
}
/**
* Filter the page number link for the current request.
*
* @since 2.5.0
*
* @param string $result The page number link.
*/
$result = apply_filters( 'get_pagenum_link', $result );
if ( $escape )
return esc_url( $result );
else
return esc_url_raw( $result );
}
/**
* Retrieve next posts page link.
*
* Backported from 2.1.3 to 2.0.10.
*
* @since 2.0.10
*
* @param int $max_page Optional. Max pages.
* @return string
*/
function get_next_posts_page_link($max_page = 0) {
global $paged;
if ( !is_single() ) {
if ( !$paged )
$paged = 1;
$nextpage = intval($paged) + 1;
if ( !$max_page || $max_page >= $nextpage )
return get_pagenum_link($nextpage);
}
}
/**
* Display or return the next posts page link.
*
* @since 0.71
*
* @param int $max_page Optional. Max pages.
* @param boolean $echo Optional. Echo or return;
*/
function next_posts( $max_page = 0, $echo = true ) {
$output = esc_url( get_next_posts_page_link( $max_page ) );
if ( $echo )
echo $output;
else
return $output;
}
/**
* Return the next posts page link.
*
* @since 2.7.0
*
* @param string $label Content for link text.
* @param int $max_page Optional. Max pages.
* @return string|null
*/
function get_next_posts_link( $label = null, $max_page = 0 ) {
global $paged, $wp_query;
if ( !$max_page )
$max_page = $wp_query->max_num_pages;
if ( !$paged )
$paged = 1;
$nextpage = intval($paged) + 1;
if ( null === $label )
$label = __( 'Next Page »' );
if ( !is_single() && ( $nextpage <= $max_page ) ) {
/**
* Filter the anchor tag attributes for the next posts page link.
*
* @since 2.7.0
*
* @param string $attributes Attributes for the anchor tag.
*/
$attr = apply_filters( 'next_posts_link_attributes', '' );
return '<a href="' . next_posts( $max_page, false ) . "\" $attr>" . preg_replace('/&([^#])(?![a-z]{1,8};)/i', '&$1', $label) . '</a>';
}
}
/**
* Display the next posts page link.
*
* @since 0.71
* @uses get_next_posts_link()
*
* @param string $label Content for link text.
* @param int $max_page Optional. Max pages.
*/
function next_posts_link( $label = null, $max_page = 0 ) {
echo get_next_posts_link( $label, $max_page );
}
/**
* Retrieve previous posts page link.
*
* Will only return string, if not on a single page or post.
*
* Backported to 2.0.10 from 2.1.3.
*
* @since 2.0.10
*
* @return string|null
*/
function get_previous_posts_page_link() {
global $paged;
if ( !is_single() ) {
$nextpage = intval($paged) - 1;
if ( $nextpage < 1 )
$nextpage = 1;
return get_pagenum_link($nextpage);
}
}
/**
* Display or return the previous posts page link.
*
* @since 0.71
*
* @param boolean $echo Optional. Echo or return;
*/
function previous_posts( $echo = true ) {
$output = esc_url( get_previous_posts_page_link() );
if ( $echo )
echo $output;
else
return $output;
}
/**
* Return the previous posts page link.
*
* @since 2.7.0
*
* @param string $label Optional. Previous page link text.
* @return string|null
*/
function get_previous_posts_link( $label = null ) {
global $paged;
if ( null === $label )
$label = __( '« Previous Page' );
if ( !is_single() && $paged > 1 ) {
/**
* Filter the anchor tag attributes for the previous posts page link.
*
* @since 2.7.0
*
* @param string $attributes Attributes for the anchor tag.
*/
$attr = apply_filters( 'previous_posts_link_attributes', '' );
return '<a href="' . previous_posts( false ) . "\" $attr>". preg_replace( '/&([^#])(?![a-z]{1,8};)/i', '&$1', $label ) .'</a>';
}
}
/**
* Display the previous posts page link.
*
* @since 0.71
* @uses get_previous_posts_link()
*
* @param string $label Optional. Previous page link text.
*/
function previous_posts_link( $label = null ) {
echo get_previous_posts_link( $label );
}
/**
* Return post pages link navigation for previous and next pages.
*
* @since 2.8.0
*
* @param string|array $args Optional args.
* @return string The posts link navigation.
*/
function get_posts_nav_link( $args = array() ) {
global $wp_query;
$return = '';
if ( !is_singular() ) {
$defaults = array(
'sep' => ' — ',
'prelabel' => __('« Previous Page'),
'nxtlabel' => __('Next Page »'),
);
$args = wp_parse_args( $args, $defaults );
$max_num_pages = $wp_query->max_num_pages;
$paged = get_query_var('paged');
//only have sep if there's both prev and next results
if ($paged < 2 || $paged >= $max_num_pages) {
$args['sep'] = '';
}
if ( $max_num_pages > 1 ) {
$return = get_previous_posts_link($args['prelabel']);
$return .= preg_replace('/&([^#])(?![a-z]{1,8};)/i', '&$1', $args['sep']);
$return .= get_next_posts_link($args['nxtlabel']);
}
}
return $return;
}
/**
* Display post pages link navigation for previous and next pages.
*
* @since 0.71
*
* @param string $sep Optional. Separator for posts navigation links.
* @param string $prelabel Optional. Label for previous pages.
* @param string $nxtlabel Optional Label for next pages.
*/
function posts_nav_link( $sep = '', $prelabel = '', $nxtlabel = '' ) {
$args = array_filter( compact('sep', 'prelabel', 'nxtlabel') );
echo get_posts_nav_link($args);
}
/**
* Retrieve comments page number link.
*
* @since 2.7.0
*
* @param int $pagenum Optional. Page number.
* @return string
*/
function get_comments_pagenum_link( $pagenum = 1, $max_page = 0 ) {
global $wp_rewrite;
$pagenum = (int) $pagenum;
$result = get_permalink();
if ( 'newest' == get_option('default_comments_page') ) {
if ( $pagenum != $max_page ) {
if ( $wp_rewrite->using_permalinks() )
$result = user_trailingslashit( trailingslashit($result) . 'comment-page-' . $pagenum, 'commentpaged');
else
$result = add_query_arg( 'cpage', $pagenum, $result );
}
} elseif ( $pagenum > 1 ) {
if ( $wp_rewrite->using_permalinks() )
$result = user_trailingslashit( trailingslashit($result) . 'comment-page-' . $pagenum, 'commentpaged');
else
$result = add_query_arg( 'cpage', $pagenum, $result );
}
$result .= '#comments';
/**
* Filter the comments page number link for the current request.
*
* @since 2.7.0
*
* @param string $result The comments page number link.
*/
$result = apply_filters( 'get_comments_pagenum_link', $result );
return $result;
}
/**
* Return the link to next comments page.
*
* @since 2.7.1
*
* @param string $label Optional. Label for link text.
* @param int $max_page Optional. Max page.
* @return string|null
*/
function get_next_comments_link( $label = '', $max_page = 0 ) {
global $wp_query;
if ( !is_singular() || !get_option('page_comments') )
return;
$page = get_query_var('cpage');
$nextpage = intval($page) + 1;
if ( empty($max_page) )
$max_page = $wp_query->max_num_comment_pages;
if ( empty($max_page) )
$max_page = get_comment_pages_count();
if ( $nextpage > $max_page )
return;
if ( empty($label) )
$label = __('Newer Comments »');
/**
* Filter the anchor tag attributes for the next comments page link.
*
* @since 2.7.0
*
* @param string $attributes Attributes for the anchor tag.
*/
return '<a href="' . esc_url( get_comments_pagenum_link( $nextpage, $max_page ) ) . '" ' . apply_filters( 'next_comments_link_attributes', '' ) . '>'. preg_replace('/&([^#])(?![a-z]{1,8};)/i', '&$1', $label) .'</a>';
}
/**
* Display the link to next comments page.
*
* @since 2.7.0
*
* @param string $label Optional. Label for link text.
* @param int $max_page Optional. Max page.
*/
function next_comments_link( $label = '', $max_page = 0 ) {
echo get_next_comments_link( $label, $max_page );
}
/**
* Return the previous comments page link.
*
* @since 2.7.1
*
* @param string $label Optional. Label for comments link text.
* @return string|null
*/
function get_previous_comments_link( $label = '' ) {
if ( !is_singular() || !get_option('page_comments') )
return;
$page = get_query_var('cpage');
if ( intval($page) <= 1 )
return;
$prevpage = intval($page) - 1;
if ( empty($label) )
$label = __('« Older Comments');
/**
* Filter the anchor tag attributes for the previous comments page link.
*
* @since 2.7.0
*
* @param string $attributes Attributes for the anchor tag.
*/
return '<a href="' . esc_url( get_comments_pagenum_link( $prevpage ) ) . '" ' . apply_filters( 'previous_comments_link_attributes', '' ) . '>' . preg_replace('/&([^#])(?![a-z]{1,8};)/i', '&$1', $label) .'</a>';
}
/**
* Display the previous comments page link.
*
* @since 2.7.0
*
* @param string $label Optional. Label for comments link text.
*/
function previous_comments_link( $label = '' ) {
echo get_previous_comments_link( $label );
}
/**
* Create pagination links for the comments on the current post.
*
* @see paginate_links()
* @since 2.7.0
*
* @param string|array $args Optional args. See paginate_links().
* @return string Markup for pagination links.
*/
function paginate_comments_links($args = array()) {
global $wp_rewrite;
if ( !is_singular() || !get_option('page_comments') )
return;
$page = get_query_var('cpage');
if ( !$page )
$page = 1;
$max_page = get_comment_pages_count();
$defaults = array(
'base' => add_query_arg( 'cpage', '%#%' ),
'format' => '',
'total' => $max_page,
'current' => $page,
'echo' => true,
'add_fragment' => '#comments'
);
if ( $wp_rewrite->using_permalinks() )
$defaults['base'] = user_trailingslashit(trailingslashit(get_permalink()) . 'comment-page-%#%', 'commentpaged');
$args = wp_parse_args( $args, $defaults );
$page_links = paginate_links( $args );
if ( $args['echo'] )
echo $page_links;
else
return $page_links;
}
/**
* Retrieve the Press This bookmarklet link.
*
* Use this in 'a' element 'href' attribute.
*
* @since 2.6.0
*
* @return string
*/
function get_shortcut_link() {
// In case of breaking changes, version this. #WP20071
$link = "javascript:
var d=document,
w=window,
e=w.getSelection,
k=d.getSelection,
x=d.selection,
s=(e?e():(k)?k():(x?x.createRange().text:0)),
f='" . admin_url('press-this.php') . "',
l=d.location,
e=encodeURIComponent,
u=f+'?u='+e(l.href)+'&t='+e(d.title)+'&s='+e(s)+'&v=4';
a=function(){if(!w.open(u,'t','toolbar=0,resizable=1,scrollbars=1,status=1,width=720,height=570'))l.href=u;};
if (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0); else a();
void(0)";
$link = str_replace(array("\r", "\n", "\t"), '', $link);
/**
* Filter the Press This bookmarklet link.
*
* @since 2.6.0
*
* @param string $link The Press This bookmarklet link.
*/
return apply_filters( 'shortcut_link', $link );
}
/**
* Retrieve the home url for the current site.
*
* Returns the 'home' option with the appropriate protocol, 'https' if
* is_ssl() and 'http' otherwise. If $scheme is 'http' or 'https', is_ssl() is
* overridden.
*
* @since 3.0.0
*
* @uses get_home_url()
*
* @param string $path (optional) Path relative to the home url.
* @param string $scheme (optional) Scheme to give the home url context. Currently 'http', 'https', or 'relative'.
* @return string Home url link with optional path appended.
*/
function home_url( $path = '', $scheme = null ) {
return get_home_url( null, $path, $scheme );
}
/**
* Retrieve the home url for a given site.
*
* Returns the 'home' option with the appropriate protocol, 'https' if
* is_ssl() and 'http' otherwise. If $scheme is 'http' or 'https', is_ssl() is
* overridden.
*
* @since 3.0.0
*
* @param int $blog_id (optional) Blog ID. Defaults to current blog.
* @param string $path (optional) Path relative to the home url.
* @param string $scheme (optional) Scheme to give the home url context. Currently 'http', 'https', or 'relative'.
* @return string Home url link with optional path appended.
*/
function get_home_url( $blog_id = null, $path = '', $scheme = null ) {
$orig_scheme = $scheme;
if ( empty( $blog_id ) || !is_multisite() ) {
$url = get_option( 'home' );
} else {
switch_to_blog( $blog_id );
$url = get_option( 'home' );
restore_current_blog();
}
if ( ! in_array( $scheme, array( 'http', 'https', 'relative' ) ) ) {
if ( is_ssl() && ! is_admin() && 'wp-login.php' !== $GLOBALS['pagenow'] )
$scheme = 'https';
else
$scheme = parse_url( $url, PHP_URL_SCHEME );
}
$url = set_url_scheme( $url, $scheme );
if ( $path && is_string( $path ) )
$url .= '/' . ltrim( $path, '/' );
/**
* Filter the home URL.
*
* @since 3.0.0
*
* @param string $url The complete home URL including scheme and path.
* @param string $path Path relative to the home URL. Blank string if no path is specified.
* @param string|null $orig_scheme Scheme to give the home URL context. Accepts 'http', 'https', 'relative' or null.
* @param int|null $blog_id Blog ID, or null for the current blog.
*/
return apply_filters( 'home_url', $url, $path, $orig_scheme, $blog_id );
}
/**
* Retrieve the site url for the current site.
*
* Returns the 'site_url' option with the appropriate protocol, 'https' if
* is_ssl() and 'http' otherwise. If $scheme is 'http' or 'https', is_ssl() is
* overridden.
*
* @since 3.0.0
*
* @uses get_site_url()
*
* @param string $path Optional. Path relative to the site url.
* @param string $scheme Optional. Scheme to give the site url context. See set_url_scheme().
* @return string Site url link with optional path appended.
*/
function site_url( $path = '', $scheme = null ) {
return get_site_url( null, $path, $scheme );
}
/**
* Retrieve the site url for a given site.
*
* Returns the 'site_url' option with the appropriate protocol, 'https' if
* is_ssl() and 'http' otherwise. If $scheme is 'http' or 'https', is_ssl() is
* overridden.
*
* @since 3.0.0
*
* @param int $blog_id (optional) Blog ID. Defaults to current blog.
* @param string $path Optional. Path relative to the site url.
* @param string $scheme Optional. Scheme to give the site url context. Currently 'http', 'https', 'login', 'login_post', 'admin', or 'relative'.
* @return string Site url link with optional path appended.
*/
function get_site_url( $blog_id = null, $path = '', $scheme = null ) {
if ( empty( $blog_id ) || !is_multisite() ) {
$url = get_option( 'siteurl' );
} else {
switch_to_blog( $blog_id );
$url = get_option( 'siteurl' );
restore_current_blog();
}
$url = set_url_scheme( $url, $scheme );
if ( $path && is_string( $path ) )
$url .= '/' . ltrim( $path, '/' );
/**
* Filter the site URL.
*
* @since 2.7.0
*
* @param string $url The complete site URL including scheme and path.
* @param string $path Path relative to the site URL. Blank string if no path is specified.
* @param string|null $scheme Scheme to give the site URL context. Accepts 'http', 'https', 'login',
* 'login_post', 'admin', 'relative' or null.
* @param int|null $blog_id Blog ID, or null for the current blog.
*/
return apply_filters( 'site_url', $url, $path, $scheme, $blog_id );
}
/**
* Retrieve the url to the admin area for the current site.
*
* @since 2.6.0
*
* @param string $path Optional path relative to the admin url.
* @param string $scheme The scheme to use. Default is 'admin', which obeys force_ssl_admin() and is_ssl(). 'http' or 'https' can be passed to force those schemes.
* @return string Admin url link with optional path appended.
*/
function admin_url( $path = '', $scheme = 'admin' ) {
return get_admin_url( null, $path, $scheme );
}
/**
* Retrieve the url to the admin area for a given site.
*
* @since 3.0.0
*
* @param int $blog_id (optional) Blog ID. Defaults to current blog.
* @param string $path Optional path relative to the admin url.
* @param string $scheme The scheme to use. Default is 'admin', which obeys force_ssl_admin() and is_ssl(). 'http' or 'https' can be passed to force those schemes.
* @return string Admin url link with optional path appended.
*/
function get_admin_url( $blog_id = null, $path = '', $scheme = 'admin' ) {
$url = get_site_url($blog_id, 'wp-admin/', $scheme);
if ( $path && is_string( $path ) )
$url .= ltrim( $path, '/' );
/**
* Filter the admin area URL.
*
* @since 2.8.0
*
* @param string $url The complete admin area URL including scheme and path.
* @param string $path Path relative to the admin area URL. Blank string if no path is specified.
* @param int|null $blog_id Blog ID, or null for the current blog.
*/
return apply_filters( 'admin_url', $url, $path, $blog_id );
}
/**
* Retrieve the url to the includes directory.
*
* @since 2.6.0
*
* @param string $path Optional. Path relative to the includes url.
* @param string $scheme Optional. Scheme to give the includes url context.
* @return string Includes url link with optional path appended.
*/
function includes_url( $path = '', $scheme = null ) {
$url = site_url( '/' . WPINC . '/', $scheme );
if ( $path && is_string( $path ) )
$url .= ltrim($path, '/');
/**
* Filter the URL to the includes directory.
*
* @since 2.8.0
*
* @param string $url The complete URL to the includes directory including scheme and path.
* @param string $path Path relative to the URL to the wp-includes directory. Blank string
* if no path is specified.
*/
return apply_filters( 'includes_url', $url, $path );
}
/**
* Retrieve the url to the content directory.
*
* @since 2.6.0
*
* @param string $path Optional. Path relative to the content url.
* @return string Content url link with optional path appended.
*/
function content_url($path = '') {
$url = set_url_scheme( WP_CONTENT_URL );
if ( $path && is_string( $path ) )
$url .= '/' . ltrim($path, '/');
/**
* Filter the URL to the content directory.
*
* @since 2.8.0
*
* @param string $url The complete URL to the content directory including scheme and path.
* @param string $path Path relative to the URL to the content directory. Blank string
* if no path is specified.
*/
return apply_filters( 'content_url', $url, $path);
}
/**
* Retrieve the url to the plugins directory or to a specific file within that directory.
* You can hardcode the plugin slug in $path or pass __FILE__ as a second argument to get the correct folder name.
*
* @since 2.6.0
*
* @param string $path Optional. Path relative to the plugins url.
* @param string $plugin Optional. The plugin file that you want to be relative to - i.e. pass in __FILE__
* @return string Plugins url link with optional path appended.
*/
function plugins_url($path = '', $plugin = '') {
$mu_plugin_dir = WPMU_PLUGIN_DIR;
foreach ( array('path', 'plugin', 'mu_plugin_dir') as $var ) {
$$var = str_replace('\\' ,'/', $$var); // sanitize for Win32 installs
$$var = preg_replace('|/+|', '/', $$var);
}
if ( !empty($plugin) && 0 === strpos($plugin, $mu_plugin_dir) )
$url = WPMU_PLUGIN_URL;
else
$url = WP_PLUGIN_URL;
$url = set_url_scheme( $url );
if ( !empty($plugin) && is_string($plugin) ) {
$folder = dirname(plugin_basename($plugin));
if ( '.' != $folder )
$url .= '/' . ltrim($folder, '/');
}
if ( $path && is_string( $path ) )
$url .= '/' . ltrim($path, '/');
/**
* Filter the URL to the plugins directory.
*
* @since 2.8.0
*
* @param string $url The complete URL to the plugins directory including scheme and path.
* @param string $path Path relative to the URL to the plugins directory. Blank string
* if no path is specified.
* @param string $plugin The plugin file path to be relative to. Blank string if no plugin
* is specified.
*/
return apply_filters( 'plugins_url', $url, $path, $plugin );
}
/**
* Retrieve the site url for the current network.
*
* Returns the site url with the appropriate protocol, 'https' if
* is_ssl() and 'http' otherwise. If $scheme is 'http' or 'https', is_ssl() is
* overridden.
*
* @since 3.0.0
*
* @param string $path Optional. Path relative to the site url.
* @param string $scheme Optional. Scheme to give the site url context. See set_url_scheme().
* @return string Site url link with optional path appended.
*/
function network_site_url( $path = '', $scheme = null ) {
if ( ! is_multisite() )
return site_url($path, $scheme);
$current_site = get_current_site();
if ( 'relative' == $scheme )
$url = $current_site->path;
else
$url = set_url_scheme( 'http://' . $current_site->domain . $current_site->path, $scheme );
if ( $path && is_string( $path ) )
$url .= ltrim( $path, '/' );
/**
* Filter the network site URL.
*
* @since 3.0.0
*
* @param string $url The complete network site URL including scheme and path.
* @param string $path Path relative to the network site URL. Blank string if
* no path is specified.
* @param string|null $scheme Scheme to give the URL context. Accepts 'http', 'https',
* 'relative' or null.
*/
return apply_filters( 'network_site_url', $url, $path, $scheme );
}
/**
* Retrieve the home url for the current network.
*
* Returns the home url with the appropriate protocol, 'https' if
* is_ssl() and 'http' otherwise. If $scheme is 'http' or 'https', is_ssl() is
* overridden.
*
* @since 3.0.0
*
* @param string $path (optional) Path relative to the home url.
* @param string $scheme (optional) Scheme to give the home url context. Currently 'http', 'https', or 'relative'.
* @return string Home url link with optional path appended.
*/
function network_home_url( $path = '', $scheme = null ) {
if ( ! is_multisite() )
return home_url($path, $scheme);
$current_site = get_current_site();
$orig_scheme = $scheme;
if ( ! in_array( $scheme, array( 'http', 'https', 'relative' ) ) )
$scheme = is_ssl() && ! is_admin() ? 'https' : 'http';
if ( 'relative' == $scheme )
$url = $current_site->path;
else
$url = set_url_scheme( 'http://' . $current_site->domain . $current_site->path, $scheme );
if ( $path && is_string( $path ) )
$url .= ltrim( $path, '/' );
/**
* Filter the network home URL.
*
* @since 3.0.0
*
* @param string $url The complete network home URL including scheme and path.
* @param string $path Path relative to the network home URL. Blank string
* if no path is specified.
* @param string|null $orig_scheme Scheme to give the URL context. Accepts 'http', 'https',
* 'relative' or null.
*/
return apply_filters( 'network_home_url', $url, $path, $orig_scheme);
}
/**
* Retrieve the url to the admin area for the network.
*
* @since 3.0.0
*
* @param string $path Optional path relative to the admin url.
* @param string $scheme The scheme to use. Default is 'admin', which obeys force_ssl_admin() and is_ssl(). 'http' or 'https' can be passed to force those schemes.
* @return string Admin url link with optional path appended.
*/
function network_admin_url( $path = '', $scheme = 'admin' ) {
if ( ! is_multisite() )
return admin_url( $path, $scheme );
$url = network_site_url('wp-admin/network/', $scheme);
if ( $path && is_string( $path ) )
$url .= ltrim($path, '/');
/**
* Filter the network admin URL.
*
* @since 3.0.0
*
* @param string $url The complete network admin URL including scheme and path.
* @param string $path Path relative to the network admin URL. Blank string if
* no path is specified.
*/
return apply_filters( 'network_admin_url', $url, $path );
}
/**
* Retrieve the url to the admin area for the current user.
*
* @since 3.0.0
*
* @param string $path Optional path relative to the admin url.
* @param string $scheme The scheme to use. Default is 'admin', which obeys force_ssl_admin() and is_ssl(). 'http' or 'https' can be passed to force those schemes.
* @return string Admin url link with optional path appended.
*/
function user_admin_url( $path = '', $scheme = 'admin' ) {
$url = network_site_url('wp-admin/user/', $scheme);
if ( $path && is_string( $path ) )
$url .= ltrim($path, '/');
/**
* Filter the user admin URL for the current user.
*
* @since 3.1.0
*
* @param string $url The complete URL including scheme and path.
* @param string $path Path relative to the URL. Blank string if
* no path is specified.
*/
return apply_filters( 'user_admin_url', $url, $path );
}
/**
* Retrieve the url to the admin area for either the current blog or the network depending on context.
*
* @since 3.1.0
*
* @param string $path Optional path relative to the admin url.
* @param string $scheme The scheme to use. Default is 'admin', which obeys force_ssl_admin() and is_ssl(). 'http' or 'https' can be passed to force those schemes.
* @return string Admin url link with optional path appended.
*/
function self_admin_url($path = '', $scheme = 'admin') {
if ( is_network_admin() )
return network_admin_url($path, $scheme);
elseif ( is_user_admin() )
return user_admin_url($path, $scheme);
else
return admin_url($path, $scheme);
}
/**
* Set the scheme for a URL
*
* @since 3.4.0
*
* @param string $url Absolute url that includes a scheme
* @param string $scheme Optional. Scheme to give $url. Currently 'http', 'https', 'login', 'login_post', 'admin', or 'relative'.
* @return string $url URL with chosen scheme.
*/
function set_url_scheme( $url, $scheme = null ) {
$orig_scheme = $scheme;
if ( ! in_array( $scheme, array( 'http', 'https', 'relative' ) ) ) {
if ( ( 'login_post' == $scheme || 'rpc' == $scheme ) && ( force_ssl_login() || force_ssl_admin() ) )
$scheme = 'https';
elseif ( ( 'login' == $scheme ) && force_ssl_admin() )
$scheme = 'https';
elseif ( ( 'admin' == $scheme ) && force_ssl_admin() )
$scheme = 'https';
else
$scheme = ( is_ssl() ? 'https' : 'http' );
}
$url = trim( $url );
if ( substr( $url, 0, 2 ) === '//' )
$url = 'http:' . $url;
if ( 'relative' == $scheme ) {
$url = ltrim( preg_replace( '#^\w+://[^/]*#', '', $url ) );
if ( $url !== '' && $url[0] === '/' )
$url = '/' . ltrim($url , "/ \t\n\r\0\x0B" );
} else {
$url = preg_replace( '#^\w+://#', $scheme . '://', $url );
}
/**
* Filter the resulting URL after setting the scheme.
*
* @since 3.4.0
*
* @param string $url The complete URL including scheme and path.
* @param string $scheme Scheme applied to the URL. One of 'http', 'https', or 'relative'.
* @param string $orig_scheme Scheme requested for the URL. One of 'http', 'https', 'login',
* 'login_post', 'admin', 'rpc', or 'relative'.
*/
return apply_filters( 'set_url_scheme', $url, $scheme, $orig_scheme );
}
/**
* Get the URL to the user's dashboard.
*
* If a user does not belong to any site, the global user dashboard is used. If the user belongs to the current site,
* the dashboard for the current site is returned. If the user cannot edit the current site, the dashboard to the user's
* primary blog is returned.
*
* @since 3.1.0
*
* @param int $user_id Optional. User ID. Defaults to current user.
* @param string $path Optional path relative to the dashboard. Use only paths known to both blog and user admins.
* @param string $scheme The scheme to use. Default is 'admin', which obeys force_ssl_admin() and is_ssl(). 'http' or 'https' can be passed to force those schemes.
* @return string Dashboard url link with optional path appended.
*/
function get_dashboard_url( $user_id = 0, $path = '', $scheme = 'admin' ) {
$user_id = $user_id ? (int) $user_id : get_current_user_id();
$blogs = get_blogs_of_user( $user_id );
if ( ! is_super_admin() && empty($blogs) ) {
$url = user_admin_url( $path, $scheme );
} elseif ( ! is_multisite() ) {
$url = admin_url( $path, $scheme );
} else {
$current_blog = get_current_blog_id();
if ( $current_blog && ( is_super_admin( $user_id ) || in_array( $current_blog, array_keys( $blogs ) ) ) ) {
$url = admin_url( $path, $scheme );
} else {
$active = get_active_blog_for_user( $user_id );
if ( $active )
$url = get_admin_url( $active->blog_id, $path, $scheme );
else
$url = user_admin_url( $path, $scheme );
}
}
/**
* Filter the dashboard URL for a user.
*
* @since 3.1.0
*
* @param string $url The complete URL including scheme and path.
* @param int $user_id The user ID.
* @param string $path Path relative to the URL. Blank string if no path is specified.
* @param string $scheme Scheme to give the URL context. Accepts 'http', 'https', 'login',
* 'login_post', 'admin', 'relative' or null.
*/
return apply_filters( 'user_dashboard_url', $url, $user_id, $path, $scheme);
}
/**
* Get the URL to the user's profile editor.
*
* @since 3.1.0
*
* @param int $user_id Optional. User ID. Defaults to current user.
* @param string $scheme The scheme to use. Default is 'admin', which obeys force_ssl_admin() and is_ssl().
* 'http' or 'https' can be passed to force those schemes.
* @return string Dashboard url link with optional path appended.
*/
function get_edit_profile_url( $user_id = 0, $scheme = 'admin' ) {
$user_id = $user_id ? (int) $user_id : get_current_user_id();
if ( is_user_admin() )
$url = user_admin_url( 'profile.php', $scheme );
elseif ( is_network_admin() )
$url = network_admin_url( 'profile.php', $scheme );
else
$url = get_dashboard_url( $user_id, 'profile.php', $scheme );
/**
* Filter the URL for a user's profile editor.
*
* @since 3.1.0
*
* @param string $url The complete URL including scheme and path.
* @param int $user_id The user ID.
* @param string $scheme Scheme to give the URL context. Accepts 'http', 'https', 'login',
* 'login_post', 'admin', 'relative' or null.
*/
return apply_filters( 'edit_profile_url', $url, $user_id, $scheme);
}
/**
* Output rel=canonical for singular queries.
*
* @since 2.9.0
*/
function rel_canonical() {
if ( !is_singular() )
return;
global $wp_the_query;
if ( !$id = $wp_the_query->get_queried_object_id() )
return;
$link = get_permalink( $id );
if ( $page = get_query_var('cpage') )
$link = get_comments_pagenum_link( $page );
echo "<link rel='canonical' href='$link' />\n";
}
/**
* Return a shortlink for a post, page, attachment, or blog.
*
* This function exists to provide a shortlink tag that all themes and plugins can target. A plugin must hook in to
* provide the actual shortlinks. Default shortlink support is limited to providing ?p= style links for posts.
* Plugins can short-circuit this function via the pre_get_shortlink filter or filter the output
* via the get_shortlink filter.
*
* @since 3.0.0.
*
* @param int $id A post or blog id. Default is 0, which means the current post or blog.
* @param string $context Whether the id is a 'blog' id, 'post' id, or 'media' id. If 'post', the post_type of the post is consulted. If 'query', the current query is consulted to determine the id and context. Default is 'post'.
* @param bool $allow_slugs Whether to allow post slugs in the shortlink. It is up to the plugin how and whether to honor this.
* @return string A shortlink or an empty string if no shortlink exists for the requested resource or if shortlinks are not enabled.
*/
function wp_get_shortlink($id = 0, $context = 'post', $allow_slugs = true) {
/**
* Filter whether to preempt generating a shortlink for the given post.
*
* Passing a truthy value to the filter will effectively short-circuit the
* shortlink-generation process, returning that value instead.
*
* @since 3.0.0
*
* @param bool|string $return Short-circuit return value. Either false or a URL string.
* @param int $id Post ID, or 0 for the current post.
* @param string $context The context for the link. One of 'post' or 'query',
* @param bool $allow_slugs Whether to allow post slugs in the shortlink.
*/
$shortlink = apply_filters( 'pre_get_shortlink', false, $id, $context, $allow_slugs );
if ( false !== $shortlink )
return $shortlink;
global $wp_query;
$post_id = 0;
if ( 'query' == $context && is_singular() ) {
$post_id = $wp_query->get_queried_object_id();
$post = get_post( $post_id );
} elseif ( 'post' == $context ) {
$post = get_post( $id );
if ( ! empty( $post->ID ) )
$post_id = $post->ID;
}
$shortlink = '';
// Return p= link for all public post types.
if ( ! empty( $post_id ) ) {
$post_type = get_post_type_object( $post->post_type );
if ( 'page' === $post->post_type && $post->ID == get_option( 'page_on_front' ) && 'page' == get_option( 'show_on_front' ) ) {
$shortlink = home_url( '/' );
} elseif ( $post_type->public ) {
$shortlink = home_url( '?p=' . $post_id );
}
}
/**
* Filter the shortlink for a post.
*
* @since 3.0.0
*
* @param string $shortlink Shortlink URL.
* @param int $id Post ID, or 0 for the current post.
* @param string $context The context for the link. One of 'post' or 'query',
* @param bool $allow_slugs Whether to allow post slugs in the shortlink. Not used by default.
*/
return apply_filters( 'get_shortlink', $shortlink, $id, $context, $allow_slugs );
}
/**
* Inject rel=shortlink into head if a shortlink is defined for the current page.
*
* Attached to the wp_head action.
*
* @since 3.0.0
*
* @uses wp_get_shortlink()
*/
function wp_shortlink_wp_head() {
$shortlink = wp_get_shortlink( 0, 'query' );
if ( empty( $shortlink ) )
return;
echo "<link rel='shortlink' href='" . esc_url( $shortlink ) . "' />\n";
}
/**
* Send a Link: rel=shortlink header if a shortlink is defined for the current page.
*
* Attached to the wp action.
*
* @since 3.0.0
*
* @uses wp_get_shortlink()
*/
function wp_shortlink_header() {
if ( headers_sent() )
return;
$shortlink = wp_get_shortlink(0, 'query');
if ( empty($shortlink) )
return;
header('Link: <' . $shortlink . '>; rel=shortlink', false);
}
/**
* Display the Short Link for a Post
*
* Must be called from inside "The Loop"
*
* Call like the_shortlink(__('Shortlinkage FTW'))
*
* @since 3.0.0
*
* @param string $text Optional The link text or HTML to be displayed. Defaults to 'This is the short link.'
* @param string $title Optional The tooltip for the link. Must be sanitized. Defaults to the sanitized post title.
* @param string $before Optional HTML to display before the link.
* @param string $after Optional HTML to display after the link.
*/
function the_shortlink( $text = '', $title = '', $before = '', $after = '' ) {
$post = get_post();
if ( empty( $text ) )
$text = __('This is the short link.');
if ( empty( $title ) )
$title = the_title_attribute( array( 'echo' => false ) );
$shortlink = wp_get_shortlink( $post->ID );
if ( !empty( $shortlink ) ) {
$link = '<a rel="shortlink" href="' . esc_url( $shortlink ) . '" title="' . $title . '">' . $text . '</a>';
/**
* Filter the shortlink anchor tag for a post.
*
* @since 3.0.0
*
* @param string $link Shortlink anchor tag.
* @param string $shortlink Shortlink URL.
* @param string $text Shortlink's text.
* @param string $title Shortlink's title attribute.
*/
$link = apply_filters( 'the_shortlink', $link, $shortlink, $text, $title );
echo $before, $link, $after;
}
}
| 01-wordpress-paypal | trunk/wp-includes/link-template.php | PHP | gpl3 | 95,521 |
<?php
/**
* Customize Setting Class.
*
* Handles saving and sanitizing of settings.
*
* @package WordPress
* @subpackage Customize
* @since 3.4.0
*/
class WP_Customize_Setting {
/**
* @access public
* @var WP_Customize_Manager
*/
public $manager;
/**
* @access public
* @var string
*/
public $id;
/**
* @access public
* @var string
*/
public $type = 'theme_mod';
/**
* Capability required to edit this setting.
*
* @var string
*/
public $capability = 'edit_theme_options';
/**
* Feature a theme is required to support to enable this setting.
*
* @access public
* @var string
*/
public $theme_supports = '';
public $default = '';
public $transport = 'refresh';
/**
* Server-side sanitization callback for the setting's value.
*
* @var callback
*/
public $sanitize_callback = '';
public $sanitize_js_callback = '';
protected $id_data = array();
/**
* Cached and sanitized $_POST value for the setting.
*
* @access private
* @var mixed
*/
private $_post_value;
/**
* Constructor.
*
* Any supplied $args override class property defaults.
*
* @since 3.4.0
*
* @param WP_Customize_Manager $manager
* @param string $id An specific ID of the setting. Can be a
* theme mod or option name.
* @param array $args Setting arguments.
* @return WP_Customize_Setting $setting
*/
function __construct( $manager, $id, $args = array() ) {
$keys = array_keys( get_class_vars( __CLASS__ ) );
foreach ( $keys as $key ) {
if ( isset( $args[ $key ] ) )
$this->$key = $args[ $key ];
}
$this->manager = $manager;
$this->id = $id;
// Parse the ID for array keys.
$this->id_data[ 'keys' ] = preg_split( '/\[/', str_replace( ']', '', $this->id ) );
$this->id_data[ 'base' ] = array_shift( $this->id_data[ 'keys' ] );
// Rebuild the ID.
$this->id = $this->id_data[ 'base' ];
if ( ! empty( $this->id_data[ 'keys' ] ) )
$this->id .= '[' . implode( '][', $this->id_data[ 'keys' ] ) . ']';
if ( $this->sanitize_callback )
add_filter( "customize_sanitize_{$this->id}", $this->sanitize_callback, 10, 2 );
if ( $this->sanitize_js_callback )
add_filter( "customize_sanitize_js_{$this->id}", $this->sanitize_js_callback, 10, 2 );
return $this;
}
/**
* Handle previewing the setting.
*
* @since 3.4.0
*/
public function preview() {
switch( $this->type ) {
case 'theme_mod' :
add_filter( 'theme_mod_' . $this->id_data[ 'base' ], array( $this, '_preview_filter' ) );
break;
case 'option' :
if ( empty( $this->id_data[ 'keys' ] ) )
add_filter( 'pre_option_' . $this->id_data[ 'base' ], array( $this, '_preview_filter' ) );
else {
add_filter( 'option_' . $this->id_data[ 'base' ], array( $this, '_preview_filter' ) );
add_filter( 'default_option_' . $this->id_data[ 'base' ], array( $this, '_preview_filter' ) );
}
break;
default :
/**
* Fires when the WP_Customize_Setting::preview() method is called for settings
* not handled as theme_mods or options.
*
* The dynamic portion of the hook name, $this->id, refers to the setting ID.
*
* @since 3.4.0
*/
do_action( 'customize_preview_' . $this->id );
}
}
/**
* Callback function to filter the theme mods and options.
*
* @since 3.4.0
* @uses WP_Customize_Setting::multidimensional_replace()
*
* @param mixed $original Old value.
* @return mixed New or old value.
*/
public function _preview_filter( $original ) {
return $this->multidimensional_replace( $original, $this->id_data[ 'keys' ], $this->post_value() );
}
/**
* Check user capabilities and theme supports, and then save
* the value of the setting.
*
* @since 3.4.0
*
* @return bool False if cap check fails or value isn't set.
*/
public final function save() {
$value = $this->post_value();
if ( ! $this->check_capabilities() || ! isset( $value ) )
return false;
/**
* Fires when the WP_Customize_Setting::save() method is called for settings
* not handled as theme_mods or options.
*
* The dynamic portion of the hook name, $this->id_data['base'] refers to
* the base slug of the setting name.
*
* @since 3.4.0
*/
do_action( 'customize_save_' . $this->id_data[ 'base' ] );
$this->update( $value );
}
/**
* Fetch and sanitize the $_POST value for the setting.
*
* @since 3.4.0
*
* @param mixed $default A default value which is used as a fallback. Default is null.
* @return mixed The default value on failure, otherwise the sanitized value.
*/
public final function post_value( $default = null ) {
// Check for a cached value
if ( isset( $this->_post_value ) )
return $this->_post_value;
// Call the manager for the post value
$result = $this->manager->post_value( $this );
if ( isset( $result ) )
return $this->_post_value = $result;
else
return $default;
}
/**
* Sanitize an input.
*
* @since 3.4.0
*
* @param mixed $value The value to sanitize.
* @return mixed Null if an input isn't valid, otherwise the sanitized value.
*/
public function sanitize( $value ) {
$value = wp_unslash( $value );
/**
* Filter a Customize setting value in un-slashed form.
*
* @since 3.4.0
*
* @param mixed $value Value of the setting.
* @param WP_Customize_Setting $this WP_Customize_Setting instance.
*/
return apply_filters( "customize_sanitize_{$this->id}", $value, $this );
}
/**
* Save the value of the setting, using the related API.
*
* @since 3.4.0
*
* @param mixed $value The value to update.
* @return mixed The result of saving the value.
*/
protected function update( $value ) {
switch( $this->type ) {
case 'theme_mod' :
return $this->_update_theme_mod( $value );
break;
case 'option' :
return $this->_update_option( $value );
break;
default :
/**
* Fires when the WP_Customize_Setting::update() method is called for settings
* not handled as theme_mods or options.
*
* The dynamic portion of the hook name, $this->type, refers to the type of setting.
*
* @since 3.4.0
*
* @param mixed $value Value of the setting.
*/
return do_action( 'customize_update_' . $this->type, $value );
}
}
/**
* Update the theme mod from the value of the parameter.
*
* @since 3.4.0
*
* @param mixed $value The value to update.
* @return mixed The result of saving the value.
*/
protected function _update_theme_mod( $value ) {
// Handle non-array theme mod.
if ( empty( $this->id_data[ 'keys' ] ) )
return set_theme_mod( $this->id_data[ 'base' ], $value );
// Handle array-based theme mod.
$mods = get_theme_mod( $this->id_data[ 'base' ] );
$mods = $this->multidimensional_replace( $mods, $this->id_data[ 'keys' ], $value );
if ( isset( $mods ) )
return set_theme_mod( $this->id_data[ 'base' ], $mods );
}
/**
* Update the option from the value of the setting.
*
* @since 3.4.0
*
* @param mixed $value The value to update.
* @return mixed The result of saving the value.
*/
protected function _update_option( $value ) {
// Handle non-array option.
if ( empty( $this->id_data[ 'keys' ] ) )
return update_option( $this->id_data[ 'base' ], $value );
// Handle array-based options.
$options = get_option( $this->id_data[ 'base' ] );
$options = $this->multidimensional_replace( $options, $this->id_data[ 'keys' ], $value );
if ( isset( $options ) )
return update_option( $this->id_data[ 'base' ], $options );
}
/**
* Fetch the value of the setting.
*
* @since 3.4.0
*
* @return mixed The value.
*/
public function value() {
// Get the callback that corresponds to the setting type.
switch( $this->type ) {
case 'theme_mod' :
$function = 'get_theme_mod';
break;
case 'option' :
$function = 'get_option';
break;
default :
/**
* Filter a Customize setting value not handled as a theme_mod or option.
*
* The dynamic portion of the hook name, $this->id_date['base'], refers to
* the base slug of the setting name.
*
* For settings handled as theme_mods or options, see those corresponding
* functions for available hooks.
*
* @since 3.4.0
*
* @param mixed $default The setting default value. Default empty.
*/
return apply_filters( 'customize_value_' . $this->id_data[ 'base' ], $this->default );
}
// Handle non-array value
if ( empty( $this->id_data[ 'keys' ] ) )
return $function( $this->id_data[ 'base' ], $this->default );
// Handle array-based value
$values = $function( $this->id_data[ 'base' ] );
return $this->multidimensional_get( $values, $this->id_data[ 'keys' ], $this->default );
}
/**
* Sanitize the setting's value for use in JavaScript.
*
* @since 3.4.0
*
* @return mixed The requested escaped value.
*/
public function js_value() {
/**
* Filter a Customize setting value for use in JavaScript.
*
* The dynamic portion of the hook name, $this->id, refers to the setting ID.
*
* @since 3.4.0
*
* @param mixed $value The setting value.
* @param WP_Customize_Setting $this WP_Customize_Setting instance.
*/
$value = apply_filters( "customize_sanitize_js_{$this->id}", $this->value(), $this );
if ( is_string( $value ) )
return html_entity_decode( $value, ENT_QUOTES, 'UTF-8');
return $value;
}
/**
* Validate user capabilities whether the theme supports the setting.
*
* @since 3.4.0
*
* @return bool False if theme doesn't support the setting or user can't change setting, otherwise true.
*/
public final function check_capabilities() {
if ( $this->capability && ! call_user_func_array( 'current_user_can', (array) $this->capability ) )
return false;
if ( $this->theme_supports && ! call_user_func_array( 'current_theme_supports', (array) $this->theme_supports ) )
return false;
return true;
}
/**
* Multidimensional helper function.
*
* @since 3.4.0
*
* @param $root
* @param $keys
* @param bool $create Default is false.
* @return null|array Keys are 'root', 'node', and 'key'.
*/
final protected function multidimensional( &$root, $keys, $create = false ) {
if ( $create && empty( $root ) )
$root = array();
if ( ! isset( $root ) || empty( $keys ) )
return;
$last = array_pop( $keys );
$node = &$root;
foreach ( $keys as $key ) {
if ( $create && ! isset( $node[ $key ] ) )
$node[ $key ] = array();
if ( ! is_array( $node ) || ! isset( $node[ $key ] ) )
return;
$node = &$node[ $key ];
}
if ( $create && ! isset( $node[ $last ] ) )
$node[ $last ] = array();
if ( ! isset( $node[ $last ] ) )
return;
return array(
'root' => &$root,
'node' => &$node,
'key' => $last,
);
}
/**
* Will attempt to replace a specific value in a multidimensional array.
*
* @since 3.4.0
*
* @param $root
* @param $keys
* @param mixed $value The value to update.
* @return
*/
final protected function multidimensional_replace( $root, $keys, $value ) {
if ( ! isset( $value ) )
return $root;
elseif ( empty( $keys ) ) // If there are no keys, we're replacing the root.
return $value;
$result = $this->multidimensional( $root, $keys, true );
if ( isset( $result ) )
$result['node'][ $result['key'] ] = $value;
return $root;
}
/**
* Will attempt to fetch a specific value from a multidimensional array.
*
* @since 3.4.0
*
* @param $root
* @param $keys
* @param $default A default value which is used as a fallback. Default is null.
* @return mixed The requested value or the default value.
*/
final protected function multidimensional_get( $root, $keys, $default = null ) {
if ( empty( $keys ) ) // If there are no keys, test the root.
return isset( $root ) ? $root : $default;
$result = $this->multidimensional( $root, $keys );
return isset( $result ) ? $result['node'][ $result['key'] ] : $default;
}
/**
* Will attempt to check if a specific value in a multidimensional array is set.
*
* @since 3.4.0
*
* @param $root
* @param $keys
* @return bool True if value is set, false if not.
*/
final protected function multidimensional_isset( $root, $keys ) {
$result = $this->multidimensional_get( $root, $keys );
return isset( $result );
}
}
/**
* A setting that is used to filter a value, but will not save the results.
*
* Results should be properly handled using another setting or callback.
*
* @package WordPress
* @subpackage Customize
* @since 3.4.0
*/
class WP_Customize_Filter_Setting extends WP_Customize_Setting {
/**
* @since 3.4.0
*/
public function update( $value ) {}
}
/**
* A setting that is used to filter a value, but will not save the results.
*
* Results should be properly handled using another setting or callback.
*
* @package WordPress
* @subpackage Customize
* @since 3.4.0
*/
final class WP_Customize_Header_Image_Setting extends WP_Customize_Setting {
public $id = 'header_image_data';
/**
* @since 3.4.0
*
* @param $value
*/
public function update( $value ) {
global $custom_image_header;
// If the value doesn't exist (removed or random),
// use the header_image value.
if ( ! $value )
$value = $this->manager->get_setting('header_image')->post_value();
if ( is_array( $value ) && isset( $value['choice'] ) )
$custom_image_header->set_header_image( $value['choice'] );
else
$custom_image_header->set_header_image( $value );
}
}
/**
* Class WP_Customize_Background_Image_Setting
*
* @package WordPress
* @subpackage Customize
* @since 3.4.0
*/
final class WP_Customize_Background_Image_Setting extends WP_Customize_Setting {
public $id = 'background_image_thumb';
/**
* @since 3.4.0
* @uses remove_theme_mod()
*
* @param $value
*/
public function update( $value ) {
remove_theme_mod( 'background_image_thumb' );
}
}
| 01-wordpress-paypal | trunk/wp-includes/class-wp-customize-setting.php | PHP | gpl3 | 14,096 |
<?php
/**
* Main WordPress Formatting API.
*
* Handles many functions for formatting output.
*
* @package WordPress
*/
/**
* Replaces common plain text characters into formatted entities
*
* As an example,
* <code>
* 'cause today's effort makes it worth tomorrow's "holiday"...
* </code>
* Becomes:
* <code>
* ’cause today’s effort makes it worth tomorrow’s “holiday”…
* </code>
* Code within certain html blocks are skipped.
*
* @since 0.71
* @uses $wp_cockneyreplace Array of formatted entities for certain common phrases
*
* @param string $text The text to be formatted
* @return string The string replaced with html entities
*/
function wptexturize($text) {
global $wp_cockneyreplace;
static $static_characters, $static_replacements, $dynamic_characters, $dynamic_replacements,
$default_no_texturize_tags, $default_no_texturize_shortcodes;
// No need to set up these static variables more than once
if ( ! isset( $static_characters ) ) {
/* translators: opening curly double quote */
$opening_quote = _x( '“', 'opening curly double quote' );
/* translators: closing curly double quote */
$closing_quote = _x( '”', 'closing curly double quote' );
/* translators: apostrophe, for example in 'cause or can't */
$apos = _x( '’', 'apostrophe' );
/* translators: prime, for example in 9' (nine feet) */
$prime = _x( '′', 'prime' );
/* translators: double prime, for example in 9" (nine inches) */
$double_prime = _x( '″', 'double prime' );
/* translators: opening curly single quote */
$opening_single_quote = _x( '‘', 'opening curly single quote' );
/* translators: closing curly single quote */
$closing_single_quote = _x( '’', 'closing curly single quote' );
/* translators: en dash */
$en_dash = _x( '–', 'en dash' );
/* translators: em dash */
$em_dash = _x( '—', 'em dash' );
$default_no_texturize_tags = array('pre', 'code', 'kbd', 'style', 'script', 'tt');
$default_no_texturize_shortcodes = array('code');
// if a plugin has provided an autocorrect array, use it
if ( isset($wp_cockneyreplace) ) {
$cockney = array_keys($wp_cockneyreplace);
$cockneyreplace = array_values($wp_cockneyreplace);
} elseif ( "'" != $apos ) { // Only bother if we're doing a replacement.
$cockney = array( "'tain't", "'twere", "'twas", "'tis", "'twill", "'til", "'bout", "'nuff", "'round", "'cause" );
$cockneyreplace = array( $apos . "tain" . $apos . "t", $apos . "twere", $apos . "twas", $apos . "tis", $apos . "twill", $apos . "til", $apos . "bout", $apos . "nuff", $apos . "round", $apos . "cause" );
} else {
$cockney = $cockneyreplace = array();
}
$static_characters = array_merge( array( '---', ' -- ', '--', ' - ', 'xn–', '...', '``', '\'\'', ' (tm)' ), $cockney );
$static_replacements = array_merge( array( $em_dash, ' ' . $em_dash . ' ', $en_dash, ' ' . $en_dash . ' ', 'xn--', '…', $opening_quote, $closing_quote, ' ™' ), $cockneyreplace );
/*
* Regex for common whitespace characters.
*
* By default, spaces include new lines, tabs, nbsp entities, and the UTF-8 nbsp.
* This is designed to replace the PCRE \s sequence. In #WP22692, that sequence
* was found to be unreliable due to random inclusion of the A0 byte.
*/
$spaces = '[\r\n\t ]|\xC2\xA0| ';
// Pattern-based replacements of characters.
$dynamic = array();
// '99 '99s '99's (apostrophe)
if ( "'" !== $apos ) {
$dynamic[ '/\'(?=\d)/' ] = $apos;
}
// Single quote at start, or preceded by (, {, <, [, ", or spaces.
if ( "'" !== $opening_single_quote ) {
$dynamic[ '/(?<=\A|[([{<"]|' . $spaces . ')\'/' ] = $opening_single_quote;
}
// 9" (double prime)
if ( '"' !== $double_prime ) {
$dynamic[ '/(?<=\d)"/' ] = $double_prime;
}
// 9' (prime)
if ( "'" !== $prime ) {
$dynamic[ '/(?<=\d)\'/' ] = $prime;
}
// Apostrophe in a word. No spaces or double primes.
if ( "'" !== $apos ) {
$dynamic[ '/(?<!' . $spaces . ')\'(?!\'|' . $spaces . ')/' ] = $apos;
}
// Double quote at start, or preceded by (, {, <, [, or spaces, and not followed by spaces.
if ( '"' !== $opening_quote ) {
$dynamic[ '/(?<=\A|[([{<]|' . $spaces . ')"(?!' . $spaces . ')/' ] = $opening_quote;
}
// Any remaining double quotes.
if ( '"' !== $closing_quote ) {
$dynamic[ '/"/' ] = $closing_quote;
}
// Single quotes followed by spaces or a period.
if ( "'" !== $closing_single_quote ) {
$dynamic[ '/\'(?=\Z|\.|' . $spaces . ')/' ] = $closing_single_quote;
}
$dynamic_characters = array_keys( $dynamic );
$dynamic_replacements = array_values( $dynamic );
}
// Transform into regexp sub-expression used in _wptexturize_pushpop_element
// Must do this every time in case plugins use these filters in a context sensitive manner
/**
* Filter the list of HTML elements not to texturize.
*
* @since 2.8.0
*
* @param array $default_no_texturize_tags An array of HTML element names.
*/
$no_texturize_tags = '(' . implode( '|', apply_filters( 'no_texturize_tags', $default_no_texturize_tags ) ) . ')';
/**
* Filter the list of shortcodes not to texturize.
*
* @since 2.8.0
*
* @param array $default_no_texturize_shortcodes An array of shortcode names.
*/
$no_texturize_shortcodes = '(' . implode( '|', apply_filters( 'no_texturize_shortcodes', $default_no_texturize_shortcodes ) ) . ')';
$no_texturize_tags_stack = array();
$no_texturize_shortcodes_stack = array();
$textarr = preg_split('/(<.*>|\[.*\])/Us', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
foreach ( $textarr as &$curl ) {
if ( empty( $curl ) ) {
continue;
}
// Only call _wptexturize_pushpop_element if first char is correct tag opening
$first = $curl[0];
if ( '<' === $first ) {
_wptexturize_pushpop_element($curl, $no_texturize_tags_stack, $no_texturize_tags, '<', '>');
} elseif ( '[' === $first ) {
_wptexturize_pushpop_element($curl, $no_texturize_shortcodes_stack, $no_texturize_shortcodes, '[', ']');
} elseif ( empty($no_texturize_shortcodes_stack) && empty($no_texturize_tags_stack) ) {
// This is not a tag, nor is the texturization disabled static strings
$curl = str_replace($static_characters, $static_replacements, $curl);
// regular expressions
$curl = preg_replace($dynamic_characters, $dynamic_replacements, $curl);
// 9x9 (times)
if ( 1 === preg_match( '/(?<=\d)x\d/', $text ) ) {
// Searching for a digit is 10 times more expensive than for the x, so we avoid doing this one!
$curl = preg_replace( '/\b(\d+)x(\d+)\b/', '$1×$2', $curl );
}
}
// Replace each & with & unless it already looks like an entity.
$curl = preg_replace('/&([^#])(?![a-zA-Z1-4]{1,8};)/', '&$1', $curl);
}
return implode( '', $textarr );
}
/**
* Search for disabled element tags. Push element to stack on tag open and pop
* on tag close. Assumes first character of $text is tag opening.
*
* @since 2.9.0
* @access private
*
* @param string $text Text to check. First character is assumed to be $opening
* @param array $stack Array used as stack of opened tag elements
* @param string $disabled_elements Tags to match against formatted as regexp sub-expression
* @param string $opening Tag opening character, assumed to be 1 character long
* @param string $closing Tag closing character
*/
function _wptexturize_pushpop_element($text, &$stack, $disabled_elements, $opening = '<', $closing = '>') {
// Check if it is a closing tag -- otherwise assume opening tag
if (strncmp($opening . '/', $text, 2)) {
// Opening? Check $text+1 against disabled elements
if (preg_match('/^' . $disabled_elements . '\b/', substr($text, 1), $matches)) {
/*
* This disables texturize until we find a closing tag of our type
* (e.g. <pre>) even if there was invalid nesting before that
*
* Example: in the case <pre>sadsadasd</code>"baba"</pre>
* "baba" won't be texturize
*/
array_push($stack, $matches[1]);
}
} else {
// Closing? Check $text+2 against disabled elements
$c = preg_quote($closing, '/');
if (preg_match('/^' . $disabled_elements . $c . '/', substr($text, 2), $matches)) {
$last = array_pop($stack);
// Make sure it matches the opening tag
if ( $last != $matches[1] ) {
array_push( $stack, $last );
}
}
}
}
/**
* Replaces double line-breaks with paragraph elements.
*
* A group of regex replaces used to identify text formatted with newlines and
* replace double line-breaks with HTML paragraph tags. The remaining
* line-breaks after conversion become <<br />> tags, unless $br is set to '0'
* or 'false'.
*
* @since 0.71
*
* @param string $pee The text which has to be formatted.
* @param bool $br Optional. If set, this will convert all remaining line-breaks after paragraphing. Default true.
* @return string Text which has been converted into correct paragraph tags.
*/
function wpautop($pee, $br = true) {
$pre_tags = array();
if ( trim($pee) === '' )
return '';
$pee = $pee . "\n"; // just to make things a little easier, pad the end
if ( strpos($pee, '<pre') !== false ) {
$pee_parts = explode( '</pre>', $pee );
$last_pee = array_pop($pee_parts);
$pee = '';
$i = 0;
foreach ( $pee_parts as $pee_part ) {
$start = strpos($pee_part, '<pre');
// Malformed html?
if ( $start === false ) {
$pee .= $pee_part;
continue;
}
$name = "<pre wp-pre-tag-$i></pre>";
$pre_tags[$name] = substr( $pee_part, $start ) . '</pre>';
$pee .= substr( $pee_part, 0, $start ) . $name;
$i++;
}
$pee .= $last_pee;
}
$pee = preg_replace('|<br />\s*<br />|', "\n\n", $pee);
// Space things out a little
$allblocks = '(?:table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|form|map|area|blockquote|address|math|style|p|h[1-6]|hr|fieldset|noscript|legend|section|article|aside|hgroup|header|footer|nav|figure|details|menu|summary)';
$pee = preg_replace('!(<' . $allblocks . '[^>]*>)!', "\n$1", $pee);
$pee = preg_replace('!(</' . $allblocks . '>)!', "$1\n\n", $pee);
$pee = str_replace(array("\r\n", "\r"), "\n", $pee); // cross-platform newlines
if ( strpos( $pee, '</object>' ) !== false ) {
// no P/BR around param and embed
$pee = preg_replace( '|(<object[^>]*>)\s*|', '$1', $pee );
$pee = preg_replace( '|\s*</object>|', '</object>', $pee );
$pee = preg_replace( '%\s*(</?(?:param|embed)[^>]*>)\s*%', '$1', $pee );
}
if ( strpos( $pee, '<source' ) !== false || strpos( $pee, '<track' ) !== false ) {
// no P/BR around source and track
$pee = preg_replace( '%([<\[](?:audio|video)[^>\]]*[>\]])\s*%', '$1', $pee );
$pee = preg_replace( '%\s*([<\[]/(?:audio|video)[>\]])%', '$1', $pee );
$pee = preg_replace( '%\s*(<(?:source|track)[^>]*>)\s*%', '$1', $pee );
}
$pee = preg_replace("/\n\n+/", "\n\n", $pee); // take care of duplicates
// make paragraphs, including one at the end
$pees = preg_split('/\n\s*\n/', $pee, -1, PREG_SPLIT_NO_EMPTY);
$pee = '';
foreach ( $pees as $tinkle ) {
$pee .= '<p>' . trim($tinkle, "\n") . "</p>\n";
}
$pee = preg_replace('|<p>\s*</p>|', '', $pee); // under certain strange conditions it could create a P of entirely whitespace
$pee = preg_replace('!<p>([^<]+)</(div|address|form)>!', "<p>$1</p></$2>", $pee);
$pee = preg_replace('!<p>\s*(</?' . $allblocks . '[^>]*>)\s*</p>!', "$1", $pee); // don't pee all over a tag
$pee = preg_replace("|<p>(<li.+?)</p>|", "$1", $pee); // problem with nested lists
$pee = preg_replace('|<p><blockquote([^>]*)>|i', "<blockquote$1><p>", $pee);
$pee = str_replace('</blockquote></p>', '</p></blockquote>', $pee);
$pee = preg_replace('!<p>\s*(</?' . $allblocks . '[^>]*>)!', "$1", $pee);
$pee = preg_replace('!(</?' . $allblocks . '[^>]*>)\s*</p>!', "$1", $pee);
if ( $br ) {
$pee = preg_replace_callback('/<(script|style).*?<\/\\1>/s', '_autop_newline_preservation_helper', $pee);
$pee = preg_replace('|(?<!<br />)\s*\n|', "<br />\n", $pee); // optionally make line breaks
$pee = str_replace('<WPPreserveNewline />', "\n", $pee);
}
$pee = preg_replace('!(</?' . $allblocks . '[^>]*>)\s*<br />!', "$1", $pee);
$pee = preg_replace('!<br />(\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)[^>]*>)!', '$1', $pee);
$pee = preg_replace( "|\n</p>$|", '</p>', $pee );
if ( !empty($pre_tags) )
$pee = str_replace(array_keys($pre_tags), array_values($pre_tags), $pee);
return $pee;
}
/**
* Newline preservation help function for wpautop
*
* @since 3.1.0
* @access private
*
* @param array $matches preg_replace_callback matches array
* @return string
*/
function _autop_newline_preservation_helper( $matches ) {
return str_replace("\n", "<WPPreserveNewline />", $matches[0]);
}
/**
* Don't auto-p wrap shortcodes that stand alone
*
* Ensures that shortcodes are not wrapped in <<p>>...<</p>>.
*
* @since 2.9.0
*
* @param string $pee The content.
* @return string The filtered content.
*/
function shortcode_unautop( $pee ) {
global $shortcode_tags;
if ( empty( $shortcode_tags ) || !is_array( $shortcode_tags ) ) {
return $pee;
}
$tagregexp = join( '|', array_map( 'preg_quote', array_keys( $shortcode_tags ) ) );
$pattern =
'/'
. '<p>' // Opening paragraph
. '\\s*+' // Optional leading whitespace
. '(' // 1: The shortcode
. '\\[' // Opening bracket
. "($tagregexp)" // 2: Shortcode name
. '(?![\\w-])' // Not followed by word character or hyphen
// Unroll the loop: Inside the opening shortcode tag
. '[^\\]\\/]*' // Not a closing bracket or forward slash
. '(?:'
. '\\/(?!\\])' // A forward slash not followed by a closing bracket
. '[^\\]\\/]*' // Not a closing bracket or forward slash
. ')*?'
. '(?:'
. '\\/\\]' // Self closing tag and closing bracket
. '|'
. '\\]' // Closing bracket
. '(?:' // Unroll the loop: Optionally, anything between the opening and closing shortcode tags
. '[^\\[]*+' // Not an opening bracket
. '(?:'
. '\\[(?!\\/\\2\\])' // An opening bracket not followed by the closing shortcode tag
. '[^\\[]*+' // Not an opening bracket
. ')*+'
. '\\[\\/\\2\\]' // Closing shortcode tag
. ')?'
. ')'
. ')'
. '\\s*+' // optional trailing whitespace
. '<\\/p>' // closing paragraph
. '/s';
return preg_replace( $pattern, '$1', $pee );
}
/**
* Checks to see if a string is utf8 encoded.
*
* NOTE: This function checks for 5-Byte sequences, UTF8
* has Bytes Sequences with a maximum length of 4.
*
* @author bmorel at ssi dot fr (modified)
* @since 1.2.1
*
* @param string $str The string to be checked
* @return bool True if $str fits a UTF-8 model, false otherwise.
*/
function seems_utf8($str) {
$length = strlen($str);
for ($i=0; $i < $length; $i++) {
$c = ord($str[$i]);
if ($c < 0x80) $n = 0; # 0bbbbbbb
elseif (($c & 0xE0) == 0xC0) $n=1; # 110bbbbb
elseif (($c & 0xF0) == 0xE0) $n=2; # 1110bbbb
elseif (($c & 0xF8) == 0xF0) $n=3; # 11110bbb
elseif (($c & 0xFC) == 0xF8) $n=4; # 111110bb
elseif (($c & 0xFE) == 0xFC) $n=5; # 1111110b
else return false; # Does not match any model
for ($j=0; $j<$n; $j++) { # n bytes matching 10bbbbbb follow ?
if ((++$i == $length) || ((ord($str[$i]) & 0xC0) != 0x80))
return false;
}
}
return true;
}
/**
* Converts a number of special characters into their HTML entities.
*
* Specifically deals with: &, <, >, ", and '.
*
* $quote_style can be set to ENT_COMPAT to encode " to
* ", or ENT_QUOTES to do both. Default is ENT_NOQUOTES where no quotes are encoded.
*
* @since 1.2.2
* @access private
*
* @param string $string The text which is to be encoded.
* @param mixed $quote_style Optional. Converts double quotes if set to ENT_COMPAT, both single and double if set to ENT_QUOTES or none if set to ENT_NOQUOTES. Also compatible with old values; converting single quotes if set to 'single', double if set to 'double' or both if otherwise set. Default is ENT_NOQUOTES.
* @param string $charset Optional. The character encoding of the string. Default is false.
* @param boolean $double_encode Optional. Whether to encode existing html entities. Default is false.
* @return string The encoded text with HTML entities.
*/
function _wp_specialchars( $string, $quote_style = ENT_NOQUOTES, $charset = false, $double_encode = false ) {
$string = (string) $string;
if ( 0 === strlen( $string ) )
return '';
// Don't bother if there are no specialchars - saves some processing
if ( ! preg_match( '/[&<>"\']/', $string ) )
return $string;
// Account for the previous behaviour of the function when the $quote_style is not an accepted value
if ( empty( $quote_style ) )
$quote_style = ENT_NOQUOTES;
elseif ( ! in_array( $quote_style, array( 0, 2, 3, 'single', 'double' ), true ) )
$quote_style = ENT_QUOTES;
// Store the site charset as a static to avoid multiple calls to wp_load_alloptions()
if ( ! $charset ) {
static $_charset;
if ( ! isset( $_charset ) ) {
$alloptions = wp_load_alloptions();
$_charset = isset( $alloptions['blog_charset'] ) ? $alloptions['blog_charset'] : '';
}
$charset = $_charset;
}
if ( in_array( $charset, array( 'utf8', 'utf-8', 'UTF8' ) ) )
$charset = 'UTF-8';
$_quote_style = $quote_style;
if ( $quote_style === 'double' ) {
$quote_style = ENT_COMPAT;
$_quote_style = ENT_COMPAT;
} elseif ( $quote_style === 'single' ) {
$quote_style = ENT_NOQUOTES;
}
// Handle double encoding ourselves
if ( $double_encode ) {
$string = @htmlspecialchars( $string, $quote_style, $charset );
} else {
// Decode & into &
$string = wp_specialchars_decode( $string, $_quote_style );
// Guarantee every &entity; is valid or re-encode the &
$string = wp_kses_normalize_entities( $string );
// Now re-encode everything except &entity;
$string = preg_split( '/(&#?x?[0-9a-z]+;)/i', $string, -1, PREG_SPLIT_DELIM_CAPTURE );
for ( $i = 0; $i < count( $string ); $i += 2 )
$string[$i] = @htmlspecialchars( $string[$i], $quote_style, $charset );
$string = implode( '', $string );
}
// Backwards compatibility
if ( 'single' === $_quote_style )
$string = str_replace( "'", ''', $string );
return $string;
}
/**
* Converts a number of HTML entities into their special characters.
*
* Specifically deals with: &, <, >, ", and '.
*
* $quote_style can be set to ENT_COMPAT to decode " entities,
* or ENT_QUOTES to do both " and '. Default is ENT_NOQUOTES where no quotes are decoded.
*
* @since 2.8.0
*
* @param string $string The text which is to be decoded.
* @param mixed $quote_style Optional. Converts double quotes if set to ENT_COMPAT, both single and double if set to ENT_QUOTES or none if set to ENT_NOQUOTES. Also compatible with old _wp_specialchars() values; converting single quotes if set to 'single', double if set to 'double' or both if otherwise set. Default is ENT_NOQUOTES.
* @return string The decoded text without HTML entities.
*/
function wp_specialchars_decode( $string, $quote_style = ENT_NOQUOTES ) {
$string = (string) $string;
if ( 0 === strlen( $string ) ) {
return '';
}
// Don't bother if there are no entities - saves a lot of processing
if ( strpos( $string, '&' ) === false ) {
return $string;
}
// Match the previous behaviour of _wp_specialchars() when the $quote_style is not an accepted value
if ( empty( $quote_style ) ) {
$quote_style = ENT_NOQUOTES;
} elseif ( !in_array( $quote_style, array( 0, 2, 3, 'single', 'double' ), true ) ) {
$quote_style = ENT_QUOTES;
}
// More complete than get_html_translation_table( HTML_SPECIALCHARS )
$single = array( ''' => '\'', ''' => '\'' );
$single_preg = array( '/�*39;/' => ''', '/�*27;/i' => ''' );
$double = array( '"' => '"', '"' => '"', '"' => '"' );
$double_preg = array( '/�*34;/' => '"', '/�*22;/i' => '"' );
$others = array( '<' => '<', '<' => '<', '>' => '>', '>' => '>', '&' => '&', '&' => '&', '&' => '&' );
$others_preg = array( '/�*60;/' => '<', '/�*62;/' => '>', '/�*38;/' => '&', '/�*26;/i' => '&' );
if ( $quote_style === ENT_QUOTES ) {
$translation = array_merge( $single, $double, $others );
$translation_preg = array_merge( $single_preg, $double_preg, $others_preg );
} elseif ( $quote_style === ENT_COMPAT || $quote_style === 'double' ) {
$translation = array_merge( $double, $others );
$translation_preg = array_merge( $double_preg, $others_preg );
} elseif ( $quote_style === 'single' ) {
$translation = array_merge( $single, $others );
$translation_preg = array_merge( $single_preg, $others_preg );
} elseif ( $quote_style === ENT_NOQUOTES ) {
$translation = $others;
$translation_preg = $others_preg;
}
// Remove zero padding on numeric entities
$string = preg_replace( array_keys( $translation_preg ), array_values( $translation_preg ), $string );
// Replace characters according to translation table
return strtr( $string, $translation );
}
/**
* Checks for invalid UTF8 in a string.
*
* @since 2.8.0
*
* @param string $string The text which is to be checked.
* @param boolean $strip Optional. Whether to attempt to strip out invalid UTF8. Default is false.
* @return string The checked text.
*/
function wp_check_invalid_utf8( $string, $strip = false ) {
$string = (string) $string;
if ( 0 === strlen( $string ) ) {
return '';
}
// Store the site charset as a static to avoid multiple calls to get_option()
static $is_utf8;
if ( !isset( $is_utf8 ) ) {
$is_utf8 = in_array( get_option( 'blog_charset' ), array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ) );
}
if ( !$is_utf8 ) {
return $string;
}
// Check for support for utf8 in the installed PCRE library once and store the result in a static
static $utf8_pcre;
if ( !isset( $utf8_pcre ) ) {
$utf8_pcre = @preg_match( '/^./u', 'a' );
}
// We can't demand utf8 in the PCRE installation, so just return the string in those cases
if ( !$utf8_pcre ) {
return $string;
}
// preg_match fails when it encounters invalid UTF8 in $string
if ( 1 === @preg_match( '/^./us', $string ) ) {
return $string;
}
// Attempt to strip the bad chars if requested (not recommended)
if ( $strip && function_exists( 'iconv' ) ) {
return iconv( 'utf-8', 'utf-8', $string );
}
return '';
}
/**
* Encode the Unicode values to be used in the URI.
*
* @since 1.5.0
*
* @param string $utf8_string
* @param int $length Max length of the string
* @return string String with Unicode encoded for URI.
*/
function utf8_uri_encode( $utf8_string, $length = 0 ) {
$unicode = '';
$values = array();
$num_octets = 1;
$unicode_length = 0;
$string_length = strlen( $utf8_string );
for ($i = 0; $i < $string_length; $i++ ) {
$value = ord( $utf8_string[ $i ] );
if ( $value < 128 ) {
if ( $length && ( $unicode_length >= $length ) )
break;
$unicode .= chr($value);
$unicode_length++;
} else {
if ( count( $values ) == 0 ) $num_octets = ( $value < 224 ) ? 2 : 3;
$values[] = $value;
if ( $length && ( $unicode_length + ($num_octets * 3) ) > $length )
break;
if ( count( $values ) == $num_octets ) {
if ($num_octets == 3) {
$unicode .= '%' . dechex($values[0]) . '%' . dechex($values[1]) . '%' . dechex($values[2]);
$unicode_length += 9;
} else {
$unicode .= '%' . dechex($values[0]) . '%' . dechex($values[1]);
$unicode_length += 6;
}
$values = array();
$num_octets = 1;
}
}
}
return $unicode;
}
/**
* Converts all accent characters to ASCII characters.
*
* If there are no accent characters, then the string given is just returned.
*
* @since 1.2.1
*
* @param string $string Text that might have accent characters
* @return string Filtered string with replaced "nice" characters.
*/
function remove_accents($string) {
if ( !preg_match('/[\x80-\xff]/', $string) )
return $string;
if (seems_utf8($string)) {
$chars = array(
// Decompositions for Latin-1 Supplement
chr(194).chr(170) => 'a', chr(194).chr(186) => 'o',
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(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(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(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(184) => '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', chr(195).chr(152) => 'O',
// Decompositions for Latin Extended-A
chr(196).chr(128) => 'A', chr(196).chr(129) => 'a',
chr(196).chr(130) => 'A', chr(196).chr(131) => 'a',
chr(196).chr(132) => 'A', chr(196).chr(133) => 'a',
chr(196).chr(134) => 'C', chr(196).chr(135) => 'c',
chr(196).chr(136) => 'C', chr(196).chr(137) => 'c',
chr(196).chr(138) => 'C', chr(196).chr(139) => 'c',
chr(196).chr(140) => 'C', chr(196).chr(141) => 'c',
chr(196).chr(142) => 'D', chr(196).chr(143) => 'd',
chr(196).chr(144) => 'D', chr(196).chr(145) => 'd',
chr(196).chr(146) => 'E', chr(196).chr(147) => 'e',
chr(196).chr(148) => 'E', chr(196).chr(149) => 'e',
chr(196).chr(150) => 'E', chr(196).chr(151) => 'e',
chr(196).chr(152) => 'E', chr(196).chr(153) => 'e',
chr(196).chr(154) => 'E', chr(196).chr(155) => 'e',
chr(196).chr(156) => 'G', chr(196).chr(157) => 'g',
chr(196).chr(158) => 'G', chr(196).chr(159) => 'g',
chr(196).chr(160) => 'G', chr(196).chr(161) => 'g',
chr(196).chr(162) => 'G', chr(196).chr(163) => 'g',
chr(196).chr(164) => 'H', chr(196).chr(165) => 'h',
chr(196).chr(166) => 'H', chr(196).chr(167) => 'h',
chr(196).chr(168) => 'I', chr(196).chr(169) => 'i',
chr(196).chr(170) => 'I', chr(196).chr(171) => 'i',
chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
chr(196).chr(186) => 'l', chr(196).chr(187) => 'L',
chr(196).chr(188) => 'l', chr(196).chr(189) => 'L',
chr(196).chr(190) => 'l', chr(196).chr(191) => 'L',
chr(197).chr(128) => 'l', chr(197).chr(129) => 'L',
chr(197).chr(130) => 'l', chr(197).chr(131) => 'N',
chr(197).chr(132) => 'n', chr(197).chr(133) => 'N',
chr(197).chr(134) => 'n', chr(197).chr(135) => 'N',
chr(197).chr(136) => 'n', chr(197).chr(137) => 'N',
chr(197).chr(138) => 'n', chr(197).chr(139) => 'N',
chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
chr(197).chr(166) => 'T', chr(197).chr(167) => 't',
chr(197).chr(168) => 'U', chr(197).chr(169) => 'u',
chr(197).chr(170) => 'U', chr(197).chr(171) => 'u',
chr(197).chr(172) => 'U', chr(197).chr(173) => 'u',
chr(197).chr(174) => 'U', chr(197).chr(175) => 'u',
chr(197).chr(176) => 'U', chr(197).chr(177) => 'u',
chr(197).chr(178) => 'U', chr(197).chr(179) => 'u',
chr(197).chr(180) => 'W', chr(197).chr(181) => 'w',
chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y',
chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z',
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
chr(194).chr(163) => '',
// Vowels with diacritic (Vietnamese)
// unmarked
chr(198).chr(160) => 'O', chr(198).chr(161) => 'o',
chr(198).chr(175) => 'U', chr(198).chr(176) => 'u',
// grave accent
chr(225).chr(186).chr(166) => 'A', chr(225).chr(186).chr(167) => 'a',
chr(225).chr(186).chr(176) => 'A', chr(225).chr(186).chr(177) => 'a',
chr(225).chr(187).chr(128) => 'E', chr(225).chr(187).chr(129) => 'e',
chr(225).chr(187).chr(146) => 'O', chr(225).chr(187).chr(147) => 'o',
chr(225).chr(187).chr(156) => 'O', chr(225).chr(187).chr(157) => 'o',
chr(225).chr(187).chr(170) => 'U', chr(225).chr(187).chr(171) => 'u',
chr(225).chr(187).chr(178) => 'Y', chr(225).chr(187).chr(179) => 'y',
// hook
chr(225).chr(186).chr(162) => 'A', chr(225).chr(186).chr(163) => 'a',
chr(225).chr(186).chr(168) => 'A', chr(225).chr(186).chr(169) => 'a',
chr(225).chr(186).chr(178) => 'A', chr(225).chr(186).chr(179) => 'a',
chr(225).chr(186).chr(186) => 'E', chr(225).chr(186).chr(187) => 'e',
chr(225).chr(187).chr(130) => 'E', chr(225).chr(187).chr(131) => 'e',
chr(225).chr(187).chr(136) => 'I', chr(225).chr(187).chr(137) => 'i',
chr(225).chr(187).chr(142) => 'O', chr(225).chr(187).chr(143) => 'o',
chr(225).chr(187).chr(148) => 'O', chr(225).chr(187).chr(149) => 'o',
chr(225).chr(187).chr(158) => 'O', chr(225).chr(187).chr(159) => 'o',
chr(225).chr(187).chr(166) => 'U', chr(225).chr(187).chr(167) => 'u',
chr(225).chr(187).chr(172) => 'U', chr(225).chr(187).chr(173) => 'u',
chr(225).chr(187).chr(182) => 'Y', chr(225).chr(187).chr(183) => 'y',
// tilde
chr(225).chr(186).chr(170) => 'A', chr(225).chr(186).chr(171) => 'a',
chr(225).chr(186).chr(180) => 'A', chr(225).chr(186).chr(181) => 'a',
chr(225).chr(186).chr(188) => 'E', chr(225).chr(186).chr(189) => 'e',
chr(225).chr(187).chr(132) => 'E', chr(225).chr(187).chr(133) => 'e',
chr(225).chr(187).chr(150) => 'O', chr(225).chr(187).chr(151) => 'o',
chr(225).chr(187).chr(160) => 'O', chr(225).chr(187).chr(161) => 'o',
chr(225).chr(187).chr(174) => 'U', chr(225).chr(187).chr(175) => 'u',
chr(225).chr(187).chr(184) => 'Y', chr(225).chr(187).chr(185) => 'y',
// acute accent
chr(225).chr(186).chr(164) => 'A', chr(225).chr(186).chr(165) => 'a',
chr(225).chr(186).chr(174) => 'A', chr(225).chr(186).chr(175) => 'a',
chr(225).chr(186).chr(190) => 'E', chr(225).chr(186).chr(191) => 'e',
chr(225).chr(187).chr(144) => 'O', chr(225).chr(187).chr(145) => 'o',
chr(225).chr(187).chr(154) => 'O', chr(225).chr(187).chr(155) => 'o',
chr(225).chr(187).chr(168) => 'U', chr(225).chr(187).chr(169) => 'u',
// dot below
chr(225).chr(186).chr(160) => 'A', chr(225).chr(186).chr(161) => 'a',
chr(225).chr(186).chr(172) => 'A', chr(225).chr(186).chr(173) => 'a',
chr(225).chr(186).chr(182) => 'A', chr(225).chr(186).chr(183) => 'a',
chr(225).chr(186).chr(184) => 'E', chr(225).chr(186).chr(185) => 'e',
chr(225).chr(187).chr(134) => 'E', chr(225).chr(187).chr(135) => 'e',
chr(225).chr(187).chr(138) => 'I', chr(225).chr(187).chr(139) => 'i',
chr(225).chr(187).chr(140) => 'O', chr(225).chr(187).chr(141) => 'o',
chr(225).chr(187).chr(152) => 'O', chr(225).chr(187).chr(153) => 'o',
chr(225).chr(187).chr(162) => 'O', chr(225).chr(187).chr(163) => 'o',
chr(225).chr(187).chr(164) => 'U', chr(225).chr(187).chr(165) => 'u',
chr(225).chr(187).chr(176) => 'U', chr(225).chr(187).chr(177) => 'u',
chr(225).chr(187).chr(180) => 'Y', chr(225).chr(187).chr(181) => 'y',
// Vowels with diacritic (Chinese, Hanyu Pinyin)
chr(201).chr(145) => 'a',
// macron
chr(199).chr(149) => 'U', chr(199).chr(150) => 'u',
// acute accent
chr(199).chr(151) => 'U', chr(199).chr(152) => 'u',
// caron
chr(199).chr(141) => 'A', chr(199).chr(142) => 'a',
chr(199).chr(143) => 'I', chr(199).chr(144) => 'i',
chr(199).chr(145) => 'O', chr(199).chr(146) => 'o',
chr(199).chr(147) => 'U', chr(199).chr(148) => 'u',
chr(199).chr(153) => 'U', chr(199).chr(154) => 'u',
// grave accent
chr(199).chr(155) => 'U', chr(199).chr(156) => 'u',
);
// Used for locale-specific rules
$locale = get_locale();
if ( 'de_DE' == $locale ) {
$chars[ chr(195).chr(132) ] = 'Ae';
$chars[ chr(195).chr(164) ] = 'ae';
$chars[ chr(195).chr(150) ] = 'Oe';
$chars[ chr(195).chr(182) ] = 'oe';
$chars[ chr(195).chr(156) ] = 'Ue';
$chars[ chr(195).chr(188) ] = 'ue';
$chars[ chr(195).chr(159) ] = 'ss';
} elseif ( 'da_DK' === $locale ) {
$chars[ chr(195).chr(134) ] = 'Ae';
$chars[ chr(195).chr(166) ] = 'ae';
$chars[ chr(195).chr(152) ] = 'Oe';
$chars[ chr(195).chr(184) ] = 'oe';
$chars[ chr(195).chr(133) ] = 'Aa';
$chars[ chr(195).chr(165) ] = 'aa';
}
$string = strtr($string, $chars);
} else {
// Assume ISO-8859-1 if not UTF-8
$chars['in'] = chr(128).chr(131).chr(138).chr(142).chr(154).chr(158)
.chr(159).chr(162).chr(165).chr(181).chr(192).chr(193).chr(194)
.chr(195).chr(196).chr(197).chr(199).chr(200).chr(201).chr(202)
.chr(203).chr(204).chr(205).chr(206).chr(207).chr(209).chr(210)
.chr(211).chr(212).chr(213).chr(214).chr(216).chr(217).chr(218)
.chr(219).chr(220).chr(221).chr(224).chr(225).chr(226).chr(227)
.chr(228).chr(229).chr(231).chr(232).chr(233).chr(234).chr(235)
.chr(236).chr(237).chr(238).chr(239).chr(241).chr(242).chr(243)
.chr(244).chr(245).chr(246).chr(248).chr(249).chr(250).chr(251)
.chr(252).chr(253).chr(255);
$chars['out'] = "EfSZszYcYuAAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuyy";
$string = strtr($string, $chars['in'], $chars['out']);
$double_chars['in'] = array(chr(140), chr(156), chr(198), chr(208), chr(222), chr(223), chr(230), chr(240), chr(254));
$double_chars['out'] = array('OE', 'oe', 'AE', 'DH', 'TH', 'ss', 'ae', 'dh', 'th');
$string = str_replace($double_chars['in'], $double_chars['out'], $string);
}
return $string;
}
/**
* Sanitizes a filename, replacing whitespace with dashes.
*
* Removes special characters that are illegal in filenames on certain
* operating systems and special characters requiring special escaping
* to manipulate at the command line. Replaces spaces and consecutive
* dashes with a single dash. Trims period, dash and underscore from beginning
* and end of filename.
*
* @since 2.1.0
*
* @param string $filename The filename to be sanitized
* @return string The sanitized filename
*/
function sanitize_file_name( $filename ) {
$filename_raw = $filename;
$special_chars = array("?", "[", "]", "/", "\\", "=", "<", ">", ":", ";", ",", "'", "\"", "&", "$", "#", "*", "(", ")", "|", "~", "`", "!", "{", "}", chr(0));
/**
* Filter the list of characters to remove from a filename.
*
* @since 2.8.0
*
* @param array $special_chars Characters to remove.
* @param string $filename_raw Filename as it was passed into sanitize_file_name().
*/
$special_chars = apply_filters( 'sanitize_file_name_chars', $special_chars, $filename_raw );
$filename = preg_replace( "#\x{00a0}#siu", ' ', $filename );
$filename = str_replace($special_chars, '', $filename);
$filename = preg_replace('/[\s-]+/', '-', $filename);
$filename = trim($filename, '.-_');
// Split the filename into a base and extension[s]
$parts = explode('.', $filename);
// Return if only one extension
if ( count( $parts ) <= 2 ) {
/**
* Filter a sanitized filename string.
*
* @since 2.8.0
*
* @param string $filename Sanitized filename.
* @param string $filename_raw The filename prior to sanitization.
*/
return apply_filters( 'sanitize_file_name', $filename, $filename_raw );
}
// Process multiple extensions
$filename = array_shift($parts);
$extension = array_pop($parts);
$mimes = get_allowed_mime_types();
/*
* Loop over any intermediate extensions. Postfix them with a trailing underscore
* if they are a 2 - 5 character long alpha string not in the extension whitelist.
*/
foreach ( (array) $parts as $part) {
$filename .= '.' . $part;
if ( preg_match("/^[a-zA-Z]{2,5}\d?$/", $part) ) {
$allowed = false;
foreach ( $mimes as $ext_preg => $mime_match ) {
$ext_preg = '!^(' . $ext_preg . ')$!i';
if ( preg_match( $ext_preg, $part ) ) {
$allowed = true;
break;
}
}
if ( !$allowed )
$filename .= '_';
}
}
$filename .= '.' . $extension;
/** This filter is documented in wp-includes/formatting.php */
return apply_filters('sanitize_file_name', $filename, $filename_raw);
}
/**
* Sanitizes a username, stripping out unsafe characters.
*
* 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
*
* @param string $username The username to be sanitized.
* @param bool $strict If set limits $username to specific characters. Default false.
* @return string The sanitized username, after passing through filters.
*/
function sanitize_user( $username, $strict = false ) {
$raw_username = $username;
$username = wp_strip_all_tags( $username );
$username = remove_accents( $username );
// Kill octets
$username = preg_replace( '|%([a-fA-F0-9][a-fA-F0-9])|', '', $username );
$username = preg_replace( '/&.+?;/', '', $username ); // Kill entities
// If strict, reduce to ASCII for max portability.
if ( $strict )
$username = preg_replace( '|[^a-z0-9 _.\-@]|i', '', $username );
$username = trim( $username );
// Consolidate contiguous whitespace
$username = preg_replace( '|\s+|', ' ', $username );
/**
* Filter a sanitized username string.
*
* @since 2.0.1
*
* @param string $username Sanitized username.
* @param string $raw_username The username prior to sanitization.
* @param bool $strict Whether to limit the sanitization to specific characters. Default false.
*/
return apply_filters( 'sanitize_user', $username, $raw_username, $strict );
}
/**
* Sanitizes a string key.
*
* Keys are used as internal identifiers. Lowercase alphanumeric characters, dashes and underscores are allowed.
*
* @since 3.0.0
*
* @param string $key String key
* @return string Sanitized key
*/
function sanitize_key( $key ) {
$raw_key = $key;
$key = strtolower( $key );
$key = preg_replace( '/[^a-z0-9_\-]/', '', $key );
/**
* Filter a sanitized key string.
*
* @since 3.0.0
*
* @param string $key Sanitized key.
* @param string $raw_key The key prior to sanitization.
*/
return apply_filters( 'sanitize_key', $key, $raw_key );
}
/**
* Sanitizes a title, or returns a fallback title.
*
* Specifically, HTML and PHP tags are stripped. Further actions can be added
* via the plugin API. If $title is empty and $fallback_title is set, the latter
* will be used.
*
* @since 1.0.0
*
* @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 = '', $context = 'save' ) {
$raw_title = $title;
if ( 'save' == $context )
$title = remove_accents($title);
/**
* Filter a sanitized title string.
*
* @since 1.2.0
*
* @param string $title Sanitized title.
* @param string $raw_title The title prior to sanitization.
* @param string $context The context for which the title is being sanitized.
*/
$title = apply_filters( 'sanitize_title', $title, $raw_title, $context );
if ( '' === $title || false === $title )
$title = $fallback_title;
return $title;
}
/**
* Sanitizes a title with the 'query' context.
*
* Used for querying the database for a value from URL.
*
* @since 3.1.0
* @uses sanitize_title()
*
* @param string $title The string to be sanitized.
* @return string The sanitized string.
*/
function sanitize_title_for_query( $title ) {
return sanitize_title( $title, '', 'query' );
}
/**
* Sanitizes a title, replacing whitespace and a few other characters with dashes.
*
* Limits the output to alphanumeric characters, underscore (_) and dash (-).
* Whitespace becomes a dash.
*
* @since 1.2.0
*
* @param string $title The title to be sanitized.
* @param string $raw_title Optional. Not used.
* @param string $context Optional. The operation for which the string is sanitized.
* @return string The sanitized title.
*/
function sanitize_title_with_dashes( $title, $raw_title = '', $context = 'display' ) {
$title = strip_tags($title);
// Preserve escaped octets.
$title = preg_replace('|%([a-fA-F0-9][a-fA-F0-9])|', '---$1---', $title);
// Remove percent signs that are not part of an octet.
$title = str_replace('%', '', $title);
// Restore octets.
$title = preg_replace('|---([a-fA-F0-9][a-fA-F0-9])---|', '%$1', $title);
if (seems_utf8($title)) {
if (function_exists('mb_strtolower')) {
$title = mb_strtolower($title, 'UTF-8');
}
$title = utf8_uri_encode($title, 200);
}
$title = strtolower($title);
$title = preg_replace('/&.+?;/', '', $title); // kill entities
$title = str_replace('.', '-', $title);
if ( 'save' == $context ) {
// Convert nbsp, ndash and mdash to hyphens
$title = str_replace( array( '%c2%a0', '%e2%80%93', '%e2%80%94' ), '-', $title );
// Strip these characters entirely
$title = str_replace( array(
// iexcl and iquest
'%c2%a1', '%c2%bf',
// angle quotes
'%c2%ab', '%c2%bb', '%e2%80%b9', '%e2%80%ba',
// curly quotes
'%e2%80%98', '%e2%80%99', '%e2%80%9c', '%e2%80%9d',
'%e2%80%9a', '%e2%80%9b', '%e2%80%9e', '%e2%80%9f',
// copy, reg, deg, hellip and trade
'%c2%a9', '%c2%ae', '%c2%b0', '%e2%80%a6', '%e2%84%a2',
// acute accents
'%c2%b4', '%cb%8a', '%cc%81', '%cd%81',
// grave accent, macron, caron
'%cc%80', '%cc%84', '%cc%8c',
), '', $title );
// Convert times to x
$title = str_replace( '%c3%97', 'x', $title );
}
$title = preg_replace('/[^%a-z0-9 _-]/', '', $title);
$title = preg_replace('/\s+/', '-', $title);
$title = preg_replace('|-+|', '-', $title);
$title = trim($title, '-');
return $title;
}
/**
* Ensures a string is a valid SQL order by clause.
*
* Accepts one or more columns, with or without ASC/DESC, and also accepts
* RAND().
*
* @since 2.5.1
*
* @param string $orderby Order by string to be checked.
* @return string|bool Returns the order by clause if it is a match, false otherwise.
*/
function sanitize_sql_orderby( $orderby ){
preg_match('/^\s*([a-z0-9_]+(\s+(ASC|DESC))?(\s*,\s*|\s*$))+|^\s*RAND\(\s*\)\s*$/i', $orderby, $obmatches);
if ( !$obmatches )
return false;
return $orderby;
}
/**
* Sanitizes an HTML classname to ensure it only contains valid characters.
*
* Strips the string down to A-Z,a-z,0-9,_,-. If this results in an empty
* string then it will return the alternative value supplied.
*
* @todo Expand to support the full range of CDATA that a class attribute can contain.
*
* @since 2.8.0
*
* @param string $class The classname to be sanitized
* @param string $fallback Optional. The value to return if the sanitization end's up as an empty string.
* Defaults to an empty string.
* @return string The sanitized value
*/
function sanitize_html_class( $class, $fallback = '' ) {
//Strip out any % encoded octets
$sanitized = preg_replace( '|%[a-fA-F0-9][a-fA-F0-9]|', '', $class );
//Limit to A-Z,a-z,0-9,_,-
$sanitized = preg_replace( '/[^A-Za-z0-9_-]/', '', $sanitized );
if ( '' == $sanitized )
$sanitized = $fallback;
/**
* Filter a sanitized HTML class string.
*
* @since 2.8.0
*
* @param string $sanitized The sanitized HTML class.
* @param string $class HTML class before sanitization.
* @param string $fallback The fallback string.
*/
return apply_filters( 'sanitize_html_class', $sanitized, $class, $fallback );
}
/**
* Converts a number of characters from a string.
*
* Metadata tags <<title>> and <<category>> are removed, <<br>> and <<hr>> are
* converted into correct XHTML and Unicode characters are converted to the
* valid range.
*
* @since 0.71
*
* @param string $content String of characters to be converted.
* @param string $deprecated Not used.
* @return string Converted string.
*/
function convert_chars($content, $deprecated = '') {
if ( !empty( $deprecated ) )
_deprecated_argument( __FUNCTION__, '0.71' );
// Translation of invalid Unicode references range to valid range
$wp_htmltranswinuni = array(
'€' => '€', // the Euro sign
'' => '',
'‚' => '‚', // these are Windows CP1252 specific characters
'ƒ' => 'ƒ', // they would look weird on non-Windows browsers
'„' => '„',
'…' => '…',
'†' => '†',
'‡' => '‡',
'ˆ' => 'ˆ',
'‰' => '‰',
'Š' => 'Š',
'‹' => '‹',
'Œ' => 'Œ',
'' => '',
'Ž' => 'Ž',
'' => '',
'' => '',
'‘' => '‘',
'’' => '’',
'“' => '“',
'”' => '”',
'•' => '•',
'–' => '–',
'—' => '—',
'˜' => '˜',
'™' => '™',
'š' => 'š',
'›' => '›',
'œ' => 'œ',
'' => '',
'ž' => 'ž',
'Ÿ' => 'Ÿ'
);
// Remove metadata tags
$content = preg_replace('/<title>(.+?)<\/title>/','',$content);
$content = preg_replace('/<category>(.+?)<\/category>/','',$content);
// Converts lone & characters into & (a.k.a. &)
$content = preg_replace('/&([^#])(?![a-z1-4]{1,8};)/i', '&$1', $content);
// Fix Word pasting
$content = strtr($content, $wp_htmltranswinuni);
// Just a little XHTML help
$content = str_replace('<br>', '<br />', $content);
$content = str_replace('<hr>', '<hr />', $content);
return $content;
}
/**
* Balances tags if forced to, or if the 'use_balanceTags' option is set to true.
*
* @since 0.71
*
* @param string $text Text to be balanced
* @param bool $force If true, forces balancing, ignoring the value of the option. Default false.
* @return string Balanced text
*/
function balanceTags( $text, $force = false ) {
if ( $force || get_option('use_balanceTags') == 1 ) {
return force_balance_tags( $text );
} else {
return $text;
}
}
/**
* Balances tags of string using a modified stack.
*
* @since 2.0.4
*
* @author Leonard Lin <leonard@acm.org>
* @license GPL
* @copyright November 4, 2001
* @version 1.1
* @todo Make better - change loop condition to $text in 1.2
* @internal Modified by Scott Reilly (coffee2code) 02 Aug 2004
* 1.1 Fixed handling of append/stack pop order of end text
* Added Cleaning Hooks
* 1.0 First Version
*
* @param string $text Text to be balanced.
* @return string Balanced text.
*/
function force_balance_tags( $text ) {
$tagstack = array();
$stacksize = 0;
$tagqueue = '';
$newtext = '';
// Known single-entity/self-closing tags
$single_tags = array( 'area', 'base', 'basefont', 'br', 'col', 'command', 'embed', 'frame', 'hr', 'img', 'input', 'isindex', 'link', 'meta', 'param', 'source' );
// Tags that can be immediately nested within themselves
$nestable_tags = array( 'blockquote', 'div', 'object', 'q', 'span' );
// WP bug fix for comments - in case you REALLY meant to type '< !--'
$text = str_replace('< !--', '< !--', $text);
// WP bug fix for LOVE <3 (and other situations with '<' before a number)
$text = preg_replace('#<([0-9]{1})#', '<$1', $text);
while ( preg_match("/<(\/?[\w:]*)\s*([^>]*)>/", $text, $regex) ) {
$newtext .= $tagqueue;
$i = strpos($text, $regex[0]);
$l = strlen($regex[0]);
// clear the shifter
$tagqueue = '';
// Pop or Push
if ( isset($regex[1][0]) && '/' == $regex[1][0] ) { // End Tag
$tag = strtolower(substr($regex[1],1));
// if too many closing tags
if( $stacksize <= 0 ) {
$tag = '';
// or close to be safe $tag = '/' . $tag;
}
// if stacktop value = tag close value then pop
else if ( $tagstack[$stacksize - 1] == $tag ) { // found closing tag
$tag = '</' . $tag . '>'; // Close Tag
// Pop
array_pop( $tagstack );
$stacksize--;
} else { // closing tag not at top, search for it
for ( $j = $stacksize-1; $j >= 0; $j-- ) {
if ( $tagstack[$j] == $tag ) {
// add tag to tagqueue
for ( $k = $stacksize-1; $k >= $j; $k--) {
$tagqueue .= '</' . array_pop( $tagstack ) . '>';
$stacksize--;
}
break;
}
}
$tag = '';
}
} else { // Begin Tag
$tag = strtolower($regex[1]);
// Tag Cleaning
// If it's an empty tag "< >", do nothing
if ( '' == $tag ) {
// do nothing
}
// ElseIf it presents itself as a self-closing tag...
elseif ( substr( $regex[2], -1 ) == '/' ) {
// ...but it isn't a known single-entity self-closing tag, then don't let it be treated as such and
// immediately close it with a closing tag (the tag will encapsulate no text as a result)
if ( ! in_array( $tag, $single_tags ) )
$regex[2] = trim( substr( $regex[2], 0, -1 ) ) . "></$tag";
}
// ElseIf it's a known single-entity tag but it doesn't close itself, do so
elseif ( in_array($tag, $single_tags) ) {
$regex[2] .= '/';
}
// Else it's not a single-entity tag
else {
// If the top of the stack is the same as the tag we want to push, close previous tag
if ( $stacksize > 0 && !in_array($tag, $nestable_tags) && $tagstack[$stacksize - 1] == $tag ) {
$tagqueue = '</' . array_pop( $tagstack ) . '>';
$stacksize--;
}
$stacksize = array_push( $tagstack, $tag );
}
// Attributes
$attributes = $regex[2];
if( ! empty( $attributes ) && $attributes[0] != '>' )
$attributes = ' ' . $attributes;
$tag = '<' . $tag . $attributes . '>';
//If already queuing a close tag, then put this tag on, too
if ( !empty($tagqueue) ) {
$tagqueue .= $tag;
$tag = '';
}
}
$newtext .= substr($text, 0, $i) . $tag;
$text = substr($text, $i + $l);
}
// Clear Tag Queue
$newtext .= $tagqueue;
// Add Remaining text
$newtext .= $text;
// Empty Stack
while( $x = array_pop($tagstack) )
$newtext .= '</' . $x . '>'; // Add remaining tags to close
// WP fix for the bug with HTML comments
$newtext = str_replace("< !--","<!--",$newtext);
$newtext = str_replace("< !--","< !--",$newtext);
return $newtext;
}
/**
* Acts on text which is about to be edited.
*
* The $content is run through esc_textarea(), which uses htmlspecialchars()
* to convert special characters to HTML entities. If $richedit is set to true,
* it is simply a holder for the 'format_to_edit' filter.
*
* @since 0.71
*
* @param string $content The text about to be edited.
* @param bool $richedit Whether the $content should not pass through htmlspecialchars(). Default false (meaning it will be passed).
* @return string The text after the filter (and possibly htmlspecialchars()) has been run.
*/
function format_to_edit( $content, $richedit = false ) {
/**
* Filter the text to be formatted for editing.
*
* @since 1.2.0
*
* @param string $content The text, prior to formatting for editing.
*/
$content = apply_filters( 'format_to_edit', $content );
if ( ! $richedit )
$content = esc_textarea( $content );
return $content;
}
/**
* Add leading zeros when necessary.
*
* If you set the threshold to '4' and the number is '10', then you will get
* back '0010'. If you set the threshold to '4' and the number is '5000', then you
* will get back '5000'.
*
* Uses sprintf to append the amount of zeros based on the $threshold parameter
* and the size of the number. If the number is large enough, then no zeros will
* be appended.
*
* @since 0.71
*
* @param mixed $number Number to append zeros to if not greater than threshold.
* @param int $threshold Digit places number needs to be to not have zeros added.
* @return string Adds leading zeros to number if needed.
*/
function zeroise($number, $threshold) {
return sprintf('%0'.$threshold.'s', $number);
}
/**
* Adds backslashes before letters and before a number at the start of a string.
*
* @since 0.71
*
* @param string $string Value to which backslashes will be added.
* @return string String with backslashes inserted.
*/
function backslashit($string) {
if ( isset( $string[0] ) && $string[0] >= '0' && $string[0] <= '9' )
$string = '\\\\' . $string;
return addcslashes( $string, 'A..Za..z' );
}
/**
* Appends a trailing slash.
*
* Will remove trailing forward and backslashes if it exists already before adding
* a trailing forward slash. This prevents double slashing a string or path.
*
* The primary use of this is for paths and thus should be used for paths. It is
* not restricted to paths and offers no specific path support.
*
* @since 1.2.0
*
* @param string $string What to add the trailing slash to.
* @return string String with trailing slash added.
*/
function trailingslashit( $string ) {
return untrailingslashit( $string ) . '/';
}
/**
* Removes trailing forward slashes and backslashes if they exist.
*
* The primary use of this is for paths and thus should be used for paths. It is
* not restricted to paths and offers no specific path support.
*
* @since 2.2.0
*
* @param string $string What to remove the trailing slashes from.
* @return string String without the trailing slashes.
*/
function untrailingslashit( $string ) {
return rtrim( $string, '/\\' );
}
/**
* Adds slashes to escape strings.
*
* Slashes will first be removed if magic_quotes_gpc is set, see {@link
* http://www.php.net/magic_quotes} for more details.
*
* @since 0.71
*
* @param string $gpc The string returned from HTTP request data.
* @return string Returns a string escaped with slashes.
*/
function addslashes_gpc($gpc) {
if ( get_magic_quotes_gpc() )
$gpc = stripslashes($gpc);
return wp_slash($gpc);
}
/**
* Navigates through an array and removes slashes from the values.
*
* If an array is passed, the array_map() function causes a callback to pass the
* value back to the function. The slashes from this value will removed.
*
* @since 2.0.0
*
* @param mixed $value The value to be stripped.
* @return mixed Stripped value.
*/
function stripslashes_deep($value) {
if ( is_array($value) ) {
$value = array_map('stripslashes_deep', $value);
} elseif ( is_object($value) ) {
$vars = get_object_vars( $value );
foreach ($vars as $key=>$data) {
$value->{$key} = stripslashes_deep( $data );
}
} elseif ( is_string( $value ) ) {
$value = stripslashes($value);
}
return $value;
}
/**
* Navigates through an array and encodes the values to be used in a URL.
*
*
* @since 2.2.0
*
* @param array|string $value The array or string to be encoded.
* @return array|string $value The encoded array (or string from the callback).
*/
function urlencode_deep($value) {
$value = is_array($value) ? array_map('urlencode_deep', $value) : urlencode($value);
return $value;
}
/**
* Navigates through an array and raw encodes the values to be used in a URL.
*
* @since 3.4.0
*
* @param array|string $value The array or string to be encoded.
* @return array|string $value The encoded array (or string from the callback).
*/
function rawurlencode_deep( $value ) {
return is_array( $value ) ? array_map( 'rawurlencode_deep', $value ) : rawurlencode( $value );
}
/**
* Converts email addresses characters to HTML entities to block spam bots.
*
* @since 0.71
*
* @param string $email_address Email address.
* @param int $hex_encoding Optional. Set to 1 to enable hex encoding.
* @return string Converted email address.
*/
function antispambot( $email_address, $hex_encoding = 0 ) {
$email_no_spam_address = '';
for ( $i = 0; $i < strlen( $email_address ); $i++ ) {
$j = rand( 0, 1 + $hex_encoding );
if ( $j == 0 ) {
$email_no_spam_address .= '&#' . ord( $email_address[$i] ) . ';';
} elseif ( $j == 1 ) {
$email_no_spam_address .= $email_address[$i];
} elseif ( $j == 2 ) {
$email_no_spam_address .= '%' . zeroise( dechex( ord( $email_address[$i] ) ), 2 );
}
}
$email_no_spam_address = str_replace( '@', '@', $email_no_spam_address );
return $email_no_spam_address;
}
/**
* Callback to convert URI match to HTML A element.
*
* This function was backported from 2.5.0 to 2.3.2. Regex callback for {@link
* make_clickable()}.
*
* @since 2.3.2
* @access private
*
* @param array $matches Single Regex Match.
* @return string HTML A element with URI address.
*/
function _make_url_clickable_cb($matches) {
$url = $matches[2];
if ( ')' == $matches[3] && strpos( $url, '(' ) ) {
// If the trailing character is a closing parethesis, and the URL has an opening parenthesis in it, add the closing parenthesis to the URL.
// Then we can let the parenthesis balancer do its thing below.
$url .= $matches[3];
$suffix = '';
} else {
$suffix = $matches[3];
}
// 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] . "<a href=\"$url\" rel=\"nofollow\">$url</a>" . $suffix;
}
/**
* Callback to convert URL match to HTML A element.
*
* This function was backported from 2.5.0 to 2.3.2. Regex callback for {@link
* make_clickable()}.
*
* @since 2.3.2
* @access private
*
* @param array $matches Single Regex Match.
* @return string HTML A element with URL address.
*/
function _make_web_ftp_clickable_cb($matches) {
$ret = '';
$dest = $matches[2];
$dest = 'http://' . $dest;
$dest = esc_url($dest);
if ( empty($dest) )
return $matches[0];
// removed trailing [.,;:)] from URL
if ( in_array( substr($dest, -1), array('.', ',', ';', ':', ')') ) === true ) {
$ret = substr($dest, -1);
$dest = substr($dest, 0, strlen($dest)-1);
}
return $matches[1] . "<a href=\"$dest\" rel=\"nofollow\">$dest</a>$ret";
}
/**
* Callback to convert email address match to HTML A element.
*
* This function was backported from 2.5.0 to 2.3.2. Regex callback for {@link
* make_clickable()}.
*
* @since 2.3.2
* @access private
*
* @param array $matches Single Regex Match.
* @return string HTML A element with email address.
*/
function _make_email_clickable_cb($matches) {
$email = $matches[2] . '@' . $matches[3];
return $matches[1] . "<a href=\"mailto:$email\">$email</a>";
}
/**
* Convert plaintext URI to HTML links.
*
* Converts URI, www and ftp, and email addresses. Finishes by fixing links
* within links.
*
* @since 0.71
*
* @param string $text Content to convert URIs.
* @return string Content with converted URIs.
*/
function make_clickable( $text ) {
$r = '';
$textarr = preg_split( '/(<[^<>]+>)/', $text, -1, PREG_SPLIT_DELIM_CAPTURE ); // split out HTML tags
$nested_code_pre = 0; // Keep track of how many levels link is nested inside <pre> or <code>
foreach ( $textarr as $piece ) {
if ( preg_match( '|^<code[\s>]|i', $piece ) || preg_match( '|^<pre[\s>]|i', $piece ) )
$nested_code_pre++;
elseif ( ( '</code>' === strtolower( $piece ) || '</pre>' === strtolower( $piece ) ) && $nested_code_pre )
$nested_code_pre--;
if ( $nested_code_pre || empty( $piece ) || ( $piece[0] === '<' && ! preg_match( '|^<\s*[\w]{1,20}+://|', $piece ) ) ) {
$r .= $piece;
continue;
}
// Long strings might contain expensive edge cases ...
if ( 10000 < strlen( $piece ) ) {
// ... break it up
foreach ( _split_str_by_whitespace( $piece, 2100 ) as $chunk ) { // 2100: Extra room for scheme and leading and trailing paretheses
if ( 2101 < strlen( $chunk ) ) {
$r .= $chunk; // Too big, no whitespace: bail.
} else {
$r .= make_clickable( $chunk );
}
}
} else {
$ret = " $piece "; // Pad with whitespace to simplify the regexes
$url_clickable = '~
([\\s(<.,;:!?]) # 1: Leading whitespace, or punctuation
( # 2: URL
[\\w]{1,20}+:// # Scheme and hier-part prefix
(?=\S{1,2000}\s) # Limit to URLs less than about 2000 characters long
[\\w\\x80-\\xff#%\\~/@\\[\\]*(+=&$-]*+ # Non-punctuation URL character
(?: # Unroll the Loop: Only allow puctuation URL character if followed by a non-punctuation URL character
[\'.,;:!?)] # Punctuation URL character
[\\w\\x80-\\xff#%\\~/@\\[\\]*(+=&$-]++ # Non-punctuation URL character
)*
)
(\)?) # 3: Trailing closing parenthesis (for parethesis balancing post processing)
~xS'; // The regex is a non-anchored pattern and does not have a single fixed starting character.
// Tell PCRE to spend more time optimizing since, when used on a page load, it will probably be used several times.
$ret = preg_replace_callback( $url_clickable, '_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 );
$ret = substr( $ret, 1, -1 ); // Remove our whitespace padding.
$r .= $ret;
}
}
// Cleanup of accidental links within links
$r = preg_replace( '#(<a([ \r\n\t]+[^>]+?>|>))<a [^>]+?>([^>]+?)</a></a>#i', "$1$3</a>", $r );
return $r;
}
/**
* Breaks a string into chunks by splitting at whitespace characters.
* The length of each returned chunk is as close to the specified length goal as possible,
* with the caveat that each chunk includes its trailing delimiter.
* Chunks longer than the goal are guaranteed to not have any inner whitespace.
*
* Joining the returned chunks with empty delimiters reconstructs the input string losslessly.
*
* Input string must have no null characters (or eventual transformations on output chunks must not care about null characters)
*
* <code>
* _split_str_by_whitespace( "1234 67890 1234 67890a cd 1234 890 123456789 1234567890a 45678 1 3 5 7 90 ", 10 ) ==
* array (
* 0 => '1234 67890 ', // 11 characters: Perfect split
* 1 => '1234 ', // 5 characters: '1234 67890a' was too long
* 2 => '67890a cd ', // 10 characters: '67890a cd 1234' was too long
* 3 => '1234 890 ', // 11 characters: Perfect split
* 4 => '123456789 ', // 10 characters: '123456789 1234567890a' was too long
* 5 => '1234567890a ', // 12 characters: Too long, but no inner whitespace on which to split
* 6 => ' 45678 ', // 11 characters: Perfect split
* 7 => '1 3 5 7 9', // 9 characters: End of $string
* );
* </code>
*
* @since 3.4.0
* @access private
*
* @param string $string The string to split.
* @param int $goal The desired chunk length.
* @return array Numeric array of chunks.
*/
function _split_str_by_whitespace( $string, $goal ) {
$chunks = array();
$string_nullspace = strtr( $string, "\r\n\t\v\f ", "\000\000\000\000\000\000" );
while ( $goal < strlen( $string_nullspace ) ) {
$pos = strrpos( substr( $string_nullspace, 0, $goal + 1 ), "\000" );
if ( false === $pos ) {
$pos = strpos( $string_nullspace, "\000", $goal + 1 );
if ( false === $pos ) {
break;
}
}
$chunks[] = substr( $string, 0, $pos + 1 );
$string = substr( $string, $pos + 1 );
$string_nullspace = substr( $string_nullspace, $pos + 1 );
}
if ( $string ) {
$chunks[] = $string;
}
return $chunks;
}
/**
* Adds rel nofollow string to all HTML A elements in content.
*
* @since 1.5.0
*
* @param string $text Content that may contain HTML A elements.
* @return string Converted content.
*/
function wp_rel_nofollow( $text ) {
// This is a pre save filter, so text is already escaped.
$text = stripslashes($text);
$text = preg_replace_callback('|<a (.+?)>|i', 'wp_rel_nofollow_callback', $text);
$text = wp_slash($text);
return $text;
}
/**
* Callback to add rel=nofollow string to HTML A element.
*
* Will remove already existing rel="nofollow" and rel='nofollow' from the
* string to prevent from invalidating (X)HTML.
*
* @since 2.3.0
*
* @param array $matches Single Match
* @return string HTML A Element with rel nofollow.
*/
function wp_rel_nofollow_callback( $matches ) {
$text = $matches[1];
$text = str_replace(array(' rel="nofollow"', " rel='nofollow'"), '', $text);
return "<a $text rel=\"nofollow\">";
}
/**
* Convert one smiley code to the icon graphic file equivalent.
*
* Callback handler for {@link convert_smilies()}.
* Looks up one smiley code in the $wpsmiliestrans global array and returns an
* <img> string for that smiley.
*
* @global array $wpsmiliestrans
* @since 2.8.0
*
* @param array $matches Single match. Smiley code to convert to image.
* @return string Image string for smiley.
*/
function translate_smiley( $matches ) {
global $wpsmiliestrans;
if ( count( $matches ) == 0 )
return '';
$smiley = trim( reset( $matches ) );
$img = $wpsmiliestrans[ $smiley ];
/**
* Filter the Smiley image URL before it's used in the image element.
*
* @since 2.9.0
*
* @param string $smiley_url URL for the smiley image.
* @param string $img Filename for the smiley image.
* @param string $site_url Site URL, as returned by site_url().
*/
$src_url = apply_filters( 'smilies_src', includes_url( "images/smilies/$img" ), $img, site_url() );
return sprintf( ' <img src="%s" alt="%s" class="wp-smiley" /> ', esc_url( $src_url ), esc_attr( $smiley ) );
}
/**
* Convert text equivalent of smilies to images.
*
* Will only convert smilies if the option 'use_smilies' is true and the global
* used in the function isn't empty.
*
* @since 0.71
* @uses $wp_smiliessearch
*
* @param string $text Content to convert smilies from text.
* @return string Converted content with text smilies replaced with images.
*/
function convert_smilies( $text ) {
global $wp_smiliessearch;
$output = '';
if ( get_option( 'use_smilies' ) && ! empty( $wp_smiliessearch ) ) {
// HTML loop taken from texturize function, could possible be consolidated
$textarr = preg_split( '/(<.*>)/U', $text, -1, PREG_SPLIT_DELIM_CAPTURE ); // capture the tags as well as in between
$stop = count( $textarr );// loop stuff
// Ignore proessing of specific tags
$tags_to_ignore = 'code|pre|style|script|textarea';
$ignore_block_element = '';
for ( $i = 0; $i < $stop; $i++ ) {
$content = $textarr[$i];
// If we're in an ignore block, wait until we find its closing tag
if ( '' == $ignore_block_element && preg_match( '/^<(' . $tags_to_ignore . ')>/', $content, $matches ) ) {
$ignore_block_element = $matches[1];
}
// If it's not a tag and not in ignore block
if ( '' == $ignore_block_element && strlen( $content ) > 0 && '<' != $content[0] ) {
$content = preg_replace_callback( $wp_smiliessearch, 'translate_smiley', $content );
}
// did we exit ignore block
if ( '' != $ignore_block_element && '</' . $ignore_block_element . '>' == $content ) {
$ignore_block_element = '';
}
$output .= $content;
}
} else {
// return default text.
$output = $text;
}
return $output;
}
/**
* Verifies that an email is valid.
*
* Does not grok i18n domains. Not RFC compliant.
*
* @since 0.71
*
* @param string $email Email address to verify.
* @param boolean $deprecated Deprecated.
* @return string|bool Either false or the valid email address.
*/
function is_email( $email, $deprecated = false ) {
if ( ! empty( $deprecated ) )
_deprecated_argument( __FUNCTION__, '3.0' );
// Test for the minimum length the email can be
if ( strlen( $email ) < 3 ) {
/**
* Filter whether an email address is valid.
*
* This filter is evaluated under several different contexts, such as 'email_too_short',
* 'email_no_at', 'local_invalid_chars', 'domain_period_sequence', 'domain_period_limits',
* 'domain_no_periods', 'sub_hyphen_limits', 'sub_invalid_chars', or no specific context.
*
* @since 2.8.0
*
* @param bool $is_email Whether the email address has passed the is_email() checks. Default false.
* @param string $email The email address being checked.
* @param string $message An explanatory message to the user.
* @param string $context Context under which the email was tested.
*/
return apply_filters( 'is_email', false, $email, 'email_too_short' );
}
// Test for an @ character after the first position
if ( strpos( $email, '@', 1 ) === false ) {
/** This filter is documented in wp-includes/formatting.php */
return apply_filters( 'is_email', false, $email, 'email_no_at' );
}
// Split out the local and domain parts
list( $local, $domain ) = explode( '@', $email, 2 );
// LOCAL PART
// Test for invalid characters
if ( !preg_match( '/^[a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~\.-]+$/', $local ) ) {
/** This filter is documented in wp-includes/formatting.php */
return apply_filters( 'is_email', false, $email, 'local_invalid_chars' );
}
// DOMAIN PART
// Test for sequences of periods
if ( preg_match( '/\.{2,}/', $domain ) ) {
/** This filter is documented in wp-includes/formatting.php */
return apply_filters( 'is_email', false, $email, 'domain_period_sequence' );
}
// Test for leading and trailing periods and whitespace
if ( trim( $domain, " \t\n\r\0\x0B." ) !== $domain ) {
/** This filter is documented in wp-includes/formatting.php */
return apply_filters( 'is_email', false, $email, 'domain_period_limits' );
}
// Split the domain into subs
$subs = explode( '.', $domain );
// Assume the domain will have at least two subs
if ( 2 > count( $subs ) ) {
/** This filter is documented in wp-includes/formatting.php */
return apply_filters( 'is_email', false, $email, 'domain_no_periods' );
}
// Loop through each sub
foreach ( $subs as $sub ) {
// Test for leading and trailing hyphens and whitespace
if ( trim( $sub, " \t\n\r\0\x0B-" ) !== $sub ) {
/** This filter is documented in wp-includes/formatting.php */
return apply_filters( 'is_email', false, $email, 'sub_hyphen_limits' );
}
// Test for invalid characters
if ( !preg_match('/^[a-z0-9-]+$/i', $sub ) ) {
/** This filter is documented in wp-includes/formatting.php */
return apply_filters( 'is_email', false, $email, 'sub_invalid_chars' );
}
}
// Congratulations your email made it!
/** This filter is documented in wp-includes/formatting.php */
return apply_filters( 'is_email', $email, $email, null );
}
/**
* Convert to ASCII from email subjects.
*
* @since 1.2.0
*
* @param string $string Subject line
* @return string Converted string to ASCII
*/
function wp_iso_descrambler($string) {
/* this may only work with iso-8859-1, I'm afraid */
if (!preg_match('#\=\?(.+)\?Q\?(.+)\?\=#i', $string, $matches)) {
return $string;
} else {
$subject = str_replace('_', ' ', $matches[2]);
$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
* @return array Converted chars
*/
function _wp_iso_convert( $match ) {
return chr( hexdec( strtolower( $match[1] ) ) );
}
/**
* Returns a date in the GMT equivalent.
*
* Requires and returns a date in the Y-m-d H:i:s format. If there is a
* timezone_string available, the date is assumed to be in that timezone,
* otherwise it simply subtracts the value of the 'gmt_offset' option. Return
* format can be overridden using the $format parameter.
*
* @since 1.2.0
*
* @uses get_option() to retrieve the value of 'gmt_offset'.
* @param string $string The date to be converted.
* @param string $format The format string for the returned date (default is Y-m-d H:i:s)
* @return string GMT version of the date provided.
*/
function get_gmt_from_date( $string, $format = 'Y-m-d H:i:s' ) {
$tz = get_option( 'timezone_string' );
if ( $tz ) {
$datetime = date_create( $string, new DateTimeZone( $tz ) );
if ( ! $datetime )
return gmdate( $format, 0 );
$datetime->setTimezone( new DateTimeZone( 'UTC' ) );
$string_gmt = $datetime->format( $format );
} else {
if ( ! preg_match( '#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $string, $matches ) )
return gmdate( $format, 0 );
$string_time = gmmktime( $matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1] );
$string_gmt = gmdate( $format, $string_time - get_option( 'gmt_offset' ) * HOUR_IN_SECONDS );
}
return $string_gmt;
}
/**
* Converts a GMT date into the correct format for the blog.
*
* Requires and returns a date in the Y-m-d H:i:s format. If there is a
* timezone_string available, the returned date is in that timezone, otherwise
* it simply adds the value of gmt_offset. Return format can be overridden
* using the $format parameter
*
* @since 1.2.0
*
* @param string $string The date to be converted.
* @param string $format The format string for the returned date (default is Y-m-d H:i:s)
* @return string Formatted date relative to the timezone / GMT offset.
*/
function get_date_from_gmt( $string, $format = 'Y-m-d H:i:s' ) {
$tz = get_option( 'timezone_string' );
if ( $tz ) {
$datetime = date_create( $string, new DateTimeZone( 'UTC' ) );
if ( ! $datetime )
return date( $format, 0 );
$datetime->setTimezone( new DateTimeZone( $tz ) );
$string_localtime = $datetime->format( $format );
} else {
if ( ! preg_match('#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $string, $matches) )
return date( $format, 0 );
$string_time = gmmktime( $matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1] );
$string_localtime = gmdate( $format, $string_time + get_option( 'gmt_offset' ) * HOUR_IN_SECONDS );
}
return $string_localtime;
}
/**
* Computes an offset in seconds from an iso8601 timezone.
*
* @since 1.5.0
*
* @param string $timezone Either 'Z' for 0 offset or '±hhmm'.
* @return int|float The offset in seconds.
*/
function iso8601_timezone_to_offset($timezone) {
// $timezone is either 'Z' or '[+|-]hhmm'
if ($timezone == 'Z') {
$offset = 0;
} else {
$sign = (substr($timezone, 0, 1) == '+') ? 1 : -1;
$hours = intval(substr($timezone, 1, 2));
$minutes = intval(substr($timezone, 3, 4)) / 60;
$offset = $sign * HOUR_IN_SECONDS * ($hours + $minutes);
}
return $offset;
}
/**
* Converts an iso8601 date to MySQL DateTime format used by post_date[_gmt].
*
* @since 1.5.0
*
* @param string $date_string Date and time in ISO 8601 format {@link http://en.wikipedia.org/wiki/ISO_8601}.
* @param string $timezone Optional. If set to GMT returns the time minus gmt_offset. Default is 'user'.
* @return string The date and time in MySQL DateTime format - Y-m-d H:i:s.
*/
function iso8601_to_datetime($date_string, $timezone = 'user') {
$timezone = strtolower($timezone);
if ($timezone == 'gmt') {
preg_match('#([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(Z|[\+|\-][0-9]{2,4}){0,1}#', $date_string, $date_bits);
if (!empty($date_bits[7])) { // we have a timezone, so let's compute an offset
$offset = iso8601_timezone_to_offset($date_bits[7]);
} else { // we don't have a timezone, so we assume user local timezone (not server's!)
$offset = HOUR_IN_SECONDS * get_option('gmt_offset');
}
$timestamp = gmmktime($date_bits[4], $date_bits[5], $date_bits[6], $date_bits[2], $date_bits[3], $date_bits[1]);
$timestamp -= $offset;
return gmdate('Y-m-d H:i:s', $timestamp);
} else if ($timezone == 'user') {
return preg_replace('#([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(Z|[\+|\-][0-9]{2,4}){0,1}#', '$1-$2-$3 $4:$5:$6', $date_string);
}
}
/**
* Adds a element attributes to open links in new windows.
*
* Comment text in popup windows should be filtered through this. Right now it's
* a moderately dumb function, ideally it would detect whether a target or rel
* attribute was already there and adjust its actions accordingly.
*
* @since 0.71
*
* @param string $text Content to replace links to open in a new window.
* @return string Content that has filtered links.
*/
function popuplinks($text) {
$text = preg_replace('/<a (.+?)>/i', "<a $1 target='_blank' rel='external'>", $text);
return $text;
}
/**
* Strips out all characters that are not allowable in an email.
*
* @since 1.5.0
*
* @param string $email Email address to filter.
* @return string Filtered email address.
*/
function sanitize_email( $email ) {
// Test for the minimum length the email can be
if ( strlen( $email ) < 3 ) {
/**
* Filter a sanitized email address.
*
* This filter is evaluated under several contexts, including 'email_too_short',
* 'email_no_at', 'local_invalid_chars', 'domain_period_sequence', 'domain_period_limits',
* 'domain_no_periods', 'domain_no_valid_subs', or no context.
*
* @since 2.8.0
*
* @param string $email The sanitized email address.
* @param string $email The email address, as provided to sanitize_email().
* @param string $message A message to pass to the user.
*/
return apply_filters( 'sanitize_email', '', $email, 'email_too_short' );
}
// Test for an @ character after the first position
if ( strpos( $email, '@', 1 ) === false ) {
/** This filter is documented in wp-includes/formatting.php */
return apply_filters( 'sanitize_email', '', $email, 'email_no_at' );
}
// Split out the local and domain parts
list( $local, $domain ) = explode( '@', $email, 2 );
// LOCAL PART
// Test for invalid characters
$local = preg_replace( '/[^a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~\.-]/', '', $local );
if ( '' === $local ) {
/** This filter is documented in wp-includes/formatting.php */
return apply_filters( 'sanitize_email', '', $email, 'local_invalid_chars' );
}
// DOMAIN PART
// Test for sequences of periods
$domain = preg_replace( '/\.{2,}/', '', $domain );
if ( '' === $domain ) {
/** This filter is documented in wp-includes/formatting.php */
return apply_filters( 'sanitize_email', '', $email, 'domain_period_sequence' );
}
// Test for leading and trailing periods and whitespace
$domain = trim( $domain, " \t\n\r\0\x0B." );
if ( '' === $domain ) {
/** This filter is documented in wp-includes/formatting.php */
return apply_filters( 'sanitize_email', '', $email, 'domain_period_limits' );
}
// Split the domain into subs
$subs = explode( '.', $domain );
// Assume the domain will have at least two subs
if ( 2 > count( $subs ) ) {
/** This filter is documented in wp-includes/formatting.php */
return apply_filters( 'sanitize_email', '', $email, 'domain_no_periods' );
}
// Create an array that will contain valid subs
$new_subs = array();
// Loop through each sub
foreach ( $subs as $sub ) {
// Test for leading and trailing hyphens
$sub = trim( $sub, " \t\n\r\0\x0B-" );
// Test for invalid characters
$sub = preg_replace( '/[^a-z0-9-]+/i', '', $sub );
// If there's anything left, add it to the valid subs
if ( '' !== $sub ) {
$new_subs[] = $sub;
}
}
// If there aren't 2 or more valid subs
if ( 2 > count( $new_subs ) ) {
/** This filter is documented in wp-includes/formatting.php */
return apply_filters( 'sanitize_email', '', $email, 'domain_no_valid_subs' );
}
// Join valid subs into the new domain
$domain = join( '.', $new_subs );
// Put the email back together
$email = $local . '@' . $domain;
// Congratulations your email made it!
/** This filter is documented in wp-includes/formatting.php */
return apply_filters( 'sanitize_email', $email, $email, null );
}
/**
* Determines the difference between two timestamps.
*
* The difference is returned in a human readable format such as "1 hour",
* "5 mins", "2 days".
*
* @since 1.5.0
*
* @param int $from Unix timestamp from which the difference begins.
* @param int $to Optional. Unix timestamp to end the time difference. Default becomes time() if not set.
* @return string Human readable time difference.
*/
function human_time_diff( $from, $to = '' ) {
if ( empty( $to ) )
$to = time();
$diff = (int) abs( $to - $from );
if ( $diff < HOUR_IN_SECONDS ) {
$mins = round( $diff / MINUTE_IN_SECONDS );
if ( $mins <= 1 )
$mins = 1;
/* translators: min=minute */
$since = sprintf( _n( '%s min', '%s mins', $mins ), $mins );
} elseif ( $diff < DAY_IN_SECONDS && $diff >= HOUR_IN_SECONDS ) {
$hours = round( $diff / HOUR_IN_SECONDS );
if ( $hours <= 1 )
$hours = 1;
$since = sprintf( _n( '%s hour', '%s hours', $hours ), $hours );
} elseif ( $diff < WEEK_IN_SECONDS && $diff >= DAY_IN_SECONDS ) {
$days = round( $diff / DAY_IN_SECONDS );
if ( $days <= 1 )
$days = 1;
$since = sprintf( _n( '%s day', '%s days', $days ), $days );
} elseif ( $diff < 30 * DAY_IN_SECONDS && $diff >= WEEK_IN_SECONDS ) {
$weeks = round( $diff / WEEK_IN_SECONDS );
if ( $weeks <= 1 )
$weeks = 1;
$since = sprintf( _n( '%s week', '%s weeks', $weeks ), $weeks );
} elseif ( $diff < YEAR_IN_SECONDS && $diff >= 30 * DAY_IN_SECONDS ) {
$months = round( $diff / ( 30 * DAY_IN_SECONDS ) );
if ( $months <= 1 )
$months = 1;
$since = sprintf( _n( '%s month', '%s months', $months ), $months );
} elseif ( $diff >= YEAR_IN_SECONDS ) {
$years = round( $diff / YEAR_IN_SECONDS );
if ( $years <= 1 )
$years = 1;
$since = sprintf( _n( '%s year', '%s years', $years ), $years );
}
return $since;
}
/**
* Generates an excerpt from the content, if needed.
*
* The excerpt word amount will be 55 words and if the amount is greater than
* that, then the string ' […]' will be appended to the excerpt. If the string
* is less than 55 words, then the content will be returned as is.
*
* The 55 word limit can be modified by plugins/themes using the excerpt_length filter
* The ' […]' string can be modified by plugins/themes using the excerpt_more filter
*
* @since 1.5.0
*
* @param string $text Optional. The excerpt. If set to empty, an excerpt is generated.
* @return string The excerpt.
*/
function wp_trim_excerpt($text = '') {
$raw_excerpt = $text;
if ( '' == $text ) {
$text = get_the_content('');
$text = strip_shortcodes( $text );
/** This filter is documented in wp-includes/post-template.php */
$text = apply_filters( 'the_content', $text );
$text = str_replace(']]>', ']]>', $text);
/**
* Filter the number of words in an excerpt.
*
* @since 2.7.0
*
* @param int $number The number of words. Default 55.
*/
$excerpt_length = apply_filters( 'excerpt_length', 55 );
/**
* Filter the string in the "more" link displayed after a trimmed excerpt.
*
* @since 2.9.0
*
* @param string $more_string The string shown within the more link.
*/
$excerpt_more = apply_filters( 'excerpt_more', ' ' . '[…]' );
$text = wp_trim_words( $text, $excerpt_length, $excerpt_more );
}
/**
* Filter the trimmed excerpt string.
*
* @since 2.8.0
*
* @param string $text The trimmed text.
* @param string $raw_excerpt The text prior to trimming.
*/
return apply_filters( 'wp_trim_excerpt', $text, $raw_excerpt );
}
/**
* Trims text to a certain number of words.
*
* This function is localized. For languages that count 'words' by the individual
* character (such as East Asian languages), the $num_words argument will apply
* to the number of individual characters.
*
* @since 3.3.0
*
* @param string $text Text to trim.
* @param int $num_words Number of words. Default 55.
* @param string $more Optional. What to append if $text needs to be trimmed. Default '…'.
* @return string Trimmed text.
*/
function wp_trim_words( $text, $num_words = 55, $more = null ) {
if ( null === $more )
$more = __( '…' );
$original_text = $text;
$text = wp_strip_all_tags( $text );
/* translators: If your word count is based on single characters (East Asian characters),
enter 'characters'. Otherwise, enter 'words'. Do not translate into your own language. */
if ( 'characters' == _x( 'words', 'word count: words or characters?' ) && preg_match( '/^utf\-?8$/i', get_option( 'blog_charset' ) ) ) {
$text = trim( preg_replace( "/[\n\r\t ]+/", ' ', $text ), ' ' );
preg_match_all( '/./u', $text, $words_array );
$words_array = array_slice( $words_array[0], 0, $num_words + 1 );
$sep = '';
} else {
$words_array = preg_split( "/[\n\r\t ]+/", $text, $num_words + 1, PREG_SPLIT_NO_EMPTY );
$sep = ' ';
}
if ( count( $words_array ) > $num_words ) {
array_pop( $words_array );
$text = implode( $sep, $words_array );
$text = $text . $more;
} else {
$text = implode( $sep, $words_array );
}
/**
* Filter the text content after words have been trimmed.
*
* @since 3.3.0
*
* @param string $text The trimmed text.
* @param int $num_words The number of words to trim the text to. Default 5.
* @param string $more An optional string to append to the end of the trimmed text, e.g. ….
* @param string $original_text The text before it was trimmed.
*/
return apply_filters( 'wp_trim_words', $text, $num_words, $more, $original_text );
}
/**
* Converts named entities into numbered entities.
*
* @since 1.5.1
*
* @param string $text The text within which entities will be converted.
* @return string Text with converted entities.
*/
function ent2ncr($text) {
/**
* Filter text before named entities are converted into numbered entities.
*
* A non-null string must be returned for the filter to be evaluated.
*
* @since 3.3.0
*
* @param null $converted_text The text to be converted. Default null.
* @param string $text The text prior to entity conversion.
*/
$filtered = apply_filters( 'pre_ent2ncr', null, $text );
if( null !== $filtered )
return $filtered;
$to_ncr = array(
'"' => '"',
'&' => '&',
'<' => '<',
'>' => '>',
'|' => '|',
' ' => ' ',
'¡' => '¡',
'¢' => '¢',
'£' => '£',
'¤' => '¤',
'¥' => '¥',
'¦' => '¦',
'&brkbar;' => '¦',
'§' => '§',
'¨' => '¨',
'¨' => '¨',
'©' => '©',
'ª' => 'ª',
'«' => '«',
'¬' => '¬',
'­' => '­',
'®' => '®',
'¯' => '¯',
'&hibar;' => '¯',
'°' => '°',
'±' => '±',
'²' => '²',
'³' => '³',
'´' => '´',
'µ' => 'µ',
'¶' => '¶',
'·' => '·',
'¸' => '¸',
'¹' => '¹',
'º' => 'º',
'»' => '»',
'¼' => '¼',
'½' => '½',
'¾' => '¾',
'¿' => '¿',
'À' => 'À',
'Á' => 'Á',
'Â' => 'Â',
'Ã' => 'Ã',
'Ä' => 'Ä',
'Å' => 'Å',
'Æ' => 'Æ',
'Ç' => 'Ç',
'È' => 'È',
'É' => 'É',
'Ê' => 'Ê',
'Ë' => 'Ë',
'Ì' => 'Ì',
'Í' => 'Í',
'Î' => 'Î',
'Ï' => 'Ï',
'Ð' => 'Ð',
'Ñ' => 'Ñ',
'Ò' => 'Ò',
'Ó' => 'Ó',
'Ô' => 'Ô',
'Õ' => 'Õ',
'Ö' => 'Ö',
'×' => '×',
'Ø' => 'Ø',
'Ù' => 'Ù',
'Ú' => 'Ú',
'Û' => 'Û',
'Ü' => 'Ü',
'Ý' => 'Ý',
'Þ' => 'Þ',
'ß' => 'ß',
'à' => 'à',
'á' => 'á',
'â' => 'â',
'ã' => 'ã',
'ä' => 'ä',
'å' => 'å',
'æ' => 'æ',
'ç' => 'ç',
'è' => 'è',
'é' => 'é',
'ê' => 'ê',
'ë' => 'ë',
'ì' => 'ì',
'í' => 'í',
'î' => 'î',
'ï' => 'ï',
'ð' => 'ð',
'ñ' => 'ñ',
'ò' => 'ò',
'ó' => 'ó',
'ô' => 'ô',
'õ' => 'õ',
'ö' => 'ö',
'÷' => '÷',
'ø' => 'ø',
'ù' => 'ù',
'ú' => 'ú',
'û' => 'û',
'ü' => 'ü',
'ý' => 'ý',
'þ' => 'þ',
'ÿ' => 'ÿ',
'Œ' => 'Œ',
'œ' => 'œ',
'Š' => 'Š',
'š' => 'š',
'Ÿ' => 'Ÿ',
'ƒ' => 'ƒ',
'ˆ' => 'ˆ',
'˜' => '˜',
'Α' => 'Α',
'Β' => 'Β',
'Γ' => 'Γ',
'Δ' => 'Δ',
'Ε' => 'Ε',
'Ζ' => 'Ζ',
'Η' => 'Η',
'Θ' => 'Θ',
'Ι' => 'Ι',
'Κ' => 'Κ',
'Λ' => 'Λ',
'Μ' => 'Μ',
'Ν' => 'Ν',
'Ξ' => 'Ξ',
'Ο' => 'Ο',
'Π' => 'Π',
'Ρ' => 'Ρ',
'Σ' => 'Σ',
'Τ' => 'Τ',
'Υ' => 'Υ',
'Φ' => 'Φ',
'Χ' => 'Χ',
'Ψ' => 'Ψ',
'Ω' => 'Ω',
'α' => 'α',
'β' => 'β',
'γ' => 'γ',
'δ' => 'δ',
'ε' => 'ε',
'ζ' => 'ζ',
'η' => 'η',
'θ' => 'θ',
'ι' => 'ι',
'κ' => 'κ',
'λ' => 'λ',
'μ' => 'μ',
'ν' => 'ν',
'ξ' => 'ξ',
'ο' => 'ο',
'π' => 'π',
'ρ' => 'ρ',
'ς' => 'ς',
'σ' => 'σ',
'τ' => 'τ',
'υ' => 'υ',
'φ' => 'φ',
'χ' => 'χ',
'ψ' => 'ψ',
'ω' => 'ω',
'ϑ' => 'ϑ',
'ϒ' => 'ϒ',
'ϖ' => 'ϖ',
' ' => ' ',
' ' => ' ',
' ' => ' ',
'‌' => '‌',
'‍' => '‍',
'‎' => '‎',
'‏' => '‏',
'–' => '–',
'—' => '—',
'‘' => '‘',
'’' => '’',
'‚' => '‚',
'“' => '“',
'”' => '”',
'„' => '„',
'†' => '†',
'‡' => '‡',
'•' => '•',
'…' => '…',
'‰' => '‰',
'′' => '′',
'″' => '″',
'‹' => '‹',
'›' => '›',
'‾' => '‾',
'⁄' => '⁄',
'€' => '€',
'ℑ' => 'ℑ',
'℘' => '℘',
'ℜ' => 'ℜ',
'™' => '™',
'ℵ' => 'ℵ',
'↵' => '↵',
'⇐' => '⇐',
'⇑' => '⇑',
'⇒' => '⇒',
'⇓' => '⇓',
'⇔' => '⇔',
'∀' => '∀',
'∂' => '∂',
'∃' => '∃',
'∅' => '∅',
'∇' => '∇',
'∈' => '∈',
'∉' => '∉',
'∋' => '∋',
'∏' => '∏',
'∑' => '∑',
'−' => '−',
'∗' => '∗',
'√' => '√',
'∝' => '∝',
'∞' => '∞',
'∠' => '∠',
'∧' => '∧',
'∨' => '∨',
'∩' => '∩',
'∪' => '∪',
'∫' => '∫',
'∴' => '∴',
'∼' => '∼',
'≅' => '≅',
'≈' => '≈',
'≠' => '≠',
'≡' => '≡',
'≤' => '≤',
'≥' => '≥',
'⊂' => '⊂',
'⊃' => '⊃',
'⊄' => '⊄',
'⊆' => '⊆',
'⊇' => '⊇',
'⊕' => '⊕',
'⊗' => '⊗',
'⊥' => '⊥',
'⋅' => '⋅',
'⌈' => '⌈',
'⌉' => '⌉',
'⌊' => '⌊',
'⌋' => '⌋',
'⟨' => '〈',
'⟩' => '〉',
'←' => '←',
'↑' => '↑',
'→' => '→',
'↓' => '↓',
'↔' => '↔',
'◊' => '◊',
'♠' => '♠',
'♣' => '♣',
'♥' => '♥',
'♦' => '♦'
);
return str_replace( array_keys($to_ncr), array_values($to_ncr), $text );
}
/**
* Formats text for the rich text editor.
*
* The filter 'richedit_pre' is applied here. If $text is empty the filter will
* be applied to an empty string.
*
* @since 2.0.0
*
* @param string $text The text to be formatted.
* @return string The formatted text after filter is applied.
*/
function wp_richedit_pre($text) {
if ( empty( $text ) ) {
/**
* Filter text returned for the rich text editor.
*
* This filter is first evaluated, and the value returned, if an empty string
* is passed to wp_richedit_pre(). If an empty string is passed, it results
* in a break tag and line feed.
*
* If a non-empty string is passed, the filter is evaluated on the wp_richedit_pre()
* return after being formatted.
*
* @since 2.0.0
*
* @param string $output Text for the rich text editor.
*/
return apply_filters( 'richedit_pre', '' );
}
$output = convert_chars($text);
$output = wpautop($output);
$output = htmlspecialchars($output, ENT_NOQUOTES, get_option( 'blog_charset' ) );
/** This filter is documented in wp-includes/formatting.php */
return apply_filters( 'richedit_pre', $output );
}
/**
* Formats text for the HTML editor.
*
* Unless $output is empty it will pass through htmlspecialchars before the
* 'htmledit_pre' filter is applied.
*
* @since 2.5.0
*
* @param string $output The text to be formatted.
* @return string Formatted text after filter applied.
*/
function wp_htmledit_pre($output) {
if ( !empty($output) )
$output = htmlspecialchars($output, ENT_NOQUOTES, get_option( 'blog_charset' ) ); // convert only < > &
/**
* Filter the text before it is formatted for the HTML editor.
*
* @since 2.5.0
*
* @param string $output The HTML-formatted text.
*/
return apply_filters( 'htmledit_pre', $output );
}
/**
* Perform a deep string replace operation to ensure the values in $search are no longer present
*
* Repeats the replacement operation until it no longer replaces anything so as to remove "nested" values
* e.g. $subject = '%0%0%0DDD', $search ='%0D', $result ='' rather than the '%0%0DD' that
* str_replace would return
*
* @since 2.8.1
* @access private
*
* @param string|array $search The value being searched for, otherwise known as the needle. An array may be used to designate multiple needles.
* @param string $subject The string being searched and replaced on, otherwise known as the haystack.
* @return string The string with the replaced svalues.
*/
function _deep_replace( $search, $subject ) {
$subject = (string) $subject;
$count = 1;
while ( $count ) {
$subject = str_replace( $search, '', $subject, $count );
}
return $subject;
}
/**
* Escapes data for use in a MySQL query.
*
* Usually you should prepare queries using wpdb::prepare().
* Sometimes, spot-escaping is required or useful. One example
* is preparing an array for use in an IN clause.
*
* @since 2.8.0
* @param string|array $data Unescaped data
* @return string|array Escaped data
*/
function esc_sql( $data ) {
global $wpdb;
return $wpdb->_escape( $data );
}
/**
* Checks and cleans a URL.
*
* A number of characters are removed from the URL. If the URL is for displaying
* (the default behaviour) ampersands are also replaced. The 'clean_url' filter
* is applied to the returned cleaned URL.
*
* @since 2.8.0
* @uses wp_kses_bad_protocol() To only permit protocols in the URL set
* via $protocols or the common ones set in the function.
*
* @param string $url The URL to be cleaned.
* @param array $protocols Optional. An array of acceptable protocols.
* Defaults to 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet', 'mms', 'rtsp', 'svn' if not set.
* @param string $_context Private. Use esc_url_raw() for database usage.
* @return string The cleaned $url after the 'clean_url' filter is applied.
*/
function esc_url( $url, $protocols = null, $_context = 'display' ) {
$original_url = $url;
if ( '' == $url )
return $url;
$url = preg_replace('|[^a-z0-9-~+_.?#=!&;,/:%@$\|*\'()\\x80-\\xff]|i', '', $url);
$strip = array('%0d', '%0a', '%0D', '%0A');
$url = _deep_replace($strip, $url);
$url = str_replace(';//', '://', $url);
/* If the URL doesn't appear to contain a scheme, we
* presume it needs http:// appended (unless a relative
* link starting with /, # or ? or a php file).
*/
if ( strpos($url, ':') === false && ! in_array( $url[0], array( '/', '#', '?' ) ) &&
! preg_match('/^[a-z0-9-]+?\.php/i', $url) )
$url = 'http://' . $url;
// Replace ampersands and single quotes only when displaying.
if ( 'display' == $_context ) {
$url = wp_kses_normalize_entities( $url );
$url = str_replace( '&', '&', $url );
$url = str_replace( "'", ''', $url );
}
if ( '/' === $url[0] ) {
$good_protocol_url = $url;
} else {
if ( ! is_array( $protocols ) )
$protocols = wp_allowed_protocols();
$good_protocol_url = wp_kses_bad_protocol( $url, $protocols );
if ( strtolower( $good_protocol_url ) != strtolower( $url ) )
return '';
}
/**
* Filter a string cleaned and escaped for output as a URL.
*
* @since 2.3.0
*
* @param string $good_protocol_url The cleaned URL to be returned.
* @param string $original_url The URL prior to cleaning.
* @param string $_context If 'display', replace ampersands and single quotes only.
*/
return apply_filters( 'clean_url', $good_protocol_url, $original_url, $_context );
}
/**
* Performs esc_url() for database usage.
*
* @since 2.8.0
* @uses esc_url()
*
* @param string $url The URL to be cleaned.
* @param array $protocols An array of acceptable protocols.
* @return string The cleaned URL.
*/
function esc_url_raw( $url, $protocols = null ) {
return esc_url( $url, $protocols, 'db' );
}
/**
* Convert entities, while preserving already-encoded entities.
*
* @link http://www.php.net/htmlentities Borrowed from the PHP Manual user notes.
*
* @since 1.2.2
*
* @param string $myHTML The text to be converted.
* @return string Converted text.
*/
function htmlentities2($myHTML) {
$translation_table = get_html_translation_table( HTML_ENTITIES, ENT_QUOTES );
$translation_table[chr(38)] = '&';
return preg_replace( "/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/", "&", strtr($myHTML, $translation_table) );
}
/**
* Escape single quotes, htmlspecialchar " < > &, and fix line endings.
*
* Escapes text strings for echoing in JS. It is intended to be used for inline JS
* (in a tag attribute, for example onclick="..."). Note that the strings have to
* be in single quotes. The filter 'js_escape' is also applied here.
*
* @since 2.8.0
*
* @param string $text The text to be escaped.
* @return string Escaped text.
*/
function esc_js( $text ) {
$safe_text = wp_check_invalid_utf8( $text );
$safe_text = _wp_specialchars( $safe_text, ENT_COMPAT );
$safe_text = preg_replace( '/&#(x)?0*(?(1)27|39);?/i', "'", stripslashes( $safe_text ) );
$safe_text = str_replace( "\r", '', $safe_text );
$safe_text = str_replace( "\n", '\\n', addslashes( $safe_text ) );
/**
* Filter a string cleaned and escaped for output in JavaScript.
*
* Text passed to esc_js() is stripped of invalid or special characters,
* and properly slashed for output.
*
* @since 2.0.6
*
* @param string $safe_text The text after it has been escaped.
* @param string $text The text prior to being escaped.
*/
return apply_filters( 'js_escape', $safe_text, $text );
}
/**
* Escaping for HTML blocks.
*
* @since 2.8.0
*
* @param string $text
* @return string
*/
function esc_html( $text ) {
$safe_text = wp_check_invalid_utf8( $text );
$safe_text = _wp_specialchars( $safe_text, ENT_QUOTES );
/**
* Filter a string cleaned and escaped for output in HTML.
*
* Text passed to esc_html() is stripped of invalid or special characters
* before output.
*
* @since 2.8.0
*
* @param string $safe_text The text after it has been escaped.
* @param string $text The text prior to being escaped.
*/
return apply_filters( 'esc_html', $safe_text, $text );
}
/**
* Escaping for HTML attributes.
*
* @since 2.8.0
*
* @param string $text
* @return string
*/
function esc_attr( $text ) {
$safe_text = wp_check_invalid_utf8( $text );
$safe_text = _wp_specialchars( $safe_text, ENT_QUOTES );
/**
* Filter a string cleaned and escaped for output in an HTML attribute.
*
* Text passed to esc_attr() is stripped of invalid or special characters
* before output.
*
* @since 2.0.6
*
* @param string $safe_text The text after it has been escaped.
* @param string $text The text prior to being escaped.
*/
return apply_filters( 'attribute_escape', $safe_text, $text );
}
/**
* Escaping for textarea values.
*
* @since 3.1.0
*
* @param string $text
* @return string
*/
function esc_textarea( $text ) {
$safe_text = htmlspecialchars( $text, ENT_QUOTES, get_option( 'blog_charset' ) );
/**
* Filter a string cleaned and escaped for output in a textarea element.
*
* @since 3.1.0
*
* @param string $safe_text The text after it has been escaped.
* @param string $text The text prior to being escaped.
*/
return apply_filters( 'esc_textarea', $safe_text, $text );
}
/**
* Escape an HTML tag name.
*
* @since 2.5.0
*
* @param string $tag_name
* @return string
*/
function tag_escape($tag_name) {
$safe_tag = strtolower( preg_replace('/[^a-zA-Z0-9_:]/', '', $tag_name) );
/**
* Filter a string cleaned and escaped for output as an HTML tag.
*
* @since 2.8.0
*
* @param string $safe_tag The tag name after it has been escaped.
* @param string $tag_name The text before it was escaped.
*/
return apply_filters( 'tag_escape', $safe_tag, $tag_name );
}
/**
* Escapes text for SQL LIKE special characters % and _.
*
* @since 2.5.0
*
* @param string $text The text to be escaped.
* @return string text, safe for inclusion in LIKE query.
*/
function like_escape($text) {
return str_replace(array("%", "_"), array("\\%", "\\_"), $text);
}
/**
* Convert full URL paths to absolute paths.
*
* Removes the http or https protocols and the domain. Keeps the path '/' at the
* beginning, so it isn't a true relative link, but from the web root base.
*
* @since 2.1.0
*
* @param string $link Full URL path.
* @return string Absolute path.
*/
function wp_make_link_relative( $link ) {
return preg_replace( '|https?://[^/]+(/.*)|i', '$1', $link );
}
/**
* Sanitises various option values based on the nature of the option.
*
* This is basically a switch statement which will pass $value through a number
* of functions depending on the $option.
*
* @since 2.0.5
*
* @param string $option The name of the option.
* @param string $value The unsanitised value.
* @return string Sanitized value.
*/
function sanitize_option($option, $value) {
switch ( $option ) {
case 'admin_email' :
case 'new_admin_email' :
$value = sanitize_email( $value );
if ( ! is_email( $value ) ) {
$value = get_option( $option ); // Resets option to stored value in the case of failed sanitization
if ( function_exists( 'add_settings_error' ) )
add_settings_error( $option, 'invalid_admin_email', __( 'The email address entered did not appear to be a valid email address. Please enter a valid email address.' ) );
}
break;
case 'thumbnail_size_w':
case 'thumbnail_size_h':
case 'medium_size_w':
case 'medium_size_h':
case 'large_size_w':
case 'large_size_h':
case 'mailserver_port':
case 'comment_max_links':
case 'page_on_front':
case 'page_for_posts':
case 'rss_excerpt_length':
case 'default_category':
case 'default_email_category':
case 'default_link_category':
case 'close_comments_days_old':
case 'comments_per_page':
case 'thread_comments_depth':
case 'users_can_register':
case 'start_of_week':
$value = absint( $value );
break;
case 'posts_per_page':
case 'posts_per_rss':
$value = (int) $value;
if ( empty($value) )
$value = 1;
if ( $value < -1 )
$value = abs($value);
break;
case 'default_ping_status':
case 'default_comment_status':
// Options that if not there have 0 value but need to be something like "closed"
if ( $value == '0' || $value == '')
$value = 'closed';
break;
case 'blogdescription':
case 'blogname':
$value = wp_kses_post( $value );
$value = esc_html( $value );
break;
case 'blog_charset':
$value = preg_replace('/[^a-zA-Z0-9_-]/', '', $value); // strips slashes
break;
case 'blog_public':
// This is the value if the settings checkbox is not checked on POST. Don't rely on this.
if ( null === $value )
$value = 1;
else
$value = intval( $value );
break;
case 'date_format':
case 'time_format':
case 'mailserver_url':
case 'mailserver_login':
case 'mailserver_pass':
case 'upload_path':
$value = strip_tags( $value );
$value = wp_kses_data( $value );
break;
case 'ping_sites':
$value = explode( "\n", $value );
$value = array_filter( array_map( 'trim', $value ) );
$value = array_filter( array_map( 'esc_url_raw', $value ) );
$value = implode( "\n", $value );
break;
case 'gmt_offset':
$value = preg_replace('/[^0-9:.-]/', '', $value); // strips slashes
break;
case 'siteurl':
if ( (bool)preg_match( '#http(s?)://(.+)#i', $value) ) {
$value = esc_url_raw($value);
} else {
$value = get_option( $option ); // Resets option to stored value in the case of failed sanitization
if ( function_exists('add_settings_error') )
add_settings_error('siteurl', 'invalid_siteurl', __('The WordPress address you entered did not appear to be a valid URL. Please enter a valid URL.'));
}
break;
case 'home':
if ( (bool)preg_match( '#http(s?)://(.+)#i', $value) ) {
$value = esc_url_raw($value);
} else {
$value = get_option( $option ); // Resets option to stored value in the case of failed sanitization
if ( function_exists('add_settings_error') )
add_settings_error('home', 'invalid_home', __('The Site address you entered did not appear to be a valid URL. Please enter a valid URL.'));
}
break;
case 'WPLANG':
$allowed = get_available_languages();
if ( ! in_array( $value, $allowed ) && ! empty( $value ) )
$value = get_option( $option );
break;
case 'illegal_names':
if ( ! is_array( $value ) )
$value = explode( ' ', $value );
$value = array_values( array_filter( array_map( 'trim', $value ) ) );
if ( ! $value )
$value = '';
break;
case 'limited_email_domains':
case 'banned_email_domains':
if ( ! is_array( $value ) )
$value = explode( "\n", $value );
$domains = array_values( array_filter( array_map( 'trim', $value ) ) );
$value = array();
foreach ( $domains as $domain ) {
if ( ! preg_match( '/(--|\.\.)/', $domain ) && preg_match( '|^([a-zA-Z0-9-\.])+$|', $domain ) )
$value[] = $domain;
}
if ( ! $value )
$value = '';
break;
case 'timezone_string':
$allowed_zones = timezone_identifiers_list();
if ( ! in_array( $value, $allowed_zones ) && ! empty( $value ) ) {
$value = get_option( $option ); // Resets option to stored value in the case of failed sanitization
if ( function_exists('add_settings_error') )
add_settings_error('timezone_string', 'invalid_timezone_string', __('The timezone you have entered is not valid. Please select a valid timezone.') );
}
break;
case 'permalink_structure':
case 'category_base':
case 'tag_base':
$value = esc_url_raw( $value );
$value = str_replace( 'http://', '', $value );
break;
case 'default_role' :
if ( ! get_role( $value ) && get_role( 'subscriber' ) )
$value = 'subscriber';
break;
}
/**
* Filter an option value following sanitization.
*
* @since 2.3.0
*
* @param string $value The sanitized option value.
* @param string $option The option name.
*/
$value = apply_filters( "sanitize_option_{$option}", $value, $option );
return $value;
}
/**
* Parses a string into variables to be stored in an array.
*
* Uses {@link http://www.php.net/parse_str parse_str()} and stripslashes if
* {@link http://www.php.net/magic_quotes magic_quotes_gpc} is on.
*
* @since 2.2.1
*
* @param string $string The string to be parsed.
* @param array $array Variables will be stored in this array.
*/
function wp_parse_str( $string, &$array ) {
parse_str( $string, $array );
if ( get_magic_quotes_gpc() )
$array = stripslashes_deep( $array );
/**
* Filter the array of variables derived from a parsed string.
*
* @since 2.3.0
*
* @param array $array The array populated with variables.
*/
$array = apply_filters( 'wp_parse_str', $array );
}
/**
* Convert lone less than signs.
*
* KSES already converts lone greater than signs.
*
* @uses wp_pre_kses_less_than_callback in the callback function.
* @since 2.3.0
*
* @param string $text Text to be converted.
* @return string Converted text.
*/
function wp_pre_kses_less_than( $text ) {
return preg_replace_callback('%<[^>]*?((?=<)|>|$)%', 'wp_pre_kses_less_than_callback', $text);
}
/**
* Callback function used by preg_replace.
*
* @uses esc_html to format the $matches text.
* @since 2.3.0
*
* @param array $matches Populated by matches to preg_replace.
* @return string The text returned after esc_html if needed.
*/
function wp_pre_kses_less_than_callback( $matches ) {
if ( false === strpos($matches[0], '>') )
return esc_html($matches[0]);
return $matches[0];
}
/**
* WordPress implementation of PHP sprintf() with filters.
*
* @since 2.5.0
* @link http://www.php.net/sprintf
*
* @param string $pattern The string which formatted args are inserted.
* @param mixed $args,... Arguments to be formatted into the $pattern string.
* @return string The formatted string.
*/
function wp_sprintf( $pattern ) {
$args = func_get_args();
$len = strlen($pattern);
$start = 0;
$result = '';
$arg_index = 0;
while ( $len > $start ) {
// Last character: append and break
if ( strlen($pattern) - 1 == $start ) {
$result .= substr($pattern, -1);
break;
}
// Literal %: append and continue
if ( substr($pattern, $start, 2) == '%%' ) {
$start += 2;
$result .= '%';
continue;
}
// Get fragment before next %
$end = strpos($pattern, '%', $start + 1);
if ( false === $end )
$end = $len;
$fragment = substr($pattern, $start, $end - $start);
// Fragment has a specifier
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]] : '';
$fragment = str_replace("%{$matches[1]}$", '%', $fragment);
} else {
++$arg_index;
$arg = isset($args[$arg_index]) ? $args[$arg_index] : '';
}
/**
* Filter a fragment from the pattern passed to wp_sprintf().
*
* If the fragment is unchanged, then sprintf() will be run on the fragment.
*
* @since 2.5.0
*
* @param string $fragment A fragment from the pattern.
* @param string $arg The argument.
*/
$_fragment = apply_filters( 'wp_sprintf', $fragment, $arg );
if ( $_fragment != $fragment )
$fragment = $_fragment;
else
$fragment = sprintf($fragment, strval($arg) );
}
// Append to result and move to next fragment
$result .= $fragment;
$start = $end;
}
return $result;
}
/**
* Localize list items before the rest of the content.
*
* The '%l' must be at the first characters can then contain the rest of the
* content. The list items will have ', ', ', and', and ' and ' added depending
* on the amount of list items in the $args parameter.
*
* @since 2.5.0
*
* @param string $pattern Content containing '%l' at the beginning.
* @param array $args List items to prepend to the content and replace '%l'.
* @return string Localized list items and rest of the content.
*/
function wp_sprintf_l($pattern, $args) {
// Not a match
if ( substr($pattern, 0, 2) != '%l' )
return $pattern;
// Nothing to work with
if ( empty($args) )
return '';
/**
* Filter the translated delimiters used by wp_sprintf_l().
* Placeholders (%s) are included to assist translators and then
* removed before the array of strings reaches the filter.
*
* Please note: Ampersands and entities should be avoided here.
*
* @since 2.5.0
*
* @param array $delimiters An array of translated delimiters.
*/
$l = apply_filters( 'wp_sprintf_l', array(
/* translators: used to join items in a list with more than 2 items */
'between' => sprintf( __('%s, %s'), '', '' ),
/* translators: used to join last two items in a list with more than 2 times */
'between_last_two' => sprintf( __('%s, and %s'), '', '' ),
/* translators: used to join items in a list with only 2 items */
'between_only_two' => sprintf( __('%s and %s'), '', '' ),
) );
$args = (array) $args;
$result = array_shift($args);
if ( count($args) == 1 )
$result .= $l['between_only_two'] . array_shift($args);
// Loop when more than two args
$i = count($args);
while ( $i ) {
$arg = array_shift($args);
$i--;
if ( 0 == $i )
$result .= $l['between_last_two'] . $arg;
else
$result .= $l['between'] . $arg;
}
return $result . substr($pattern, 2);
}
/**
* Safely extracts not more than the first $count characters from html string.
*
* UTF-8, tags and entities safe prefix extraction. Entities inside will *NOT*
* be counted as one character. For example & will be counted as 4, < as
* 3, etc.
*
* @since 2.5.0
*
* @param string $str String to get the excerpt from.
* @param integer $count Maximum number of characters to take.
* @param string $more Optional. What to append if $str needs to be trimmed. Defaults to empty string.
* @return string The excerpt.
*/
function wp_html_excerpt( $str, $count, $more = null ) {
if ( null === $more )
$more = '';
$str = wp_strip_all_tags( $str, true );
$excerpt = mb_substr( $str, 0, $count );
// remove part of an entity at the end
$excerpt = preg_replace( '/&[^;\s]{0,6}$/', '', $excerpt );
if ( $str != $excerpt )
$excerpt = trim( $excerpt ) . $more;
return $excerpt;
}
/**
* Add a Base url to relative links in passed content.
*
* By default it supports the 'src' and 'href' attributes. However this can be
* changed via the 3rd param.
*
* @since 2.7.0
*
* @param string $content String to search for links in.
* @param string $base The base URL to prefix to links.
* @param array $attrs The attributes which should be processed.
* @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", '_links_add_base', $content );
}
/**
* Callback to add a base url to relative links in passed content.
*
* @since 2.7.0
* @access private
*
* @param string $m The matched link.
* @return string The processed link.
*/
function _links_add_base($m) {
global $_links_add_base;
//1 = attribute name 2 = quotation mark 3 = URL
return $m[1] . '=' . $m[2] .
( preg_match( '#^(\w{1,20}):#', $m[3], $protocol ) && in_array( $protocol[1], wp_allowed_protocols() ) ?
$m[3] :
path_join( $_links_add_base, $m[3] ) )
. $m[2];
}
/**
* Adds a Target attribute to all links in passed content.
*
* This function by default only applies to <a> tags, however this can be
* modified by the 3rd param.
*
* <b>NOTE:</b> Any current target attributed will be stripped and replaced.
*
* @since 2.7.0
*
* @param string $content String to search for links in.
* @param string $target The Target to add to the links.
* @param array $tags An array of tags to apply to.
* @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", '_links_add_target', $content );
}
/**
* Callback to add a target attribute to all links in passed content.
*
* @since 2.7.0
* @access private
*
* @param string $m The matched link.
* @return string The processed link.
*/
function _links_add_target( $m ) {
global $_links_add_target;
$tag = $m[1];
$link = preg_replace('|( target=([\'"])(.*?)\2)|i', '', $m[2]);
return '<' . $tag . $link . ' target="' . esc_attr( $_links_add_target ) . '">';
}
/**
* Normalize EOL characters and strip duplicate whitespace.
*
* @since 2.7.0
*
* @param string $str The string to normalize.
* @return string The normalized string.
*/
function normalize_whitespace( $str ) {
$str = trim( $str );
$str = str_replace( "\r", "\n", $str );
$str = preg_replace( array( '/\n+/', '/[ \t]+/' ), array( "\n", ' ' ), $str );
return $str;
}
/**
* Properly strip all HTML tags including script and style
*
* This differs from strip_tags() because it removes the contents of
* the <script> and <style> tags. E.g. strip_tags( '<script>something</script>' )
* will return 'something'. wp_strip_all_tags will return ''
*
* @since 2.9.0
*
* @param string $string String containing HTML tags
* @param bool $remove_breaks optional Whether to remove left over line breaks and white space chars
* @return string The processed string.
*/
function wp_strip_all_tags($string, $remove_breaks = false) {
$string = preg_replace( '@<(script|style)[^>]*?>.*?</\\1>@si', '', $string );
$string = strip_tags($string);
if ( $remove_breaks )
$string = preg_replace('/[\r\n\t ]+/', ' ', $string);
return trim( $string );
}
/**
* Sanitize a string from user input or from the db
*
* check for invalid UTF-8,
* Convert single < characters to entity,
* strip all tags,
* remove line breaks, tabs and extra white space,
* strip octets.
*
* @since 2.9.0
*
* @param string $str
* @return string
*/
function sanitize_text_field($str) {
$filtered = wp_check_invalid_utf8( $str );
if ( strpos($filtered, '<') !== false ) {
$filtered = wp_pre_kses_less_than( $filtered );
// This will strip extra whitespace for us.
$filtered = wp_strip_all_tags( $filtered, true );
} else {
$filtered = trim( preg_replace('/[\r\n\t ]+/', ' ', $filtered) );
}
$found = false;
while ( preg_match('/%[a-f0-9]{2}/i', $filtered, $match) ) {
$filtered = str_replace($match[0], '', $filtered);
$found = true;
}
if ( $found ) {
// Strip out the whitespace that may now exist after removing the octets.
$filtered = trim( preg_replace('/ +/', ' ', $filtered) );
}
/**
* Filter a sanitized text field string.
*
* @since 2.9.0
*
* @param string $filtered The sanitized string.
* @param string $str The string prior to being sanitized.
*/
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( array( '%2F', '%5C' ), '/', urlencode( $path ) ), $suffix ) );
}
/**
* Forever eliminate "Wordpress" from the planet (or at least the little bit we can influence).
*
* Violating our coding standards for a good function name.
*
* @since 3.0.0
*/
function capital_P_dangit( $text ) {
// Simple replacement for titles
$current_filter = current_filter();
if ( 'the_title' === $current_filter || 'wp_title' === $current_filter )
return str_replace( 'Wordpress', 'WordPress', $text );
// Still here? Use the more judicious replacement
static $dblq = false;
if ( false === $dblq )
$dblq = _x( '“', 'opening curly double quote' );
return str_replace(
array( ' Wordpress', '‘Wordpress', $dblq . 'Wordpress', '>Wordpress', '(Wordpress' ),
array( ' WordPress', '‘WordPress', $dblq . 'WordPress', '>WordPress', '(WordPress' ),
$text );
}
/**
* Sanitize a mime type
*
* @since 3.1.3
*
* @param string $mime_type Mime type
* @return string Sanitized mime type
*/
function sanitize_mime_type( $mime_type ) {
$sani_mime_type = preg_replace( '/[^-+*.a-zA-Z0-9\/]/', '', $mime_type );
/**
* Filter a mime type following sanitization.
*
* @since 3.1.3
*
* @param string $sani_mime_type The sanitized mime type.
* @param string $mime_type The mime type prior to sanitization.
*/
return apply_filters( 'sanitize_mime_type', $sani_mime_type, $mime_type );
}
/**
* Sanitize space or carriage return separated URLs that are used to send trackbacks.
*
* @since 3.4.0
*
* @param string $to_ping Space or carriage return separated URLs
* @return string URLs starting with the http or https protocol, separated by a carriage return.
*/
function sanitize_trackback_urls( $to_ping ) {
$urls_to_ping = preg_split( '/[\r\n\t ]/', trim( $to_ping ), -1, PREG_SPLIT_NO_EMPTY );
foreach ( $urls_to_ping as $k => $url ) {
if ( !preg_match( '#^https?://.#i', $url ) )
unset( $urls_to_ping[$k] );
}
$urls_to_ping = array_map( 'esc_url_raw', $urls_to_ping );
$urls_to_ping = implode( "\n", $urls_to_ping );
/**
* Filter a list of trackback URLs following sanitization.
*
* The string returned here consists of a space or carriage return-delimited list
* of trackback URLs.
*
* @since 3.4.0
*
* @param string $urls_to_ping Sanitized space or carriage return separated URLs.
* @param string $to_ping Space or carriage return separated URLs before sanitization.
*/
return apply_filters( 'sanitize_trackback_urls', $urls_to_ping, $to_ping );
}
/**
* Add slashes to a string or array of strings.
*
* This should be used when preparing data for core API that expects slashed data.
* This should not be used to escape data going directly into an SQL query.
*
* @since 3.6.0
*
* @param string|array $value String or array of strings to slash.
* @return string|array Slashed $value
*/
function wp_slash( $value ) {
if ( is_array( $value ) ) {
foreach ( $value as $k => $v ) {
if ( is_array( $v ) ) {
$value[$k] = wp_slash( $v );
} else {
$value[$k] = addslashes( $v );
}
}
} else {
$value = addslashes( $value );
}
return $value;
}
/**
* Remove slashes from a string or array of strings.
*
* This should be used to remove slashes from data passed to core API that
* expects data to be unslashed.
*
* @since 3.6.0
*
* @param string|array $value String or array of strings to unslash.
* @return string|array Unslashed $value
*/
function wp_unslash( $value ) {
return stripslashes_deep( $value );
}
/**
* Extract and return the first URL from passed content.
*
* @since 3.6.0
*
* @param string $content A string which might contain a URL.
* @return string The found URL.
*/
function get_url_in_content( $content ) {
if ( empty( $content ) ) {
return false;
}
if ( preg_match( '/<a\s[^>]*?href=([\'"])(.+?)\1/is', $content, $matches ) ) {
return esc_url_raw( $matches[2] );
}
return false;
}
| 01-wordpress-paypal | trunk/wp-includes/formatting.php | PHP | gpl3 | 126,097 |
<?php
/**
* Defines constants and global variables that can be overridden, generally in wp-config.php.
*
* @package WordPress
* @subpackage Multisite
* @since 3.0.0
*/
/**
* Defines Multisite upload constants.
*
* Exists for backward compatibility with legacy file-serving through
* wp-includes/ms-files.php (wp-content/blogs.php in MU).
*
* @since 3.0.0
*/
function ms_upload_constants() {
global $wpdb;
// This filter is attached in ms-default-filters.php but that file is not included during SHORTINIT.
add_filter( 'default_site_option_ms_files_rewriting', '__return_true' );
if ( ! get_site_option( 'ms_files_rewriting' ) )
return;
// Base uploads dir relative to ABSPATH
if ( !defined( 'UPLOADBLOGSDIR' ) )
define( 'UPLOADBLOGSDIR', 'wp-content/blogs.dir' );
// Note, the main site in a post-MU network uses wp-content/uploads.
// This is handled in wp_upload_dir() by ignoring UPLOADS for this case.
if ( ! defined( 'UPLOADS' ) ) {
define( 'UPLOADS', UPLOADBLOGSDIR . "/{$wpdb->blogid}/files/" );
// Uploads dir relative to ABSPATH
if ( 'wp-content/blogs.dir' == UPLOADBLOGSDIR && ! defined( 'BLOGUPLOADDIR' ) )
define( 'BLOGUPLOADDIR', WP_CONTENT_DIR . "/blogs.dir/{$wpdb->blogid}/files/" );
}
}
/**
* Defines Multisite cookie constants.
*
* @since 3.0.0
*/
function ms_cookie_constants( ) {
$current_site = get_current_site();
/**
* @since 1.2.0
*/
if ( !defined( 'COOKIEPATH' ) )
define( 'COOKIEPATH', $current_site->path );
/**
* @since 1.5.0
*/
if ( !defined( 'SITECOOKIEPATH' ) )
define( 'SITECOOKIEPATH', $current_site->path );
/**
* @since 2.6.0
*/
if ( !defined( 'ADMIN_COOKIE_PATH' ) ) {
if ( ! is_subdomain_install() || trim( parse_url( get_option( 'siteurl' ), PHP_URL_PATH ), '/' ) ) {
define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH );
} else {
define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH . 'wp-admin' );
}
}
/**
* @since 2.0.0
*/
if ( !defined('COOKIE_DOMAIN') && is_subdomain_install() ) {
if ( !empty( $current_site->cookie_domain ) )
define('COOKIE_DOMAIN', '.' . $current_site->cookie_domain);
else
define('COOKIE_DOMAIN', '.' . $current_site->domain);
}
}
/**
* Defines Multisite file constants.
*
* Exists for backward compatibility with legacy file-serving through
* wp-includes/ms-files.php (wp-content/blogs.php in MU).
*
* @since 3.0.0
*/
function ms_file_constants() {
/**
* Optional support for X-Sendfile header
* @since 3.0.0
*/
if ( !defined( 'WPMU_SENDFILE' ) )
define( 'WPMU_SENDFILE', false );
/**
* Optional support for X-Accel-Redirect header
* @since 3.0.0
*/
if ( !defined( 'WPMU_ACCEL_REDIRECT' ) )
define( 'WPMU_ACCEL_REDIRECT', false );
}
/**
* Defines Multisite subdomain constants and handles warnings and notices.
*
* VHOST is deprecated in favor of SUBDOMAIN_INSTALL, which is a bool.
*
* On first call, the constants are checked and defined. On second call,
* we will have translations loaded and can trigger warnings easily.
*
* @since 3.0.0
*/
function ms_subdomain_constants() {
static $error = null;
static $error_warn = false;
if ( false === $error )
return;
if ( $error ) {
$vhost_deprecated = __( 'The constant <code>VHOST</code> <strong>is deprecated</strong>. Use the boolean constant <code>SUBDOMAIN_INSTALL</code> in wp-config.php to enable a subdomain configuration. Use is_subdomain_install() to check whether a subdomain configuration is enabled.' );
if ( $error_warn ) {
trigger_error( __( '<strong>Conflicting values for the constants VHOST and SUBDOMAIN_INSTALL.</strong> The value of SUBDOMAIN_INSTALL will be assumed to be your subdomain configuration setting.' ) . ' ' . $vhost_deprecated, E_USER_WARNING );
} else {
_deprecated_argument( 'define()', '3.0', $vhost_deprecated );
}
return;
}
if ( defined( 'SUBDOMAIN_INSTALL' ) && defined( 'VHOST' ) ) {
if ( SUBDOMAIN_INSTALL == ( 'yes' == VHOST ) ) {
$error = true;
} else {
$error = $error_warn = true;
}
} elseif ( defined( 'SUBDOMAIN_INSTALL' ) ) {
define( 'VHOST', SUBDOMAIN_INSTALL ? 'yes' : 'no' );
} elseif ( defined( 'VHOST' ) ) {
$error = true;
define( 'SUBDOMAIN_INSTALL', 'yes' == VHOST );
} else {
define( 'SUBDOMAIN_INSTALL', false );
define( 'VHOST', 'no' );
}
}
add_action( 'init', 'ms_subdomain_constants' );
| 01-wordpress-paypal | trunk/wp-includes/ms-default-constants.php | PHP | gpl3 | 4,341 |
<?php
/**
* PHPMailer - PHP email creation and transport class.
* PHP Version 5.0.0
* Version 5.2.7
* @package PHPMailer
* @link https://github.com/PHPMailer/PHPMailer/
* @author Marcus Bointon (coolbru) <phpmailer@synchromedia.co.uk>
* @author Jim Jagielski (jimjag) <jimjag@gmail.com>
* @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
* @author Brent R. Matzelle (original founder)
* @copyright 2013 Marcus Bointon
* @copyright 2010 - 2012 Jim Jagielski
* @copyright 2004 - 2009 Andy Prevost
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
* @note This program is distributed in the hope that it will be useful - WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*/
if (version_compare(PHP_VERSION, '5.0.0', '<')) {
exit("Sorry, PHPMailer will only run on PHP version 5 or greater!\n");
}
/**
* PHPMailer - PHP email creation and transport class.
* PHP Version 5.0.0
* @package PHPMailer
* @author Marcus Bointon (coolbru) <phpmailer@synchromedia.co.uk>
* @author Jim Jagielski (jimjag) <jimjag@gmail.com>
* @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
* @author Brent R. Matzelle (original founder)
* @copyright 2013 Marcus Bointon
* @copyright 2010 - 2012 Jim Jagielski
* @copyright 2004 - 2009 Andy Prevost
*/
class PHPMailer
{
/**
* The PHPMailer Version number.
* @type string
*/
public $Version = '5.2.7';
/**
* Email priority.
* Options: 1 = High, 3 = Normal, 5 = low.
* @type int
*/
public $Priority = 3;
/**
* The character set of the message.
* @type string
*/
public $CharSet = 'iso-8859-1';
/**
* The MIME Content-type of the message.
* @type string
*/
public $ContentType = 'text/plain';
/**
* The message encoding.
* Options: "8bit", "7bit", "binary", "base64", and "quoted-printable".
* @type string
*/
public $Encoding = '8bit';
/**
* Holds the most recent mailer error message.
* @type string
*/
public $ErrorInfo = '';
/**
* The From email address for the message.
* @type string
*/
public $From = 'root@localhost';
/**
* The From name of the message.
* @type string
*/
public $FromName = 'Root User';
/**
* The Sender email (Return-Path) of the message.
* If not empty, will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode.
* @type string
*/
public $Sender = '';
/**
* The Return-Path of the message.
* If empty, it will be set to either From or Sender.
* @type string
*/
public $ReturnPath = '';
/**
* The Subject of the message.
* @type string
*/
public $Subject = '';
/**
* An HTML or plain text message body.
* If HTML then call isHTML(true).
* @type string
*/
public $Body = '';
/**
* The plain-text message body.
* This body can be read by mail clients that do not have HTML email
* capability such as mutt & Eudora.
* Clients that can read HTML will view the normal Body.
* @type string
*/
public $AltBody = '';
/**
* An iCal message part body.
* Only supported in simple alt or alt_inline message types
* To generate iCal events, use the bundled extras/EasyPeasyICS.php class or iCalcreator
* @link http://sprain.ch/blog/downloads/php-class-easypeasyics-create-ical-files-with-php/
* @link http://kigkonsult.se/iCalcreator/
* @type string
*/
public $Ical = '';
/**
* The complete compiled MIME message body.
* @access protected
* @type string
*/
protected $MIMEBody = '';
/**
* The complete compiled MIME message headers.
* @type string
* @access protected
*/
protected $MIMEHeader = '';
/**
* Extra headers that createHeader() doesn't fold in.
* @type string
* @access protected
*/
protected $mailHeader = '';
/**
* Word-wrap the message body to this number of chars.
* @type int
*/
public $WordWrap = 0;
/**
* Which method to use to send mail.
* Options: "mail", "sendmail", or "smtp".
* @type string
*/
public $Mailer = 'mail';
/**
* The path to the sendmail program.
* @type string
*/
public $Sendmail = '/usr/sbin/sendmail';
/**
* Whether mail() uses a fully sendmail-compatible MTA.
* One which supports sendmail's "-oi -f" options.
* @type bool
*/
public $UseSendmailOptions = true;
/**
* Path to PHPMailer plugins.
* Useful if the SMTP class is not in the PHP include path.
* @type string
* @deprecated Should not be needed now there is an autoloader.
*/
public $PluginDir = '';
/**
* The email address that a reading confirmation should be sent to.
* @type string
*/
public $ConfirmReadingTo = '';
/**
* The hostname to use in Message-Id and Received headers
* and as default HELO string.
* If empty, the value returned
* by SERVER_NAME is used or 'localhost.localdomain'.
* @type string
*/
public $Hostname = '';
/**
* An ID to be used in the Message-Id header.
* If empty, a unique id will be generated.
* @type string
*/
public $MessageID = '';
/**
* The message Date to be used in the Date header.
* If empty, the current date will be added.
* @type string
*/
public $MessageDate = '';
/**
* SMTP hosts.
* Either a single hostname or multiple semicolon-delimited hostnames.
* You can also specify a different port
* for each host by using this format: [hostname:port]
* (e.g. "smtp1.example.com:25;smtp2.example.com").
* Hosts will be tried in order.
* @type string
*/
public $Host = 'localhost';
/**
* The default SMTP server port.
* @type int
* @Todo Why is this needed when the SMTP class takes care of it?
*/
public $Port = 25;
/**
* The SMTP HELO of the message.
* Default is $Hostname.
* @type string
* @see PHPMailer::$Hostname
*/
public $Helo = '';
/**
* The secure connection prefix.
* Options: "", "ssl" or "tls"
* @type string
*/
public $SMTPSecure = '';
/**
* Whether to use SMTP authentication.
* Uses the Username and Password properties.
* @type bool
* @see PHPMailer::$Username
* @see PHPMailer::$Password
*/
public $SMTPAuth = false;
/**
* SMTP username.
* @type string
*/
public $Username = '';
/**
* SMTP password.
* @type string
*/
public $Password = '';
/**
* SMTP auth type.
* Options are LOGIN (default), PLAIN, NTLM, CRAM-MD5
* @type string
*/
public $AuthType = '';
/**
* SMTP realm.
* Used for NTLM auth
* @type string
*/
public $Realm = '';
/**
* SMTP workstation.
* Used for NTLM auth
* @type string
*/
public $Workstation = '';
/**
* The SMTP server timeout in seconds.
* @type int
*/
public $Timeout = 10;
/**
* SMTP class debug output mode.
* Options: 0 = off, 1 = commands, 2 = commands and data
* @type int
* @see SMTP::$do_debug
*/
public $SMTPDebug = 0;
/**
* The function/method to use for debugging output.
* Options: "echo" or "error_log"
* @type string
* @see SMTP::$Debugoutput
*/
public $Debugoutput = "echo";
/**
* Whether to keep SMTP connection open after each message.
* If this is set to true then to close the connection
* requires an explicit call to smtpClose().
* @type bool
*/
public $SMTPKeepAlive = false;
/**
* Whether to split multiple to addresses into multiple messages
* or send them all in one message.
* @type bool
*/
public $SingleTo = false;
/**
* Storage for addresses when SingleTo is enabled.
* @type array
* @todo This should really not be public
*/
public $SingleToArray = array();
/**
* Whether to generate VERP addresses on send.
* Only applicable when sending via SMTP.
* @link http://en.wikipedia.org/wiki/Variable_envelope_return_path
* @type bool
*/
public $do_verp = false;
/**
* Whether to allow sending messages with an empty body.
* @type bool
*/
public $AllowEmpty = false;
/**
* The default line ending.
* @note The default remains "\n". We force CRLF where we know
* it must be used via self::CRLF.
* @type string
*/
public $LE = "\n";
/**
* DKIM selector.
* @type string
*/
public $DKIM_selector = '';
/**
* DKIM Identity.
* Usually the email address used as the source of the email
* @type string
*/
public $DKIM_identity = '';
/**
* DKIM passphrase.
* Used if your key is encrypted.
* @type string
*/
public $DKIM_passphrase = '';
/**
* DKIM signing domain name.
* @example 'example.com'
* @type string
*/
public $DKIM_domain = '';
/**
* DKIM private key file path.
* @type string
*/
public $DKIM_private = '';
/**
* Callback Action function name.
*
* The function that handles the result of the send email action.
* It is called out by send() for each email sent.
*
* Value can be:
* - 'function_name' for function names
* - 'Class::Method' for static method calls
* - array($object, 'Method') for calling methods on $object
* See http://php.net/is_callable manual page for more details.
*
* Parameters:
* bool $result result of the send action
* string $to email address of the recipient
* string $cc cc email addresses
* string $bcc bcc email addresses
* string $subject the subject
* string $body the email body
* string $from email address of sender
*
* @type string
*/
public $action_function = '';
/**
* What to use in the X-Mailer header.
* Options: null for default, whitespace for none, or a string to use
* @type string
*/
public $XMailer = '';
/**
* An instance of the SMTP sender class.
* @type SMTP
* @access protected
*/
protected $smtp = null;
/**
* The array of 'to' addresses.
* @type array
* @access protected
*/
protected $to = array();
/**
* The array of 'cc' addresses.
* @type array
* @access protected
*/
protected $cc = array();
/**
* The array of 'bcc' addresses.
* @type array
* @access protected
*/
protected $bcc = array();
/**
* The array of reply-to names and addresses.
* @type array
* @access protected
*/
protected $ReplyTo = array();
/**
* An array of all kinds of addresses.
* Includes all of $to, $cc, $bcc, $replyto
* @type array
* @access protected
*/
protected $all_recipients = array();
/**
* The array of attachments.
* @type array
* @access protected
*/
protected $attachment = array();
/**
* The array of custom headers.
* @type array
* @access protected
*/
protected $CustomHeader = array();
/**
* The most recent Message-ID (including angular brackets).
* @type string
* @access protected
*/
protected $lastMessageID = '';
/**
* The message's MIME type.
* @type string
* @access protected
*/
protected $message_type = '';
/**
* The array of MIME boundary strings.
* @type array
* @access protected
*/
protected $boundary = array();
/**
* The array of available languages.
* @type array
* @access protected
*/
protected $language = array();
/**
* The number of errors encountered.
* @type integer
* @access protected
*/
protected $error_count = 0;
/**
* The S/MIME certificate file path.
* @type string
* @access protected
*/
protected $sign_cert_file = '';
/**
* The S/MIME key file path.
* @type string
* @access protected
*/
protected $sign_key_file = '';
/**
* The S/MIME password for the key.
* Used only if the key is encrypted.
* @type string
* @access protected
*/
protected $sign_key_pass = '';
/**
* Whether to throw exceptions for errors.
* @type bool
* @access protected
*/
protected $exceptions = false;
/**
* Error severity: message only, continue processing
*/
const STOP_MESSAGE = 0;
/**
* Error severity: message, likely ok to continue processing
*/
const STOP_CONTINUE = 1;
/**
* Error severity: message, plus full stop, critical error reached
*/
const STOP_CRITICAL = 2;
/**
* SMTP RFC standard line ending
*/
const CRLF = "\r\n";
/**
* Constructor
* @param bool $exceptions Should we throw external exceptions?
*/
public function __construct($exceptions = false)
{
$this->exceptions = ($exceptions == true);
}
/**
* Destructor.
*/
public function __destruct()
{
if ($this->Mailer == 'smtp') { //close any open SMTP connection nicely
$this->smtpClose();
}
}
/**
* Call mail() in a safe_mode-aware fashion.
* Also, unless sendmail_path points to sendmail (or something that
* claims to be sendmail), don't pass params (not a perfect fix,
* but it will do)
* @param string $to To
* @param string $subject Subject
* @param string $body Message Body
* @param string $header Additional Header(s)
* @param string $params Params
* @access private
* @return bool
*/
private function mailPassthru($to, $subject, $body, $header, $params)
{
if (ini_get('safe_mode') || !($this->UseSendmailOptions)) {
$rt = @mail($to, $this->encodeHeader($this->secureHeader($subject)), $body, $header);
} else {
$rt = @mail($to, $this->encodeHeader($this->secureHeader($subject)), $body, $header, $params);
}
return $rt;
}
/**
* Output debugging info via user-defined method.
* Only if debug output is enabled.
* @see PHPMailer::$Debugoutput
* @see PHPMailer::$SMTPDebug
* @param string $str
*/
protected function edebug($str)
{
if (!$this->SMTPDebug) {
return;
}
switch ($this->Debugoutput) {
case 'error_log':
error_log($str);
break;
case 'html':
//Cleans up output a bit for a better looking display that's HTML-safe
echo htmlentities(preg_replace('/[\r\n]+/', '', $str), ENT_QUOTES, $this->CharSet) . "<br>\n";
break;
case 'echo':
default:
//Just echoes exactly what was received
echo $str;
}
}
/**
* Sets message type to HTML or plain.
* @param bool $ishtml True for HTML mode.
* @return void
*/
public function isHTML($ishtml = true)
{
if ($ishtml) {
$this->ContentType = 'text/html';
} else {
$this->ContentType = 'text/plain';
}
}
/**
* Send messages using SMTP.
* @return void
*/
public function isSMTP()
{
$this->Mailer = 'smtp';
}
/**
* Send messages using PHP's mail() function.
* @return void
*/
public function isMail()
{
$this->Mailer = 'mail';
}
/**
* Send messages using $Sendmail.
* @return void
*/
public function isSendmail()
{
if (!stristr(ini_get('sendmail_path'), 'sendmail')) {
$this->Sendmail = '/var/qmail/bin/sendmail';
}
$this->Mailer = 'sendmail';
}
/**
* Send messages using qmail.
* @return void
*/
public function isQmail()
{
if (stristr(ini_get('sendmail_path'), 'qmail')) {
$this->Sendmail = '/var/qmail/bin/sendmail';
}
$this->Mailer = 'sendmail';
}
/**
* Add a "To" address.
* @param string $address
* @param string $name
* @return bool true on success, false if address already used
*/
public function addAddress($address, $name = '')
{
return $this->addAnAddress('to', $address, $name);
}
/**
* Add a "CC" address.
* @note: This function works with the SMTP mailer on win32, not with the "mail" mailer.
* @param string $address
* @param string $name
* @return bool true on success, false if address already used
*/
public function addCC($address, $name = '')
{
return $this->addAnAddress('cc', $address, $name);
}
/**
* Add a "BCC" address.
* @note: This function works with the SMTP mailer on win32, not with the "mail" mailer.
* @param string $address
* @param string $name
* @return bool true on success, false if address already used
*/
public function addBCC($address, $name = '')
{
return $this->addAnAddress('bcc', $address, $name);
}
/**
* Add a "Reply-to" address.
* @param string $address
* @param string $name
* @return bool
*/
public function addReplyTo($address, $name = '')
{
return $this->addAnAddress('Reply-To', $address, $name);
}
/**
* Add an address to one of the recipient arrays.
* Addresses that have been added already return false, but do not throw exceptions
* @param string $kind One of 'to', 'cc', 'bcc', 'ReplyTo'
* @param string $address The email address to send to
* @param string $name
* @throws phpmailerException
* @return bool true on success, false if address already used or invalid in some way
* @access protected
*/
protected function addAnAddress($kind, $address, $name = '')
{
if (!preg_match('/^(to|cc|bcc|Reply-To)$/', $kind)) {
$this->setError($this->lang('Invalid recipient array') . ': ' . $kind);
if ($this->exceptions) {
throw new phpmailerException('Invalid recipient array: ' . $kind);
}
$this->edebug($this->lang('Invalid recipient array') . ': ' . $kind);
return false;
}
$address = trim($address);
$name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
if (!$this->validateAddress($address)) {
$this->setError($this->lang('invalid_address') . ': ' . $address);
if ($this->exceptions) {
throw new phpmailerException($this->lang('invalid_address') . ': ' . $address);
}
$this->edebug($this->lang('invalid_address') . ': ' . $address);
return false;
}
if ($kind != 'Reply-To') {
if (!isset($this->all_recipients[strtolower($address)])) {
array_push($this->$kind, array($address, $name));
$this->all_recipients[strtolower($address)] = true;
return true;
}
} else {
if (!array_key_exists(strtolower($address), $this->ReplyTo)) {
$this->ReplyTo[strtolower($address)] = array($address, $name);
return true;
}
}
return false;
}
/**
* Set the From and FromName properties.
* @param string $address
* @param string $name
* @param bool $auto Whether to also set the Sender address, defaults to true
* @throws phpmailerException
* @return bool
*/
public function setFrom($address, $name = '', $auto = true)
{
$address = trim($address);
$name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
if (!$this->validateAddress($address)) {
$this->setError($this->lang('invalid_address') . ': ' . $address);
if ($this->exceptions) {
throw new phpmailerException($this->lang('invalid_address') . ': ' . $address);
}
$this->edebug($this->lang('invalid_address') . ': ' . $address);
return false;
}
$this->From = $address;
$this->FromName = $name;
if ($auto) {
if (empty($this->Sender)) {
$this->Sender = $address;
}
}
return true;
}
/**
* Return the Message-ID header of the last email.
* Technically this is the value from the last time the headers were created,
* but it's also the message ID of the last sent message except in
* pathological cases.
* @return string
*/
public function getLastMessageID()
{
return $this->lastMessageID;
}
/**
* Check that a string looks like an email address.
* @param string $address The email address to check
* @param string $patternselect A selector for the validation pattern to use :
* 'auto' - pick best one automatically;
* 'pcre8' - use the squiloople.com pattern, requires PCRE > 8.0, PHP >= 5.3.2, 5.2.14;
* 'pcre' - use old PCRE implementation;
* 'php' - use PHP built-in FILTER_VALIDATE_EMAIL; faster, less thorough;
* 'noregex' - super fast, really dumb.
* @return bool
* @static
* @access public
*/
public static function validateAddress($address, $patternselect = 'auto')
{
if ($patternselect == 'auto') {
if (defined(
'PCRE_VERSION'
)
) { //Check this instead of extension_loaded so it works when that function is disabled
if (version_compare(PCRE_VERSION, '8.0') >= 0) {
$patternselect = 'pcre8';
} else {
$patternselect = 'pcre';
}
} else {
//Filter_var appeared in PHP 5.2.0 and does not require the PCRE extension
if (version_compare(PHP_VERSION, '5.2.0') >= 0) {
$patternselect = 'php';
} else {
$patternselect = 'noregex';
}
}
}
switch ($patternselect) {
case 'pcre8':
/**
* Conforms to RFC5322: Uses *correct* regex on which FILTER_VALIDATE_EMAIL is
* based; So why not use FILTER_VALIDATE_EMAIL? Because it was broken to
* not allow a@b type valid addresses :(
* @link http://squiloople.com/2009/12/20/email-address-validation/
* @copyright 2009-2010 Michael Rushton
* Feel free to use and redistribute this code. But please keep this copyright notice.
*/
return (bool)preg_match(
'/^(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){255,})(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){65,}@)' .
'((?>(?>(?>((?>(?>(?>\x0D\x0A)?[\t ])+|(?>[\t ]*\x0D\x0A)?[\t ]+)?)(\((?>(?2)' .
'(?>[\x01-\x08\x0B\x0C\x0E-\'*-\[\]-\x7F]|\\\[\x00-\x7F]|(?3)))*(?2)\)))+(?2))|(?2))?)' .
'([!#-\'*+\/-9=?^-~-]+|"(?>(?2)(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\x7F]))*' .
'(?2)")(?>(?1)\.(?1)(?4))*(?1)@(?!(?1)[a-z0-9-]{64,})(?1)(?>([a-z0-9](?>[a-z0-9-]*[a-z0-9])?)' .
'(?>(?1)\.(?!(?1)[a-z0-9-]{64,})(?1)(?5)){0,126}|\[(?:(?>IPv6:(?>([a-f0-9]{1,4})(?>:(?6)){7}' .
'|(?!(?:.*[a-f0-9][:\]]){8,})((?6)(?>:(?6)){0,6})?::(?7)?))|(?>(?>IPv6:(?>(?6)(?>:(?6)){5}:' .
'|(?!(?:.*[a-f0-9]:){6,})(?8)?::(?>((?6)(?>:(?6)){0,4}):)?))?(25[0-5]|2[0-4][0-9]|1[0-9]{2}' .
'|[1-9]?[0-9])(?>\.(?9)){3}))\])(?1)$/isD',
$address
);
break;
case 'pcre':
//An older regex that doesn't need a recent PCRE
return (bool)preg_match(
'/^(?!(?>"?(?>\\\[ -~]|[^"])"?){255,})(?!(?>"?(?>\\\[ -~]|[^"])"?){65,}@)(?>' .
'[!#-\'*+\/-9=?^-~-]+|"(?>(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\xFF]))*")' .
'(?>\.(?>[!#-\'*+\/-9=?^-~-]+|"(?>(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\xFF]))*"))*' .
'@(?>(?![a-z0-9-]{64,})(?>[a-z0-9](?>[a-z0-9-]*[a-z0-9])?)(?>\.(?![a-z0-9-]{64,})' .
'(?>[a-z0-9](?>[a-z0-9-]*[a-z0-9])?)){0,126}|\[(?:(?>IPv6:(?>(?>[a-f0-9]{1,4})(?>:' .
'[a-f0-9]{1,4}){7}|(?!(?:.*[a-f0-9][:\]]){8,})(?>[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,6})?' .
'::(?>[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,6})?))|(?>(?>IPv6:(?>[a-f0-9]{1,4}(?>:' .
'[a-f0-9]{1,4}){5}:|(?!(?:.*[a-f0-9]:){6,})(?>[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,4})?' .
'::(?>(?:[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,4}):)?))?(?>25[0-5]|2[0-4][0-9]|1[0-9]{2}' .
'|[1-9]?[0-9])(?>\.(?>25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}))\])$/isD',
$address
);
break;
case 'php':
default:
return (bool)filter_var($address, FILTER_VALIDATE_EMAIL);
break;
case 'noregex':
//No PCRE! Do something _very_ approximate!
//Check the address is 3 chars or longer and contains an @ that's not the first or last char
return (strlen($address) >= 3
and strpos($address, '@') >= 1
and strpos($address, '@') != strlen($address) - 1);
break;
}
}
/**
* Create a message and send it.
* Uses the sending method specified by $Mailer.
* Returns false on error - Use the ErrorInfo variable to view description of the error.
* @throws phpmailerException
* @return bool
*/
public function send()
{
try {
if (!$this->preSend()) {
return false;
}
return $this->postSend();
} catch (phpmailerException $e) {
$this->mailHeader = '';
$this->setError($e->getMessage());
if ($this->exceptions) {
throw $e;
}
return false;
}
}
/**
* Prepare a message for sending.
* @throws phpmailerException
* @return bool
*/
public function preSend()
{
try {
$this->mailHeader = "";
if ((count($this->to) + count($this->cc) + count($this->bcc)) < 1) {
throw new phpmailerException($this->lang('provide_address'), self::STOP_CRITICAL);
}
// Set whether the message is multipart/alternative
if (!empty($this->AltBody)) {
$this->ContentType = 'multipart/alternative';
}
$this->error_count = 0; // reset errors
$this->setMessageType();
// Refuse to send an empty message unless we are specifically allowing it
if (!$this->AllowEmpty and empty($this->Body)) {
throw new phpmailerException($this->lang('empty_message'), self::STOP_CRITICAL);
}
$this->MIMEHeader = $this->createHeader();
$this->MIMEBody = $this->createBody();
// To capture the complete message when using mail(), create
// an extra header list which createHeader() doesn't fold in
if ($this->Mailer == 'mail') {
if (count($this->to) > 0) {
$this->mailHeader .= $this->addrAppend("To", $this->to);
} else {
$this->mailHeader .= $this->headerLine("To", "undisclosed-recipients:;");
}
$this->mailHeader .= $this->headerLine(
'Subject',
$this->encodeHeader($this->secureHeader(trim($this->Subject)))
);
}
// Sign with DKIM if enabled
if (!empty($this->DKIM_domain)
&& !empty($this->DKIM_private)
&& !empty($this->DKIM_selector)
&& !empty($this->DKIM_domain)
&& file_exists($this->DKIM_private)) {
$header_dkim = $this->DKIM_Add(
$this->MIMEHeader . $this->mailHeader,
$this->encodeHeader($this->secureHeader($this->Subject)),
$this->MIMEBody
);
$this->MIMEHeader = rtrim($this->MIMEHeader, "\r\n ") . self::CRLF .
str_replace("\r\n", "\n", $header_dkim) . self::CRLF;
}
return true;
} catch (phpmailerException $e) {
$this->setError($e->getMessage());
if ($this->exceptions) {
throw $e;
}
return false;
}
}
/**
* Actually send a message.
* Send the email via the selected mechanism
* @throws phpmailerException
* @return bool
*/
public function postSend()
{
try {
// Choose the mailer and send through it
switch ($this->Mailer) {
case 'sendmail':
return $this->sendmailSend($this->MIMEHeader, $this->MIMEBody);
case 'smtp':
return $this->smtpSend($this->MIMEHeader, $this->MIMEBody);
case 'mail':
return $this->mailSend($this->MIMEHeader, $this->MIMEBody);
default:
return $this->mailSend($this->MIMEHeader, $this->MIMEBody);
}
} catch (phpmailerException $e) {
$this->setError($e->getMessage());
if ($this->exceptions) {
throw $e;
}
$this->edebug($e->getMessage() . "\n");
}
return false;
}
/**
* Send mail using the $Sendmail program.
* @param string $header The message headers
* @param string $body The message body
* @see PHPMailer::$Sendmail
* @throws phpmailerException
* @access protected
* @return bool
*/
protected function sendmailSend($header, $body)
{
if ($this->Sender != '') {
$sendmail = sprintf("%s -oi -f%s -t", escapeshellcmd($this->Sendmail), escapeshellarg($this->Sender));
} else {
$sendmail = sprintf("%s -oi -t", escapeshellcmd($this->Sendmail));
}
if ($this->SingleTo === true) {
foreach ($this->SingleToArray as $val) {
if (!@$mail = popen($sendmail, 'w')) {
throw new phpmailerException($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
}
fputs($mail, "To: " . $val . "\n");
fputs($mail, $header);
fputs($mail, $body);
$result = pclose($mail);
// implement call back function if it exists
$isSent = ($result == 0) ? 1 : 0;
$this->doCallback($isSent, $val, $this->cc, $this->bcc, $this->Subject, $body, $this->From);
if ($result != 0) {
throw new phpmailerException($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
}
}
} else {
if (!@$mail = popen($sendmail, 'w')) {
throw new phpmailerException($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
}
fputs($mail, $header);
fputs($mail, $body);
$result = pclose($mail);
// implement call back function if it exists
$isSent = ($result == 0) ? 1 : 0;
$this->doCallback($isSent, $this->to, $this->cc, $this->bcc, $this->Subject, $body, $this->From);
if ($result != 0) {
throw new phpmailerException($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
}
}
return true;
}
/**
* Send mail using the PHP mail() function.
* @param string $header The message headers
* @param string $body The message body
* @link http://www.php.net/manual/en/book.mail.php
* @throws phpmailerException
* @access protected
* @return bool
*/
protected function mailSend($header, $body)
{
$toArr = array();
foreach ($this->to as $t) {
$toArr[] = $this->addrFormat($t);
}
$to = implode(', ', $toArr);
if (empty($this->Sender)) {
$params = " ";
} else {
$params = sprintf("-f%s", $this->Sender);
}
if ($this->Sender != '' and !ini_get('safe_mode')) {
$old_from = ini_get('sendmail_from');
ini_set('sendmail_from', $this->Sender);
}
$rt = false;
if ($this->SingleTo === true && count($toArr) > 1) {
foreach ($toArr as $val) {
$rt = $this->mailPassthru($val, $this->Subject, $body, $header, $params);
// implement call back function if it exists
$isSent = ($rt == 1) ? 1 : 0;
$this->doCallback($isSent, $val, $this->cc, $this->bcc, $this->Subject, $body, $this->From);
}
} else {
$rt = $this->mailPassthru($to, $this->Subject, $body, $header, $params);
// implement call back function if it exists
$isSent = ($rt == 1) ? 1 : 0;
$this->doCallback($isSent, $to, $this->cc, $this->bcc, $this->Subject, $body, $this->From);
}
if (isset($old_from)) {
ini_set('sendmail_from', $old_from);
}
if (!$rt) {
throw new phpmailerException($this->lang('instantiate'), self::STOP_CRITICAL);
}
return true;
}
/**
* Get an instance to use for SMTP operations.
* Override this function to load your own SMTP implementation
* @return SMTP
*/
public function getSMTPInstance()
{
if (!is_object($this->smtp)) {
require_once 'class-smtp.php';
$this->smtp = new SMTP;
}
return $this->smtp;
}
/**
* Send mail via SMTP.
* Returns false if there is a bad MAIL FROM, RCPT, or DATA input.
* Uses the PHPMailerSMTP class by default.
* @see PHPMailer::getSMTPInstance() to use a different class.
* @param string $header The message headers
* @param string $body The message body
* @throws phpmailerException
* @uses SMTP
* @access protected
* @return bool
*/
protected function smtpSend($header, $body)
{
$bad_rcpt = array();
if (!$this->smtpConnect()) {
throw new phpmailerException($this->lang('smtp_connect_failed'), self::STOP_CRITICAL);
}
$smtp_from = ($this->Sender == '') ? $this->From : $this->Sender;
if (!$this->smtp->mail($smtp_from)) {
$this->setError($this->lang('from_failed') . $smtp_from . ' : ' . implode(',', $this->smtp->getError()));
throw new phpmailerException($this->ErrorInfo, self::STOP_CRITICAL);
}
// Attempt to send attach all recipients
foreach ($this->to as $to) {
if (!$this->smtp->recipient($to[0])) {
$bad_rcpt[] = $to[0];
$isSent = 0;
} else {
$isSent = 1;
}
$this->doCallback($isSent, $to[0], '', '', $this->Subject, $body, $this->From);
}
foreach ($this->cc as $cc) {
if (!$this->smtp->recipient($cc[0])) {
$bad_rcpt[] = $cc[0];
$isSent = 0;
} else {
$isSent = 1;
}
$this->doCallback($isSent, '', $cc[0], '', $this->Subject, $body, $this->From);
}
foreach ($this->bcc as $bcc) {
if (!$this->smtp->recipient($bcc[0])) {
$bad_rcpt[] = $bcc[0];
$isSent = 0;
} else {
$isSent = 1;
}
$this->doCallback($isSent, '', '', $bcc[0], $this->Subject, $body, $this->From);
}
if (count($bad_rcpt) > 0) { //Create error message for any bad addresses
throw new phpmailerException($this->lang('recipients_failed') . implode(', ', $bad_rcpt));
}
if (!$this->smtp->data($header . $body)) {
throw new phpmailerException($this->lang('data_not_accepted'), self::STOP_CRITICAL);
}
if ($this->SMTPKeepAlive == true) {
$this->smtp->reset();
} else {
$this->smtp->quit();
$this->smtp->close();
}
return true;
}
/**
* Initiate a connection to an SMTP server.
* Returns false if the operation failed.
* @param array $options An array of options compatible with stream_context_create()
* @uses SMTP
* @access public
* @throws phpmailerException
* @return bool
*/
public function smtpConnect($options = array())
{
if (is_null($this->smtp)) {
$this->smtp = $this->getSMTPInstance();
}
//Already connected?
if ($this->smtp->connected()) {
return true;
}
$this->smtp->setTimeout($this->Timeout);
$this->smtp->setDebugLevel($this->SMTPDebug);
$this->smtp->setDebugOutput($this->Debugoutput);
$this->smtp->setVerp($this->do_verp);
$tls = ($this->SMTPSecure == 'tls');
$ssl = ($this->SMTPSecure == 'ssl');
$hosts = explode(';', $this->Host);
$lastexception = null;
foreach ($hosts as $hostentry) {
$hostinfo = array();
$host = $hostentry;
$port = $this->Port;
if (preg_match(
'/^(.+):([0-9]+)$/',
$hostentry,
$hostinfo
)
) { //If $hostentry contains 'address:port', override default
$host = $hostinfo[1];
$port = $hostinfo[2];
}
if ($this->smtp->connect(($ssl ? 'ssl://' : '') . $host, $port, $this->Timeout, $options)) {
try {
if ($this->Helo) {
$hello = $this->Helo;
} else {
$hello = $this->serverHostname();
}
$this->smtp->hello($hello);
if ($tls) {
if (!$this->smtp->startTLS()) {
throw new phpmailerException($this->lang('connect_host'));
}
//We must resend HELO after tls negotiation
$this->smtp->hello($hello);
}
if ($this->SMTPAuth) {
if (!$this->smtp->authenticate(
$this->Username,
$this->Password,
$this->AuthType,
$this->Realm,
$this->Workstation
)
) {
throw new phpmailerException($this->lang('authenticate'));
}
}
return true;
} catch (phpmailerException $e) {
$lastexception = $e;
//We must have connected, but then failed TLS or Auth, so close connection nicely
$this->smtp->quit();
}
}
}
//If we get here, all connection attempts have failed, so close connection hard
$this->smtp->close();
//As we've caught all exceptions, just report whatever the last one was
if ($this->exceptions and !is_null($lastexception)) {
throw $lastexception;
}
return false;
}
/**
* Close the active SMTP session if one exists.
* @return void
*/
public function smtpClose()
{
if ($this->smtp !== null) {
if ($this->smtp->connected()) {
$this->smtp->quit();
$this->smtp->close();
}
}
}
/**
* Set the language for error messages.
* Returns false if it cannot load the language file.
* The default language is English.
* @param string $langcode ISO 639-1 2-character language code (e.g. French is "fr")
* @param string $lang_path Path to the language file directory, with trailing separator (slash)
* @return bool
* @access public
*/
public function setLanguage($langcode = 'en', $lang_path = 'language/')
{
//Define full set of translatable strings
$PHPMAILER_LANG = array(
'authenticate' => 'SMTP Error: Could not authenticate.',
'connect_host' => 'SMTP Error: Could not connect to SMTP host.',
'data_not_accepted' => 'SMTP Error: data not accepted.',
'empty_message' => 'Message body empty',
'encoding' => 'Unknown encoding: ',
'execute' => 'Could not execute: ',
'file_access' => 'Could not access file: ',
'file_open' => 'File Error: Could not open file: ',
'from_failed' => 'The following From address failed: ',
'instantiate' => 'Could not instantiate mail function.',
'invalid_address' => 'Invalid address',
'mailer_not_supported' => ' mailer is not supported.',
'provide_address' => 'You must provide at least one recipient email address.',
'recipients_failed' => 'SMTP Error: The following recipients failed: ',
'signing' => 'Signing Error: ',
'smtp_connect_failed' => 'SMTP connect() failed.',
'smtp_error' => 'SMTP server error: ',
'variable_set' => 'Cannot set or reset variable: '
);
//Overwrite language-specific strings.
//This way we'll never have missing translations - no more "language string failed to load"!
$l = true;
if ($langcode != 'en') { //There is no English translation file
$l = @include $lang_path . 'phpmailer.lang-' . $langcode . '.php';
}
$this->language = $PHPMAILER_LANG;
return ($l == true); //Returns false if language not found
}
/**
* Get the array of strings for the current language.
* @return array
*/
public function getTranslations()
{
return $this->language;
}
/**
* Create recipient headers.
* @access public
* @param string $type
* @param array $addr An array of recipient,
* where each recipient is a 2-element indexed array with element 0 containing an address
* and element 1 containing a name, like:
* array(array('joe@example.com', 'Joe User'), array('zoe@example.com', 'Zoe User'))
* @return string
*/
public function addrAppend($type, $addr)
{
$addresses = array();
foreach ($addr as $a) {
$addresses[] = $this->addrFormat($a);
}
return $type . ': ' . implode(', ', $addresses) . $this->LE;
}
/**
* Format an address for use in a message header.
* @access public
* @param array $addr A 2-element indexed array, element 0 containing an address, element 1 containing a name
* like array('joe@example.com', 'Joe User')
* @return string
*/
public function addrFormat($addr)
{
if (empty($addr[1])) { // No name provided
return $this->secureHeader($addr[0]);
} else {
return $this->encodeHeader($this->secureHeader($addr[1]), 'phrase') . " <" . $this->secureHeader(
$addr[0]
) . ">";
}
}
/**
* Word-wrap message.
* For use with mailers that do not automatically perform wrapping
* and for quoted-printable encoded messages.
* Original written by philippe.
* @param string $message The message to wrap
* @param integer $length The line length to wrap to
* @param bool $qp_mode Whether to run in Quoted-Printable mode
* @access public
* @return string
*/
public function wrapText($message, $length, $qp_mode = false)
{
$soft_break = ($qp_mode) ? sprintf(" =%s", $this->LE) : $this->LE;
// If utf-8 encoding is used, we will need to make sure we don't
// split multibyte characters when we wrap
$is_utf8 = (strtolower($this->CharSet) == "utf-8");
$lelen = strlen($this->LE);
$crlflen = strlen(self::CRLF);
$message = $this->fixEOL($message);
if (substr($message, -$lelen) == $this->LE) {
$message = substr($message, 0, -$lelen);
}
$line = explode($this->LE, $message); // Magic. We know fixEOL uses $LE
$message = '';
for ($i = 0; $i < count($line); $i++) {
$line_part = explode(' ', $line[$i]);
$buf = '';
for ($e = 0; $e < count($line_part); $e++) {
$word = $line_part[$e];
if ($qp_mode and (strlen($word) > $length)) {
$space_left = $length - strlen($buf) - $crlflen;
if ($e != 0) {
if ($space_left > 20) {
$len = $space_left;
if ($is_utf8) {
$len = $this->utf8CharBoundary($word, $len);
} elseif (substr($word, $len - 1, 1) == "=") {
$len--;
} elseif (substr($word, $len - 2, 1) == "=") {
$len -= 2;
}
$part = substr($word, 0, $len);
$word = substr($word, $len);
$buf .= ' ' . $part;
$message .= $buf . sprintf("=%s", self::CRLF);
} else {
$message .= $buf . $soft_break;
}
$buf = '';
}
while (strlen($word) > 0) {
if ($length <= 0) {
break;
}
$len = $length;
if ($is_utf8) {
$len = $this->utf8CharBoundary($word, $len);
} elseif (substr($word, $len - 1, 1) == "=") {
$len--;
} elseif (substr($word, $len - 2, 1) == "=") {
$len -= 2;
}
$part = substr($word, 0, $len);
$word = substr($word, $len);
if (strlen($word) > 0) {
$message .= $part . sprintf("=%s", self::CRLF);
} else {
$buf = $part;
}
}
} else {
$buf_o = $buf;
$buf .= ($e == 0) ? $word : (' ' . $word);
if (strlen($buf) > $length and $buf_o != '') {
$message .= $buf_o . $soft_break;
$buf = $word;
}
}
}
$message .= $buf . self::CRLF;
}
return $message;
}
/**
* Find the last character boundary prior to $maxLength in a utf-8
* quoted (printable) encoded string.
* Original written by Colin Brown.
* @access public
* @param string $encodedText utf-8 QP text
* @param int $maxLength find last character boundary prior to this length
* @return int
*/
public function utf8CharBoundary($encodedText, $maxLength)
{
$foundSplitPos = false;
$lookBack = 3;
while (!$foundSplitPos) {
$lastChunk = substr($encodedText, $maxLength - $lookBack, $lookBack);
$encodedCharPos = strpos($lastChunk, "=");
if ($encodedCharPos !== false) {
// Found start of encoded character byte within $lookBack block.
// Check the encoded byte value (the 2 chars after the '=')
$hex = substr($encodedText, $maxLength - $lookBack + $encodedCharPos + 1, 2);
$dec = hexdec($hex);
if ($dec < 128) { // Single byte character.
// If the encoded char was found at pos 0, it will fit
// otherwise reduce maxLength to start of the encoded char
$maxLength = ($encodedCharPos == 0) ? $maxLength :
$maxLength - ($lookBack - $encodedCharPos);
$foundSplitPos = true;
} elseif ($dec >= 192) { // First byte of a multi byte character
// Reduce maxLength to split at start of character
$maxLength = $maxLength - ($lookBack - $encodedCharPos);
$foundSplitPos = true;
} elseif ($dec < 192) { // Middle byte of a multi byte character, look further back
$lookBack += 3;
}
} else {
// No encoded character found
$foundSplitPos = true;
}
}
return $maxLength;
}
/**
* Set the body wrapping.
* @access public
* @return void
*/
public function setWordWrap()
{
if ($this->WordWrap < 1) {
return;
}
switch ($this->message_type) {
case 'alt':
case 'alt_inline':
case 'alt_attach':
case 'alt_inline_attach':
$this->AltBody = $this->wrapText($this->AltBody, $this->WordWrap);
break;
default:
$this->Body = $this->wrapText($this->Body, $this->WordWrap);
break;
}
}
/**
* Assemble message headers.
* @access public
* @return string The assembled headers
*/
public function createHeader()
{
$result = '';
// Set the boundaries
$uniq_id = md5(uniqid(time()));
$this->boundary[1] = 'b1_' . $uniq_id;
$this->boundary[2] = 'b2_' . $uniq_id;
$this->boundary[3] = 'b3_' . $uniq_id;
if ($this->MessageDate == '') {
$result .= $this->headerLine('Date', self::rfcDate());
} else {
$result .= $this->headerLine('Date', $this->MessageDate);
}
if ($this->ReturnPath) {
$result .= $this->headerLine('Return-Path', '<' . trim($this->ReturnPath) . '>');
} elseif ($this->Sender == '') {
$result .= $this->headerLine('Return-Path', '<' . trim($this->From) . '>');
} else {
$result .= $this->headerLine('Return-Path', '<' . trim($this->Sender) . '>');
}
// To be created automatically by mail()
if ($this->Mailer != 'mail') {
if ($this->SingleTo === true) {
foreach ($this->to as $t) {
$this->SingleToArray[] = $this->addrFormat($t);
}
} else {
if (count($this->to) > 0) {
$result .= $this->addrAppend('To', $this->to);
} elseif (count($this->cc) == 0) {
$result .= $this->headerLine('To', 'undisclosed-recipients:;');
}
}
}
$result .= $this->addrAppend('From', array(array(trim($this->From), $this->FromName)));
// sendmail and mail() extract Cc from the header before sending
if (count($this->cc) > 0) {
$result .= $this->addrAppend('Cc', $this->cc);
}
// sendmail and mail() extract Bcc from the header before sending
if ((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->bcc) > 0)) {
$result .= $this->addrAppend('Bcc', $this->bcc);
}
if (count($this->ReplyTo) > 0) {
$result .= $this->addrAppend('Reply-To', $this->ReplyTo);
}
// mail() sets the subject itself
if ($this->Mailer != 'mail') {
$result .= $this->headerLine('Subject', $this->encodeHeader($this->secureHeader($this->Subject)));
}
if ($this->MessageID != '') {
$this->lastMessageID = $this->MessageID;
} else {
$this->lastMessageID = sprintf("<%s@%s>", $uniq_id, $this->ServerHostname());
}
$result .= $this->HeaderLine('Message-ID', $this->lastMessageID);
$result .= $this->headerLine('X-Priority', $this->Priority);
if ($this->XMailer == '') {
$result .= $this->headerLine(
'X-Mailer',
'PHPMailer ' . $this->Version . ' (https://github.com/PHPMailer/PHPMailer/)'
);
} else {
$myXmailer = trim($this->XMailer);
if ($myXmailer) {
$result .= $this->headerLine('X-Mailer', $myXmailer);
}
}
if ($this->ConfirmReadingTo != '') {
$result .= $this->headerLine('Disposition-Notification-To', '<' . trim($this->ConfirmReadingTo) . '>');
}
// Add custom headers
for ($index = 0; $index < count($this->CustomHeader); $index++) {
$result .= $this->headerLine(
trim($this->CustomHeader[$index][0]),
$this->encodeHeader(trim($this->CustomHeader[$index][1]))
);
}
if (!$this->sign_key_file) {
$result .= $this->headerLine('MIME-Version', '1.0');
$result .= $this->getMailMIME();
}
return $result;
}
/**
* Get the message MIME type headers.
* @access public
* @return string
*/
public function getMailMIME()
{
$result = '';
switch ($this->message_type) {
case 'inline':
$result .= $this->headerLine('Content-Type', 'multipart/related;');
$result .= $this->textLine("\tboundary=\"" . $this->boundary[1] . '"');
break;
case 'attach':
case 'inline_attach':
case 'alt_attach':
case 'alt_inline_attach':
$result .= $this->headerLine('Content-Type', 'multipart/mixed;');
$result .= $this->textLine("\tboundary=\"" . $this->boundary[1] . '"');
break;
case 'alt':
case 'alt_inline':
$result .= $this->headerLine('Content-Type', 'multipart/alternative;');
$result .= $this->textLine("\tboundary=\"" . $this->boundary[1] . '"');
break;
default:
// Catches case 'plain': and case '':
$result .= $this->textLine('Content-Type: ' . $this->ContentType . '; charset=' . $this->CharSet);
break;
}
//RFC1341 part 5 says 7bit is assumed if not specified
if ($this->Encoding != '7bit') {
$result .= $this->headerLine('Content-Transfer-Encoding', $this->Encoding);
}
if ($this->Mailer != 'mail') {
$result .= $this->LE;
}
return $result;
}
/**
* Returns the whole MIME message.
* Includes complete headers and body.
* Only valid post PreSend().
* @see PHPMailer::PreSend()
* @access public
* @return string
*/
public function getSentMIMEMessage()
{
return $this->MIMEHeader . $this->mailHeader . self::CRLF . $this->MIMEBody;
}
/**
* Assemble the message body.
* Returns an empty string on failure.
* @access public
* @throws phpmailerException
* @return string The assembled message body
*/
public function createBody()
{
$body = '';
if ($this->sign_key_file) {
$body .= $this->getMailMIME() . $this->LE;
}
$this->setWordWrap();
switch ($this->message_type) {
case 'inline':
$body .= $this->getBoundary($this->boundary[1], '', '', '');
$body .= $this->encodeString($this->Body, $this->Encoding);
$body .= $this->LE . $this->LE;
$body .= $this->attachAll('inline', $this->boundary[1]);
break;
case 'attach':
$body .= $this->getBoundary($this->boundary[1], '', '', '');
$body .= $this->encodeString($this->Body, $this->Encoding);
$body .= $this->LE . $this->LE;
$body .= $this->attachAll('attachment', $this->boundary[1]);
break;
case 'inline_attach':
$body .= $this->textLine('--' . $this->boundary[1]);
$body .= $this->headerLine('Content-Type', 'multipart/related;');
$body .= $this->textLine("\tboundary=\"" . $this->boundary[2] . '"');
$body .= $this->LE;
$body .= $this->getBoundary($this->boundary[2], '', '', '');
$body .= $this->encodeString($this->Body, $this->Encoding);
$body .= $this->LE . $this->LE;
$body .= $this->attachAll('inline', $this->boundary[2]);
$body .= $this->LE;
$body .= $this->attachAll('attachment', $this->boundary[1]);
break;
case 'alt':
$body .= $this->getBoundary($this->boundary[1], '', 'text/plain', '');
$body .= $this->encodeString($this->AltBody, $this->Encoding);
$body .= $this->LE . $this->LE;
$body .= $this->getBoundary($this->boundary[1], '', 'text/html', '');
$body .= $this->encodeString($this->Body, $this->Encoding);
$body .= $this->LE . $this->LE;
if (!empty($this->Ical)) {
$body .= $this->getBoundary($this->boundary[1], '', 'text/calendar; method=REQUEST', '');
$body .= $this->encodeString($this->Ical, $this->Encoding);
$body .= $this->LE . $this->LE;
}
$body .= $this->endBoundary($this->boundary[1]);
break;
case 'alt_inline':
$body .= $this->getBoundary($this->boundary[1], '', 'text/plain', '');
$body .= $this->encodeString($this->AltBody, $this->Encoding);
$body .= $this->LE . $this->LE;
$body .= $this->textLine('--' . $this->boundary[1]);
$body .= $this->headerLine('Content-Type', 'multipart/related;');
$body .= $this->textLine("\tboundary=\"" . $this->boundary[2] . '"');
$body .= $this->LE;
$body .= $this->getBoundary($this->boundary[2], '', 'text/html', '');
$body .= $this->encodeString($this->Body, $this->Encoding);
$body .= $this->LE . $this->LE;
$body .= $this->attachAll('inline', $this->boundary[2]);
$body .= $this->LE;
$body .= $this->endBoundary($this->boundary[1]);
break;
case 'alt_attach':
$body .= $this->textLine('--' . $this->boundary[1]);
$body .= $this->headerLine('Content-Type', 'multipart/alternative;');
$body .= $this->textLine("\tboundary=\"" . $this->boundary[2] . '"');
$body .= $this->LE;
$body .= $this->getBoundary($this->boundary[2], '', 'text/plain', '');
$body .= $this->encodeString($this->AltBody, $this->Encoding);
$body .= $this->LE . $this->LE;
$body .= $this->getBoundary($this->boundary[2], '', 'text/html', '');
$body .= $this->encodeString($this->Body, $this->Encoding);
$body .= $this->LE . $this->LE;
$body .= $this->endBoundary($this->boundary[2]);
$body .= $this->LE;
$body .= $this->attachAll('attachment', $this->boundary[1]);
break;
case 'alt_inline_attach':
$body .= $this->textLine('--' . $this->boundary[1]);
$body .= $this->headerLine('Content-Type', 'multipart/alternative;');
$body .= $this->textLine("\tboundary=\"" . $this->boundary[2] . '"');
$body .= $this->LE;
$body .= $this->getBoundary($this->boundary[2], '', 'text/plain', '');
$body .= $this->encodeString($this->AltBody, $this->Encoding);
$body .= $this->LE . $this->LE;
$body .= $this->textLine('--' . $this->boundary[2]);
$body .= $this->headerLine('Content-Type', 'multipart/related;');
$body .= $this->textLine("\tboundary=\"" . $this->boundary[3] . '"');
$body .= $this->LE;
$body .= $this->getBoundary($this->boundary[3], '', 'text/html', '');
$body .= $this->encodeString($this->Body, $this->Encoding);
$body .= $this->LE . $this->LE;
$body .= $this->attachAll('inline', $this->boundary[3]);
$body .= $this->LE;
$body .= $this->endBoundary($this->boundary[2]);
$body .= $this->LE;
$body .= $this->attachAll('attachment', $this->boundary[1]);
break;
default:
// catch case 'plain' and case ''
$body .= $this->encodeString($this->Body, $this->Encoding);
break;
}
if ($this->isError()) {
$body = '';
} elseif ($this->sign_key_file) {
try {
if (!defined('PKCS7_TEXT')) {
throw new phpmailerException($this->lang('signing') . ' OpenSSL extension missing.');
}
$file = tempnam(sys_get_temp_dir(), 'mail');
file_put_contents($file, $body); //TODO check this worked
$signed = tempnam(sys_get_temp_dir(), 'signed');
if (@openssl_pkcs7_sign(
$file,
$signed,
'file://' . realpath($this->sign_cert_file),
array('file://' . realpath($this->sign_key_file), $this->sign_key_pass),
null
)
) {
@unlink($file);
$body = file_get_contents($signed);
@unlink($signed);
} else {
@unlink($file);
@unlink($signed);
throw new phpmailerException($this->lang('signing') . openssl_error_string());
}
} catch (phpmailerException $e) {
$body = '';
if ($this->exceptions) {
throw $e;
}
}
}
return $body;
}
/**
* Return the start of a message boundary.
* @access protected
* @param string $boundary
* @param string $charSet
* @param string $contentType
* @param string $encoding
* @return string
*/
protected function getBoundary($boundary, $charSet, $contentType, $encoding)
{
$result = '';
if ($charSet == '') {
$charSet = $this->CharSet;
}
if ($contentType == '') {
$contentType = $this->ContentType;
}
if ($encoding == '') {
$encoding = $this->Encoding;
}
$result .= $this->textLine('--' . $boundary);
$result .= sprintf("Content-Type: %s; charset=%s", $contentType, $charSet);
$result .= $this->LE;
$result .= $this->headerLine('Content-Transfer-Encoding', $encoding);
$result .= $this->LE;
return $result;
}
/**
* Return the end of a message boundary.
* @access protected
* @param string $boundary
* @return string
*/
protected function endBoundary($boundary)
{
return $this->LE . '--' . $boundary . '--' . $this->LE;
}
/**
* Set the message type.
* PHPMailer only supports some preset message types,
* not arbitrary MIME structures.
* @access protected
* @return void
*/
protected function setMessageType()
{
$this->message_type = array();
if ($this->alternativeExists()) {
$this->message_type[] = "alt";
}
if ($this->inlineImageExists()) {
$this->message_type[] = "inline";
}
if ($this->attachmentExists()) {
$this->message_type[] = "attach";
}
$this->message_type = implode("_", $this->message_type);
if ($this->message_type == "") {
$this->message_type = "plain";
}
}
/**
* Format a header line.
* @access public
* @param string $name
* @param string $value
* @return string
*/
public function headerLine($name, $value)
{
return $name . ': ' . $value . $this->LE;
}
/**
* Return a formatted mail line.
* @access public
* @param string $value
* @return string
*/
public function textLine($value)
{
return $value . $this->LE;
}
/**
* Add an attachment from a path on the filesystem.
* Returns false if the file could not be found or read.
* @param string $path Path to the attachment.
* @param string $name Overrides the attachment name.
* @param string $encoding File encoding (see $Encoding).
* @param string $type File extension (MIME) type.
* @param string $disposition Disposition to use
* @throws phpmailerException
* @return bool
*/
public function addAttachment($path, $name = '', $encoding = 'base64', $type = '', $disposition = 'attachment')
{
try {
if (!@is_file($path)) {
throw new phpmailerException($this->lang('file_access') . $path, self::STOP_CONTINUE);
}
//If a MIME type is not specified, try to work it out from the file name
if ($type == '') {
$type = self::filenameToType($path);
}
$filename = basename($path);
if ($name == '') {
$name = $filename;
}
$this->attachment[] = array(
0 => $path,
1 => $filename,
2 => $name,
3 => $encoding,
4 => $type,
5 => false, // isStringAttachment
6 => $disposition,
7 => 0
);
} catch (phpmailerException $e) {
$this->setError($e->getMessage());
if ($this->exceptions) {
throw $e;
}
$this->edebug($e->getMessage() . "\n");
return false;
}
return true;
}
/**
* Return the array of attachments.
* @return array
*/
public function getAttachments()
{
return $this->attachment;
}
/**
* Attach all file, string, and binary attachments to the message.
* Returns an empty string on failure.
* @access protected
* @param string $disposition_type
* @param string $boundary
* @return string
*/
protected function attachAll($disposition_type, $boundary)
{
// Return text of body
$mime = array();
$cidUniq = array();
$incl = array();
// Add all attachments
foreach ($this->attachment as $attachment) {
// Check if it is a valid disposition_filter
if ($attachment[6] == $disposition_type) {
// Check for string attachment
$string = '';
$path = '';
$bString = $attachment[5];
if ($bString) {
$string = $attachment[0];
} else {
$path = $attachment[0];
}
$inclhash = md5(serialize($attachment));
if (in_array($inclhash, $incl)) {
continue;
}
$incl[] = $inclhash;
$name = $attachment[2];
$encoding = $attachment[3];
$type = $attachment[4];
$disposition = $attachment[6];
$cid = $attachment[7];
if ($disposition == 'inline' && isset($cidUniq[$cid])) {
continue;
}
$cidUniq[$cid] = true;
$mime[] = sprintf("--%s%s", $boundary, $this->LE);
$mime[] = sprintf(
"Content-Type: %s; name=\"%s\"%s",
$type,
$this->encodeHeader($this->secureHeader($name)),
$this->LE
);
$mime[] = sprintf("Content-Transfer-Encoding: %s%s", $encoding, $this->LE);
if ($disposition == 'inline') {
$mime[] = sprintf("Content-ID: <%s>%s", $cid, $this->LE);
}
// If a filename contains any of these chars, it should be quoted,
// but not otherwise: RFC2183 & RFC2045 5.1
// Fixes a warning in IETF's msglint MIME checker
// Allow for bypassing the Content-Disposition header totally
if (!(empty($disposition))) {
if (preg_match('/[ \(\)<>@,;:\\"\/\[\]\?=]/', $name)) {
$mime[] = sprintf(
"Content-Disposition: %s; filename=\"%s\"%s",
$disposition,
$this->encodeHeader($this->secureHeader($name)),
$this->LE . $this->LE
);
} else {
$mime[] = sprintf(
"Content-Disposition: %s; filename=%s%s",
$disposition,
$this->encodeHeader($this->secureHeader($name)),
$this->LE . $this->LE
);
}
} else {
$mime[] = $this->LE;
}
// Encode as string attachment
if ($bString) {
$mime[] = $this->encodeString($string, $encoding);
if ($this->isError()) {
return '';
}
$mime[] = $this->LE . $this->LE;
} else {
$mime[] = $this->encodeFile($path, $encoding);
if ($this->isError()) {
return '';
}
$mime[] = $this->LE . $this->LE;
}
}
}
$mime[] = sprintf("--%s--%s", $boundary, $this->LE);
return implode("", $mime);
}
/**
* Encode a file attachment in requested format.
* Returns an empty string on failure.
* @param string $path The full path to the file
* @param string $encoding The encoding to use; one of 'base64', '7bit', '8bit', 'binary', 'quoted-printable'
* @throws phpmailerException
* @see EncodeFile(encodeFile
* @access protected
* @return string
*/
protected function encodeFile($path, $encoding = 'base64')
{
try {
if (!is_readable($path)) {
throw new phpmailerException($this->lang('file_open') . $path, self::STOP_CONTINUE);
}
$magic_quotes = get_magic_quotes_runtime();
if ($magic_quotes) {
if (version_compare(PHP_VERSION, '5.3.0', '<')) {
set_magic_quotes_runtime(0);
} else {
ini_set('magic_quotes_runtime', 0);
}
}
$file_buffer = file_get_contents($path);
$file_buffer = $this->encodeString($file_buffer, $encoding);
if ($magic_quotes) {
if (version_compare(PHP_VERSION, '5.3.0', '<')) {
set_magic_quotes_runtime($magic_quotes);
} else {
ini_set('magic_quotes_runtime', $magic_quotes);
}
}
return $file_buffer;
} catch (Exception $e) {
$this->setError($e->getMessage());
return '';
}
}
/**
* Encode a string in requested format.
* Returns an empty string on failure.
* @param string $str The text to encode
* @param string $encoding The encoding to use; one of 'base64', '7bit', '8bit', 'binary', 'quoted-printable'
* @access public
* @return string
*/
public function encodeString($str, $encoding = 'base64')
{
$encoded = '';
switch (strtolower($encoding)) {
case 'base64':
$encoded = chunk_split(base64_encode($str), 76, $this->LE);
break;
case '7bit':
case '8bit':
$encoded = $this->fixEOL($str);
//Make sure it ends with a line break
if (substr($encoded, -(strlen($this->LE))) != $this->LE) {
$encoded .= $this->LE;
}
break;
case 'binary':
$encoded = $str;
break;
case 'quoted-printable':
$encoded = $this->encodeQP($str);
break;
default:
$this->setError($this->lang('encoding') . $encoding);
break;
}
return $encoded;
}
/**
* Encode a header string optimally.
* Picks shortest of Q, B, quoted-printable or none.
* @access public
* @param string $str
* @param string $position
* @return string
*/
public function encodeHeader($str, $position = 'text')
{
$x = 0;
switch (strtolower($position)) {
case 'phrase':
if (!preg_match('/[\200-\377]/', $str)) {
// Can't use addslashes as we don't know what value has magic_quotes_sybase
$encoded = addcslashes($str, "\0..\37\177\\\"");
if (($str == $encoded) && !preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str)) {
return ($encoded);
} else {
return ("\"$encoded\"");
}
}
$x = preg_match_all('/[^\040\041\043-\133\135-\176]/', $str, $matches);
break;
/** @noinspection PhpMissingBreakStatementInspection */
case 'comment':
$x = preg_match_all('/[()"]/', $str, $matches);
// Intentional fall-through
case 'text':
default:
$x += preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches);
break;
}
if ($x == 0) { //There are no chars that need encoding
return ($str);
}
$maxlen = 75 - 7 - strlen($this->CharSet);
// Try to select the encoding which should produce the shortest output
if ($x > strlen($str) / 3) {
//More than a third of the content will need encoding, so B encoding will be most efficient
$encoding = 'B';
if (function_exists('mb_strlen') && $this->hasMultiBytes($str)) {
// Use a custom function which correctly encodes and wraps long
// multibyte strings without breaking lines within a character
$encoded = $this->base64EncodeWrapMB($str, "\n");
} else {
$encoded = base64_encode($str);
$maxlen -= $maxlen % 4;
$encoded = trim(chunk_split($encoded, $maxlen, "\n"));
}
} else {
$encoding = 'Q';
$encoded = $this->encodeQ($str, $position);
$encoded = $this->wrapText($encoded, $maxlen, true);
$encoded = str_replace('=' . self::CRLF, "\n", trim($encoded));
}
$encoded = preg_replace('/^(.*)$/m', " =?" . $this->CharSet . "?$encoding?\\1?=", $encoded);
$encoded = trim(str_replace("\n", $this->LE, $encoded));
return $encoded;
}
/**
* Check if a string contains multi-byte characters.
* @access public
* @param string $str multi-byte text to wrap encode
* @return bool
*/
public function hasMultiBytes($str)
{
if (function_exists('mb_strlen')) {
return (strlen($str) > mb_strlen($str, $this->CharSet));
} else { // Assume no multibytes (we can't handle without mbstring functions anyway)
return false;
}
}
/**
* Encode and wrap long multibyte strings for mail headers
* without breaking lines within a character.
* Adapted from a function by paravoid at http://uk.php.net/manual/en/function.mb-encode-mimeheader.php
* @access public
* @param string $str multi-byte text to wrap encode
* @param string $lf string to use as linefeed/end-of-line
* @return string
*/
public function base64EncodeWrapMB($str, $lf = null)
{
$start = "=?" . $this->CharSet . "?B?";
$end = "?=";
$encoded = "";
if ($lf === null) {
$lf = $this->LE;
}
$mb_length = mb_strlen($str, $this->CharSet);
// Each line must have length <= 75, including $start and $end
$length = 75 - strlen($start) - strlen($end);
// Average multi-byte ratio
$ratio = $mb_length / strlen($str);
// Base64 has a 4:3 ratio
$avgLength = floor($length * $ratio * .75);
for ($i = 0; $i < $mb_length; $i += $offset) {
$lookBack = 0;
do {
$offset = $avgLength - $lookBack;
$chunk = mb_substr($str, $i, $offset, $this->CharSet);
$chunk = base64_encode($chunk);
$lookBack++;
} while (strlen($chunk) > $length);
$encoded .= $chunk . $lf;
}
// Chomp the last linefeed
$encoded = substr($encoded, 0, -strlen($lf));
return $encoded;
}
/**
* Encode a string in quoted-printable format.
* According to RFC2045 section 6.7.
* @access public
* @param string $string The text to encode
* @param integer $line_max Number of chars allowed on a line before wrapping
* @return string
* @link PHP version adapted from http://www.php.net/manual/en/function.quoted-printable-decode.php#89417
*/
public function encodeQP($string, $line_max = 76)
{
if (function_exists('quoted_printable_encode')) { //Use native function if it's available (>= PHP5.3)
return quoted_printable_encode($string);
}
//Fall back to a pure PHP implementation
$string = str_replace(
array('%20', '%0D%0A.', '%0D%0A', '%'),
array(' ', "\r\n=2E", "\r\n", '='),
rawurlencode($string)
);
$string = preg_replace('/[^\r\n]{' . ($line_max - 3) . '}[^=\r\n]{2}/', "$0=\r\n", $string);
return $string;
}
/**
* Backward compatibility wrapper for an old QP encoding function that was removed.
* @see PHPMailer::encodeQP()
* @access public
* @param string $string
* @param integer $line_max
* @param bool $space_conv
* @return string
* @deprecated Use encodeQP instead.
*/
public function encodeQPphp(
$string,
$line_max = 76,
/** @noinspection PhpUnusedParameterInspection */ $space_conv = false
) {
return $this->encodeQP($string, $line_max);
}
/**
* Encode a string using Q encoding.
* @link http://tools.ietf.org/html/rfc2047
* @param string $str the text to encode
* @param string $position Where the text is going to be used, see the RFC for what that means
* @access public
* @return string
*/
public function encodeQ($str, $position = 'text')
{
//There should not be any EOL in the string
$pattern = '';
$encoded = str_replace(array("\r", "\n"), '', $str);
switch (strtolower($position)) {
case 'phrase':
//RFC 2047 section 5.3
$pattern = '^A-Za-z0-9!*+\/ -';
break;
/** @noinspection PhpMissingBreakStatementInspection */
case 'comment':
//RFC 2047 section 5.2
$pattern = '\(\)"';
//intentional fall-through
//for this reason we build the $pattern without including delimiters and []
case 'text':
default:
//RFC 2047 section 5.1
//Replace every high ascii, control, =, ? and _ characters
$pattern = '\000-\011\013\014\016-\037\075\077\137\177-\377' . $pattern;
break;
}
$matches = array();
if (preg_match_all("/[{$pattern}]/", $encoded, $matches)) {
//If the string contains an '=', make sure it's the first thing we replace
//so as to avoid double-encoding
$s = array_search('=', $matches[0]);
if ($s !== false) {
unset($matches[0][$s]);
array_unshift($matches[0], '=');
}
foreach (array_unique($matches[0]) as $char) {
$encoded = str_replace($char, '=' . sprintf('%02X', ord($char)), $encoded);
}
}
//Replace every spaces to _ (more readable than =20)
return str_replace(' ', '_', $encoded);
}
/**
* Add a string or binary attachment (non-filesystem).
* This method can be used to attach ascii or binary data,
* such as a BLOB record from a database.
* @param string $string String attachment data.
* @param string $filename Name of the attachment.
* @param string $encoding File encoding (see $Encoding).
* @param string $type File extension (MIME) type.
* @param string $disposition Disposition to use
* @return void
*/
public function addStringAttachment(
$string,
$filename,
$encoding = 'base64',
$type = '',
$disposition = 'attachment'
) {
//If a MIME type is not specified, try to work it out from the file name
if ($type == '') {
$type = self::filenameToType($filename);
}
// Append to $attachment array
$this->attachment[] = array(
0 => $string,
1 => $filename,
2 => basename($filename),
3 => $encoding,
4 => $type,
5 => true, // isStringAttachment
6 => $disposition,
7 => 0
);
}
/**
* Add an embedded (inline) attachment from a file.
* This can include images, sounds, and just about any other document type.
* These differ from 'regular' attachmants in that they are intended to be
* displayed inline with the message, not just attached for download.
* This is used in HTML messages that embed the images
* the HTML refers to using the $cid value.
* @param string $path Path to the attachment.
* @param string $cid Content ID of the attachment; Use this to reference
* the content when using an embedded image in HTML.
* @param string $name Overrides the attachment name.
* @param string $encoding File encoding (see $Encoding).
* @param string $type File MIME type.
* @param string $disposition Disposition to use
* @return bool True on successfully adding an attachment
*/
public function addEmbeddedImage($path, $cid, $name = '', $encoding = 'base64', $type = '', $disposition = 'inline')
{
if (!@is_file($path)) {
$this->setError($this->lang('file_access') . $path);
return false;
}
//If a MIME type is not specified, try to work it out from the file name
if ($type == '') {
$type = self::filenameToType($path);
}
$filename = basename($path);
if ($name == '') {
$name = $filename;
}
// Append to $attachment array
$this->attachment[] = array(
0 => $path,
1 => $filename,
2 => $name,
3 => $encoding,
4 => $type,
5 => false, // isStringAttachment
6 => $disposition,
7 => $cid
);
return true;
}
/**
* Add an embedded stringified attachment.
* This can include images, sounds, and just about any other document type.
* Be sure to set the $type to an image type for images:
* JPEG images use 'image/jpeg', GIF uses 'image/gif', PNG uses 'image/png'.
* @param string $string The attachment binary data.
* @param string $cid Content ID of the attachment; Use this to reference
* the content when using an embedded image in HTML.
* @param string $name
* @param string $encoding File encoding (see $Encoding).
* @param string $type MIME type.
* @param string $disposition Disposition to use
* @return bool True on successfully adding an attachment
*/
public function addStringEmbeddedImage(
$string,
$cid,
$name = '',
$encoding = 'base64',
$type = '',
$disposition = 'inline'
) {
//If a MIME type is not specified, try to work it out from the name
if ($type == '') {
$type = self::filenameToType($name);
}
// Append to $attachment array
$this->attachment[] = array(
0 => $string,
1 => $name,
2 => $name,
3 => $encoding,
4 => $type,
5 => true, // isStringAttachment
6 => $disposition,
7 => $cid
);
return true;
}
/**
* Check if an inline attachment is present.
* @access public
* @return bool
*/
public function inlineImageExists()
{
foreach ($this->attachment as $attachment) {
if ($attachment[6] == 'inline') {
return true;
}
}
return false;
}
/**
* Check if an attachment (non-inline) is present.
* @return bool
*/
public function attachmentExists()
{
foreach ($this->attachment as $attachment) {
if ($attachment[6] == 'attachment') {
return true;
}
}
return false;
}
/**
* Check if this message has an alternative body set.
* @return bool
*/
public function alternativeExists()
{
return !empty($this->AltBody);
}
/**
* Clear all To recipients.
* @return void
*/
public function clearAddresses()
{
foreach ($this->to as $to) {
unset($this->all_recipients[strtolower($to[0])]);
}
$this->to = array();
}
/**
* Clear all CC recipients.
* @return void
*/
public function clearCCs()
{
foreach ($this->cc as $cc) {
unset($this->all_recipients[strtolower($cc[0])]);
}
$this->cc = array();
}
/**
* Clear all BCC recipients.
* @return void
*/
public function clearBCCs()
{
foreach ($this->bcc as $bcc) {
unset($this->all_recipients[strtolower($bcc[0])]);
}
$this->bcc = array();
}
/**
* Clear all ReplyTo recipients.
* @return void
*/
public function clearReplyTos()
{
$this->ReplyTo = array();
}
/**
* Clear all recipient types.
* @return void
*/
public function clearAllRecipients()
{
$this->to = array();
$this->cc = array();
$this->bcc = array();
$this->all_recipients = array();
}
/**
* Clear all filesystem, string, and binary attachments.
* @return void
*/
public function clearAttachments()
{
$this->attachment = array();
}
/**
* Clear all custom headers.
* @return void
*/
public function clearCustomHeaders()
{
$this->CustomHeader = array();
}
/**
* Add an error message to the error container.
* @access protected
* @param string $msg
* @return void
*/
protected function setError($msg)
{
$this->error_count++;
if ($this->Mailer == 'smtp' and !is_null($this->smtp)) {
$lasterror = $this->smtp->getError();
if (!empty($lasterror) and array_key_exists('smtp_msg', $lasterror)) {
$msg .= '<p>' . $this->lang('smtp_error') . $lasterror['smtp_msg'] . "</p>\n";
}
}
$this->ErrorInfo = $msg;
}
/**
* Return an RFC 822 formatted date.
* @access public
* @return string
* @static
*/
public static function rfcDate()
{
//Set the time zone to whatever the default is to avoid 500 errors
//Will default to UTC if it's not set properly in php.ini
date_default_timezone_set(@date_default_timezone_get());
return date('D, j M Y H:i:s O');
}
/**
* Get the server hostname.
* Returns 'localhost.localdomain' if unknown.
* @access protected
* @return string
*/
protected function serverHostname()
{
if (!empty($this->Hostname)) {
$result = $this->Hostname;
} elseif (isset($_SERVER['SERVER_NAME'])) {
$result = $_SERVER['SERVER_NAME'];
} else {
$result = 'localhost.localdomain';
}
return $result;
}
/**
* Get an error message in the current language.
* @access protected
* @param string $key
* @return string
*/
protected function lang($key)
{
if (count($this->language) < 1) {
$this->setLanguage('en'); // set the default language
}
if (isset($this->language[$key])) {
return $this->language[$key];
} else {
return 'Language string failed to load: ' . $key;
}
}
/**
* Check if an error occurred.
* @access public
* @return bool True if an error did occur.
*/
public function isError()
{
return ($this->error_count > 0);
}
/**
* Ensure consistent line endings in a string.
* Changes every end of line from CRLF, CR or LF to $this->LE.
* @access public
* @param string $str String to fixEOL
* @return string
*/
public function fixEOL($str)
{
// Normalise to \n
$nstr = str_replace(array("\r\n", "\r"), "\n", $str);
// Now convert LE as needed
if ($this->LE !== "\n") {
$nstr = str_replace("\n", $this->LE, $nstr);
}
return $nstr;
}
/**
* Add a custom header.
* $name value can be overloaded to contain
* both header name and value (name:value)
* @access public
* @param string $name Custom header name
* @param string $value Header value
* @return void
*/
public function addCustomHeader($name, $value = null)
{
if ($value === null) {
// Value passed in as name:value
$this->CustomHeader[] = explode(':', $name, 2);
} else {
$this->CustomHeader[] = array($name, $value);
}
}
/**
* Create a message from an HTML string.
* Automatically makes modifications for inline images and backgrounds
* and creates a plain-text version by converting the HTML.
* Overwrites any existing values in $this->Body and $this->AltBody
* @access public
* @param string $message HTML message string
* @param string $basedir baseline directory for path
* @param bool $advanced Whether to use the advanced HTML to text converter
* @return string $message
*/
public function msgHTML($message, $basedir = '', $advanced = false)
{
preg_match_all("/(src|background)=[\"'](.*)[\"']/Ui", $message, $images);
if (isset($images[2])) {
foreach ($images[2] as $i => $url) {
// do not change urls for absolute images (thanks to corvuscorax)
if (!preg_match('#^[A-z]+://#', $url)) {
$filename = basename($url);
$directory = dirname($url);
if ($directory == '.') {
$directory = '';
}
$cid = md5($url) . '@phpmailer.0'; //RFC2392 S 2
if (strlen($basedir) > 1 && substr($basedir, -1) != '/') {
$basedir .= '/';
}
if (strlen($directory) > 1 && substr($directory, -1) != '/') {
$directory .= '/';
}
if ($this->addEmbeddedImage(
$basedir . $directory . $filename,
$cid,
$filename,
'base64',
self::_mime_types(self::mb_pathinfo($filename, PATHINFO_EXTENSION))
)
) {
$message = preg_replace(
"/" . $images[1][$i] . "=[\"']" . preg_quote($url, '/') . "[\"']/Ui",
$images[1][$i] . "=\"cid:" . $cid . "\"",
$message
);
}
}
}
}
$this->isHTML(true);
if (empty($this->AltBody)) {
$this->AltBody = 'To view this email message, open it in a program that understands HTML!' . "\n\n";
}
//Convert all message body line breaks to CRLF, makes quoted-printable encoding work much better
$this->Body = $this->normalizeBreaks($message);
$this->AltBody = $this->normalizeBreaks($this->html2text($message, $advanced));
return $this->Body;
}
/**
* Convert an HTML string into plain text.
* @param string $html The HTML text to convert
* @param bool $advanced Should this use the more complex html2text converter or just a simple one?
* @return string
*/
public function html2text($html, $advanced = false)
{
if ($advanced) {
require_once 'extras/class.html2text.php';
$h = new html2text($html);
return $h->get_text();
}
return html_entity_decode(
trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/si', '', $html))),
ENT_QUOTES,
$this->CharSet
);
}
/**
* Get the MIME type for a file extension.
* @param string $ext File extension
* @access public
* @return string MIME type of file.
* @static
*/
public static function _mime_types($ext = '')
{
$mimes = array(
'xl' => 'application/excel',
'hqx' => 'application/mac-binhex40',
'cpt' => 'application/mac-compactpro',
'bin' => 'application/macbinary',
'doc' => 'application/msword',
'word' => 'application/msword',
'class' => 'application/octet-stream',
'dll' => 'application/octet-stream',
'dms' => 'application/octet-stream',
'exe' => 'application/octet-stream',
'lha' => 'application/octet-stream',
'lzh' => 'application/octet-stream',
'psd' => 'application/octet-stream',
'sea' => 'application/octet-stream',
'so' => 'application/octet-stream',
'oda' => 'application/oda',
'pdf' => 'application/pdf',
'ai' => 'application/postscript',
'eps' => 'application/postscript',
'ps' => 'application/postscript',
'smi' => 'application/smil',
'smil' => 'application/smil',
'mif' => 'application/vnd.mif',
'xls' => 'application/vnd.ms-excel',
'ppt' => 'application/vnd.ms-powerpoint',
'wbxml' => 'application/vnd.wap.wbxml',
'wmlc' => 'application/vnd.wap.wmlc',
'dcr' => 'application/x-director',
'dir' => 'application/x-director',
'dxr' => 'application/x-director',
'dvi' => 'application/x-dvi',
'gtar' => 'application/x-gtar',
'php3' => 'application/x-httpd-php',
'php4' => 'application/x-httpd-php',
'php' => 'application/x-httpd-php',
'phtml' => 'application/x-httpd-php',
'phps' => 'application/x-httpd-php-source',
'js' => 'application/x-javascript',
'swf' => 'application/x-shockwave-flash',
'sit' => 'application/x-stuffit',
'tar' => 'application/x-tar',
'tgz' => 'application/x-tar',
'xht' => 'application/xhtml+xml',
'xhtml' => 'application/xhtml+xml',
'zip' => 'application/zip',
'mid' => 'audio/midi',
'midi' => 'audio/midi',
'mp2' => 'audio/mpeg',
'mp3' => 'audio/mpeg',
'mpga' => 'audio/mpeg',
'aif' => 'audio/x-aiff',
'aifc' => 'audio/x-aiff',
'aiff' => 'audio/x-aiff',
'ram' => 'audio/x-pn-realaudio',
'rm' => 'audio/x-pn-realaudio',
'rpm' => 'audio/x-pn-realaudio-plugin',
'ra' => 'audio/x-realaudio',
'wav' => 'audio/x-wav',
'bmp' => 'image/bmp',
'gif' => 'image/gif',
'jpeg' => 'image/jpeg',
'jpe' => 'image/jpeg',
'jpg' => 'image/jpeg',
'png' => 'image/png',
'tiff' => 'image/tiff',
'tif' => 'image/tiff',
'eml' => 'message/rfc822',
'css' => 'text/css',
'html' => 'text/html',
'htm' => 'text/html',
'shtml' => 'text/html',
'log' => 'text/plain',
'text' => 'text/plain',
'txt' => 'text/plain',
'rtx' => 'text/richtext',
'rtf' => 'text/rtf',
'xml' => 'text/xml',
'xsl' => 'text/xml',
'mpeg' => 'video/mpeg',
'mpe' => 'video/mpeg',
'mpg' => 'video/mpeg',
'mov' => 'video/quicktime',
'qt' => 'video/quicktime',
'rv' => 'video/vnd.rn-realvideo',
'avi' => 'video/x-msvideo',
'movie' => 'video/x-sgi-movie'
);
return (array_key_exists(strtolower($ext), $mimes) ? $mimes[strtolower($ext)]: 'application/octet-stream');
}
/**
* Map a file name to a MIME type.
* Defaults to 'application/octet-stream', i.e.. arbitrary binary data.
* @param string $filename A file name or full path, does not need to exist as a file
* @return string
* @static
*/
public static function filenameToType($filename)
{
//In case the path is a URL, strip any query string before getting extension
$qpos = strpos($filename, '?');
if ($qpos !== false) {
$filename = substr($filename, 0, $qpos);
}
$pathinfo = self::mb_pathinfo($filename);
return self::_mime_types($pathinfo['extension']);
}
/**
* Multi-byte-safe pathinfo replacement.
* Drop-in replacement for pathinfo(), but multibyte-safe, cross-platform-safe, old-version-safe.
* Works similarly to the one in PHP >= 5.2.0
* @link http://www.php.net/manual/en/function.pathinfo.php#107461
* @param string $path A filename or path, does not need to exist as a file
* @param integer|string $options Either a PATHINFO_* constant,
* or a string name to return only the specified piece, allows 'filename' to work on PHP < 5.2
* @return string|array
* @static
*/
public static function mb_pathinfo($path, $options = null)
{
$ret = array('dirname' => '', 'basename' => '', 'extension' => '', 'filename' => '');
$m = array();
preg_match('%^(.*?)[\\\\/]*(([^/\\\\]*?)(\.([^\.\\\\/]+?)|))[\\\\/\.]*$%im', $path, $m);
if (array_key_exists(1, $m)) {
$ret['dirname'] = $m[1];
}
if (array_key_exists(2, $m)) {
$ret['basename'] = $m[2];
}
if (array_key_exists(5, $m)) {
$ret['extension'] = $m[5];
}
if (array_key_exists(3, $m)) {
$ret['filename'] = $m[3];
}
switch ($options) {
case PATHINFO_DIRNAME:
case 'dirname':
return $ret['dirname'];
break;
case PATHINFO_BASENAME:
case 'basename':
return $ret['basename'];
break;
case PATHINFO_EXTENSION:
case 'extension':
return $ret['extension'];
break;
case PATHINFO_FILENAME:
case 'filename':
return $ret['filename'];
break;
default:
return $ret;
}
}
/**
* Set or reset instance properties.
*
* Usage Example:
* $page->set('X-Priority', '3');
*
* @access public
* @param string $name
* @param mixed $value
* NOTE: will not work with arrays, there are no arrays to set/reset
* @throws phpmailerException
* @return bool
* @todo Should this not be using __set() magic function?
*/
public function set($name, $value = '')
{
try {
if (isset($this->$name)) {
$this->$name = $value;
} else {
throw new phpmailerException($this->lang('variable_set') . $name, self::STOP_CRITICAL);
}
} catch (Exception $e) {
$this->setError($e->getMessage());
if ($e->getCode() == self::STOP_CRITICAL) {
return false;
}
}
return true;
}
/**
* Strip newlines to prevent header injection.
* @access public
* @param string $str
* @return string
*/
public function secureHeader($str)
{
return trim(str_replace(array("\r", "\n"), '', $str));
}
/**
* Normalize line breaks in a string.
* Converts UNIX LF, Mac CR and Windows CRLF line breaks into a single line break format.
* Defaults to CRLF (for message bodies) and preserves consecutive breaks.
* @param string $text
* @param string $breaktype What kind of line break to use, defaults to CRLF
* @return string
* @access public
* @static
*/
public static function normalizeBreaks($text, $breaktype = "\r\n")
{
return preg_replace('/(\r\n|\r|\n)/ms', $breaktype, $text);
}
/**
* Set the private key file and password for S/MIME signing.
* @access public
* @param string $cert_filename
* @param string $key_filename
* @param string $key_pass Password for private key
*/
public function sign($cert_filename, $key_filename, $key_pass)
{
$this->sign_cert_file = $cert_filename;
$this->sign_key_file = $key_filename;
$this->sign_key_pass = $key_pass;
}
/**
* Quoted-Printable-encode a DKIM header.
* @access public
* @param string $txt
* @return string
*/
public function DKIM_QP($txt)
{
$line = '';
for ($i = 0; $i < strlen($txt); $i++) {
$ord = ord($txt[$i]);
if (((0x21 <= $ord) && ($ord <= 0x3A)) || $ord == 0x3C || ((0x3E <= $ord) && ($ord <= 0x7E))) {
$line .= $txt[$i];
} else {
$line .= "=" . sprintf("%02X", $ord);
}
}
return $line;
}
/**
* Generate a DKIM signature.
* @access public
* @param string $s Header
* @throws phpmailerException
* @return string
*/
public function DKIM_Sign($s)
{
if (!defined('PKCS7_TEXT')) {
if ($this->exceptions) {
throw new phpmailerException($this->lang("signing") . ' OpenSSL extension missing.');
}
return '';
}
$privKeyStr = file_get_contents($this->DKIM_private);
if ($this->DKIM_passphrase != '') {
$privKey = openssl_pkey_get_private($privKeyStr, $this->DKIM_passphrase);
} else {
$privKey = $privKeyStr;
}
if (openssl_sign($s, $signature, $privKey)) {
return base64_encode($signature);
}
return '';
}
/**
* Generate a DKIM canonicalization header.
* @access public
* @param string $s Header
* @return string
*/
public function DKIM_HeaderC($s)
{
$s = preg_replace("/\r\n\s+/", " ", $s);
$lines = explode("\r\n", $s);
foreach ($lines as $key => $line) {
list($heading, $value) = explode(":", $line, 2);
$heading = strtolower($heading);
$value = preg_replace("/\s+/", " ", $value); // Compress useless spaces
$lines[$key] = $heading . ":" . trim($value); // Don't forget to remove WSP around the value
}
$s = implode("\r\n", $lines);
return $s;
}
/**
* Generate a DKIM canonicalization body.
* @access public
* @param string $body Message Body
* @return string
*/
public function DKIM_BodyC($body)
{
if ($body == '') {
return "\r\n";
}
// stabilize line endings
$body = str_replace("\r\n", "\n", $body);
$body = str_replace("\n", "\r\n", $body);
// END stabilize line endings
while (substr($body, strlen($body) - 4, 4) == "\r\n\r\n") {
$body = substr($body, 0, strlen($body) - 2);
}
return $body;
}
/**
* Create the DKIM header and body in a new message header.
* @access public
* @param string $headers_line Header lines
* @param string $subject Subject
* @param string $body Body
* @return string
*/
public function DKIM_Add($headers_line, $subject, $body)
{
$DKIMsignatureType = 'rsa-sha1'; // Signature & hash algorithms
$DKIMcanonicalization = 'relaxed/simple'; // Canonicalization of header/body
$DKIMquery = 'dns/txt'; // Query method
$DKIMtime = time(); // Signature Timestamp = seconds since 00:00:00 - Jan 1, 1970 (UTC time zone)
$subject_header = "Subject: $subject";
$headers = explode($this->LE, $headers_line);
$from_header = '';
$to_header = '';
$current = '';
foreach ($headers as $header) {
if (strpos($header, 'From:') === 0) {
$from_header = $header;
$current = 'from_header';
} elseif (strpos($header, 'To:') === 0) {
$to_header = $header;
$current = 'to_header';
} else {
if ($current && strpos($header, ' =?') === 0) {
$current .= $header;
} else {
$current = '';
}
}
}
$from = str_replace('|', '=7C', $this->DKIM_QP($from_header));
$to = str_replace('|', '=7C', $this->DKIM_QP($to_header));
$subject = str_replace(
'|',
'=7C',
$this->DKIM_QP($subject_header)
); // Copied header fields (dkim-quoted-printable)
$body = $this->DKIM_BodyC($body);
$DKIMlen = strlen($body); // Length of body
$DKIMb64 = base64_encode(pack("H*", sha1($body))); // Base64 of packed binary SHA-1 hash of body
$ident = ($this->DKIM_identity == '') ? '' : " i=" . $this->DKIM_identity . ";";
$dkimhdrs = "DKIM-Signature: v=1; a=" .
$DKIMsignatureType . "; q=" .
$DKIMquery . "; l=" .
$DKIMlen . "; s=" .
$this->DKIM_selector .
";\r\n" .
"\tt=" . $DKIMtime . "; c=" . $DKIMcanonicalization . ";\r\n" .
"\th=From:To:Subject;\r\n" .
"\td=" . $this->DKIM_domain . ";" . $ident . "\r\n" .
"\tz=$from\r\n" .
"\t|$to\r\n" .
"\t|$subject;\r\n" .
"\tbh=" . $DKIMb64 . ";\r\n" .
"\tb=";
$toSign = $this->DKIM_HeaderC(
$from_header . "\r\n" . $to_header . "\r\n" . $subject_header . "\r\n" . $dkimhdrs
);
$signed = $this->DKIM_Sign($toSign);
return $dkimhdrs . $signed . "\r\n";
}
/**
* Perform a callback.
* @param bool $isSent
* @param string $to
* @param string $cc
* @param string $bcc
* @param string $subject
* @param string $body
* @param string $from
*/
protected function doCallback($isSent, $to, $cc, $bcc, $subject, $body, $from = null)
{
if (!empty($this->action_function) && is_callable($this->action_function)) {
$params = array($isSent, $to, $cc, $bcc, $subject, $body, $from);
call_user_func_array($this->action_function, $params);
}
}
}
/**
* PHPMailer exception handler
* @package PHPMailer
*/
class phpmailerException extends Exception
{
/**
* Prettify error message output
* @return string
*/
public function errorMessage()
{
$errorMsg = '<strong>' . $this->getMessage() . "</strong><br />\n";
return $errorMsg;
}
}
| 01-wordpress-paypal | trunk/wp-includes/class-phpmailer.php | PHP | gpl3 | 110,931 |
<?php
/**
* Main WordPress API
*
* @package WordPress
*/
require( ABSPATH . WPINC . '/option.php' );
/**
* Converts given date string into a different format.
*
* $format should be either a PHP date format string, e.g. 'U' for a Unix
* timestamp, or 'G' for a Unix timestamp assuming that $date is GMT.
*
* If $translate is true then the given date and format string will
* be passed to date_i18n() for translation.
*
* @since 0.71
*
* @param string $format Format of the date to return.
* @param string $date Date string to convert.
* @param bool $translate Whether the return date should be translated. Default is true.
* @return string|int Formatted date string, or Unix timestamp.
*/
function mysql2date( $format, $date, $translate = true ) {
if ( empty( $date ) )
return false;
if ( 'G' == $format )
return strtotime( $date . ' +0000' );
$i = strtotime( $date );
if ( 'U' == $format )
return $i;
if ( $translate )
return date_i18n( $format, $i );
else
return date( $format, $i );
}
/**
* Retrieve the current time based on specified type.
*
* The 'mysql' type will return the time in the format for MySQL DATETIME field.
* The 'timestamp' type will return the current timestamp.
* Other strings will be interpreted as PHP date formats (e.g. 'Y-m-d').
*
* If $gmt is set to either '1' or 'true', then both types will use GMT time.
* if $gmt is false, the output is adjusted with the GMT offset in the WordPress option.
*
* @since 1.0.0
*
* @param string $type 'mysql', 'timestamp', or PHP date format string (e.g. 'Y-m-d').
* @param int|bool $gmt Optional. Whether to use GMT timezone. Default is false.
* @return int|string String if $type is 'gmt', int if $type is 'timestamp'.
*/
function current_time( $type, $gmt = 0 ) {
switch ( $type ) {
case 'mysql':
return ( $gmt ) ? gmdate( 'Y-m-d H:i:s' ) : gmdate( 'Y-m-d H:i:s', ( time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) ) );
break;
case 'timestamp':
return ( $gmt ) ? time() : time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS );
break;
default:
return ( $gmt ) ? date( $type ) : date( $type, time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) );
break;
}
}
/**
* Retrieve the date in localized format, based on timestamp.
*
* If the locale specifies the locale month and weekday, then the locale will
* take over the format for the date. If it isn't, then the date format string
* will be used instead.
*
* @since 0.71
*
* @param string $dateformatstring Format to display the date.
* @param int $unixtimestamp Optional. Unix timestamp.
* @param bool $gmt Optional, default is false. Whether to convert to GMT for time.
* @return string The date, translated if locale specifies it.
*/
function date_i18n( $dateformatstring, $unixtimestamp = false, $gmt = false ) {
global $wp_locale;
$i = $unixtimestamp;
if ( false === $i ) {
if ( ! $gmt )
$i = current_time( 'timestamp' );
else
$i = time();
// we should not let date() interfere with our
// specially computed timestamp
$gmt = true;
}
// store original value for language with untypical grammars
// see http://core.trac.wordpress.org/ticket/9396
$req_format = $dateformatstring;
$datefunc = $gmt? 'gmdate' : 'date';
if ( ( !empty( $wp_locale->month ) ) && ( !empty( $wp_locale->weekday ) ) ) {
$datemonth = $wp_locale->get_month( $datefunc( 'm', $i ) );
$datemonth_abbrev = $wp_locale->get_month_abbrev( $datemonth );
$dateweekday = $wp_locale->get_weekday( $datefunc( 'w', $i ) );
$dateweekday_abbrev = $wp_locale->get_weekday_abbrev( $dateweekday );
$datemeridiem = $wp_locale->get_meridiem( $datefunc( 'a', $i ) );
$datemeridiem_capital = $wp_locale->get_meridiem( $datefunc( 'A', $i ) );
$dateformatstring = ' '.$dateformatstring;
$dateformatstring = preg_replace( "/([^\\\])D/", "\\1" . backslashit( $dateweekday_abbrev ), $dateformatstring );
$dateformatstring = preg_replace( "/([^\\\])F/", "\\1" . backslashit( $datemonth ), $dateformatstring );
$dateformatstring = preg_replace( "/([^\\\])l/", "\\1" . backslashit( $dateweekday ), $dateformatstring );
$dateformatstring = preg_replace( "/([^\\\])M/", "\\1" . backslashit( $datemonth_abbrev ), $dateformatstring );
$dateformatstring = preg_replace( "/([^\\\])a/", "\\1" . backslashit( $datemeridiem ), $dateformatstring );
$dateformatstring = preg_replace( "/([^\\\])A/", "\\1" . backslashit( $datemeridiem_capital ), $dateformatstring );
$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 ) ) {
$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 );
/**
* Filter the date formatted based on the locale.
*
* @since 2.8.0
*
* @param string $j Formatted date string.
* @param string $req_format Format to display the date.
* @param int $i Unix timestamp.
* @param bool $gmt Whether to convert to GMT for time. Default false.
*/
$j = apply_filters( 'date_i18n', $j, $req_format, $i, $gmt );
return $j;
}
/**
* Convert integer number to format based on the locale.
*
* @since 2.3.0
*
* @param int $number The number to convert based on locale.
* @param int $decimals Precision of the number of decimal places.
* @return string Converted number in string format.
*/
function number_format_i18n( $number, $decimals = 0 ) {
global $wp_locale;
$formatted = number_format( $number, absint( $decimals ), $wp_locale->number_format['decimal_point'], $wp_locale->number_format['thousands_sep'] );
/**
* Filter the number formatted based on the locale.
*
* @since 2.8.0
*
* @param string $formatted Converted number in string format.
*/
return apply_filters( 'number_format_i18n', $formatted );
}
/**
* Convert number of bytes largest unit bytes will fit into.
*
* It is easier to read 1kB than 1024 bytes and 1MB than 1048576 bytes. Converts
* number of bytes to human readable number by taking the number of that unit
* that the bytes will go into it. Supports TB value.
*
* Please note that integers in PHP are limited to 32 bits, unless they are on
* 64 bit architecture, then they have 64 bit size. If you need to place the
* larger size then what PHP integer type will hold, then use a string. It will
* be converted to a double, which should always have 64 bit length.
*
* Technically the correct unit names for powers of 1024 are KiB, MiB etc.
* @link http://en.wikipedia.org/wiki/Byte
*
* @since 2.3.0
*
* @param int|string $bytes Number of bytes. Note max integer size for integers.
* @param int $decimals Precision of number of decimal places. Deprecated.
* @return bool|string False on failure. Number string on success.
*/
function size_format( $bytes, $decimals = 0 ) {
$quant = array(
// ========================= Origin ====
'TB' => 1099511627776, // pow( 1024, 4)
'GB' => 1073741824, // pow( 1024, 3)
'MB' => 1048576, // pow( 1024, 2)
'kB' => 1024, // pow( 1024, 1)
'B ' => 1, // pow( 1024, 0)
);
foreach ( $quant as $unit => $mag )
if ( doubleval($bytes) >= $mag )
return number_format_i18n( $bytes / $mag, $decimals ) . ' ' . $unit;
return false;
}
/**
* Get the week start and end from the datetime or date string from mysql.
*
* @since 0.71
*
* @param string $mysqlstring Date or datetime field type from mysql.
* @param int $start_of_week Optional. Start of the week as an integer.
* @return array Keys are 'start' and 'end'.
*/
function get_weekstartend( $mysqlstring, $start_of_week = '' ) {
$my = substr( $mysqlstring, 0, 4 ); // Mysql string Year
$mm = substr( $mysqlstring, 8, 2 ); // Mysql string Month
$md = substr( $mysqlstring, 5, 2 ); // Mysql string day
$day = mktime( 0, 0, 0, $md, $mm, $my ); // The timestamp for mysqlstring day.
$weekday = date( 'w', $day ); // The day of the week from the timestamp
if ( !is_numeric($start_of_week) )
$start_of_week = get_option( 'start_of_week' );
if ( $weekday < $start_of_week )
$weekday += 7;
$start = $day - DAY_IN_SECONDS * ( $weekday - $start_of_week ); // The most recent week start day on or before $day
$end = $start + 7 * DAY_IN_SECONDS - 1; // $start + 7 days - 1 second
return compact( 'start', 'end' );
}
/**
* Unserialize value only if it was serialized.
*
* @since 2.0.0
*
* @param string $original Maybe unserialized original, if is needed.
* @return mixed Unserialized data can be any type.
*/
function maybe_unserialize( $original ) {
if ( is_serialized( $original ) ) // don't attempt to unserialize data that wasn't serialized going in
return @unserialize( $original );
return $original;
}
/**
* Check value to find if it was serialized.
*
* If $data is not an string, then returned value will always be false.
* Serialized data is always a string.
*
* @since 2.0.5
*
* @param mixed $data Value to check to see if was serialized.
* @param bool $strict Optional. Whether to be strict about the end of the string. Defaults true.
* @return bool False if not serialized and true if it was.
*/
function is_serialized( $data, $strict = true ) {
// if it isn't a string, it isn't serialized
if ( ! is_string( $data ) ) {
return false;
}
$data = trim( $data );
if ( 'N;' == $data ) {
return true;
}
if ( strlen( $data ) < 4 ) {
return false;
}
if ( ':' !== $data[1] ) {
return false;
}
if ( $strict ) {
$lastc = substr( $data, -1 );
if ( ';' !== $lastc && '}' !== $lastc ) {
return false;
}
} else {
$semicolon = strpos( $data, ';' );
$brace = strpos( $data, '}' );
// Either ; or } must exist.
if ( false === $semicolon && false === $brace )
return false;
// But neither must be in the first X characters.
if ( false !== $semicolon && $semicolon < 3 )
return false;
if ( false !== $brace && $brace < 4 )
return false;
}
$token = $data[0];
switch ( $token ) {
case 's' :
if ( $strict ) {
if ( '"' !== substr( $data, -2, 1 ) ) {
return false;
}
} elseif ( false === strpos( $data, '"' ) ) {
return false;
}
// or else fall through
case 'a' :
case 'O' :
return (bool) preg_match( "/^{$token}:[0-9]+:/s", $data );
case 'b' :
case 'i' :
case 'd' :
$end = $strict ? '$' : '';
return (bool) preg_match( "/^{$token}:[0-9.E-]+;$end/", $data );
}
return false;
}
/**
* Check whether serialized data is of string type.
*
* @since 2.0.5
*
* @param mixed $data Serialized data
* @return bool False if not a serialized string, true if it is.
*/
function is_serialized_string( $data ) {
// if it isn't a string, it isn't a serialized string
if ( ! is_string( $data ) ) {
return false;
}
$data = trim( $data );
if ( strlen( $data ) < 4 ) {
return false;
} elseif ( ':' !== $data[1] ) {
return false;
} elseif ( ';' !== substr( $data, -1 ) ) {
return false;
} elseif ( $data[0] !== 's' ) {
return false;
} elseif ( '"' !== substr( $data, -2, 1 ) ) {
return false;
} else {
return true;
}
}
/**
* Serialize data, if needed.
*
* @since 2.0.5
*
* @param mixed $data Data that might be serialized.
* @return mixed A scalar data
*/
function maybe_serialize( $data ) {
if ( is_array( $data ) || is_object( $data ) )
return serialize( $data );
// Double serialization is required for backward compatibility.
// See http://core.trac.wordpress.org/ticket/12930
if ( is_serialized( $data, false ) )
return serialize( $data );
return $data;
}
/**
* Retrieve post title from XMLRPC XML.
*
* If the title element is not part of the XML, then the default post title from
* the $post_default_title will be used instead.
*
* @since 0.71
*
* @global string $post_default_title Default XMLRPC post title.
*
* @param string $content XMLRPC XML Request content
* @return string Post title
*/
function xmlrpc_getposttitle( $content ) {
global $post_default_title;
if ( preg_match( '/<title>(.+?)<\/title>/is', $content, $matchtitle ) ) {
$post_title = $matchtitle[1];
} else {
$post_title = $post_default_title;
}
return $post_title;
}
/**
* Retrieve the post category or categories from XMLRPC XML.
*
* If the category element is not found, then the default post category will be
* used. The return type then would be what $post_default_category. If the
* category is found, then it will always be an array.
*
* @since 0.71
*
* @global string $post_default_category Default XMLRPC post category.
*
* @param string $content XMLRPC XML Request content
* @return string|array List of categories or category name.
*/
function xmlrpc_getpostcategory( $content ) {
global $post_default_category;
if ( preg_match( '/<category>(.+?)<\/category>/is', $content, $matchcat ) ) {
$post_category = trim( $matchcat[1], ',' );
$post_category = explode( ',', $post_category );
} else {
$post_category = $post_default_category;
}
return $post_category;
}
/**
* XMLRPC XML content without title and category elements.
*
* @since 0.71
*
* @param string $content XMLRPC XML Request content
* @return string XMLRPC XML Request content without title and category elements.
*/
function xmlrpc_removepostdata( $content ) {
$content = preg_replace( '/<title>(.+?)<\/title>/si', '', $content );
$content = preg_replace( '/<category>(.+?)<\/category>/si', '', $content );
$content = trim( $content );
return $content;
}
/**
* Use RegEx to extract URLs from arbitrary content
*
* @since 3.7.0
*
* @param string $content
* @return array URLs found in passed string
*/
function wp_extract_urls( $content ) {
preg_match_all(
"#((?:[\w-]+://?|[\w\d]+[.])[^\s()<>]+[.](?:\([\w\d]+\)|(?:[^`!()\[\]{};:'\".,<>?«»“”‘’\s]|(?:[:]\d+)?/?)+))#",
$content,
$post_links
);
$post_links = array_unique( array_map( 'html_entity_decode', $post_links[0] ) );
return array_values( $post_links );
}
/**
* Check content for video and audio links to add as enclosures.
*
* Will not add enclosures that have already been added and will
* remove enclosures that are no longer in the post. This is called as
* pingbacks and trackbacks.
*
* @since 1.5.0
*
* @uses $wpdb
*
* @param string $content Post Content
* @param int $post_ID Post ID
*/
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' );
$post_links = array();
$pung = get_enclosed( $post_ID );
$post_links_temp = wp_extract_urls( $content );
foreach ( $pung as $link_test ) {
if ( ! in_array( $link_test, $post_links_temp ) ) { // link no longer in post
$mids = $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 ) . '%') );
foreach ( $mids as $mid )
delete_metadata_by_mid( 'post', $mid );
}
}
foreach ( (array) $post_links_temp as $link_test ) {
if ( !in_array( $link_test, $pung ) ) { // If we haven't pung it already
$test = @parse_url( $link_test );
if ( false === $test )
continue;
if ( isset( $test['query'] ) )
$post_links[] = $link_test;
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, like_escape( $url ) . '%' ) ) ) {
if ( $headers = wp_get_http_headers( $url) ) {
$len = isset( $headers['content-length'] ) ? (int) $headers['content-length'] : 0;
$type = isset( $headers['content-type'] ) ? $headers['content-type'] : '';
$allowed_types = array( 'video', 'audio' );
// Check to see if we can figure out the mime type from
// the extension
$url_parts = @parse_url( $url );
if ( false !== $url_parts ) {
$extension = pathinfo( $url_parts['path'], PATHINFO_EXTENSION );
if ( !empty( $extension ) ) {
foreach ( wp_get_mime_types() as $exts => $mime ) {
if ( preg_match( '!^(' . $exts . ')$!i', $extension ) ) {
$type = $mime;
break;
}
}
}
}
if ( in_array( substr( $type, 0, strpos( $type, "/" ) ), $allowed_types ) ) {
add_post_meta( $post_ID, 'enclosure', "$url\n$len\n$mime\n" );
}
}
}
}
}
/**
* Perform a HTTP HEAD or GET request.
*
* If $file_path is a writable filename, this will do a GET request and write
* the file to that path.
*
* @since 2.5.0
*
* @param string $url URL to fetch.
* @param string|bool $file_path Optional. File path to write request to.
* @param int $red (private) The number of Redirects followed, Upon 5 being hit, returns false.
* @return bool|string False on failure and string of headers if HEAD request.
*/
function wp_get_http( $url, $file_path = false, $red = 1 ) {
@set_time_limit( 60 );
if ( $red > 5 )
return false;
$options = array();
$options['redirection'] = 5;
if ( false == $file_path )
$options['method'] = 'HEAD';
else
$options['method'] = 'GET';
$response = wp_safe_remote_request( $url, $options );
if ( is_wp_error( $response ) )
return false;
$headers = wp_remote_retrieve_headers( $response );
$headers['response'] = wp_remote_retrieve_response_code( $response );
// WP_HTTP no longer follows redirects for HEAD requests.
if ( 'HEAD' == $options['method'] && in_array($headers['response'], array(301, 302)) && isset( $headers['location'] ) ) {
return wp_get_http( $headers['location'], $file_path, ++$red );
}
if ( false == $file_path )
return $headers;
// GET request - write it to the supplied filename
$out_fp = fopen($file_path, 'w');
if ( !$out_fp )
return $headers;
fwrite( $out_fp, wp_remote_retrieve_body( $response ) );
fclose($out_fp);
clearstatcache();
return $headers;
}
/**
* Retrieve HTTP Headers from URL.
*
* @since 1.5.1
*
* @param string $url
* @param bool $deprecated Not Used.
* @return bool|string False on failure, headers on success.
*/
function wp_get_http_headers( $url, $deprecated = false ) {
if ( !empty( $deprecated ) )
_deprecated_argument( __FUNCTION__, '2.7' );
$response = wp_safe_remote_head( $url );
if ( is_wp_error( $response ) )
return false;
return wp_remote_retrieve_headers( $response );
}
/**
* Whether today is a new day.
*
* @since 0.71
* @uses $day Today
* @uses $previousday Previous day
*
* @return int 1 when new day, 0 if not a new day.
*/
function is_new_day() {
global $currentday, $previousday;
if ( $currentday != $previousday )
return 1;
else
return 0;
}
/**
* Build URL query based on an associative and, or indexed array.
*
* This is a convenient function for easily building url queries. It sets the
* separator to '&' and uses _http_build_query() function.
*
* @see _http_build_query() Used to build the query
* @link http://us2.php.net/manual/en/function.http-build-query.php more on what
* http_build_query() does.
*
* @since 2.3.0
*
* @param array $data URL-encode key/value pairs.
* @return string URL encoded string
*/
function build_query( $data ) {
return _http_build_query( $data, null, '&', '', false );
}
// from php.net (modified by Mark Jaquith to behave like the native PHP5 function)
function _http_build_query($data, $prefix=null, $sep=null, $key='', $urlencode=true) {
$ret = array();
foreach ( (array) $data as $k => $v ) {
if ( $urlencode)
$k = urlencode($k);
if ( is_int($k) && $prefix != null )
$k = $prefix.$k;
if ( !empty($key) )
$k = $key . '%5B' . $k . '%5D';
if ( $v === null )
continue;
elseif ( $v === FALSE )
$v = '0';
if ( is_array($v) || is_object($v) )
array_push($ret,_http_build_query($v, '', $sep, $k, $urlencode));
elseif ( $urlencode )
array_push($ret, $k.'='.urlencode($v));
else
array_push($ret, $k.'='.$v);
}
if ( null === $sep )
$sep = ini_get('arg_separator.output');
return implode($sep, $ret);
}
/**
* Retrieve a modified URL query string.
*
* You can rebuild the URL and append a new query variable to the URL query by
* using this function. You can also retrieve the full URL with query data.
*
* Adding a single key & value or an associative array. Setting a key value to
* an empty string removes the key. Omitting oldquery_or_uri uses the $_SERVER
* value. Additional values provided are expected to be encoded appropriately
* with urlencode() or rawurlencode().
*
* @since 1.5.0
*
* @param mixed $param1 Either newkey or an associative_array
* @param mixed $param2 Either newvalue or oldquery or uri
* @param mixed $param3 Optional. Old query or uri
* @return string New URL query string.
*/
function add_query_arg() {
$ret = '';
$args = func_get_args();
if ( is_array( $args[0] ) ) {
if ( count( $args ) < 2 || false === $args[1] )
$uri = $_SERVER['REQUEST_URI'];
else
$uri = $args[1];
} else {
if ( count( $args ) < 3 || false === $args[2] )
$uri = $_SERVER['REQUEST_URI'];
else
$uri = $args[2];
}
if ( $frag = strstr( $uri, '#' ) )
$uri = substr( $uri, 0, -strlen( $frag ) );
else
$frag = '';
if ( 0 === stripos( $uri, 'http://' ) ) {
$protocol = 'http://';
$uri = substr( $uri, 7 );
} elseif ( 0 === stripos( $uri, 'https://' ) ) {
$protocol = 'https://';
$uri = substr( $uri, 8 );
} else {
$protocol = '';
}
if ( strpos( $uri, '?' ) !== false ) {
list( $base, $query ) = explode( '?', $uri, 2 );
$base .= '?';
} elseif ( $protocol || strpos( $uri, '=' ) === false ) {
$base = $uri . '?';
$query = '';
} else {
$base = '';
$query = $uri;
}
wp_parse_str( $query, $qs );
$qs = urlencode_deep( $qs ); // this re-URL-encodes things that were already in the query string
if ( is_array( $args[0] ) ) {
$kayvees = $args[0];
$qs = array_merge( $qs, $kayvees );
} else {
$qs[ $args[0] ] = $args[1];
}
foreach ( $qs as $k => $v ) {
if ( $v === false )
unset( $qs[$k] );
}
$ret = build_query( $qs );
$ret = trim( $ret, '?' );
$ret = preg_replace( '#=(&|$)#', '$1', $ret );
$ret = $protocol . $base . $ret . $frag;
$ret = rtrim( $ret, '?' );
return $ret;
}
/**
* Removes an item or list from the query string.
*
* @since 1.5.0
*
* @param string|array $key Query key or keys to remove.
* @param bool $query When false uses the $_SERVER value.
* @return string New URL query string.
*/
function remove_query_arg( $key, $query=false ) {
if ( is_array( $key ) ) { // removing multiple keys
foreach ( $key as $k )
$query = add_query_arg( $k, false, $query );
return $query;
}
return add_query_arg( $key, false, $query );
}
/**
* Walks the array while sanitizing the contents.
*
* @since 0.71
*
* @param array $array Array to walk while sanitizing contents.
* @return array Sanitized $array.
*/
function add_magic_quotes( $array ) {
foreach ( (array) $array as $k => $v ) {
if ( is_array( $v ) ) {
$array[$k] = add_magic_quotes( $v );
} else {
$array[$k] = addslashes( $v );
}
}
return $array;
}
/**
* HTTP request for URI to retrieve content.
*
* @since 1.5.1
* @uses wp_remote_get()
*
* @param string $uri URI/URL of web page to retrieve.
* @return bool|string HTTP content. False on failure.
*/
function wp_remote_fopen( $uri ) {
$parsed_url = @parse_url( $uri );
if ( !$parsed_url || !is_array( $parsed_url ) )
return false;
$options = array();
$options['timeout'] = 10;
$response = wp_safe_remote_get( $uri, $options );
if ( is_wp_error( $response ) )
return false;
return wp_remote_retrieve_body( $response );
}
/**
* Set up the WordPress query.
*
* @since 2.0.0
*
* @param string $query_vars Default WP_Query arguments.
*/
function wp( $query_vars = '' ) {
global $wp, $wp_query, $wp_the_query;
$wp->main( $query_vars );
if ( !isset($wp_the_query) )
$wp_the_query = $wp_query;
}
/**
* Retrieve the description for the HTTP status.
*
* @since 2.3.0
*
* @param int $code HTTP status code.
* @return string Empty string if not found, or description if found.
*/
function get_status_header_desc( $code ) {
global $wp_header_to_desc;
$code = absint( $code );
if ( !isset( $wp_header_to_desc ) ) {
$wp_header_to_desc = array(
100 => 'Continue',
101 => 'Switching Protocols',
102 => 'Processing',
200 => 'OK',
201 => 'Created',
202 => 'Accepted',
203 => 'Non-Authoritative Information',
204 => 'No Content',
205 => 'Reset Content',
206 => 'Partial Content',
207 => 'Multi-Status',
226 => 'IM Used',
300 => 'Multiple Choices',
301 => 'Moved Permanently',
302 => 'Found',
303 => 'See Other',
304 => 'Not Modified',
305 => 'Use Proxy',
306 => 'Reserved',
307 => 'Temporary Redirect',
400 => 'Bad Request',
401 => 'Unauthorized',
402 => 'Payment Required',
403 => 'Forbidden',
404 => 'Not Found',
405 => 'Method Not Allowed',
406 => 'Not Acceptable',
407 => 'Proxy Authentication Required',
408 => 'Request Timeout',
409 => 'Conflict',
410 => 'Gone',
411 => 'Length Required',
412 => 'Precondition Failed',
413 => 'Request Entity Too Large',
414 => 'Request-URI Too Long',
415 => 'Unsupported Media Type',
416 => 'Requested Range Not Satisfiable',
417 => 'Expectation Failed',
418 => 'I\'m a teapot',
422 => 'Unprocessable Entity',
423 => 'Locked',
424 => 'Failed Dependency',
426 => 'Upgrade Required',
428 => 'Precondition Required',
429 => 'Too Many Requests',
431 => 'Request Header Fields Too Large',
500 => 'Internal Server Error',
501 => 'Not Implemented',
502 => 'Bad Gateway',
503 => 'Service Unavailable',
504 => 'Gateway Timeout',
505 => 'HTTP Version Not Supported',
506 => 'Variant Also Negotiates',
507 => 'Insufficient Storage',
510 => 'Not Extended',
511 => 'Network Authentication Required',
);
}
if ( isset( $wp_header_to_desc[$code] ) )
return $wp_header_to_desc[$code];
else
return '';
}
/**
* Set HTTP status header.
*
* @since 2.0.0
* @see get_status_header_desc()
*
* @param int $code HTTP status code.
*/
function status_header( $code ) {
$description = get_status_header_desc( $code );
if ( empty( $description ) )
return;
$protocol = $_SERVER['SERVER_PROTOCOL'];
if ( 'HTTP/1.1' != $protocol && 'HTTP/1.0' != $protocol )
$protocol = 'HTTP/1.0';
$status_header = "$protocol $code $description";
if ( function_exists( 'apply_filters' ) )
/**
* Filter an HTTP status header.
*
* @since 2.2.0
*
* @param string $status_header HTTP status header.
* @param int $code HTTP status code.
* @param string $description Description for the status code.
* @param string $protocol Server protocol.
*/
$status_header = apply_filters( 'status_header', $status_header, $code, $description, $protocol );
@header( $status_header, true, $code );
}
/**
* Gets the header information to prevent caching.
*
* The several different headers cover the different ways cache prevention is handled
* by different browsers
*
* @since 2.8.0
*
* @return array The associative array of header names and field values.
*/
function wp_get_nocache_headers() {
$headers = array(
'Expires' => 'Wed, 11 Jan 1984 05:00:00 GMT',
'Cache-Control' => 'no-cache, must-revalidate, max-age=0',
'Pragma' => 'no-cache',
);
if ( function_exists('apply_filters') ) {
/**
* Filter the cache-controlling headers.
*
* @since 2.8.0
*
* @param array $headers {
* Header names and field values.
*
* @type string $Expires Expires header.
* @type string $Cache-Control Cache-Control header.
* @type string $Pragma Pragma header.
* }
*/
$headers = (array) apply_filters( 'nocache_headers', $headers );
}
$headers['Last-Modified'] = false;
return $headers;
}
/**
* Sets the headers to prevent caching for the different browsers.
*
* Different browsers support different nocache headers, so several headers must
* be sent so that all of them get the point that no caching should occur.
*
* @since 2.0.0
* @see wp_get_nocache_headers()
*/
function nocache_headers() {
$headers = wp_get_nocache_headers();
unset( $headers['Last-Modified'] );
// In PHP 5.3+, make sure we are not sending a Last-Modified header.
if ( function_exists( 'header_remove' ) ) {
@header_remove( 'Last-Modified' );
} else {
// In PHP 5.2, send an empty Last-Modified header, but only as a
// last resort to override a header already sent. #WP23021
foreach ( headers_list() as $header ) {
if ( 0 === stripos( $header, 'Last-Modified' ) ) {
$headers['Last-Modified'] = '';
break;
}
}
}
foreach( $headers as $name => $field_value )
@header("{$name}: {$field_value}");
}
/**
* Set the headers for caching for 10 days with JavaScript content type.
*
* @since 2.1.0
*/
function cache_javascript_headers() {
$expiresOffset = 10 * DAY_IN_SECONDS;
header( "Content-Type: text/javascript; charset=" . get_bloginfo( 'charset' ) );
header( "Vary: Accept-Encoding" ); // Handle proxies
header( "Expires: " . gmdate( "D, d M Y H:i:s", time() + $expiresOffset ) . " GMT" );
}
/**
* Retrieve the number of database queries during the WordPress execution.
*
* @since 2.0.0
*
* @return int Number of database queries
*/
function get_num_queries() {
global $wpdb;
return $wpdb->num_queries;
}
/**
* Whether input is yes or no. Must be 'y' to be true.
*
* @since 1.0.0
*
* @param string $yn Character string containing either 'y' or 'n'
* @return bool True if yes, false on anything else
*/
function bool_from_yn( $yn ) {
return ( strtolower( $yn ) == 'y' );
}
/**
* Loads the feed template from the use of an action hook.
*
* If the feed action does not have a hook, then the function will die with a
* message telling the visitor that the feed is not valid.
*
* It is better to only have one hook for each feed.
*
* @since 2.1.0
*
* @uses $wp_query Used to tell if the use a comment feed.
*/
function do_feed() {
global $wp_query;
$feed = get_query_var( 'feed' );
// Remove the pad, if present.
$feed = preg_replace( '/^_+/', '', $feed );
if ( $feed == '' || $feed == 'feed' )
$feed = get_default_feed();
$hook = 'do_feed_' . $feed;
if ( ! has_action( $hook ) )
wp_die( __( 'ERROR: This is not a valid feed template.' ), '', array( 'response' => 404 ) );
/**
* Fires once the given feed is loaded.
*
* The dynamic hook name, $hook, refers to the feed name.
*
* @since 2.1.0
*
* @param bool $is_comment_feed Whether the feed is a comment feed.
*/
do_action( $hook, $wp_query->is_comment_feed );
}
/**
* Load the RDF RSS 0.91 Feed template.
*
* @since 2.1.0
*/
function do_feed_rdf() {
load_template( ABSPATH . WPINC . '/feed-rdf.php' );
}
/**
* Load the RSS 1.0 Feed Template.
*
* @since 2.1.0
*/
function do_feed_rss() {
load_template( ABSPATH . WPINC . '/feed-rss.php' );
}
/**
* Load either the RSS2 comment feed or the RSS2 posts feed.
*
* @since 2.1.0
*
* @param bool $for_comments True for the comment feed, false for normal feed.
*/
function do_feed_rss2( $for_comments ) {
if ( $for_comments )
load_template( ABSPATH . WPINC . '/feed-rss2-comments.php' );
else
load_template( ABSPATH . WPINC . '/feed-rss2.php' );
}
/**
* Load either Atom comment feed or Atom posts feed.
*
* @since 2.1.0
*
* @param bool $for_comments True for the comment feed, false for normal feed.
*/
function do_feed_atom( $for_comments ) {
if ($for_comments)
load_template( ABSPATH . WPINC . '/feed-atom-comments.php');
else
load_template( ABSPATH . WPINC . '/feed-atom.php' );
}
/**
* Display the robots.txt file content.
*
* The echo content should be with usage of the permalinks or for creating the
* robots.txt file.
*
* @since 2.1.0
*/
function do_robots() {
header( 'Content-Type: text/plain; charset=utf-8' );
/**
* Fires when displaying the robots.txt file.
*
* @since 2.1.0
*/
do_action( 'do_robotstxt' );
$output = "User-agent: *\n";
$public = get_option( 'blog_public' );
if ( '0' == $public ) {
$output .= "Disallow: /\n";
} else {
$site_url = parse_url( site_url() );
$path = ( !empty( $site_url['path'] ) ) ? $site_url['path'] : '';
$output .= "Disallow: $path/wp-admin/\n";
$output .= "Disallow: $path/wp-includes/\n";
}
/**
* Filter the robots.txt output.
*
* @since 3.0.0
*
* @param string $output Robots.txt output.
* @param bool $public Whether the site is considered "public".
*/
echo apply_filters( 'robots_txt', $output, $public );
}
/**
* Test whether blog is already installed.
*
* The cache will be checked first. If you have a cache plugin, which saves the
* cache values, then this will work. If you use the default WordPress cache,
* and the database goes away, then you might have problems.
*
* Checks for the option siteurl for whether WordPress is installed.
*
* @since 2.1.0
* @uses $wpdb
*
* @return bool Whether blog is already installed.
*/
function is_blog_installed() {
global $wpdb;
// Check cache first. If options table goes away and we have true cached, oh well.
if ( wp_cache_get( 'is_blog_installed' ) )
return true;
$suppress = $wpdb->suppress_errors();
if ( ! defined( 'WP_INSTALLING' ) ) {
$alloptions = wp_load_alloptions();
}
// If siteurl is not set to autoload, check it specifically
if ( !isset( $alloptions['siteurl'] ) )
$installed = $wpdb->get_var( "SELECT option_value FROM $wpdb->options WHERE option_name = 'siteurl'" );
else
$installed = $alloptions['siteurl'];
$wpdb->suppress_errors( $suppress );
$installed = !empty( $installed );
wp_cache_set( 'is_blog_installed', $installed );
if ( $installed )
return true;
// If visiting repair.php, return true and let it take over.
if ( defined( 'WP_REPAIRING' ) )
return true;
$suppress = $wpdb->suppress_errors();
// Loop over the WP tables. If none exist, then scratch install is allowed.
// If one or more exist, suggest table repair since we got here because the options
// table could not be accessed.
$wp_tables = $wpdb->tables();
foreach ( $wp_tables as $table ) {
// The existence of custom user tables shouldn't suggest an insane state or prevent a clean install.
if ( defined( 'CUSTOM_USER_TABLE' ) && CUSTOM_USER_TABLE == $table )
continue;
if ( defined( 'CUSTOM_USER_META_TABLE' ) && CUSTOM_USER_META_TABLE == $table )
continue;
if ( ! $wpdb->get_results( "DESCRIBE $table;" ) )
continue;
// One or more tables exist. We are insane.
wp_load_translations_early();
// Die with a DB error.
$wpdb->error = sprintf( __( 'One or more database tables are unavailable. The database may need to be <a href="%s">repaired</a>.' ), 'maint/repair.php?referrer=is_blog_installed' );
dead_db();
}
$wpdb->suppress_errors( $suppress );
wp_cache_set( 'is_blog_installed', false );
return false;
}
/**
* Retrieve URL with nonce added to URL query.
*
* @since 2.0.4
*
* @param string $actionurl URL to add nonce action.
* @param string $action Optional. Nonce action name.
* @param string $name Optional. Nonce name.
* @return string Escaped URL with nonce action added.
*/
function wp_nonce_url( $actionurl, $action = -1, $name = '_wpnonce' ) {
$actionurl = str_replace( '&', '&', $actionurl );
return esc_html( add_query_arg( $name, wp_create_nonce( $action ), $actionurl ) );
}
/**
* Retrieve or display nonce hidden field for forms.
*
* The nonce field is used to validate that the contents of the form came from
* the location on the current site and not somewhere else. The nonce does not
* offer absolute protection, but should protect against most cases. It is very
* important to use nonce field in forms.
*
* The $action and $name are optional, but if you want to have better security,
* it is strongly suggested to set those two parameters. It is easier to just
* call the function without any parameters, because validation of the nonce
* doesn't require any parameters, but since crackers know what the default is
* it won't be difficult for them to find a way around your nonce and cause
* damage.
*
* The input name will be whatever $name value you gave. The input value will be
* the nonce creation value.
*
* @since 2.0.4
*
* @param string $action Optional. Action name.
* @param string $name Optional. Nonce name.
* @param bool $referer Optional, default true. Whether to set the referer field for validation.
* @param bool $echo Optional, default true. Whether to display or return hidden form field.
* @return string Nonce field.
*/
function wp_nonce_field( $action = -1, $name = "_wpnonce", $referer = true , $echo = true ) {
$name = esc_attr( $name );
$nonce_field = '<input type="hidden" id="' . $name . '" name="' . $name . '" value="' . wp_create_nonce( $action ) . '" />';
if ( $referer )
$nonce_field .= wp_referer_field( false );
if ( $echo )
echo $nonce_field;
return $nonce_field;
}
/**
* Retrieve or display referer hidden field for forms.
*
* The referer link is the current Request URI from the server super global. The
* input name is '_wp_http_referer', in case you wanted to check manually.
*
* @since 2.0.4
*
* @param bool $echo Whether to echo or return the referer field.
* @return string Referer field.
*/
function wp_referer_field( $echo = true ) {
$referer_field = '<input type="hidden" name="_wp_http_referer" value="'. esc_attr( wp_unslash( $_SERVER['REQUEST_URI'] ) ) . '" />';
if ( $echo )
echo $referer_field;
return $referer_field;
}
/**
* Retrieve or display original referer hidden field for forms.
*
* The input name is '_wp_original_http_referer' and will be either the same
* value of {@link wp_referer_field()}, if that was posted already or it will
* be the current page, if it doesn't exist.
*
* @since 2.0.4
*
* @param bool $echo Whether to echo the original http referer
* @param string $jump_back_to Optional, default is 'current'. Can be 'previous' or page you want to jump back to.
* @return string Original referer field.
*/
function wp_original_referer_field( $echo = true, $jump_back_to = 'current' ) {
if ( ! $ref = wp_get_original_referer() ) {
$ref = 'previous' == $jump_back_to ? wp_get_referer() : wp_unslash( $_SERVER['REQUEST_URI'] );
}
$orig_referer_field = '<input type="hidden" name="_wp_original_http_referer" value="' . esc_attr( $ref ) . '" />';
if ( $echo )
echo $orig_referer_field;
return $orig_referer_field;
}
/**
* Retrieve referer from '_wp_http_referer' or HTTP referer. If it's the same
* as the current request URL, will return false.
*
* @since 2.0.4
*
* @return string|bool False on failure. Referer URL on success.
*/
function wp_get_referer() {
if ( ! function_exists( 'wp_validate_redirect' ) )
return false;
$ref = false;
if ( ! empty( $_REQUEST['_wp_http_referer'] ) )
$ref = wp_unslash( $_REQUEST['_wp_http_referer'] );
else if ( ! empty( $_SERVER['HTTP_REFERER'] ) )
$ref = wp_unslash( $_SERVER['HTTP_REFERER'] );
if ( $ref && $ref !== wp_unslash( $_SERVER['REQUEST_URI'] ) )
return wp_validate_redirect( $ref, false );
return false;
}
/**
* Retrieve original referer that was posted, if it exists.
*
* @since 2.0.4
*
* @return string|bool False if no original referer or original referer if set.
*/
function wp_get_original_referer() {
if ( ! empty( $_REQUEST['_wp_original_http_referer'] ) && function_exists( 'wp_validate_redirect' ) )
return wp_validate_redirect( wp_unslash( $_REQUEST['_wp_original_http_referer'] ), false );
return false;
}
/**
* Recursive directory creation based on full path.
*
* Will attempt to set permissions on folders.
*
* @since 2.0.1
*
* @param string $target Full path to attempt to create.
* @return bool Whether the path was created. True if path already exists.
*/
function wp_mkdir_p( $target ) {
$wrapper = null;
// strip the protocol
if( wp_is_stream( $target ) ) {
list( $wrapper, $target ) = explode( '://', $target, 2 );
}
// from php.net/mkdir user contributed notes
$target = str_replace( '//', '/', $target );
// put the wrapper back on the target
if( $wrapper !== null ) {
$target = $wrapper . '://' . $target;
}
// safe mode fails with a trailing slash under certain PHP versions.
$target = rtrim($target, '/'); // Use rtrim() instead of untrailingslashit to avoid formatting.php dependency.
if ( empty($target) )
$target = '/';
if ( file_exists( $target ) )
return @is_dir( $target );
// We need to find the permissions of the parent folder that exists and inherit that.
$target_parent = dirname( $target );
while ( '.' != $target_parent && ! is_dir( $target_parent ) ) {
$target_parent = dirname( $target_parent );
}
// Get the permission bits.
$dir_perms = false;
if ( $stat = @stat( $target_parent ) ) {
$dir_perms = $stat['mode'] & 0007777;
} else {
$dir_perms = 0777;
}
if ( @mkdir( $target, $dir_perms, true ) ) {
// If a umask is set that modifies $dir_perms, we'll have to re-set the $dir_perms correctly with chmod()
if ( $dir_perms != ( $dir_perms & ~umask() ) ) {
$folder_parts = explode( '/', substr( $target, strlen( $target_parent ) + 1 ) );
for ( $i = 1; $i <= count( $folder_parts ); $i++ ) {
@chmod( $target_parent . '/' . implode( '/', array_slice( $folder_parts, 0, $i ) ), $dir_perms );
}
}
return true;
}
return false;
}
/**
* Test if a give filesystem path is absolute ('/foo/bar', 'c:\windows').
*
* @since 2.5.0
*
* @param string $path File path
* @return bool True if path is absolute, false is not absolute.
*/
function path_is_absolute( $path ) {
// this is definitive if true but fails if $path does not exist or contains a symbolic link
if ( realpath($path) == $path )
return true;
if ( strlen($path) == 0 || $path[0] == '.' )
return false;
// windows allows absolute paths like this
if ( preg_match('#^[a-zA-Z]:\\\\#', $path) )
return true;
// a path starting with / or \ is absolute; anything else is relative
return ( $path[0] == '/' || $path[0] == '\\' );
}
/**
* Join two filesystem paths together (e.g. 'give me $path relative to $base').
*
* If the $path is absolute, then it the full path is returned.
*
* @since 2.5.0
*
* @param string $base
* @param string $path
* @return string The path with the base or absolute path.
*/
function path_join( $base, $path ) {
if ( path_is_absolute($path) )
return $path;
return rtrim($base, '/') . '/' . ltrim($path, '/');
}
/**
* Normalize a filesystem path.
*
* Replaces backslashes with forward slashes for Windows systems,
* and ensures no duplicate slashes exist.
*
* @since 3.9.0
*
* @param string $path Path to normalize.
* @return string Normalized path.
*/
function wp_normalize_path( $path ) {
$path = str_replace( '\\', '/', $path );
$path = preg_replace( '|/+|','/', $path );
return $path;
}
/**
* Determines a writable directory for temporary files.
* Function's preference is the return value of <code>sys_get_temp_dir()</code>,
* followed by your PHP temporary upload directory, followed by WP_CONTENT_DIR,
* before finally defaulting to /tmp/
*
* In the event that this function does not find a writable location,
* It may be overridden by the <code>WP_TEMP_DIR</code> constant in
* your <code>wp-config.php</code> file.
*
* @since 2.5.0
*
* @return string Writable temporary directory
*/
function get_temp_dir() {
static $temp;
if ( defined('WP_TEMP_DIR') )
return trailingslashit(WP_TEMP_DIR);
if ( $temp )
return trailingslashit( $temp );
if ( function_exists('sys_get_temp_dir') ) {
$temp = sys_get_temp_dir();
if ( @is_dir( $temp ) && wp_is_writable( $temp ) )
return trailingslashit( $temp );
}
$temp = ini_get('upload_tmp_dir');
if ( @is_dir( $temp ) && wp_is_writable( $temp ) )
return trailingslashit( $temp );
$temp = WP_CONTENT_DIR . '/';
if ( is_dir( $temp ) && wp_is_writable( $temp ) )
return $temp;
$temp = '/tmp/';
return $temp;
}
/**
* Determine if a directory is writable.
*
* This function is used to work around certain ACL issues
* in PHP primarily affecting Windows Servers.
*
* @see win_is_writable()
*
* @since 3.6.0
*
* @param string $path
* @return bool
*/
function wp_is_writable( $path ) {
if ( 'WIN' === strtoupper( substr( PHP_OS, 0, 3 ) ) )
return win_is_writable( $path );
else
return @is_writable( $path );
}
/**
* Workaround for Windows bug in is_writable() function
*
* PHP has issues with Windows ACL's for determine if a
* directory is writable or not, this works around them by
* checking the ability to open files rather than relying
* upon PHP to interprate the OS ACL.
*
* @link http://bugs.php.net/bug.php?id=27609
* @link http://bugs.php.net/bug.php?id=30931
*
* @since 2.8.0
*
* @param string $path
* @return bool
*/
function win_is_writable( $path ) {
if ( $path[strlen( $path ) - 1] == '/' ) // if it looks like a directory, check a random file within the directory
return win_is_writable( $path . uniqid( mt_rand() ) . '.tmp');
else if ( is_dir( $path ) ) // If it's a directory (and not a file) check a random file within the directory
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;
}
/**
* Get an array containing the current upload directory's path and url.
*
* Checks the 'upload_path' option, which should be from the web root folder,
* and if it isn't empty it will be used. If it is empty, then the path will be
* 'WP_CONTENT_DIR/uploads'. If the 'UPLOADS' constant is defined, then it will
* override the 'upload_path' option and 'WP_CONTENT_DIR/uploads' path.
*
* The upload URL path is set either by the 'upload_url_path' option or by using
* the 'WP_CONTENT_URL' constant and appending '/uploads' to the path.
*
* If the 'uploads_use_yearmonth_folders' is set to true (checkbox if checked in
* the administration settings panel), then the time will be used. The format
* will be year first and then month.
*
* If the path couldn't be created, then an error will be returned with the key
* 'error' containing the error message. The error suggests that the parent
* directory is not writable by the server.
*
* On success, the returned array will have many indices:
* 'path' - base directory and sub directory or full path to upload directory.
* 'url' - base url and sub directory or absolute URL to upload directory.
* 'subdir' - sub directory if uploads use year/month folders option is on.
* 'basedir' - path without subdir.
* 'baseurl' - URL path without subdir.
* 'error' - set to false.
*
* @since 2.0.0
*
* @param string $time Optional. Time formatted in 'yyyy/mm'.
* @return array See above for description.
*/
function wp_upload_dir( $time = null ) {
$siteurl = get_option( 'siteurl' );
$upload_path = trim( get_option( 'upload_path' ) );
if ( empty( $upload_path ) || 'wp-content/uploads' == $upload_path ) {
$dir = WP_CONTENT_DIR . '/uploads';
} elseif ( 0 !== strpos( $upload_path, ABSPATH ) ) {
// $dir is absolute, $upload_path is (maybe) relative to ABSPATH
$dir = path_join( ABSPATH, $upload_path );
} else {
$dir = $upload_path;
}
if ( !$url = get_option( 'upload_url_path' ) ) {
if ( empty($upload_path) || ( 'wp-content/uploads' == $upload_path ) || ( $upload_path == $dir ) )
$url = WP_CONTENT_URL . '/uploads';
else
$url = trailingslashit( $siteurl ) . $upload_path;
}
// Obey the value of UPLOADS. This happens as long as ms-files rewriting is disabled.
// We also sometimes obey UPLOADS when rewriting is enabled -- see the next block.
if ( defined( 'UPLOADS' ) && ! ( is_multisite() && get_site_option( 'ms_files_rewriting' ) ) ) {
$dir = ABSPATH . UPLOADS;
$url = trailingslashit( $siteurl ) . UPLOADS;
}
// If multisite (and if not the main site in a post-MU network)
if ( is_multisite() && ! ( is_main_network() && is_main_site() && defined( 'MULTISITE' ) ) ) {
if ( ! get_site_option( 'ms_files_rewriting' ) ) {
// If ms-files rewriting is disabled (networks created post-3.5), it is fairly straightforward:
// Append sites/%d if we're not on the main site (for post-MU networks). (The extra directory
// prevents a four-digit ID from conflicting with a year-based directory for the main site.
// But if a MU-era network has disabled ms-files rewriting manually, they don't need the extra
// directory, as they never had wp-content/uploads for the main site.)
if ( defined( 'MULTISITE' ) )
$ms_dir = '/sites/' . get_current_blog_id();
else
$ms_dir = '/' . get_current_blog_id();
$dir .= $ms_dir;
$url .= $ms_dir;
} elseif ( defined( 'UPLOADS' ) && ! ms_is_switched() ) {
// Handle the old-form ms-files.php rewriting if the network still has that enabled.
// When ms-files rewriting is enabled, then we only listen to UPLOADS when:
// 1) we are not on the main site in a post-MU network,
// as wp-content/uploads is used there, and
// 2) we are not switched, as ms_upload_constants() hardcodes
// these constants to reflect the original blog ID.
//
// Rather than UPLOADS, we actually use BLOGUPLOADDIR if it is set, as it is absolute.
// (And it will be set, see ms_upload_constants().) Otherwise, UPLOADS can be used, as
// as it is relative to ABSPATH. For the final piece: when UPLOADS is used with ms-files
// rewriting in multisite, the resulting URL is /files. (#WP22702 for background.)
if ( defined( 'BLOGUPLOADDIR' ) )
$dir = untrailingslashit( BLOGUPLOADDIR );
else
$dir = ABSPATH . UPLOADS;
$url = trailingslashit( $siteurl ) . 'files';
}
}
$basedir = $dir;
$baseurl = $url;
$subdir = '';
if ( get_option( 'uploads_use_yearmonth_folders' ) ) {
// Generate the yearly and monthly dirs
if ( !$time )
$time = current_time( 'mysql' );
$y = substr( $time, 0, 4 );
$m = substr( $time, 5, 2 );
$subdir = "/$y/$m";
}
$dir .= $subdir;
$url .= $subdir;
/**
* Filter the uploads directory data.
*
* @since 2.0.0
*
* @param array $uploads Array of upload directory data with keys of 'path',
* 'url', 'subdir, 'basedir', and 'error'.
*/
$uploads = apply_filters( 'upload_dir',
array(
'path' => $dir,
'url' => $url,
'subdir' => $subdir,
'basedir' => $basedir,
'baseurl' => $baseurl,
'error' => false,
) );
// Make sure we have an uploads dir
if ( ! wp_mkdir_p( $uploads['path'] ) ) {
if ( 0 === strpos( $uploads['basedir'], ABSPATH ) )
$error_path = str_replace( ABSPATH, '', $uploads['basedir'] ) . $uploads['subdir'];
else
$error_path = basename( $uploads['basedir'] ) . $uploads['subdir'];
$message = sprintf( __( 'Unable to create directory %s. Is its parent directory writable by the server?' ), $error_path );
$uploads['error'] = $message;
}
return $uploads;
}
/**
* Get a filename that is sanitized and unique for the given directory.
*
* If the filename is not unique, then a number will be added to the filename
* before the extension, and will continue adding numbers until the filename is
* unique.
*
* 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.0
*
* @param string $dir
* @param string $filename
* @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 ) {
// sanitize the file name before we begin processing
$filename = sanitize_file_name($filename);
// separate the filename into a name and extension
$info = pathinfo($filename);
$ext = !empty($info['extension']) ? '.' . $info['extension'] : '';
$name = basename($filename, $ext);
// edge case: if file is named '.ext', treat as an empty name
if ( $name === $ext )
$name = '';
// 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 = call_user_func( $unique_filename_callback, $dir, $name, $ext );
} else {
$number = '';
// change '.ext' to lower case
if ( $ext && strtolower($ext) != $ext ) {
$ext2 = strtolower($ext);
$filename2 = preg_replace( '|' . preg_quote($ext) . '$|', $ext2, $filename );
// check for both lower and upper case extension or image sub-sizes may be overwritten
while ( file_exists($dir . "/$filename") || file_exists($dir . "/$filename2") ) {
$new_number = $number + 1;
$filename = str_replace( "$number$ext", "$new_number$ext", $filename );
$filename2 = str_replace( "$number$ext2", "$new_number$ext2", $filename2 );
$number = $new_number;
}
return $filename2;
}
while ( file_exists( $dir . "/$filename" ) ) {
if ( '' == "$number$ext" )
$filename = $filename . ++$number . $ext;
else
$filename = str_replace( "$number$ext", ++$number . $ext, $filename );
}
}
return $filename;
}
/**
* Create a file in the upload folder with given content.
*
* If there is an error, then the key 'error' will exist with the error message.
* If success, then the key 'file' will have the unique file path, the 'url' key
* will have the link to the new file. and the 'error' key will be set to false.
*
* This function will not move an uploaded file to the upload folder. It will
* create a new file with the content in $bits parameter. If you move the upload
* file, read the content of the uploaded file, and then you can give the
* filename and content to this function, which will add it to the upload
* folder.
*
* The permissions will be set on the new file automatically by this function.
*
* @since 2.0.0
*
* @param string $name
* @param null $deprecated Never used. Set to null.
* @param mixed $bits File content
* @param string $time Optional. Time formatted in 'yyyy/mm'.
* @return array
*/
function wp_upload_bits( $name, $deprecated, $bits, $time = null ) {
if ( !empty( $deprecated ) )
_deprecated_argument( __FUNCTION__, '2.0' );
if ( empty( $name ) )
return array( 'error' => __( 'Empty filename' ) );
$wp_filetype = wp_check_filetype( $name );
if ( ! $wp_filetype['ext'] && ! current_user_can( 'unfiltered_upload' ) )
return array( 'error' => __( 'Invalid file type' ) );
$upload = wp_upload_dir( $time );
if ( $upload['error'] !== false )
return $upload;
/**
* Filter whether to treat the upload bits as an error.
*
* Passing a non-array to the filter will effectively short-circuit preparing
* the upload bits, returning that value instead.
*
* @since 3.0.0
*
* @param mixed $upload_bits_error An array of upload bits data, or a non-array error to return.
*/
$upload_bits_error = apply_filters( 'wp_upload_bits', array( 'name' => $name, 'bits' => $bits, 'time' => $time ) );
if ( !is_array( $upload_bits_error ) ) {
$upload[ 'error' ] = $upload_bits_error;
return $upload;
}
$filename = wp_unique_filename( $upload['path'], $name );
$new_file = $upload['path'] . "/$filename";
if ( ! wp_mkdir_p( dirname( $new_file ) ) ) {
if ( 0 === strpos( $upload['basedir'], ABSPATH ) )
$error_path = str_replace( ABSPATH, '', $upload['basedir'] ) . $upload['subdir'];
else
$error_path = basename( $upload['basedir'] ) . $upload['subdir'];
$message = sprintf( __( 'Unable to create directory %s. Is its parent directory writable by the server?' ), $error_path );
return array( 'error' => $message );
}
$ifp = @ fopen( $new_file, 'wb' );
if ( ! $ifp )
return array( 'error' => sprintf( __( 'Could not write file %s' ), $new_file ) );
@fwrite( $ifp, $bits );
fclose( $ifp );
clearstatcache();
// Set correct file permissions
$stat = @ stat( dirname( $new_file ) );
$perms = $stat['mode'] & 0007777;
$perms = $perms & 0000666;
@ chmod( $new_file, $perms );
clearstatcache();
// Compute the URL
$url = $upload['url'] . "/$filename";
return array( 'file' => $new_file, 'url' => $url, 'error' => false );
}
/**
* Retrieve the file type based on the extension name.
*
* @since 2.5.0
*
* @param string $ext The extension to search.
* @return string|null The file type, example: audio, video, document, spreadsheet, etc.
* Null if not found.
*/
function wp_ext2type( $ext ) {
$ext = strtolower( $ext );
/**
* Filter file type based on the extension name.
*
* @since 2.5.0
*
* @see wp_ext2type()
*
* @param array $ext2type Multi-dimensional array with extensions for a default set
* of file types.
*/
$ext2type = apply_filters( 'ext2type', array(
'image' => array( 'jpg', 'jpeg', 'jpe', 'gif', 'png', 'bmp', 'tif', 'tiff', 'ico' ),
'audio' => array( 'aac', 'ac3', 'aif', 'aiff', 'm3a', 'm4a', 'm4b', 'mka', 'mp1', 'mp2', 'mp3', 'ogg', 'oga', 'ram', 'wav', 'wma' ),
'video' => array( 'asf', 'avi', 'divx', 'dv', 'flv', 'm4v', 'mkv', 'mov', 'mp4', 'mpeg', 'mpg', 'mpv', 'ogm', 'ogv', 'qt', 'rm', 'vob', 'wmv' ),
'document' => array( 'doc', 'docx', 'docm', 'dotm', 'odt', 'pages', 'pdf', 'rtf', 'wp', 'wpd' ),
'spreadsheet' => array( 'numbers', 'ods', 'xls', 'xlsx', 'xlsm', 'xlsb' ),
'interactive' => array( 'swf', 'key', 'ppt', 'pptx', 'pptm', 'pps', 'ppsx', 'ppsm', 'sldx', 'sldm', 'odp' ),
'text' => array( 'asc', 'csv', 'tsv', 'txt' ),
'archive' => array( 'bz2', 'cab', 'dmg', 'gz', 'rar', 'sea', 'sit', 'sqx', 'tar', 'tgz', 'zip', '7z' ),
'code' => array( 'css', 'htm', 'html', 'php', 'js' ),
) );
foreach ( $ext2type as $type => $exts )
if ( in_array( $ext, $exts ) )
return $type;
return null;
}
/**
* Retrieve the file type from the file name.
*
* You can optionally define the mime array, if needed.
*
* @since 2.0.4
*
* @param string $filename File name or path.
* @param array $mimes Optional. Key is the file extension with value as the mime type.
* @return array Values with extension first and mime type.
*/
function wp_check_filetype( $filename, $mimes = null ) {
if ( empty($mimes) )
$mimes = get_allowed_mime_types();
$type = false;
$ext = false;
foreach ( $mimes as $ext_preg => $mime_match ) {
$ext_preg = '!\.(' . $ext_preg . ')$!i';
if ( preg_match( $ext_preg, $filename, $ext_matches ) ) {
$type = $mime_match;
$ext = $ext_matches[1];
break;
}
}
return compact( 'ext', 'type' );
}
/**
* Attempt to determine the real file type of a file.
* If unable to, the file name extension will be used to determine type.
*
* If it's determined that the extension does not match the file's real type,
* then the "proper_filename" value will be set with a proper filename and extension.
*
* Currently this function only supports validating images known to getimagesize().
*
* @since 3.0.0
*
* @param string $file Full path to the file.
* @param string $filename The name of the file (may differ from $file due to $file being in a tmp directory)
* @param array $mimes Optional. Key is the file extension with value as the mime type.
* @return array Values for the extension, MIME, and either a corrected filename or false if original $filename is valid
*/
function wp_check_filetype_and_ext( $file, $filename, $mimes = null ) {
$proper_filename = false;
// Do basic extension validation and MIME mapping
$wp_filetype = wp_check_filetype( $filename, $mimes );
extract( $wp_filetype );
// We can't do any further validation without a file to work with
if ( ! file_exists( $file ) )
return compact( 'ext', 'type', 'proper_filename' );
// We're able to validate images using GD
if ( $type && 0 === strpos( $type, 'image/' ) && function_exists('getimagesize') ) {
// Attempt to figure out what type of image it actually is
$imgstats = @getimagesize( $file );
// If getimagesize() knows what kind of image it really is and if the real MIME doesn't match the claimed MIME
if ( !empty($imgstats['mime']) && $imgstats['mime'] != $type ) {
/**
* Filter the list mapping image mime types to their respective extensions.
*
* @since 3.0.0
*
* @param array $mime_to_ext Array of image mime types and their matching extensions.
*/
$mime_to_ext = apply_filters( 'getimagesize_mimes_to_exts', array(
'image/jpeg' => 'jpg',
'image/png' => 'png',
'image/gif' => 'gif',
'image/bmp' => 'bmp',
'image/tiff' => 'tif',
) );
// Replace whatever is after the last period in the filename with the correct extension
if ( ! empty( $mime_to_ext[ $imgstats['mime'] ] ) ) {
$filename_parts = explode( '.', $filename );
array_pop( $filename_parts );
$filename_parts[] = $mime_to_ext[ $imgstats['mime'] ];
$new_filename = implode( '.', $filename_parts );
if ( $new_filename != $filename )
$proper_filename = $new_filename; // Mark that it changed
// Redefine the extension / MIME
$wp_filetype = wp_check_filetype( $new_filename, $mimes );
extract( $wp_filetype );
}
}
}
/**
* Filter the "real" file type of the given file.
*
* @since 3.0.0
*
* @param array $wp_check_filetype_and_ext File data array containing 'ext', 'type', and
* 'proper_filename' keys.
* @param string $file Full path to the file.
* @param string $filename The name of the file (may differ from $file due to
* $file being in a tmp directory).
* @param array $mimes Key is the file extension with value as the mime type.
*/
return apply_filters( 'wp_check_filetype_and_ext', compact( 'ext', 'type', 'proper_filename' ), $file, $filename, $mimes );
}
/**
* Retrieve list of mime types and file extensions.
*
* @since 3.5.0
*
* @return array Array of mime types keyed by the file extension regex corresponding to those types.
*/
function wp_get_mime_types() {
/**
* Filter the list of mime types and file extensions.
*
* This filter should be used to add, not remove, mime types. To remove
* mime types, use the 'upload_mimes' filter.
*
* @since 3.5.0
*
* @param array $wp_get_mime_types Mime types keyed by the file extension regex
* corresponding to those types.
*/
return apply_filters( 'mime_types', array(
// Image formats
'jpg|jpeg|jpe' => 'image/jpeg',
'gif' => 'image/gif',
'png' => 'image/png',
'bmp' => 'image/bmp',
'tif|tiff' => 'image/tiff',
'ico' => 'image/x-icon',
// Video formats
'asf|asx' => 'video/x-ms-asf',
'wmv' => 'video/x-ms-wmv',
'wmx' => 'video/x-ms-wmx',
'wm' => 'video/x-ms-wm',
'avi' => 'video/avi',
'divx' => 'video/divx',
'flv' => 'video/x-flv',
'mov|qt' => 'video/quicktime',
'mpeg|mpg|mpe' => 'video/mpeg',
'mp4|m4v' => 'video/mp4',
'ogv' => 'video/ogg',
'webm' => 'video/webm',
'mkv' => 'video/x-matroska',
// Text formats
'txt|asc|c|cc|h' => 'text/plain',
'csv' => 'text/csv',
'tsv' => 'text/tab-separated-values',
'ics' => 'text/calendar',
'rtx' => 'text/richtext',
'css' => 'text/css',
'htm|html' => 'text/html',
'vtt' => 'text/vtt',
// Audio formats
'mp3|m4a|m4b' => 'audio/mpeg',
'ra|ram' => 'audio/x-realaudio',
'wav' => 'audio/wav',
'ogg|oga' => 'audio/ogg',
'mid|midi' => 'audio/midi',
'wma' => 'audio/x-ms-wma',
'wax' => 'audio/x-ms-wax',
'mka' => 'audio/x-matroska',
// Misc application formats
'rtf' => 'application/rtf',
'js' => 'application/javascript',
'pdf' => 'application/pdf',
'swf' => 'application/x-shockwave-flash',
'class' => 'application/java',
'tar' => 'application/x-tar',
'zip' => 'application/zip',
'gz|gzip' => 'application/x-gzip',
'rar' => 'application/rar',
'7z' => 'application/x-7z-compressed',
'exe' => 'application/x-msdownload',
// MS Office formats
'doc' => 'application/msword',
'pot|pps|ppt' => 'application/vnd.ms-powerpoint',
'wri' => 'application/vnd.ms-write',
'xla|xls|xlt|xlw' => 'application/vnd.ms-excel',
'mdb' => 'application/vnd.ms-access',
'mpp' => 'application/vnd.ms-project',
'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'docm' => 'application/vnd.ms-word.document.macroEnabled.12',
'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
'dotm' => 'application/vnd.ms-word.template.macroEnabled.12',
'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'xlsm' => 'application/vnd.ms-excel.sheet.macroEnabled.12',
'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12',
'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
'xltm' => 'application/vnd.ms-excel.template.macroEnabled.12',
'xlam' => 'application/vnd.ms-excel.addin.macroEnabled.12',
'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
'pptm' => 'application/vnd.ms-powerpoint.presentation.macroEnabled.12',
'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
'ppsm' => 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12',
'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template',
'potm' => 'application/vnd.ms-powerpoint.template.macroEnabled.12',
'ppam' => 'application/vnd.ms-powerpoint.addin.macroEnabled.12',
'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide',
'sldm' => 'application/vnd.ms-powerpoint.slide.macroEnabled.12',
'onetoc|onetoc2|onetmp|onepkg' => 'application/onenote',
// OpenOffice formats
'odt' => 'application/vnd.oasis.opendocument.text',
'odp' => 'application/vnd.oasis.opendocument.presentation',
'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
'odg' => 'application/vnd.oasis.opendocument.graphics',
'odc' => 'application/vnd.oasis.opendocument.chart',
'odb' => 'application/vnd.oasis.opendocument.database',
'odf' => 'application/vnd.oasis.opendocument.formula',
// WordPerfect formats
'wp|wpd' => 'application/wordperfect',
// iWork formats
'key' => 'application/vnd.apple.keynote',
'numbers' => 'application/vnd.apple.numbers',
'pages' => 'application/vnd.apple.pages',
) );
}
/**
* Retrieve list of allowed mime types and file extensions.
*
* @since 2.8.6
*
* @uses wp_get_upload_mime_types() to fetch the list of mime types
*
* @param int|WP_User $user Optional. User to check. Defaults to current user.
* @return array Array of mime types keyed by the file extension regex corresponding to those types.
*/
function get_allowed_mime_types( $user = null ) {
$t = wp_get_mime_types();
unset( $t['swf'], $t['exe'] );
if ( function_exists( 'current_user_can' ) )
$unfiltered = $user ? user_can( $user, 'unfiltered_html' ) : current_user_can( 'unfiltered_html' );
if ( empty( $unfiltered ) )
unset( $t['htm|html'] );
/**
* Filter list of allowed mime types and file extensions.
*
* @since 2.0.0
*
* @param array $t Mime types keyed by the file extension regex corresponding to
* those types. 'swf' and 'exe' removed from full list. 'htm|html' also
* removed depending on '$user' capabilities.
* @param int|WP_User|null $user User ID, User object or null if not provided (indicates current user).
*/
return apply_filters( 'upload_mimes', $t, $user );
}
/**
* Display "Are You Sure" message to confirm the action being taken.
*
* If the action has the nonce explain message, then it will be displayed along
* with the "Are you sure?" message.
*
* @since 2.0.4
*
* @param string $action The nonce action.
*/
function wp_nonce_ays( $action ) {
$title = __( 'WordPress Failure Notice' );
if ( 'log-out' == $action ) {
$html = sprintf( __( 'You are attempting to log out of %s' ), get_bloginfo( 'name' ) ) . '</p><p>';
$redirect_to = isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '';
$html .= sprintf( __( "Do you really want to <a href='%s'>log out</a>?"), wp_logout_url( $redirect_to ) );
} else {
$html = __( 'Are you sure you want to do this?' );
if ( wp_get_referer() )
$html .= "</p><p><a href='" . esc_url( remove_query_arg( 'updated', wp_get_referer() ) ) . "'>" . __( 'Please try again.' ) . "</a>";
}
wp_die( $html, $title, array('response' => 403) );
}
/**
* Kill WordPress execution and display HTML message with error message.
*
* This function complements the die() PHP function. The difference is that
* HTML will be displayed to the user. It is recommended to use this function
* only, when the execution should not continue any further. It is not
* recommended to call this function very often and try to handle as many errors
* as possible silently.
*
* @since 2.0.4
*
* @param string $message Error message.
* @param string $title Error title.
* @param string|array $args Optional arguments to control behavior.
*/
function wp_die( $message = '', $title = '', $args = array() ) {
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
/**
* Filter callback for killing WordPress execution for AJAX requests.
*
* @since 3.4.0
*
* @param callback $function Callback function name.
*/
$function = apply_filters( 'wp_die_ajax_handler', '_ajax_wp_die_handler' );
} elseif ( defined( 'XMLRPC_REQUEST' ) && XMLRPC_REQUEST ) {
/**
* Filter callback for killing WordPress execution for XML-RPC requests.
*
* @since 3.4.0
*
* @param callback $function Callback function name.
*/
$function = apply_filters( 'wp_die_xmlrpc_handler', '_xmlrpc_wp_die_handler' );
} else {
/**
* Filter callback for killing WordPress execution for all non-AJAX, non-XML-RPC requests.
*
* @since 3.0.0
*
* @param callback $function Callback function name.
*/
$function = apply_filters( 'wp_die_handler', '_default_wp_die_handler' );
}
call_user_func( $function, $message, $title, $args );
}
/**
* Kill WordPress execution and display HTML message with error message.
*
* This is the default handler for wp_die if you want a custom one for your
* site then you can overload using the wp_die_handler filter in wp_die
*
* @since 3.0.0
* @access private
*
* @param string $message Error message.
* @param string $title Error title.
* @param string|array $args Optional arguments to control behavior.
*/
function _default_wp_die_handler( $message, $title = '', $args = array() ) {
$defaults = array( 'response' => 500 );
$r = wp_parse_args($args, $defaults);
$have_gettext = function_exists('__');
if ( function_exists( 'is_wp_error' ) && is_wp_error( $message ) ) {
if ( empty( $title ) ) {
$error_data = $message->get_error_data();
if ( is_array( $error_data ) && isset( $error_data['title'] ) )
$title = $error_data['title'];
}
$errors = $message->get_error_messages();
switch ( count( $errors ) ) :
case 0 :
$message = '';
break;
case 1 :
$message = "<p>{$errors[0]}</p>";
break;
default :
$message = "<ul>\n\t\t<li>" . join( "</li>\n\t\t<li>", $errors ) . "</li>\n\t</ul>";
break;
endswitch;
} elseif ( is_string( $message ) ) {
$message = "<p>$message</p>";
}
if ( isset( $r['back_link'] ) && $r['back_link'] ) {
$back_text = $have_gettext? __('« Back') : '« Back';
$message .= "\n<p><a href='javascript:history.back()'>$back_text</a></p>";
}
if ( ! did_action( 'admin_head' ) ) :
if ( !headers_sent() ) {
status_header( $r['response'] );
nocache_headers();
header( 'Content-Type: text/html; charset=utf-8' );
}
if ( empty($title) )
$title = $have_gettext ? __('WordPress › Error') : 'WordPress › Error';
$text_direction = 'ltr';
if ( isset($r['text_direction']) && 'rtl' == $r['text_direction'] )
$text_direction = 'rtl';
elseif ( function_exists( 'is_rtl' ) && is_rtl() )
$text_direction = 'rtl';
?>
<!DOCTYPE html>
<!-- Ticket #11289, IE bug fix: always pad the error page with enough characters such that it is greater than 512 bytes, even after gzip compression abcdefghijklmnopqrstuvwxyz1234567890aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz11223344556677889900abacbcbdcdcededfefegfgfhghgihihjijikjkjlklkmlmlnmnmononpopoqpqprqrqsrsrtstsubcbcdcdedefefgfabcadefbghicjkldmnoepqrfstugvwxhyz1i234j567k890laabmbccnddeoeffpgghqhiirjjksklltmmnunoovppqwqrrxsstytuuzvvw0wxx1yyz2z113223434455666777889890091abc2def3ghi4jkl5mno6pqr7stu8vwx9yz11aab2bcc3dd4ee5ff6gg7hh8ii9j0jk1kl2lmm3nnoo4p5pq6qrr7ss8tt9uuvv0wwx1x2yyzz13aba4cbcb5dcdc6dedfef8egf9gfh0ghg1ihi2hji3jik4jkj5lkl6kml7mln8mnm9ono
-->
<html xmlns="http://www.w3.org/1999/xhtml" <?php if ( function_exists( 'language_attributes' ) && function_exists( 'is_rtl' ) ) language_attributes(); else echo "dir='$text_direction'"; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $title ?></title>
<style type="text/css">
html {
background: #f1f1f1;
}
body {
background: #fff;
color: #444;
font-family: "Open Sans", sans-serif;
margin: 2em auto;
padding: 1em 2em;
max-width: 700px;
-webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.13);
box-shadow: 0 1px 3px rgba(0,0,0,0.13);
}
h1 {
border-bottom: 1px solid #dadada;
clear: both;
color: #666;
font: 24px "Open Sans", sans-serif;
margin: 30px 0 0 0;
padding: 0;
padding-bottom: 7px;
}
#error-page {
margin-top: 50px;
}
#error-page p {
font-size: 14px;
line-height: 1.5;
margin: 25px 0 20px;
}
#error-page code {
font-family: Consolas, Monaco, monospace;
}
ul li {
margin-bottom: 10px;
font-size: 14px ;
}
a {
color: #21759B;
text-decoration: none;
}
a:hover {
color: #D54E21;
}
.button {
background: #f7f7f7;
border: 1px solid #cccccc;
color: #555;
display: inline-block;
text-decoration: none;
font-size: 13px;
line-height: 26px;
height: 28px;
margin: 0;
padding: 0 10px 1px;
cursor: pointer;
-webkit-border-radius: 3px;
-webkit-appearance: none;
border-radius: 3px;
white-space: nowrap;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
-webkit-box-shadow: inset 0 1px 0 #fff, 0 1px 0 rgba(0,0,0,.08);
box-shadow: inset 0 1px 0 #fff, 0 1px 0 rgba(0,0,0,.08);
vertical-align: top;
}
.button.button-large {
height: 29px;
line-height: 28px;
padding: 0 12px;
}
.button:hover,
.button:focus {
background: #fafafa;
border-color: #999;
color: #222;
}
.button:focus {
-webkit-box-shadow: 1px 1px 1px rgba(0,0,0,.2);
box-shadow: 1px 1px 1px rgba(0,0,0,.2);
}
.button:active {
background: #eee;
border-color: #999;
color: #333;
-webkit-box-shadow: inset 0 2px 5px -3px rgba( 0, 0, 0, 0.5 );
box-shadow: inset 0 2px 5px -3px rgba( 0, 0, 0, 0.5 );
}
<?php if ( 'rtl' == $text_direction ) : ?>
body { font-family: Tahoma, Arial; }
<?php endif; ?>
</style>
</head>
<body id="error-page">
<?php endif; // ! did_action( 'admin_head' ) ?>
<?php echo $message; ?>
</body>
</html>
<?php
die();
}
/**
* Kill WordPress execution and display XML message with error message.
*
* This is the handler for wp_die when processing XMLRPC requests.
*
* @since 3.2.0
* @access private
*
* @param string $message Error message.
* @param string $title Error title.
* @param string|array $args Optional arguments to control behavior.
*/
function _xmlrpc_wp_die_handler( $message, $title = '', $args = array() ) {
global $wp_xmlrpc_server;
$defaults = array( 'response' => 500 );
$r = wp_parse_args($args, $defaults);
if ( $wp_xmlrpc_server ) {
$error = new IXR_Error( $r['response'] , $message);
$wp_xmlrpc_server->output( $error->getXml() );
}
die();
}
/**
* Kill WordPress ajax execution.
*
* This is the handler for wp_die when processing Ajax requests.
*
* @since 3.4.0
* @access private
*
* @param string $message Optional. Response to print.
*/
function _ajax_wp_die_handler( $message = '' ) {
if ( is_scalar( $message ) )
die( (string) $message );
die( '0' );
}
/**
* Kill WordPress execution.
*
* This is the handler for wp_die when processing APP requests.
*
* @since 3.4.0
* @access private
*
* @param string $message Optional. Response to print.
*/
function _scalar_wp_die_handler( $message = '' ) {
if ( is_scalar( $message ) )
die( (string) $message );
die();
}
/**
* Send a JSON response back to an Ajax request.
*
* @since 3.5.0
*
* @param mixed $response Variable (usually an array or object) to encode as JSON, then print and die.
*/
function wp_send_json( $response ) {
@header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) );
echo json_encode( $response );
if ( defined( 'DOING_AJAX' ) && DOING_AJAX )
wp_die();
else
die;
}
/**
* Send a JSON response back to an Ajax request, indicating success.
*
* @since 3.5.0
*
* @param mixed $data Data to encode as JSON, then print and die.
*/
function wp_send_json_success( $data = null ) {
$response = array( 'success' => true );
if ( isset( $data ) )
$response['data'] = $data;
wp_send_json( $response );
}
/**
* Send a JSON response back to an Ajax request, indicating failure.
*
* @since 3.5.0
*
* @param mixed $data Data to encode as JSON, then print and die.
*/
function wp_send_json_error( $data = null ) {
$response = array( 'success' => false );
if ( isset( $data ) )
$response['data'] = $data;
wp_send_json( $response );
}
/**
* Retrieve the WordPress home page URL.
*
* If the constant named 'WP_HOME' exists, then it will be used and returned by
* the function. This can be used to counter the redirection on your local
* development environment.
*
* @access private
* @since 2.2.0
*
* @param string $url URL for the home location
* @return string Homepage location.
*/
function _config_wp_home( $url = '' ) {
if ( defined( 'WP_HOME' ) )
return untrailingslashit( WP_HOME );
return $url;
}
/**
* Retrieve the WordPress site URL.
*
* If the constant named 'WP_SITEURL' is defined, then the value in that
* constant will always be returned. This can be used for debugging a site on
* your localhost while not having to change the database to your URL.
*
* @access private
* @since 2.2.0
*
* @param string $url URL to set the WordPress site location.
* @return string The WordPress Site URL
*/
function _config_wp_siteurl( $url = '' ) {
if ( defined( 'WP_SITEURL' ) )
return untrailingslashit( WP_SITEURL );
return $url;
}
/**
* Set the localized direction for MCE plugin.
*
* Will only set the direction to 'rtl', if the WordPress locale has the text
* direction set to 'rtl'.
*
* Fills in the 'directionality' setting, enables the 'directionality' plugin,
* and adds the 'ltr' button to 'toolbar1', formerly 'theme_advanced_buttons1' array
* keys. These keys are then returned in the $input (TinyMCE settings) array.
*
* @access private
* @since 2.1.0
*
* @param array $input MCE settings array.
* @return array Direction set for 'rtl', if needed by locale.
*/
function _mce_set_direction( $input ) {
if ( is_rtl() ) {
$input['directionality'] = 'rtl';
$input['plugins'] .= ',directionality';
$input['toolbar1'] .= ',ltr';
}
return $input;
}
/**
* Convert smiley code to the icon graphic file equivalent.
*
* You can turn off smilies, by going to the write setting screen and unchecking
* the box, or by setting 'use_smilies' option to false or removing the option.
*
* Plugins may override the default smiley list by setting the $wpsmiliestrans
* to an array, with the key the code the blogger types in and the value the
* image file.
*
* The $wp_smiliessearch global is for the regular expression and is set each
* time the function is called.
*
* The full list of smilies can be found in the function and won't be listed in
* the description. Probably should create a Codex page for it, so that it is
* available.
*
* @global array $wpsmiliestrans
* @global array $wp_smiliessearch
* @since 2.2.0
*/
function smilies_init() {
global $wpsmiliestrans, $wp_smiliessearch;
// don't bother setting up smilies if they are disabled
if ( !get_option( 'use_smilies' ) )
return;
if ( !isset( $wpsmiliestrans ) ) {
$wpsmiliestrans = array(
':mrgreen:' => 'icon_mrgreen.gif',
':neutral:' => 'icon_neutral.gif',
':twisted:' => 'icon_twisted.gif',
':arrow:' => 'icon_arrow.gif',
':shock:' => 'icon_eek.gif',
':smile:' => 'icon_smile.gif',
':???:' => 'icon_confused.gif',
':cool:' => 'icon_cool.gif',
':evil:' => 'icon_evil.gif',
':grin:' => 'icon_biggrin.gif',
':idea:' => 'icon_idea.gif',
':oops:' => 'icon_redface.gif',
':razz:' => 'icon_razz.gif',
':roll:' => 'icon_rolleyes.gif',
':wink:' => 'icon_wink.gif',
':cry:' => 'icon_cry.gif',
':eek:' => 'icon_surprised.gif',
':lol:' => 'icon_lol.gif',
':mad:' => 'icon_mad.gif',
':sad:' => 'icon_sad.gif',
'8-)' => 'icon_cool.gif',
'8-O' => 'icon_eek.gif',
':-(' => 'icon_sad.gif',
':-)' => 'icon_smile.gif',
':-?' => 'icon_confused.gif',
':-D' => 'icon_biggrin.gif',
':-P' => 'icon_razz.gif',
':-o' => 'icon_surprised.gif',
':-x' => 'icon_mad.gif',
':-|' => 'icon_neutral.gif',
';-)' => 'icon_wink.gif',
// This one transformation breaks regular text with frequency.
// '8)' => 'icon_cool.gif',
'8O' => 'icon_eek.gif',
':(' => 'icon_sad.gif',
':)' => 'icon_smile.gif',
':?' => 'icon_confused.gif',
':D' => 'icon_biggrin.gif',
':P' => 'icon_razz.gif',
':o' => 'icon_surprised.gif',
':x' => 'icon_mad.gif',
':|' => 'icon_neutral.gif',
';)' => 'icon_wink.gif',
':!:' => 'icon_exclaim.gif',
':?:' => 'icon_question.gif',
);
}
if (count($wpsmiliestrans) == 0) {
return;
}
/*
* NOTE: we sort the smilies in reverse key order. This is to make sure
* we match the longest possible smilie (:???: vs :?) as the regular
* expression used below is first-match
*/
krsort($wpsmiliestrans);
$wp_smiliessearch = '/((?:\s|^)';
$subchar = '';
foreach ( (array) $wpsmiliestrans as $smiley => $img ) {
$firstchar = substr($smiley, 0, 1);
$rest = substr($smiley, 1);
// new subpattern?
if ($firstchar != $subchar) {
if ($subchar != '') {
$wp_smiliessearch .= ')(?=\s|$))|((?:\s|^)'; ;
}
$subchar = $firstchar;
$wp_smiliessearch .= preg_quote($firstchar, '/') . '(?:';
} else {
$wp_smiliessearch .= '|';
}
$wp_smiliessearch .= preg_quote($rest, '/');
}
$wp_smiliessearch .= ')(?=\s|$))/m';
}
/**
* Merge user defined arguments into defaults array.
*
* This function is used throughout WordPress to allow for both string or array
* to be merged into another array.
*
* @since 2.2.0
*
* @param string|array $args Value to merge with $defaults
* @param array $defaults Array that serves as the defaults.
* @return array Merged user defined values with defaults.
*/
function wp_parse_args( $args, $defaults = '' ) {
if ( is_object( $args ) )
$r = get_object_vars( $args );
elseif ( is_array( $args ) )
$r =& $args;
else
wp_parse_str( $args, $r );
if ( is_array( $defaults ) )
return array_merge( $defaults, $r );
return $r;
}
/**
* Clean up an array, comma- or space-separated list of IDs.
*
* @since 3.0.0
*
* @param array|string $list
* @return array Sanitized array of IDs
*/
function wp_parse_id_list( $list ) {
if ( !is_array($list) )
$list = preg_split('/[\s,]+/', $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.
*
* @since 3.0.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. 'or' means only one element
* from the array needs to match; 'and' means all elements must match. The default is 'and'.
* @param bool|string $field A field from the object to place instead of the entire object
* @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 ) )
return array();
$list = wp_list_filter( $list, $args, $operator );
if ( $field )
$list = wp_list_pluck( $list, $field );
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 ) {
$to_match = (array) $obj;
$matched = 0;
foreach ( $args as $m_key => $m_value ) {
if ( array_key_exists( $m_key, $to_match ) && $m_value == $to_match[ $m_key ] )
$matched++;
}
if ( ( 'AND' == $operator && $matched == $count )
|| ( 'OR' == $operator && $matched > 0 )
|| ( '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 ) {
if ( is_object( $value ) )
$list[ $key ] = $value->$field;
else
$list[ $key ] = $value[ $field ];
}
return $list;
}
/**
* Determines if Widgets library should be loaded.
*
* Checks to make sure that the widgets library hasn't already been loaded. If
* it hasn't, then it will load the widgets library and run an action hook.
*
* @since 2.2.0
* @uses add_action() Calls '_admin_menu' hook with 'wp_widgets_add_menu' value.
*/
function wp_maybe_load_widgets() {
/**
* Filter whether to load the Widgets library.
*
* @since 2.8.0
*
* @param bool $wp_maybe_load_widgets Whether to load the Widgets library.
* Default true.
*/
if ( ! apply_filters( 'load_default_widgets', true ) ) {
return;
}
require_once( ABSPATH . WPINC . '/default-widgets.php' );
add_action( '_admin_menu', 'wp_widgets_add_menu' );
}
/**
* Append the Widgets menu to the themes main menu.
*
* @since 2.2.0
* @uses $submenu The administration submenu list.
*/
function wp_widgets_add_menu() {
global $submenu;
if ( ! current_theme_supports( 'widgets' ) )
return;
$submenu['themes.php'][7] = array( __( 'Widgets' ), 'edit_theme_options', 'widgets.php' );
ksort( $submenu['themes.php'], SORT_NUMERIC );
}
/**
* Flush all output buffers for PHP 5.2.
*
* Make sure all output buffers are flushed before our singletons our destroyed.
*
* @since 2.2.0
*/
function wp_ob_end_flush_all() {
$levels = ob_get_level();
for ($i=0; $i<$levels; $i++)
ob_end_flush();
}
/**
* Load custom DB error or display WordPress DB error.
*
* If a file exists in the wp-content directory named db-error.php, then it will
* be loaded instead of displaying the WordPress DB error. If it is not found,
* then the WordPress DB error will be displayed instead.
*
* The WordPress DB error sets the HTTP status header to 500 to try to prevent
* search engines from caching the message. Custom DB messages should do the
* same.
*
* This function was backported to WordPress 2.3.2, but originally was added
* in WordPress 2.5.0.
*
* @since 2.3.2
* @uses $wpdb
*/
function dead_db() {
global $wpdb;
wp_load_translations_early();
// Load custom DB error template, if present.
if ( file_exists( WP_CONTENT_DIR . '/db-error.php' ) ) {
require_once( WP_CONTENT_DIR . '/db-error.php' );
die();
}
// If installing or in the admin, provide the verbose message.
if ( defined('WP_INSTALLING') || defined('WP_ADMIN') )
wp_die($wpdb->error);
// Otherwise, be terse.
status_header( 500 );
nocache_headers();
header( 'Content-Type: text/html; charset=utf-8' );
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"<?php if ( is_rtl() ) echo ' dir="rtl"'; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php _e( 'Database Error' ); ?></title>
</head>
<body>
<h1><?php _e( 'Error establishing a database connection' ); ?></h1>
</body>
</html>
<?php
die();
}
/**
* Converts value to nonnegative integer.
*
* @since 2.5.0
*
* @param mixed $maybeint Data you wish to have converted to a nonnegative integer
* @return int An nonnegative integer
*/
function absint( $maybeint ) {
return abs( intval( $maybeint ) );
}
/**
* Determines if the blog can be accessed over SSL.
*
* Determines if blog can be accessed over SSL by using cURL to access the site
* using the https in the siteurl. Requires cURL extension to work correctly.
*
* @since 2.5.0
*
* @param string $url
* @return bool Whether SSL access is available
*/
function url_is_accessable_via_ssl($url)
{
if ( in_array( 'curl', get_loaded_extensions() ) ) {
$ssl = set_url_scheme( $url, 'https' );
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $ssl);
curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close ($ch);
if ($status == 200 || $status == 401) {
return true;
}
}
return false;
}
/**
* Marks a function as deprecated and informs when it has been used.
*
* There is a hook deprecated_function_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.
*
* This function is to be used in every function that is deprecated.
*
* @since 2.5.0
* @access private
*
* @param string $function The function that was called
* @param string $version The version of WordPress that deprecated the function
* @param string $replacement Optional. The function that should have been called
*/
function _deprecated_function( $function, $version, $replacement = null ) {
/**
* Fires when a deprecated function is called.
*
* @since 2.5.0
*
* @param string $function The function that was called.
* @param string $replacement The function that should have been called.
* @param string $version The version of WordPress that deprecated the function.
*/
do_action( 'deprecated_function_run', $function, $replacement, $version );
/**
* Filter whether to trigger an error for deprecated functions.
*
* @since 2.5.0
*
* @param bool $trigger Whether to trigger the error for deprecated functions. Default true.
*/
if ( WP_DEBUG && apply_filters( 'deprecated_function_trigger_error', true ) ) {
if ( function_exists( '__' ) ) {
if ( ! is_null( $replacement ) )
trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.'), $function, $version, $replacement ) );
else
trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.'), $function, $version ) );
} else {
if ( ! is_null( $replacement ) )
trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', $function, $version, $replacement ) );
else
trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.', $function, $version ) );
}
}
}
/**
* Marks a file as deprecated and informs when it has been used.
*
* There is a hook deprecated_file_included that will be called that can be used
* to get the backtrace up to what file and function included the deprecated
* file.
*
* 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 deprecated.
*
* @since 2.5.0
* @access private
*
* @param string $file The file that was included
* @param string $version The version of WordPress that deprecated the file
* @param string $replacement Optional. The file that should have been included based on ABSPATH
* @param string $message Optional. A message regarding the change
*/
function _deprecated_file( $file, $version, $replacement = null, $message = '' ) {
/**
* Fires when a deprecated file is called.
*
* @since 2.5.0
*
* @param string $file The file that was called.
* @param string $replacement The file that should have been included based on ABSPATH.
* @param string $version The version of WordPress that deprecated the file.
* @param string $message A message regarding the change.
*/
do_action( 'deprecated_file_included', $file, $replacement, $version, $message );
/**
* Filter whether to trigger an error for deprecated files.
*
* @since 2.5.0
*
* @param bool $trigger Whether to trigger the error for deprecated files. Default true.
*/
if ( WP_DEBUG && apply_filters( 'deprecated_file_trigger_error', true ) ) {
$message = empty( $message ) ? '' : ' ' . $message;
if ( function_exists( '__' ) ) {
if ( ! is_null( $replacement ) )
trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.'), $file, $version, $replacement ) . $message );
else
trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.'), $file, $version ) . $message );
} else {
if ( ! is_null( $replacement ) )
trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', $file, $version, $replacement ) . $message );
else
trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.', $file, $version ) . $message );
}
}
}
/**
* Marks a function argument as deprecated and informs when it has been used.
*
* This function is to be used whenever a deprecated function argument is used.
* Before this function is called, the argument must be checked for whether it was
* used by comparing it to its default value or evaluating whether it is empty.
* For example:
* <code>
* if ( !empty($deprecated) )
* _deprecated_argument( __FUNCTION__, '3.0' );
* </code>
*
* There is a hook deprecated_argument_run that will be called that can be used
* to get the backtrace up to what file and function used the deprecated
* argument.
*
* The current behavior is to trigger a user error if WP_DEBUG is true.
*
* @since 3.0.0
* @access private
*
* @param string $function The function that was called
* @param string $version The version of WordPress that deprecated the argument used
* @param string $message Optional. A message regarding the change.
*/
function _deprecated_argument( $function, $version, $message = null ) {
/**
* Fires when a deprecated argument is called.
*
* @since 3.0.0
*
* @param string $function The function that was called.
* @param string $message A message regarding the change.
* @param string $version The version of WordPress that deprecated the argument used.
*/
do_action( 'deprecated_argument_run', $function, $message, $version );
/**
* Filter whether to trigger an error for deprecated arguments.
*
* @since 3.0.0
*
* @param bool $trigger Whether to trigger the error for deprecated arguments. Default true.
*/
if ( WP_DEBUG && apply_filters( 'deprecated_argument_trigger_error', true ) ) {
if ( function_exists( '__' ) ) {
if ( ! is_null( $message ) )
trigger_error( sprintf( __('%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s! %3$s'), $function, $version, $message ) );
else
trigger_error( sprintf( __('%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s with no alternative available.'), $function, $version ) );
} else {
if ( ! is_null( $message ) )
trigger_error( sprintf( '%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s! %3$s', $function, $version, $message ) );
else
trigger_error( sprintf( '%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s with no alternative available.', $function, $version ) );
}
}
}
/**
* 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.
*
* @since 3.1.0
* @access private
*
* @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 ) {
/**
* Fires when the given function is being used incorrectly.
*
* @since 3.1.0
*
* @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.
*/
do_action( 'doing_it_wrong_run', $function, $message, $version );
/**
* Filter whether to trigger an error for _doing_it_wrong() calls.
*
* @since 3.1.0
*
* @param bool $trigger Whether to trigger the error for _doing_it_wrong() calls. Default true.
*/
if ( WP_DEBUG && apply_filters( 'doing_it_wrong_trigger_error', true ) ) {
if ( function_exists( '__' ) ) {
$version = is_null( $version ) ? '' : sprintf( __( '(This message was added in version %s.)' ), $version );
$message .= ' ' . __( 'Please see <a href="http://codex.wordpress.org/Debugging_in_WordPress">Debugging in WordPress</a> for more information.' );
trigger_error( sprintf( __( '%1$s was called <strong>incorrectly</strong>. %2$s %3$s' ), $function, $message, $version ) );
} else {
$version = is_null( $version ) ? '' : sprintf( '(This message was added in version %s.)', $version );
$message .= ' Please see <a href="http://codex.wordpress.org/Debugging_in_WordPress">Debugging in WordPress</a> for more information.';
trigger_error( sprintf( '%1$s was called <strong>incorrectly</strong>. %2$s %3$s', $function, $message, $version ) );
}
}
}
/**
* Is the server running earlier than 1.5.0 version of lighttpd?
*
* @since 2.5.0
*
* @return bool Whether the server is running lighttpd < 1.5.0
*/
function is_lighttpd_before_150() {
$server_parts = explode( '/', isset( $_SERVER['SERVER_SOFTWARE'] )? $_SERVER['SERVER_SOFTWARE'] : '' );
$server_parts[1] = isset( $server_parts[1] )? $server_parts[1] : '';
return 'lighttpd' == $server_parts[0] && -1 == version_compare( $server_parts[1], '1.5.0' );
}
/**
* Does the specified module exist in the Apache config?
*
* @since 2.5.0
*
* @param string $mod e.g. mod_rewrite
* @param bool $default The default return value if the module is not found
* @return bool
*/
function apache_mod_loaded($mod, $default = false) {
global $is_apache;
if ( !$is_apache )
return false;
if ( function_exists('apache_get_modules') ) {
$mods = apache_get_modules();
if ( in_array($mod, $mods) )
return true;
} elseif ( function_exists('phpinfo') ) {
ob_start();
phpinfo(8);
$phpinfo = ob_get_clean();
if ( false !== strpos($phpinfo, $mod) )
return true;
}
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, then we cannot
* easily update the xml configuration file, hence we just bail out and tell user that
* pretty permalinks cannot be used.
*
* 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' );
}
/**
* Filter whether IIS 7+ supports pretty permalinks.
*
* @since 2.8.0
*
* @param bool $supports_permalinks Whether IIS7 supports permalinks. Default false.
*/
return apply_filters( 'iis7_supports_permalinks', $supports_permalinks );
}
/**
* File validates against allowed set of defined rules.
*
* A return value of '1' means that the $file contains either '..' or './'. A
* return value of '2' means that the $file contains ':' after the first
* character. A return value of '3' means that the file is not in the allowed
* files list.
*
* @since 1.2.0
*
* @param string $file File path.
* @param array $allowed_files List of allowed files.
* @return int 0 means nothing is wrong, greater than 0 means something was wrong.
*/
function validate_file( $file, $allowed_files = '' ) {
if ( false !== strpos( $file, '..' ) )
return 1;
if ( false !== strpos( $file, './' ) )
return 1;
if ( ! empty( $allowed_files ) && ! in_array( $file, $allowed_files ) )
return 3;
if (':' == substr( $file, 1, 1 ) )
return 2;
return 0;
}
/**
* Determine if SSL is used.
*
* @since 2.6.0
*
* @return bool True if SSL, false if not used.
*/
function is_ssl() {
if ( isset($_SERVER['HTTPS']) ) {
if ( 'on' == strtolower($_SERVER['HTTPS']) )
return true;
if ( '1' == $_SERVER['HTTPS'] )
return true;
} elseif ( isset($_SERVER['SERVER_PORT']) && ( '443' == $_SERVER['SERVER_PORT'] ) ) {
return true;
}
return false;
}
/**
* Whether SSL login should be forced.
*
* @since 2.6.0
*
* @param string|bool $force Optional.
* @return bool True if forced, false if not forced.
*/
function force_ssl_login( $force = null ) {
static $forced = false;
if ( !is_null( $force ) ) {
$old_forced = $forced;
$forced = $force;
return $old_forced;
}
return $forced;
}
/**
* Whether to force SSL used for the Administration Screens.
*
* @since 2.6.0
*
* @param string|bool $force
* @return bool True if forced, false if not forced.
*/
function force_ssl_admin( $force = null ) {
static $forced = false;
if ( !is_null( $force ) ) {
$old_forced = $forced;
$forced = $force;
return $old_forced;
}
return $forced;
}
/**
* Guess the URL for the site.
*
* Will remove wp-admin links to retrieve only return URLs not in the wp-admin
* directory.
*
* @since 2.6.0
*
* @return string
*/
function wp_guess_url() {
if ( defined('WP_SITEURL') && '' != WP_SITEURL ) {
$url = WP_SITEURL;
} else {
$abspath_fix = str_replace( '\\', '/', ABSPATH );
$script_filename_dir = dirname( $_SERVER['SCRIPT_FILENAME'] );
// The request is for the admin
if ( strpos( $_SERVER['REQUEST_URI'], 'wp-admin' ) !== false || strpos( $_SERVER['REQUEST_URI'], 'wp-login.php' ) !== false ) {
$path = preg_replace( '#/(wp-admin/.*|wp-login.php)#i', '', $_SERVER['REQUEST_URI'] );
// The request is for a file in ABSPATH
} elseif ( $script_filename_dir . '/' == $abspath_fix ) {
// Strip off any file/query params in the path
$path = preg_replace( '#/[^/]*$#i', '', $_SERVER['PHP_SELF'] );
} else {
if ( false !== strpos( $_SERVER['SCRIPT_FILENAME'], $abspath_fix ) ) {
// Request is hitting a file inside ABSPATH
$directory = str_replace( ABSPATH, '', $script_filename_dir );
// Strip off the sub directory, and any file/query paramss
$path = preg_replace( '#/' . preg_quote( $directory, '#' ) . '/[^/]*$#i', '' , $_SERVER['REQUEST_URI'] );
} elseif ( false !== strpos( $abspath_fix, $script_filename_dir ) ) {
// Request is hitting a file above ABSPATH
$subdirectory = substr( $abspath_fix, strpos( $abspath_fix, $script_filename_dir ) + strlen( $script_filename_dir ) );
// Strip off any file/query params from the path, appending the sub directory to the install
$path = preg_replace( '#/[^/]*$#i', '' , $_SERVER['REQUEST_URI'] ) . $subdirectory;
} else {
$path = $_SERVER['REQUEST_URI'];
}
}
$schema = is_ssl() ? 'https://' : 'http://'; // set_url_scheme() is not defined yet
$url = $schema . $_SERVER['HTTP_HOST'] . $path;
}
return rtrim($url, '/');
}
/**
* Temporarily suspend cache additions.
*
* Stops more data being added to the cache, but still allows cache retrieval.
* This is useful for actions, such as imports, when a lot of data would otherwise
* be almost uselessly added to the cache.
*
* Suspension lasts for a single page load at most. Remember to call this
* function again if you wish to re-enable cache adds earlier.
*
* @since 3.3.0
*
* @param bool $suspend Optional. Suspends additions if true, re-enables them if false.
* @return bool The current suspend setting
*/
function wp_suspend_cache_addition( $suspend = null ) {
static $_suspend = false;
if ( is_bool( $suspend ) )
$_suspend = $suspend;
return $_suspend;
}
/**
* Suspend cache invalidation.
*
* Turns cache invalidation on and off. Useful during imports where you don't wont to do invalidations
* every time a post is inserted. Callers must be sure that what they are doing won't lead to an inconsistent
* cache when invalidation is suspended.
*
* @since 2.7.0
*
* @param bool $suspend Whether to suspend or enable cache invalidation
* @return bool The current suspend setting
*/
function wp_suspend_cache_invalidation($suspend = true) {
global $_wp_suspend_cache_invalidation;
$current_suspend = $_wp_suspend_cache_invalidation;
$_wp_suspend_cache_invalidation = $suspend;
return $current_suspend;
}
/**
* Whether a site is the main site of the current network.
*
* @since 3.0.0
*
* @param int $site_id Optional. Site ID to test. Defaults to current site.
* @return bool True if $site_id is the main site of the network, or if not running multisite.
*/
function is_main_site( $site_id = null ) {
// This is the current network's information; 'site' is old terminology.
global $current_site;
if ( ! is_multisite() )
return true;
if ( ! $site_id )
$site_id = get_current_blog_id();
return (int) $site_id === (int) $current_site->blog_id;
}
/**
* Whether a network is the main network of the multisite install.
*
* @since 3.7.0
*
* @param int $network_id Optional. Network ID to test. Defaults to current network.
* @return bool True if $network_id is the main network, or if not running multisite.
*/
function is_main_network( $network_id = null ) {
global $wpdb;
if ( ! is_multisite() )
return true;
$current_network_id = (int) get_current_site()->id;
if ( ! $network_id )
$network_id = $current_network_id;
$network_id = (int) $network_id;
if ( defined( 'PRIMARY_NETWORK_ID' ) )
return $network_id === (int) PRIMARY_NETWORK_ID;
if ( 1 === $current_network_id )
return $network_id === $current_network_id;
$primary_network_id = (int) wp_cache_get( 'primary_network_id', 'site-options' );
if ( $primary_network_id )
return $network_id === $primary_network_id;
$primary_network_id = (int) $wpdb->get_var( "SELECT id FROM $wpdb->site ORDER BY id LIMIT 1" );
wp_cache_add( 'primary_network_id', $primary_network_id, 'site-options' );
return $network_id === $primary_network_id;
}
/**
* Whether global terms are enabled.
*
*
* @since 3.0.0
*
* @return bool True if multisite and global terms enabled
*/
function global_terms_enabled() {
if ( ! is_multisite() )
return false;
static $global_terms = null;
if ( is_null( $global_terms ) ) {
/**
* Filter whether global terms are enabled.
*
* Passing a non-null value to the filter will effectively short-circuit the function,
* returning the value of the 'global_terms_enabled' site option instead.
*
* @since 3.0.0
*
* @param null $anbled Whether global terms are enabled.
*/
$filter = apply_filters( 'global_terms_enabled', null );
if ( ! is_null( $filter ) )
$global_terms = (bool) $filter;
else
$global_terms = (bool) get_site_option( 'global_terms_enabled', false );
}
return $global_terms;
}
/**
* gmt_offset modification for smart timezone handling.
*
* Overrides the gmt_offset option if we have a timezone_string available.
*
* @since 2.8.0
*
* @return float|bool
*/
function wp_timezone_override_offset() {
if ( !$timezone_string = get_option( 'timezone_string' ) ) {
return false;
}
$timezone_object = timezone_open( $timezone_string );
$datetime_object = date_create();
if ( false === $timezone_object || false === $datetime_object ) {
return false;
}
return round( timezone_offset_get( $timezone_object, $datetime_object ) / HOUR_IN_SECONDS, 2 );
}
/**
* Sort-helper for timezones.
*
* @since 2.9.0
*
* @param array $a
* @param array $b
* @return int
*/
function _wp_timezone_choice_usort_callback( $a, $b ) {
// Don't use translated versions of Etc
if ( 'Etc' === $a['continent'] && 'Etc' === $b['continent'] ) {
// Make the order of these more like the old dropdown
if ( 'GMT+' === substr( $a['city'], 0, 4 ) && 'GMT+' === substr( $b['city'], 0, 4 ) ) {
return -1 * ( strnatcasecmp( $a['city'], $b['city'] ) );
}
if ( 'UTC' === $a['city'] ) {
if ( 'GMT+' === substr( $b['city'], 0, 4 ) ) {
return 1;
}
return -1;
}
if ( 'UTC' === $b['city'] ) {
if ( 'GMT+' === substr( $a['city'], 0, 4 ) ) {
return -1;
}
return 1;
}
return strnatcasecmp( $a['city'], $b['city'] );
}
if ( $a['t_continent'] == $b['t_continent'] ) {
if ( $a['t_city'] == $b['t_city'] ) {
return strnatcasecmp( $a['t_subcity'], $b['t_subcity'] );
}
return strnatcasecmp( $a['t_city'], $b['t_city'] );
} else {
// Force Etc to the bottom of the list
if ( 'Etc' === $a['continent'] ) {
return 1;
}
if ( 'Etc' === $b['continent'] ) {
return -1;
}
return strnatcasecmp( $a['t_continent'], $b['t_continent'] );
}
}
/**
* Gives a nicely formatted list of timezone strings.
*
* @since 2.9.0
*
* @param string $selected_zone Selected Zone
* @return string
*/
function wp_timezone_choice( $selected_zone ) {
static $mo_loaded = false;
$continents = array( 'Africa', 'America', 'Antarctica', 'Arctic', 'Asia', 'Atlantic', 'Australia', 'Europe', 'Indian', 'Pacific');
// Load translations for continents and cities
if ( !$mo_loaded ) {
$locale = get_locale();
$mofile = WP_LANG_DIR . '/continents-cities-' . $locale . '.mo';
load_textdomain( 'continents-cities', $mofile );
$mo_loaded = true;
}
$zonen = array();
foreach ( timezone_identifiers_list() as $zone ) {
$zone = explode( '/', $zone );
if ( !in_array( $zone[0], $continents ) ) {
continue;
}
// This determines what gets set and translated - we don't translate Etc/* strings here, they are done later
$exists = array(
0 => ( isset( $zone[0] ) && $zone[0] ),
1 => ( isset( $zone[1] ) && $zone[1] ),
2 => ( isset( $zone[2] ) && $zone[2] ),
);
$exists[3] = ( $exists[0] && 'Etc' !== $zone[0] );
$exists[4] = ( $exists[1] && $exists[3] );
$exists[5] = ( $exists[2] && $exists[3] );
$zonen[] = array(
'continent' => ( $exists[0] ? $zone[0] : '' ),
'city' => ( $exists[1] ? $zone[1] : '' ),
'subcity' => ( $exists[2] ? $zone[2] : '' ),
't_continent' => ( $exists[3] ? translate( str_replace( '_', ' ', $zone[0] ), 'continents-cities' ) : '' ),
't_city' => ( $exists[4] ? translate( str_replace( '_', ' ', $zone[1] ), 'continents-cities' ) : '' ),
't_subcity' => ( $exists[5] ? translate( str_replace( '_', ' ', $zone[2] ), 'continents-cities' ) : '' )
);
}
usort( $zonen, '_wp_timezone_choice_usort_callback' );
$structure = array();
if ( empty( $selected_zone ) ) {
$structure[] = '<option selected="selected" value="">' . __( 'Select a city' ) . '</option>';
}
foreach ( $zonen as $key => $zone ) {
// Build value in an array to join later
$value = array( $zone['continent'] );
if ( empty( $zone['city'] ) ) {
// It's at the continent level (generally won't happen)
$display = $zone['t_continent'];
} else {
// It's inside a continent group
// Continent optgroup
if ( !isset( $zonen[$key - 1] ) || $zonen[$key - 1]['continent'] !== $zone['continent'] ) {
$label = $zone['t_continent'];
$structure[] = '<optgroup label="'. esc_attr( $label ) .'">';
}
// Add the city to the value
$value[] = $zone['city'];
$display = $zone['t_city'];
if ( !empty( $zone['subcity'] ) ) {
// Add the subcity to the value
$value[] = $zone['subcity'];
$display .= ' - ' . $zone['t_subcity'];
}
}
// Build the value
$value = join( '/', $value );
$selected = '';
if ( $value === $selected_zone ) {
$selected = 'selected="selected" ';
}
$structure[] = '<option ' . $selected . 'value="' . esc_attr( $value ) . '">' . esc_html( $display ) . "</option>";
// Close continent optgroup
if ( !empty( $zone['city'] ) && ( !isset($zonen[$key + 1]) || (isset( $zonen[$key + 1] ) && $zonen[$key + 1]['continent'] !== $zone['continent']) ) ) {
$structure[] = '</optgroup>';
}
}
// Do UTC
$structure[] = '<optgroup label="'. esc_attr__( 'UTC' ) .'">';
$selected = '';
if ( 'UTC' === $selected_zone )
$selected = 'selected="selected" ';
$structure[] = '<option ' . $selected . 'value="' . esc_attr( 'UTC' ) . '">' . __('UTC') . '</option>';
$structure[] = '</optgroup>';
// Do manual UTC offsets
$structure[] = '<optgroup label="'. esc_attr__( 'Manual Offsets' ) .'">';
$offset_range = array (-12, -11.5, -11, -10.5, -10, -9.5, -9, -8.5, -8, -7.5, -7, -6.5, -6, -5.5, -5, -4.5, -4, -3.5, -3, -2.5, -2, -1.5, -1, -0.5,
0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 5.75, 6, 6.5, 7, 7.5, 8, 8.5, 8.75, 9, 9.5, 10, 10.5, 11, 11.5, 12, 12.75, 13, 13.75, 14);
foreach ( $offset_range as $offset ) {
if ( 0 <= $offset )
$offset_name = '+' . $offset;
else
$offset_name = (string) $offset;
$offset_value = $offset_name;
$offset_name = str_replace(array('.25','.5','.75'), array(':15',':30',':45'), $offset_name);
$offset_name = 'UTC' . $offset_name;
$offset_value = 'UTC' . $offset_value;
$selected = '';
if ( $offset_value === $selected_zone )
$selected = 'selected="selected" ';
$structure[] = '<option ' . $selected . 'value="' . esc_attr( $offset_value ) . '">' . esc_html( $offset_name ) . "</option>";
}
$structure[] = '</optgroup>';
return join( "\n", $structure );
}
/**
* Strip close comment and close php tags from file headers used by WP.
* See http://core.trac.wordpress.org/ticket/8497
*
* @since 2.8.0
*
* @param string $str
* @return string
*/
function _cleanup_header_comment($str) {
return trim(preg_replace("/\s*(?:\*\/|\?>).*/", '', $str));
}
/**
* Permanently deletes posts, pages, attachments, and comments which have been in the trash for EMPTY_TRASH_DAYS.
*
* @since 2.9.0
*/
function wp_scheduled_delete() {
global $wpdb;
$delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS );
$posts_to_delete = $wpdb->get_results($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wp_trash_meta_time' AND meta_value < '%d'", $delete_timestamp), ARRAY_A);
foreach ( (array) $posts_to_delete as $post ) {
$post_id = (int) $post['post_id'];
if ( !$post_id )
continue;
$del_post = get_post($post_id);
if ( !$del_post || 'trash' != $del_post->post_status ) {
delete_post_meta($post_id, '_wp_trash_meta_status');
delete_post_meta($post_id, '_wp_trash_meta_time');
} else {
wp_delete_post($post_id);
}
}
$comments_to_delete = $wpdb->get_results($wpdb->prepare("SELECT comment_id FROM $wpdb->commentmeta WHERE meta_key = '_wp_trash_meta_time' AND meta_value < '%d'", $delete_timestamp), ARRAY_A);
foreach ( (array) $comments_to_delete as $comment ) {
$comment_id = (int) $comment['comment_id'];
if ( !$comment_id )
continue;
$del_comment = get_comment($comment_id);
if ( !$del_comment || 'trash' != $del_comment->comment_approved ) {
delete_comment_meta($comment_id, '_wp_trash_meta_time');
delete_comment_meta($comment_id, '_wp_trash_meta_status');
} else {
wp_delete_comment($comment_id);
}
}
}
/**
* Retrieve metadata from a file.
*
* 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 multiple
* lines, the value will get cut at the end of the first line.
*
* 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.
*
* @see http://codex.wordpress.org/File_Header
*
* @since 2.9.0
* @param string $file Path to the file
* @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.
$fp = fopen( $file, 'r' );
// Pull only the first 8kiB of the file in.
$file_data = fread( $fp, 8192 );
// PHP will close file handle, but we are good citizens.
fclose( $fp );
// Make sure we catch CR-only line endings.
$file_data = str_replace( "\r", "\n", $file_data );
/**
* Filter extra file headers by context.
*
* The dynamic portion of the hook name, $context, refers to the context
* where extra headers might be loaded.
*
* @since 2.9.0
*
* @param array $extra_context_headers Empty array by default.
*/
if ( $context && $extra_headers = apply_filters( "extra_{$context}_headers", array() ) ) {
$extra_headers = array_combine( $extra_headers, $extra_headers ); // keys equal values
$all_headers = array_merge( $extra_headers, (array) $default_headers );
} else {
$all_headers = $default_headers;
}
foreach ( $all_headers as $field => $regex ) {
if ( preg_match( '/^[ \t\/*#@]*' . preg_quote( $regex, '/' ) . ':(.*)$/mi', $file_data, $match ) && $match[1] )
$all_headers[ $field ] = _cleanup_header_comment( $match[1] );
else
$all_headers[ $field ] = '';
}
return $all_headers;
}
/**
* Returns true.
*
* Useful for returning true to filters easily.
*
* @since 3.0.0
* @see __return_false()
* @return bool true
*/
function __return_true() {
return true;
}
/**
* Returns false.
*
* Useful for returning false to filters easily.
*
* @since 3.0.0
* @see __return_true()
* @return bool false
*/
function __return_false() {
return false;
}
/**
* Returns 0.
*
* Useful for returning 0 to filters easily.
*
* @since 3.0.0
* @return int 0
*/
function __return_zero() {
return 0;
}
/**
* Returns an empty array.
*
* Useful for returning an empty array to filters easily.
*
* @since 3.0.0
* @return array Empty array
*/
function __return_empty_array() {
return array();
}
/**
* Returns null.
*
* Useful for returning null to filters easily.
*
* @since 3.4.0
* @return null
*/
function __return_null() {
return null;
}
/**
* Returns an empty string.
*
* Useful for returning an empty string to filters easily.
*
* @since 3.7.0
* @see __return_null()
* @return string Empty string
*/
function __return_empty_string() {
return '';
}
/**
* Send a HTTP header to disable content type sniffing in browsers which support it.
*
* @link http://blogs.msdn.com/ie/archive/2008/07/02/ie8-security-part-v-comprehensive-protection.aspx
* @link http://src.chromium.org/viewvc/chrome?view=rev&revision=6985
*
* @since 3.0.0
* @return none
*/
function send_nosniff_header() {
@header( 'X-Content-Type-Options: nosniff' );
}
/**
* Returns a MySQL expression for selecting the week number based on the start_of_week option.
*
* @internal
* @since 3.0.0
* @param string $column
* @return string
*/
function _wp_mysql_week( $column ) {
switch ( $start_of_week = (int) get_option( 'start_of_week' ) ) {
default :
case 0 :
return "WEEK( $column, 0 )";
case 1 :
return "WEEK( $column, 1 )";
case 2 :
case 3 :
case 4 :
case 5 :
case 6 :
return "WEEK( DATE_SUB( $column, INTERVAL $start_of_week DAY ), 0 )";
}
}
/**
* 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 accepts ( 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;
}
/**
* Send a HTTP header to limit rendering of pages to same origin iframes.
*
* @link https://developer.mozilla.org/en/the_x-frame-options_response_header
*
* @since 3.1.3
* @return none
*/
function send_frame_options_header() {
@header( 'X-Frame-Options: SAMEORIGIN' );
}
/**
* Retrieve a list of protocols to allow in HTML attributes.
*
* @since 3.3.0
* @see wp_kses()
* @see esc_url()
*
* @return array Array of allowed protocols
*/
function wp_allowed_protocols() {
static $protocols;
if ( empty( $protocols ) ) {
$protocols = array( 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet', 'mms', 'rtsp', 'svn', 'tel', 'fax', 'xmpp' );
/**
* Filter the list of protocols allowed in HTML attributes.
*
* @since 3.0.0
*
* @param array $protocols Array of allowed protocols e.g. 'http', 'ftp', 'tel', and more.
*/
$protocols = apply_filters( 'kses_allowed_protocols', $protocols );
}
return $protocols;
}
/**
* Return a comma separated string of functions that have been called to get to the current point in code.
*
* @link http://core.trac.wordpress.org/ticket/19589
* @since 3.4.0
*
* @param string $ignore_class A class to ignore all function calls within - useful when you want to just give info about the callee
* @param int $skip_frames A number of stack frames to skip - useful for unwinding back to the source of the issue
* @param bool $pretty Whether or not you want a comma separated string or raw array returned
* @return string|array Either a string containing a reversed comma separated trace or an array of individual calls.
*/
function wp_debug_backtrace_summary( $ignore_class = null, $skip_frames = 0, $pretty = true ) {
if ( version_compare( PHP_VERSION, '5.2.5', '>=' ) )
$trace = debug_backtrace( false );
else
$trace = debug_backtrace();
$caller = array();
$check_class = ! is_null( $ignore_class );
$skip_frames++; // skip this function
foreach ( $trace as $call ) {
if ( $skip_frames > 0 ) {
$skip_frames--;
} elseif ( isset( $call['class'] ) ) {
if ( $check_class && $ignore_class == $call['class'] )
continue; // Filter out calls
$caller[] = "{$call['class']}{$call['type']}{$call['function']}";
} else {
if ( in_array( $call['function'], array( 'do_action', 'apply_filters' ) ) ) {
$caller[] = "{$call['function']}('{$call['args'][0]}')";
} elseif ( in_array( $call['function'], array( 'include', 'include_once', 'require', 'require_once' ) ) ) {
$caller[] = $call['function'] . "('" . str_replace( array( WP_CONTENT_DIR, ABSPATH ) , '', $call['args'][0] ) . "')";
} else {
$caller[] = $call['function'];
}
}
}
if ( $pretty )
return join( ', ', array_reverse( $caller ) );
else
return $caller;
}
/**
* Retrieve ids that are not already present in the cache
*
* @since 3.4.0
*
* @param array $object_ids ID list
* @param string $cache_key The cache bucket to check against
*
* @return array
*/
function _get_non_cached_ids( $object_ids, $cache_key ) {
$clean = array();
foreach ( $object_ids as $id ) {
$id = (int) $id;
if ( !wp_cache_get( $id, $cache_key ) ) {
$clean[] = $id;
}
}
return $clean;
}
/**
* Test if the current device has the capability to upload files.
*
* @since 3.4.0
* @access private
*
* @return bool true|false
*/
function _device_can_upload() {
if ( ! wp_is_mobile() )
return true;
$ua = $_SERVER['HTTP_USER_AGENT'];
if ( strpos($ua, 'iPhone') !== false
|| strpos($ua, 'iPad') !== false
|| strpos($ua, 'iPod') !== false ) {
return preg_match( '#OS ([\d_]+) like Mac OS X#', $ua, $version ) && version_compare( $version[1], '6', '>=' );
}
return true;
}
/**
* Test if a given path is a stream URL
*
* @param string $path The resource path or URL
* @return bool True if the path is a stream URL
*/
function wp_is_stream( $path ) {
$wrappers = stream_get_wrappers();
$wrappers_re = '(' . join('|', $wrappers) . ')';
return preg_match( "!^$wrappers_re://!", $path ) === 1;
}
/**
* Test if the supplied date is valid for the Gregorian calendar
*
* @since 3.5.0
*
* @return bool true|false
*/
function wp_checkdate( $month, $day, $year, $source_date ) {
/**
* Filter whether the given date is valid for the Gregorian calendar.
*
* @since 3.5.0
*
* @param bool $checkdate Whether the given date is valid.
* @param string $source_date Date to check.
*/
return apply_filters( 'wp_checkdate', checkdate( $month, $day, $year ), $source_date );
}
/**
* Load the auth check for monitoring whether the user is still logged in.
*
* Can be disabled with remove_action( 'admin_enqueue_scripts', 'wp_auth_check_load' );
*
* This is disabled for certain screens where a login screen could cause an
* inconvenient interruption. A filter called wp_auth_check_load can be used
* for fine-grained control.
*
* @since 3.6.0
*/
function wp_auth_check_load() {
if ( ! is_admin() && ! is_user_logged_in() )
return;
if ( defined( 'IFRAME_REQUEST' ) )
return;
$screen = get_current_screen();
$hidden = array( 'update', 'update-network', 'update-core', 'update-core-network', 'upgrade', 'upgrade-network', 'network' );
$show = ! in_array( $screen->id, $hidden );
/**
* Filter whether to load the authentication check.
*
* @since 3.6.0
*
* @param bool $show Whether to load the authentication check.
* @param WP_Screen $screen The current screen object.
*/
if ( apply_filters( 'wp_auth_check_load', $show, $screen ) ) {
wp_enqueue_style( 'wp-auth-check' );
wp_enqueue_script( 'wp-auth-check' );
add_action( 'admin_print_footer_scripts', 'wp_auth_check_html', 5 );
add_action( 'wp_print_footer_scripts', 'wp_auth_check_html', 5 );
}
}
/**
* Output the HTML that shows the wp-login dialog when the user is no longer logged in.
*
* @since 3.6.0
*/
function wp_auth_check_html() {
$login_url = wp_login_url();
$current_domain = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'];
$same_domain = ( strpos( $login_url, $current_domain ) === 0 );
if ( $same_domain && force_ssl_login() && ! force_ssl_admin() )
$same_domain = false;
/**
* Filter whether the authentication check originated at the same domain.
*
* @since 3.6.0
*
* @param bool $same_domain Whether the authentication check originated at the same domain.
*/
$same_domain = apply_filters( 'wp_auth_check_same_domain', $same_domain );
$wrap_class = $same_domain ? 'hidden' : 'hidden fallback';
?>
<div id="wp-auth-check-wrap" class="<?php echo $wrap_class; ?>">
<div id="wp-auth-check-bg"></div>
<div id="wp-auth-check">
<div class="wp-auth-check-close" tabindex="0" title="<?php esc_attr_e('Close'); ?>"></div>
<?php
if ( $same_domain ) {
?>
<div id="wp-auth-check-form" data-src="<?php echo esc_url( add_query_arg( array( 'interim-login' => 1 ), $login_url ) ); ?>"></div>
<?php
}
?>
<div class="wp-auth-fallback">
<p><b class="wp-auth-fallback-expired" tabindex="0"><?php _e('Session expired'); ?></b></p>
<p><a href="<?php echo esc_url( $login_url ); ?>" target="_blank"><?php _e('Please log in again.'); ?></a>
<?php _e('The login page will open in a new window. After logging in you can close it and return to this page.'); ?></p>
</div>
</div>
</div>
<?php
}
/**
* Check whether a user is still logged in, for the heartbeat.
*
* Send a result that shows a log-in box if the user is no longer logged in,
* or if their cookie is within the grace period.
*
* @since 3.6.0
*/
function wp_auth_check( $response ) {
$response['wp-auth-check'] = is_user_logged_in() && empty( $GLOBALS['login_grace_period'] );
return $response;
}
/**
* Return RegEx body to liberally match an opening HTML tag that:
* 1. Is self-closing or
* 2. Has no body but has a closing tag of the same name or
* 3. Contains a body and a closing tag of the same name
*
* Note: this RegEx does not balance inner tags and does not attempt to produce valid HTML
*
* @since 3.6.0
*
* @param string $tag An HTML tag name. Example: 'video'
* @return string
*/
function get_tag_regex( $tag ) {
if ( empty( $tag ) )
return;
return sprintf( '<%1$s[^<]*(?:>[\s\S]*<\/%1$s>|\s*\/>)', tag_escape( $tag ) );
}
/**
* Return a canonical form of the provided charset appropriate for passing to PHP
* functions such as htmlspecialchars() and charset html attributes.
*
* @link http://core.trac.wordpress.org/ticket/23688
* @since 3.6.0
*
* @param string A charset name
* @return string The canonical form of the charset
*/
function _canonical_charset( $charset ) {
if ( 'UTF-8' === $charset || 'utf-8' === $charset || 'utf8' === $charset ||
'UTF8' === $charset )
return 'UTF-8';
if ( 'ISO-8859-1' === $charset || 'iso-8859-1' === $charset ||
'iso8859-1' === $charset || 'ISO8859-1' === $charset )
return 'ISO-8859-1';
return $charset;
}
/**
* Sets the mbstring internal encoding to a binary safe encoding whne func_overload is enabled.
*
* When mbstring.func_overload is in use for multi-byte encodings, the results from strlen() and
* similar functions respect the utf8 characters, causing binary data to return incorrect lengths.
*
* This function overrides the mbstring encoding to a binary-safe encoding, and resets it to the
* users expected encoding afterwards through the `reset_mbstring_encoding` function.
*
* It is safe to recursively call this function, however each `mbstring_binary_safe_encoding()`
* call must be followed up with an equal number of `reset_mbstring_encoding()` calls.
*
* @see reset_mbstring_encoding()
*
* @since 3.7.0
*
* @param bool $reset Whether to reset the encoding back to a previously-set encoding.
*/
function mbstring_binary_safe_encoding( $reset = false ) {
static $encodings = array();
static $overloaded = null;
if ( is_null( $overloaded ) )
$overloaded = function_exists( 'mb_internal_encoding' ) && ( ini_get( 'mbstring.func_overload' ) & 2 );
if ( false === $overloaded )
return;
if ( ! $reset ) {
$encoding = mb_internal_encoding();
array_push( $encodings, $encoding );
mb_internal_encoding( 'ISO-8859-1' );
}
if ( $reset && $encodings ) {
$encoding = array_pop( $encodings );
mb_internal_encoding( $encoding );
}
}
/**
* Resets the mbstring internal encoding to a users previously set encoding.
*
* @see mbstring_binary_safe_encoding()
*
* @since 3.7.0
*/
function reset_mbstring_encoding() {
mbstring_binary_safe_encoding( true );
}
| 01-wordpress-paypal | trunk/wp-includes/functions.php | PHP | gpl3 | 136,147 |
<?php
/**
* Loads the correct template based on the visitor's url
* @package WordPress
*/
if ( defined('WP_USE_THEMES') && WP_USE_THEMES )
/**
* Fires before determining which template to load.
*
* @since 1.5.0
*/
do_action( 'template_redirect' );
/**
* Filter whether to allow 'HEAD' requests to generate content.
*
* Provides a significant performance bump by exiting before the page
* content loads for 'HEAD' requests. See #14348.
*
* @since 3.5.0
*
* @param bool $exit Whether to exit without generating any content for 'HEAD' requests. Default true.
*/
if ( 'HEAD' === $_SERVER['REQUEST_METHOD'] && apply_filters( 'exit_on_http_head', true ) )
exit();
// Process feeds and trackbacks even if not using themes.
if ( is_robots() ) :
/**
* Fired when the template loader determines a robots.txt request.
*
* @since 2.1.0
*/
do_action( 'do_robots' );
return;
elseif ( is_feed() ) :
do_feed();
return;
elseif ( is_trackback() ) :
include( ABSPATH . 'wp-trackback.php' );
return;
endif;
if ( defined('WP_USE_THEMES') && WP_USE_THEMES ) :
$template = false;
if ( is_404() && $template = get_404_template() ) :
elseif ( is_search() && $template = get_search_template() ) :
elseif ( is_front_page() && $template = get_front_page_template() ) :
elseif ( is_home() && $template = get_home_template() ) :
elseif ( is_post_type_archive() && $template = get_post_type_archive_template() ) :
elseif ( is_tax() && $template = get_taxonomy_template() ) :
elseif ( is_attachment() && $template = get_attachment_template() ) :
remove_filter('the_content', 'prepend_attachment');
elseif ( is_single() && $template = get_single_template() ) :
elseif ( is_page() && $template = get_page_template() ) :
elseif ( is_category() && $template = get_category_template() ) :
elseif ( is_tag() && $template = get_tag_template() ) :
elseif ( is_author() && $template = get_author_template() ) :
elseif ( is_date() && $template = get_date_template() ) :
elseif ( is_archive() && $template = get_archive_template() ) :
elseif ( is_comments_popup() && $template = get_comments_popup_template() ) :
elseif ( is_paged() && $template = get_paged_template() ) :
else :
$template = get_index_template();
endif;
/**
* Filter the path of the current template before including it.
*
* @since 3.0.0
*
* @param string $template The path of the template to include.
*/
if ( $template = apply_filters( 'template_include', $template ) )
include( $template );
return;
endif;
| 01-wordpress-paypal | trunk/wp-includes/template-loader.php | PHP | gpl3 | 2,747 |
<?php
/**
* WP_Theme Class
*
* @package WordPress
* @subpackage Theme
*/
final class WP_Theme implements ArrayAccess {
/**
* Headers for style.css files.
*
* @static
* @access private
* @var array
*/
private static $file_headers = array(
'Name' => 'Theme Name',
'ThemeURI' => 'Theme URI',
'Description' => 'Description',
'Author' => 'Author',
'AuthorURI' => 'Author URI',
'Version' => 'Version',
'Template' => 'Template',
'Status' => 'Status',
'Tags' => 'Tags',
'TextDomain' => 'Text Domain',
'DomainPath' => 'Domain Path',
);
/**
* Default themes.
*
* @static
* @access private
* @var array
*/
private static $default_themes = array(
'classic' => 'WordPress Classic',
'default' => 'WordPress Default',
'twentyten' => 'Twenty Ten',
'twentyeleven' => 'Twenty Eleven',
'twentytwelve' => 'Twenty Twelve',
'twentythirteen' => 'Twenty Thirteen',
'twentyfourteen' => 'Twenty Fourteen',
);
/**
* Renamed theme tags.
*/
private static $tag_map = array(
'fixed-width' => 'fixed-layout',
'flexible-width' => 'fluid-layout',
);
/**
* Absolute path to the theme root, usually wp-content/themes
*
* @access private
* @var string
*/
private $theme_root;
/**
* Header data from the theme's style.css file.
*
* @access private
* @var array
*/
private $headers = array();
/**
* Header data from the theme's style.css file after being sanitized.
*
* @access private
* @var array
*/
private $headers_sanitized;
/**
* Header name from the theme's style.css after being translated.
*
* Cached due to sorting functions running over the translated name.
*/
private $name_translated;
/**
* Errors encountered when initializing the theme.
*
* @access private
* @var WP_Error
*/
private $errors;
/**
* The directory name of the theme's files, inside the theme root.
*
* In the case of a child theme, this is directory name of the child theme.
* Otherwise, 'stylesheet' is the same as 'template'.
*
* @access private
* @var string
*/
private $stylesheet;
/**
* The directory name of the theme's files, inside the theme root.
*
* In the case of a child theme, this is the directory name of the parent theme.
* Otherwise, 'template' is the same as 'stylesheet'.
*
* @access private
* @var string
*/
private $template;
/**
* A reference to the parent theme, in the case of a child theme.
*
* @access private
* @var WP_Theme
*/
private $parent;
/**
* URL to the theme root, usually an absolute URL to wp-content/themes
*
* @access private
* var string
*/
private $theme_root_uri;
/**
* Flag for whether the theme's textdomain is loaded.
*
* @access private
* @var bool
*/
private $textdomain_loaded;
/**
* Stores an md5 hash of the theme root, to function as the cache key.
*
* @access private
* @var string
*/
private $cache_hash;
/**
* Flag for whether the themes cache bucket should be persistently cached.
*
* Default is false. Can be set with the wp_cache_themes_persistently filter.
*
* @access private
* @var bool
*/
private static $persistently_cache;
/**
* Expiration time for the themes cache bucket.
*
* By default the bucket is not cached, so this value is useless.
*
* @access private
* @var bool
*/
private static $cache_expiration = 1800;
/**
* Constructor for WP_Theme.
*
* @param string $theme_dir Directory of the theme within the theme_root.
* @param string $theme_root Theme root.
* @param WP_Error|null $_child If this theme is a parent theme, the child may be passed for validation purposes.
*/
public function __construct( $theme_dir, $theme_root, $_child = null ) {
global $wp_theme_directories;
// Initialize caching on first run.
if ( ! isset( self::$persistently_cache ) ) {
/** This action is documented in wp-includes/theme.php */
self::$persistently_cache = apply_filters( 'wp_cache_themes_persistently', false, 'WP_Theme' );
if ( self::$persistently_cache ) {
wp_cache_add_global_groups( 'themes' );
if ( is_int( self::$persistently_cache ) )
self::$cache_expiration = self::$persistently_cache;
} else {
wp_cache_add_non_persistent_groups( 'themes' );
}
}
$this->theme_root = $theme_root;
$this->stylesheet = $theme_dir;
// Correct a situation where the theme is 'some-directory/some-theme' but 'some-directory' was passed in as part of the theme root instead.
if ( ! in_array( $theme_root, (array) $wp_theme_directories ) && in_array( dirname( $theme_root ), (array) $wp_theme_directories ) ) {
$this->stylesheet = basename( $this->theme_root ) . '/' . $this->stylesheet;
$this->theme_root = dirname( $theme_root );
}
$this->cache_hash = md5( $this->theme_root . '/' . $this->stylesheet );
$theme_file = $this->stylesheet . '/style.css';
$cache = $this->cache_get( 'theme' );
if ( is_array( $cache ) ) {
foreach ( array( 'errors', 'headers', 'template' ) as $key ) {
if ( isset( $cache[ $key ] ) )
$this->$key = $cache[ $key ];
}
if ( $this->errors )
return;
if ( isset( $cache['theme_root_template'] ) )
$theme_root_template = $cache['theme_root_template'];
} elseif ( ! file_exists( $this->theme_root . '/' . $theme_file ) ) {
$this->headers['Name'] = $this->stylesheet;
if ( ! file_exists( $this->theme_root . '/' . $this->stylesheet ) )
$this->errors = new WP_Error( 'theme_not_found', sprintf( __( 'The theme directory "%s" does not exist.' ), $this->stylesheet ) );
else
$this->errors = new WP_Error( 'theme_no_stylesheet', __( 'Stylesheet is missing.' ) );
$this->template = $this->stylesheet;
$this->cache_add( 'theme', array( 'headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet, 'template' => $this->template ) );
if ( ! file_exists( $this->theme_root ) ) // Don't cache this one.
$this->errors->add( 'theme_root_missing', __( 'ERROR: The themes directory is either empty or doesn’t exist. Please check your installation.' ) );
return;
} elseif ( ! is_readable( $this->theme_root . '/' . $theme_file ) ) {
$this->headers['Name'] = $this->stylesheet;
$this->errors = new WP_Error( 'theme_stylesheet_not_readable', __( 'Stylesheet is not readable.' ) );
$this->template = $this->stylesheet;
$this->cache_add( 'theme', array( 'headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet, 'template' => $this->template ) );
return;
} else {
$this->headers = get_file_data( $this->theme_root . '/' . $theme_file, self::$file_headers, 'theme' );
// Default themes always trump their pretenders.
// Properly identify default themes that are inside a directory within wp-content/themes.
if ( $default_theme_slug = array_search( $this->headers['Name'], self::$default_themes ) ) {
if ( basename( $this->stylesheet ) != $default_theme_slug )
$this->headers['Name'] .= '/' . $this->stylesheet;
}
}
// (If template is set from cache [and there are no errors], we know it's good.)
if ( ! $this->template && ! ( $this->template = $this->headers['Template'] ) ) {
$this->template = $this->stylesheet;
if ( ! file_exists( $this->theme_root . '/' . $this->stylesheet . '/index.php' ) ) {
$this->errors = new WP_Error( 'theme_no_index', __( 'Template is missing.' ) );
$this->cache_add( 'theme', array( 'headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet, 'template' => $this->template ) );
return;
}
}
// If we got our data from cache, we can assume that 'template' is pointing to the right place.
if ( ! is_array( $cache ) && $this->template != $this->stylesheet && ! file_exists( $this->theme_root . '/' . $this->template . '/index.php' ) ) {
// If we're in a directory of themes inside /themes, look for the parent nearby.
// wp-content/themes/directory-of-themes/*
$parent_dir = dirname( $this->stylesheet );
if ( '.' != $parent_dir && file_exists( $this->theme_root . '/' . $parent_dir . '/' . $this->template . '/index.php' ) ) {
$this->template = $parent_dir . '/' . $this->template;
} elseif ( ( $directories = search_theme_directories() ) && isset( $directories[ $this->template ] ) ) {
// Look for the template in the search_theme_directories() results, in case it is in another theme root.
// We don't look into directories of themes, just the theme root.
$theme_root_template = $directories[ $this->template ]['theme_root'];
} else {
// Parent theme is missing.
$this->errors = new WP_Error( 'theme_no_parent', sprintf( __( 'The parent theme is missing. Please install the "%s" parent theme.' ), $this->template ) );
$this->cache_add( 'theme', array( 'headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet, 'template' => $this->template ) );
$this->parent = new WP_Theme( $this->template, $this->theme_root, $this );
return;
}
}
// Set the parent, if we're a child theme.
if ( $this->template != $this->stylesheet ) {
// If we are a parent, then there is a problem. Only two generations allowed! Cancel things out.
if ( is_a( $_child, 'WP_Theme' ) && $_child->template == $this->stylesheet ) {
$_child->parent = null;
$_child->errors = new WP_Error( 'theme_parent_invalid', sprintf( __( 'The "%s" theme is not a valid parent theme.' ), $_child->template ) );
$_child->cache_add( 'theme', array( 'headers' => $_child->headers, 'errors' => $_child->errors, 'stylesheet' => $_child->stylesheet, 'template' => $_child->template ) );
// The two themes actually reference each other with the Template header.
if ( $_child->stylesheet == $this->template ) {
$this->errors = new WP_Error( 'theme_parent_invalid', sprintf( __( 'The "%s" theme is not a valid parent theme.' ), $this->template ) );
$this->cache_add( 'theme', array( 'headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet, 'template' => $this->template ) );
}
return;
}
// Set the parent. Pass the current instance so we can do the crazy checks above and assess errors.
$this->parent = new WP_Theme( $this->template, isset( $theme_root_template ) ? $theme_root_template : $this->theme_root, $this );
}
// We're good. If we didn't retrieve from cache, set it.
if ( ! is_array( $cache ) ) {
$cache = array( 'headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet, 'template' => $this->template );
// If the parent theme is in another root, we'll want to cache this. Avoids an entire branch of filesystem calls above.
if ( isset( $theme_root_template ) )
$cache['theme_root_template'] = $theme_root_template;
$this->cache_add( 'theme', $cache );
}
}
/**
* When converting the object to a string, the theme name is returned.
*
* @return string Theme name, ready for display (translated)
*/
public function __toString() {
return (string) $this->display('Name');
}
/**
* __isset() magic method for properties formerly returned by current_theme_info()
*/
public function __isset( $offset ) {
static $properties = array(
'name', 'title', 'version', 'parent_theme', 'template_dir', 'stylesheet_dir', 'template', 'stylesheet',
'screenshot', 'description', 'author', 'tags', 'theme_root', 'theme_root_uri',
);
return in_array( $offset, $properties );
}
/**
* __get() magic method for properties formerly returned by current_theme_info()
*/
public function __get( $offset ) {
switch ( $offset ) {
case 'name' :
case 'title' :
return $this->get('Name');
case 'version' :
return $this->get('Version');
case 'parent_theme' :
return $this->parent() ? $this->parent()->get('Name') : '';
case 'template_dir' :
return $this->get_template_directory();
case 'stylesheet_dir' :
return $this->get_stylesheet_directory();
case 'template' :
return $this->get_template();
case 'stylesheet' :
return $this->get_stylesheet();
case 'screenshot' :
return $this->get_screenshot( 'relative' );
// 'author' and 'description' did not previously return translated data.
case 'description' :
return $this->display('Description');
case 'author' :
return $this->display('Author');
case 'tags' :
return $this->get( 'Tags' );
case 'theme_root' :
return $this->get_theme_root();
case 'theme_root_uri' :
return $this->get_theme_root_uri();
// For cases where the array was converted to an object.
default :
return $this->offsetGet( $offset );
}
}
/**
* Method to implement ArrayAccess for keys formerly returned by get_themes()
*/
public function offsetSet( $offset, $value ) {}
/**
* Method to implement ArrayAccess for keys formerly returned by get_themes()
*/
public function offsetUnset( $offset ) {}
/**
* Method to implement ArrayAccess for keys formerly returned by get_themes()
*/
public function offsetExists( $offset ) {
static $keys = array(
'Name', 'Version', 'Status', 'Title', 'Author', 'Author Name', 'Author URI', 'Description',
'Template', 'Stylesheet', 'Template Files', 'Stylesheet Files', 'Template Dir', 'Stylesheet Dir',
'Screenshot', 'Tags', 'Theme Root', 'Theme Root URI', 'Parent Theme',
);
return in_array( $offset, $keys );
}
/**
* Method to implement ArrayAccess for keys formerly returned by get_themes().
*
* Author, Author Name, Author URI, and Description did not previously return
* translated data. We are doing so now as it is safe to do. However, as
* Name and Title could have been used as the key for get_themes(), both remain
* untranslated for back compatibility. This means that ['Name'] is not ideal,
* and care should be taken to use $theme->display('Name') to get a properly
* translated header.
*/
public function offsetGet( $offset ) {
switch ( $offset ) {
case 'Name' :
case 'Title' :
// See note above about using translated data. get() is not ideal.
// It is only for backwards compatibility. Use display().
return $this->get('Name');
case 'Author' :
return $this->display( 'Author');
case 'Author Name' :
return $this->display( 'Author', false);
case 'Author URI' :
return $this->display('AuthorURI');
case 'Description' :
return $this->display( 'Description');
case 'Version' :
case 'Status' :
return $this->get( $offset );
case 'Template' :
return $this->get_template();
case 'Stylesheet' :
return $this->get_stylesheet();
case 'Template Files' :
return $this->get_files( 'php', 1, true );
case 'Stylesheet Files' :
return $this->get_files( 'css', 0, false );
case 'Template Dir' :
return $this->get_template_directory();
case 'Stylesheet Dir' :
return $this->get_stylesheet_directory();
case 'Screenshot' :
return $this->get_screenshot( 'relative' );
case 'Tags' :
return $this->get('Tags');
case 'Theme Root' :
return $this->get_theme_root();
case 'Theme Root URI' :
return $this->get_theme_root_uri();
case 'Parent Theme' :
return $this->parent() ? $this->parent()->get('Name') : '';
default :
return null;
}
}
/**
* Returns errors property.
*
* @since 3.4.0
* @access public
*
* @return WP_Error|bool WP_Error if there are errors, or false.
*/
public function errors() {
return is_wp_error( $this->errors ) ? $this->errors : false;
}
/**
* Whether the theme exists.
*
* A theme with errors exists. A theme with the error of 'theme_not_found',
* meaning that the theme's directory was not found, does not exist.
*
* @since 3.4.0
* @access public
*
* @return bool Whether the theme exists.
*/
public function exists() {
return ! ( $this->errors() && in_array( 'theme_not_found', $this->errors()->get_error_codes() ) );
}
/**
* Returns reference to the parent theme.
*
* @since 3.4.0
* @access public
*
* @return WP_Theme|bool Parent theme, or false if the current theme is not a child theme.
*/
public function parent() {
return isset( $this->parent ) ? $this->parent : false;
}
/**
* Adds theme data to cache.
*
* Cache entries keyed by the theme and the type of data.
*
* @access private
* @since 3.4.0
*
* @param string $key Type of data to store (theme, screenshot, headers, page_templates)
* @param string $data Data to store
* @return bool Return value from wp_cache_add()
*/
private function cache_add( $key, $data ) {
return wp_cache_add( $key . '-' . $this->cache_hash, $data, 'themes', self::$cache_expiration );
}
/**
* Gets theme data from cache.
*
* Cache entries are keyed by the theme and the type of data.
*
* @access private
* @since 3.4.0
*
* @param string $key Type of data to retrieve (theme, screenshot, headers, page_templates)
* @return mixed Retrieved data
*/
private function cache_get( $key ) {
return wp_cache_get( $key . '-' . $this->cache_hash, 'themes' );
}
/**
* Clears the cache for the theme.
*
* @access public
* @since 3.4.0
*/
public function cache_delete() {
foreach ( array( 'theme', 'screenshot', 'headers', 'page_templates' ) as $key )
wp_cache_delete( $key . '-' . $this->cache_hash, 'themes' );
$this->template = $this->textdomain_loaded = $this->theme_root_uri = $this->parent = $this->errors = $this->headers_sanitized = $this->name_translated = null;
$this->headers = array();
$this->__construct( $this->stylesheet, $this->theme_root );
}
/**
* Get a raw, unformatted theme header.
*
* The header is sanitized, but is not translated, and is not marked up for display.
* To get a theme header for display, use the display() method.
*
* Use the get_template() method, not the 'Template' header, for finding the template.
* The 'Template' header is only good for what was written in the style.css, while
* get_template() takes into account where WordPress actually located the theme and
* whether it is actually valid.
*
* @access public
* @since 3.4.0
*
* @param string $header Theme header. Name, Description, Author, Version, ThemeURI, AuthorURI, Status, Tags.
* @return string|bool String on success, false on failure.
*/
public function get( $header ) {
if ( ! isset( $this->headers[ $header ] ) )
return false;
if ( ! isset( $this->headers_sanitized ) ) {
$this->headers_sanitized = $this->cache_get( 'headers' );
if ( ! is_array( $this->headers_sanitized ) )
$this->headers_sanitized = array();
}
if ( isset( $this->headers_sanitized[ $header ] ) )
return $this->headers_sanitized[ $header ];
// If themes are a persistent group, sanitize everything and cache it. One cache add is better than many cache sets.
if ( self::$persistently_cache ) {
foreach ( array_keys( $this->headers ) as $_header )
$this->headers_sanitized[ $_header ] = $this->sanitize_header( $_header, $this->headers[ $_header ] );
$this->cache_add( 'headers', $this->headers_sanitized );
} else {
$this->headers_sanitized[ $header ] = $this->sanitize_header( $header, $this->headers[ $header ] );
}
return $this->headers_sanitized[ $header ];
}
/**
* Gets a theme header, formatted and translated for display.
*
* @access public
* @since 3.4.0
*
* @param string $header Theme header. Name, Description, Author, Version, ThemeURI, AuthorURI, Status, Tags.
* @param bool $markup Optional. Whether to mark up the header. Defaults to true.
* @param bool $translate Optional. Whether to translate the header. Defaults to true.
* @return string|bool Processed header, false on failure.
*/
public function display( $header, $markup = true, $translate = true ) {
$value = $this->get( $header );
if ( false === $value ) {
return false;
}
if ( $translate && ( empty( $value ) || ! $this->load_textdomain() ) )
$translate = false;
if ( $translate )
$value = $this->translate_header( $header, $value );
if ( $markup )
$value = $this->markup_header( $header, $value, $translate );
return $value;
}
/**
* Sanitize a theme header.
*
* @param string $header Theme header. Name, Description, Author, Version, ThemeURI, AuthorURI, Status, Tags.
* @param string $value Value to sanitize.
*/
private function sanitize_header( $header, $value ) {
switch ( $header ) {
case 'Status' :
if ( ! $value ) {
$value = 'publish';
break;
}
// Fall through otherwise.
case 'Name' :
static $header_tags = array(
'abbr' => array( 'title' => true ),
'acronym' => array( 'title' => true ),
'code' => true,
'em' => true,
'strong' => true,
);
$value = wp_kses( $value, $header_tags );
break;
case 'Author' :
// There shouldn't be anchor tags in Author, but some themes like to be challenging.
case 'Description' :
static $header_tags_with_a = array(
'a' => array( 'href' => true, 'title' => true ),
'abbr' => array( 'title' => true ),
'acronym' => array( 'title' => true ),
'code' => true,
'em' => true,
'strong' => true,
);
$value = wp_kses( $value, $header_tags_with_a );
break;
case 'ThemeURI' :
case 'AuthorURI' :
$value = esc_url_raw( $value );
break;
case 'Tags' :
$value = array_filter( array_map( 'trim', explode( ',', strip_tags( $value ) ) ) );
break;
}
return $value;
}
/**
* Mark up a theme header.
*
* @access private
* @since 3.4.0
*
* @param string $header Theme header. Name, Description, Author, Version, ThemeURI, AuthorURI, Status, Tags.
* @param string $value Value to mark up.
* @param string $translate Whether the header has been translated.
* @return string Value, marked up.
*/
private function markup_header( $header, $value, $translate ) {
switch ( $header ) {
case 'Name' :
if ( empty( $value ) )
$value = $this->get_stylesheet();
break;
case 'Description' :
$value = wptexturize( $value );
break;
case 'Author' :
if ( $this->get('AuthorURI') ) {
static $attr = null;
if ( ! isset( $attr ) )
$attr = esc_attr__( 'Visit author homepage' );
$value = sprintf( '<a href="%1$s" title="%2$s">%3$s</a>', $this->display( 'AuthorURI', true, $translate ), $attr, $value );
} elseif ( ! $value ) {
$value = __( 'Anonymous' );
}
break;
case 'Tags' :
static $comma = null;
if ( ! isset( $comma ) ) {
/* translators: used between list items, there is a space after the comma */
$comma = __( ', ' );
}
$value = implode( $comma, $value );
break;
case 'ThemeURI' :
case 'AuthorURI' :
$value = esc_url( $value );
break;
}
return $value;
}
/**
* Translate a theme header.
*
* @access private
* @since 3.4.0
*
* @param string $header Theme header. Name, Description, Author, Version, ThemeURI, AuthorURI, Status, Tags.
* @param string $value Value to translate.
* @return string Translated value.
*/
private function translate_header( $header, $value ) {
switch ( $header ) {
case 'Name' :
// Cached for sorting reasons.
if ( isset( $this->name_translated ) )
return $this->name_translated;
$this->name_translated = translate( $value, $this->get('TextDomain' ) );
return $this->name_translated;
case 'Tags' :
if ( empty( $value ) || ! function_exists( 'get_theme_feature_list' ) )
return $value;
static $tags_list;
if ( ! isset( $tags_list ) ) {
$tags_list = array();
$feature_list = get_theme_feature_list( false ); // No API
foreach ( $feature_list as $tags )
$tags_list += $tags;
}
foreach ( $value as &$tag ) {
if ( isset( $tags_list[ $tag ] ) ) {
$tag = $tags_list[ $tag ];
} elseif ( isset( self::$tag_map[ $tag ] ) ) {
$tag = $tags_list[ self::$tag_map[ $tag ] ];
}
}
return $value;
break;
default :
$value = translate( $value, $this->get('TextDomain') );
}
return $value;
}
/**
* The directory name of the theme's "stylesheet" files, inside the theme root.
*
* In the case of a child theme, this is directory name of the child theme.
* Otherwise, get_stylesheet() is the same as get_template().
*
* @since 3.4.0
* @access public
*
* @return string Stylesheet
*/
public function get_stylesheet() {
return $this->stylesheet;
}
/**
* The directory name of the theme's "template" files, inside the theme root.
*
* In the case of a child theme, this is the directory name of the parent theme.
* Otherwise, the get_template() is the same as get_stylesheet().
*
* @since 3.4.0
* @access public
*
* @return string Template
*/
public function get_template() {
return $this->template;
}
/**
* Returns the absolute path to the directory of a theme's "stylesheet" files.
*
* In the case of a child theme, this is the absolute path to the directory
* of the child theme's files.
*
* @since 3.4.0
* @access public
*
* @return string Absolute path of the stylesheet directory.
*/
public function get_stylesheet_directory() {
if ( $this->errors() && in_array( 'theme_root_missing', $this->errors()->get_error_codes() ) )
return '';
return $this->theme_root . '/' . $this->stylesheet;
}
/**
* Returns the absolute path to the directory of a theme's "template" files.
*
* In the case of a child theme, this is the absolute path to the directory
* of the parent theme's files.
*
* @since 3.4.0
* @access public
*
* @return string Absolute path of the template directory.
*/
public function get_template_directory() {
if ( $this->parent() )
$theme_root = $this->parent()->theme_root;
else
$theme_root = $this->theme_root;
return $theme_root . '/' . $this->template;
}
/**
* Returns the URL to the directory of a theme's "stylesheet" files.
*
* In the case of a child theme, this is the URL to the directory of the
* child theme's files.
*
* @since 3.4.0
* @access public
*
* @return string URL to the stylesheet directory.
*/
public function get_stylesheet_directory_uri() {
return $this->get_theme_root_uri() . '/' . str_replace( '%2F', '/', rawurlencode( $this->stylesheet ) );
}
/**
* Returns the URL to the directory of a theme's "template" files.
*
* In the case of a child theme, this is the URL to the directory of the
* parent theme's files.
*
* @since 3.4.0
* @access public
*
* @return string URL to the template directory.
*/
public function get_template_directory_uri() {
if ( $this->parent() )
$theme_root_uri = $this->parent()->get_theme_root_uri();
else
$theme_root_uri = $this->get_theme_root_uri();
return $theme_root_uri . '/' . str_replace( '%2F', '/', rawurlencode( $this->template ) );
}
/**
* The absolute path to the directory of the theme root.
*
* This is typically the absolute path to wp-content/themes.
*
* @since 3.4.0
* @access public
*
* @return string Theme root.
*/
public function get_theme_root() {
return $this->theme_root;
}
/**
* Returns the URL to the directory of the theme root.
*
* This is typically the absolute URL to wp-content/themes. This forms the basis
* for all other URLs returned by WP_Theme, so we pass it to the public function
* get_theme_root_uri() and allow it to run the theme_root_uri filter.
*
* @uses get_theme_root_uri()
*
* @since 3.4.0
* @access public
*
* @return string Theme root URI.
*/
public function get_theme_root_uri() {
if ( ! isset( $this->theme_root_uri ) )
$this->theme_root_uri = get_theme_root_uri( $this->stylesheet, $this->theme_root );
return $this->theme_root_uri;
}
/**
* Returns the main screenshot file for the theme.
*
* The main screenshot is called screenshot.png. gif and jpg extensions are also allowed.
*
* Screenshots for a theme must be in the stylesheet directory. (In the case of child
* themes, parent theme screenshots are not inherited.)
*
* @since 3.4.0
* @access public
*
* @param string $uri Type of URL to return, either 'relative' or an absolute URI. Defaults to absolute URI.
* @return mixed Screenshot file. False if the theme does not have a screenshot.
*/
public function get_screenshot( $uri = 'uri' ) {
$screenshot = $this->cache_get( 'screenshot' );
if ( $screenshot ) {
if ( 'relative' == $uri )
return $screenshot;
return $this->get_stylesheet_directory_uri() . '/' . $screenshot;
} elseif ( 0 === $screenshot ) {
return false;
}
foreach ( array( 'png', 'gif', 'jpg', 'jpeg' ) as $ext ) {
if ( file_exists( $this->get_stylesheet_directory() . "/screenshot.$ext" ) ) {
$this->cache_add( 'screenshot', 'screenshot.' . $ext );
if ( 'relative' == $uri )
return 'screenshot.' . $ext;
return $this->get_stylesheet_directory_uri() . '/' . 'screenshot.' . $ext;
}
}
$this->cache_add( 'screenshot', 0 );
return false;
}
/**
* Return files in the theme's directory.
*
* @since 3.4.0
* @access public
*
* @param mixed $type Optional. Array of extensions to return. Defaults to all files (null).
* @param int $depth Optional. How deep to search for files. Defaults to a flat scan (0 depth). -1 depth is infinite.
* @param bool $search_parent Optional. Whether to return parent files. Defaults to false.
* @return array Array of files, keyed by the path to the file relative to the theme's directory, with the values
* being absolute paths.
*/
public function get_files( $type = null, $depth = 0, $search_parent = false ) {
$files = (array) self::scandir( $this->get_stylesheet_directory(), $type, $depth );
if ( $search_parent && $this->parent() )
$files += (array) self::scandir( $this->get_template_directory(), $type, $depth );
return $files;
}
/**
* Returns the theme's page templates.
*
* @since 3.4.0
* @access public
*
* @param WP_Post|null $post Optional. The post being edited, provided for context.
* @return array Array of page templates, keyed by filename, with the value of the translated header name.
*/
public function get_page_templates( $post = null ) {
// If you screw up your current theme and we invalidate your parent, most things still work. Let it slide.
if ( $this->errors() && $this->errors()->get_error_codes() !== array( 'theme_parent_invalid' ) )
return array();
$page_templates = $this->cache_get( 'page_templates' );
if ( ! is_array( $page_templates ) ) {
$page_templates = array();
$files = (array) $this->get_files( 'php', 1 );
foreach ( $files as $file => $full_path ) {
if ( ! preg_match( '|Template Name:(.*)$|mi', file_get_contents( $full_path ), $header ) )
continue;
$page_templates[ $file ] = _cleanup_header_comment( $header[1] );
}
$this->cache_add( 'page_templates', $page_templates );
}
if ( $this->load_textdomain() ) {
foreach ( $page_templates as &$page_template ) {
$page_template = $this->translate_header( 'Template Name', $page_template );
}
}
if ( $this->parent() )
$page_templates += $this->parent()->get_page_templates( $post );
/**
* Filter list of page templates for a theme.
*
* This filter does not currently allow for page templates to be added.
*
* @since 3.9.0
*
* @param array $page_templates Array of page templates. Keys are filenames,
* values are translated names.
* @param WP_Theme $this The theme object.
* @param WP_Post|null $post The post being edited, provided for context, or null.
*/
$return = apply_filters( 'theme_page_templates', $page_templates, $this, $post );
return array_intersect_assoc( $return, $page_templates );
}
/**
* Scans a directory for files of a certain extension.
*
* @since 3.4.0
* @access private
*
* @param string $path Absolute path to search.
* @param mixed Array of extensions to find, string of a single extension, or null for all extensions.
* @param int $depth How deep to search for files. Optional, defaults to a flat scan (0 depth). -1 depth is infinite.
* @param string $relative_path The basename of the absolute path. Used to control the returned path
* for the found files, particularly when this function recurses to lower depths.
*/
private static function scandir( $path, $extensions = null, $depth = 0, $relative_path = '' ) {
if ( ! is_dir( $path ) )
return false;
if ( $extensions ) {
$extensions = (array) $extensions;
$_extensions = implode( '|', $extensions );
}
$relative_path = trailingslashit( $relative_path );
if ( '/' == $relative_path )
$relative_path = '';
$results = scandir( $path );
$files = array();
foreach ( $results as $result ) {
if ( '.' == $result[0] )
continue;
if ( is_dir( $path . '/' . $result ) ) {
if ( ! $depth || 'CVS' == $result )
continue;
$found = self::scandir( $path . '/' . $result, $extensions, $depth - 1 , $relative_path . $result );
$files = array_merge_recursive( $files, $found );
} elseif ( ! $extensions || preg_match( '~\.(' . $_extensions . ')$~', $result ) ) {
$files[ $relative_path . $result ] = $path . '/' . $result;
}
}
return $files;
}
/**
* Loads the theme's textdomain.
*
* Translation files are not inherited from the parent theme. Todo: if this fails for the
* child theme, it should probably try to load the parent theme's translations.
*
* @since 3.4.0
* @access public
*
* @return True if the textdomain was successfully loaded or has already been loaded. False if
* no textdomain was specified in the file headers, or if the domain could not be loaded.
*/
public function load_textdomain() {
if ( isset( $this->textdomain_loaded ) )
return $this->textdomain_loaded;
$textdomain = $this->get('TextDomain');
if ( ! $textdomain ) {
$this->textdomain_loaded = false;
return false;
}
if ( is_textdomain_loaded( $textdomain ) ) {
$this->textdomain_loaded = true;
return true;
}
$path = $this->get_stylesheet_directory();
if ( $domainpath = $this->get('DomainPath') )
$path .= $domainpath;
else
$path .= '/languages';
$this->textdomain_loaded = load_theme_textdomain( $textdomain, $path );
return $this->textdomain_loaded;
}
/**
* Whether the theme is allowed (multisite only).
*
* @since 3.4.0
* @access public
*
* @param string $check Optional. Whether to check only the 'network'-wide settings, the 'site'
* settings, or 'both'. Defaults to 'both'.
* @param int $blog_id Optional. Ignored if only network-wide settings are checked. Defaults to current blog.
* @return bool Whether the theme is allowed for the network. Returns true in single-site.
*/
public function is_allowed( $check = 'both', $blog_id = null ) {
if ( ! is_multisite() )
return true;
if ( 'both' == $check || 'network' == $check ) {
$allowed = self::get_allowed_on_network();
if ( ! empty( $allowed[ $this->get_stylesheet() ] ) )
return true;
}
if ( 'both' == $check || 'site' == $check ) {
$allowed = self::get_allowed_on_site( $blog_id );
if ( ! empty( $allowed[ $this->get_stylesheet() ] ) )
return true;
}
return false;
}
/**
* Returns array of stylesheet names of themes allowed on the site or network.
*
* @since 3.4.0
* @access public
*
* @param int $blog_id Optional. Defaults to current blog.
* @return array Array of stylesheet names.
*/
public static function get_allowed( $blog_id = null ) {
/**
* Filter the array of themes allowed on the site or network.
*
* @since MU
*
* @param array $allowed_themes An array of theme stylesheet names.
*/
$network = (array) apply_filters( 'allowed_themes', self::get_allowed_on_network() );
return $network + self::get_allowed_on_site( $blog_id );
}
/**
* Returns array of stylesheet names of themes allowed on the network.
*
* @since 3.4.0
* @access public
*
* @return array Array of stylesheet names.
*/
public static function get_allowed_on_network() {
static $allowed_themes;
if ( ! isset( $allowed_themes ) )
$allowed_themes = (array) get_site_option( 'allowedthemes' );
return $allowed_themes;
}
/**
* Returns array of stylesheet names of themes allowed on the site.
*
* @since 3.4.0
* @access public
*
* @param int $blog_id Optional. Defaults to current blog.
* @return array Array of stylesheet names.
*/
public static function get_allowed_on_site( $blog_id = null ) {
static $allowed_themes = array();
if ( ! $blog_id || ! is_multisite() )
$blog_id = get_current_blog_id();
if ( isset( $allowed_themes[ $blog_id ] ) )
return $allowed_themes[ $blog_id ];
$current = $blog_id == get_current_blog_id();
if ( $current ) {
$allowed_themes[ $blog_id ] = get_option( 'allowedthemes' );
} else {
switch_to_blog( $blog_id );
$allowed_themes[ $blog_id ] = get_option( 'allowedthemes' );
restore_current_blog();
}
// This is all super old MU back compat joy.
// 'allowedthemes' keys things by stylesheet. 'allowed_themes' keyed things by name.
if ( false === $allowed_themes[ $blog_id ] ) {
if ( $current ) {
$allowed_themes[ $blog_id ] = get_option( 'allowed_themes' );
} else {
switch_to_blog( $blog_id );
$allowed_themes[ $blog_id ] = get_option( 'allowed_themes' );
restore_current_blog();
}
if ( ! is_array( $allowed_themes[ $blog_id ] ) || empty( $allowed_themes[ $blog_id ] ) ) {
$allowed_themes[ $blog_id ] = array();
} else {
$converted = array();
$themes = wp_get_themes();
foreach ( $themes as $stylesheet => $theme_data ) {
if ( isset( $allowed_themes[ $blog_id ][ $theme_data->get('Name') ] ) )
$converted[ $stylesheet ] = true;
}
$allowed_themes[ $blog_id ] = $converted;
}
// Set the option so we never have to go through this pain again.
if ( is_admin() && $allowed_themes[ $blog_id ] ) {
if ( $current ) {
update_option( 'allowedthemes', $allowed_themes[ $blog_id ] );
delete_option( 'allowed_themes' );
} else {
switch_to_blog( $blog_id );
update_option( 'allowedthemes', $allowed_themes[ $blog_id ] );
delete_option( 'allowed_themes' );
restore_current_blog();
}
}
}
return (array) $allowed_themes[ $blog_id ];
}
/**
* Sort themes by name.
*
* @since 3.4.0
* @access public
*/
public static function sort_by_name( &$themes ) {
if ( 0 === strpos( get_locale(), 'en_' ) ) {
uasort( $themes, array( 'WP_Theme', '_name_sort' ) );
} else {
uasort( $themes, array( 'WP_Theme', '_name_sort_i18n' ) );
}
}
/**
* Callback function for usort() to naturally sort themes by name.
*
* Accesses the Name header directly from the class for maximum speed.
* Would choke on HTML but we don't care enough to slow it down with strip_tags().
*
* @since 3.4.0
* @access private
*/
private static function _name_sort( $a, $b ) {
return strnatcasecmp( $a->headers['Name'], $b->headers['Name'] );
}
/**
* Name sort (with translation).
*
* @since 3.4.0
* @access private
*/
private static function _name_sort_i18n( $a, $b ) {
// Don't mark up; Do translate.
return strnatcasecmp( $a->display( 'Name', false, true ), $b->display( 'Name', false, true ) );
}
}
| 01-wordpress-paypal | trunk/wp-includes/class-wp-theme.php | PHP | gpl3 | 39,587 |
<?php
/**
* Date and Time Locale object
*
* @package WordPress
* @subpackage i18n
*/
/**
* Class that loads the calendar locale.
*
* @since 2.1.0
*/
class WP_Locale {
/**
* Stores the translated strings for the full weekday names.
*
* @since 2.1.0
* @var array
* @access private
*/
var $weekday;
/**
* Stores the translated strings for the one character weekday names.
*
* There is a hack to make sure that Tuesday and Thursday, as well
* as Sunday and Saturday, don't conflict. See init() method for more.
*
* @see WP_Locale::init() for how to handle the hack.
*
* @since 2.1.0
* @var array
* @access private
*/
var $weekday_initial;
/**
* Stores the translated strings for the abbreviated weekday names.
*
* @since 2.1.0
* @var array
* @access private
*/
var $weekday_abbrev;
/**
* Stores the translated strings for the full month names.
*
* @since 2.1.0
* @var array
* @access private
*/
var $month;
/**
* Stores the translated strings for the abbreviated month names.
*
* @since 2.1.0
* @var array
* @access private
*/
var $month_abbrev;
/**
* Stores the translated strings for 'am' and 'pm'.
*
* Also the capitalized versions.
*
* @since 2.1.0
* @var array
* @access private
*/
var $meridiem;
/**
* The text direction of the locale language.
*
* Default is left to right 'ltr'.
*
* @since 2.1.0
* @var string
* @access private
*/
var $text_direction = 'ltr';
/**
* Sets up the translated strings and object properties.
*
* The method creates the translatable strings for various
* calendar elements. Which allows for specifying locale
* specific calendar names and text direction.
*
* @since 2.1.0
* @access private
*/
function init() {
// The Weekdays
$this->weekday[0] = /* translators: weekday */ __('Sunday');
$this->weekday[1] = /* translators: weekday */ __('Monday');
$this->weekday[2] = /* translators: weekday */ __('Tuesday');
$this->weekday[3] = /* translators: weekday */ __('Wednesday');
$this->weekday[4] = /* translators: weekday */ __('Thursday');
$this->weekday[5] = /* translators: weekday */ __('Friday');
$this->weekday[6] = /* translators: weekday */ __('Saturday');
// The first letter of each day. The _%day%_initial suffix is a hack to make
// sure the day initials are unique.
$this->weekday_initial[__('Sunday')] = /* translators: one-letter abbreviation of the weekday */ __('S_Sunday_initial');
$this->weekday_initial[__('Monday')] = /* translators: one-letter abbreviation of the weekday */ __('M_Monday_initial');
$this->weekday_initial[__('Tuesday')] = /* translators: one-letter abbreviation of the weekday */ __('T_Tuesday_initial');
$this->weekday_initial[__('Wednesday')] = /* translators: one-letter abbreviation of the weekday */ __('W_Wednesday_initial');
$this->weekday_initial[__('Thursday')] = /* translators: one-letter abbreviation of the weekday */ __('T_Thursday_initial');
$this->weekday_initial[__('Friday')] = /* translators: one-letter abbreviation of the weekday */ __('F_Friday_initial');
$this->weekday_initial[__('Saturday')] = /* translators: one-letter abbreviation of the weekday */ __('S_Saturday_initial');
foreach ($this->weekday_initial as $weekday_ => $weekday_initial_) {
$this->weekday_initial[$weekday_] = preg_replace('/_.+_initial$/', '', $weekday_initial_);
}
// Abbreviations for each day.
$this->weekday_abbrev[__('Sunday')] = /* translators: three-letter abbreviation of the weekday */ __('Sun');
$this->weekday_abbrev[__('Monday')] = /* translators: three-letter abbreviation of the weekday */ __('Mon');
$this->weekday_abbrev[__('Tuesday')] = /* translators: three-letter abbreviation of the weekday */ __('Tue');
$this->weekday_abbrev[__('Wednesday')] = /* translators: three-letter abbreviation of the weekday */ __('Wed');
$this->weekday_abbrev[__('Thursday')] = /* translators: three-letter abbreviation of the weekday */ __('Thu');
$this->weekday_abbrev[__('Friday')] = /* translators: three-letter abbreviation of the weekday */ __('Fri');
$this->weekday_abbrev[__('Saturday')] = /* translators: three-letter abbreviation of the weekday */ __('Sat');
// The Months
$this->month['01'] = /* translators: month name */ __('January');
$this->month['02'] = /* translators: month name */ __('February');
$this->month['03'] = /* translators: month name */ __('March');
$this->month['04'] = /* translators: month name */ __('April');
$this->month['05'] = /* translators: month name */ __('May');
$this->month['06'] = /* translators: month name */ __('June');
$this->month['07'] = /* translators: month name */ __('July');
$this->month['08'] = /* translators: month name */ __('August');
$this->month['09'] = /* translators: month name */ __('September');
$this->month['10'] = /* translators: month name */ __('October');
$this->month['11'] = /* translators: month name */ __('November');
$this->month['12'] = /* translators: month name */ __('December');
// Abbreviations for each month. Uses the same hack as above to get around the
// 'May' duplication.
$this->month_abbrev[__('January')] = /* translators: three-letter abbreviation of the month */ __('Jan_January_abbreviation');
$this->month_abbrev[__('February')] = /* translators: three-letter abbreviation of the month */ __('Feb_February_abbreviation');
$this->month_abbrev[__('March')] = /* translators: three-letter abbreviation of the month */ __('Mar_March_abbreviation');
$this->month_abbrev[__('April')] = /* translators: three-letter abbreviation of the month */ __('Apr_April_abbreviation');
$this->month_abbrev[__('May')] = /* translators: three-letter abbreviation of the month */ __('May_May_abbreviation');
$this->month_abbrev[__('June')] = /* translators: three-letter abbreviation of the month */ __('Jun_June_abbreviation');
$this->month_abbrev[__('July')] = /* translators: three-letter abbreviation of the month */ __('Jul_July_abbreviation');
$this->month_abbrev[__('August')] = /* translators: three-letter abbreviation of the month */ __('Aug_August_abbreviation');
$this->month_abbrev[__('September')] = /* translators: three-letter abbreviation of the month */ __('Sep_September_abbreviation');
$this->month_abbrev[__('October')] = /* translators: three-letter abbreviation of the month */ __('Oct_October_abbreviation');
$this->month_abbrev[__('November')] = /* translators: three-letter abbreviation of the month */ __('Nov_November_abbreviation');
$this->month_abbrev[__('December')] = /* translators: three-letter abbreviation of the month */ __('Dec_December_abbreviation');
foreach ($this->month_abbrev as $month_ => $month_abbrev_) {
$this->month_abbrev[$month_] = preg_replace('/_.+_abbreviation$/', '', $month_abbrev_);
}
// The Meridiems
$this->meridiem['am'] = __('am');
$this->meridiem['pm'] = __('pm');
$this->meridiem['AM'] = __('AM');
$this->meridiem['PM'] = __('PM');
// Numbers formatting
// See http://php.net/number_format
/* translators: $thousands_sep argument for http://php.net/number_format, default is , */
$trans = __('number_format_thousands_sep');
$this->number_format['thousands_sep'] = ('number_format_thousands_sep' == $trans) ? ',' : $trans;
/* translators: $dec_point argument for http://php.net/number_format, default is . */
$trans = __('number_format_decimal_point');
$this->number_format['decimal_point'] = ('number_format_decimal_point' == $trans) ? '.' : $trans;
// Set text direction.
if ( isset( $GLOBALS['text_direction'] ) )
$this->text_direction = $GLOBALS['text_direction'];
/* translators: 'rtl' or 'ltr'. This sets the text direction for WordPress. */
elseif ( 'rtl' == _x( 'ltr', 'text direction' ) )
$this->text_direction = 'rtl';
if ( 'rtl' === $this->text_direction && strpos( $GLOBALS['wp_version'], '-src' ) ) {
$this->text_direction = 'ltr';
add_action( 'all_admin_notices', array( $this, 'rtl_src_admin_notice' ) );
}
}
function rtl_src_admin_notice() {
echo '<div class="error"><p>' . 'The <code>build</code> directory of the develop repository must be used for RTL.' . '</p></div>';
}
/**
* Retrieve the full translated weekday word.
*
* Week starts on translated Sunday and can be fetched
* by using 0 (zero). So the week starts with 0 (zero)
* and ends on Saturday with is fetched by using 6 (six).
*
* @since 2.1.0
* @access public
*
* @param int $weekday_number 0 for Sunday through 6 Saturday
* @return string Full translated weekday
*/
function get_weekday($weekday_number) {
return $this->weekday[$weekday_number];
}
/**
* Retrieve the translated weekday initial.
*
* The weekday initial is retrieved by the translated
* full weekday word. When translating the weekday initial
* pay attention to make sure that the starting letter does
* not conflict.
*
* @since 2.1.0
* @access public
*
* @param string $weekday_name
* @return string
*/
function get_weekday_initial($weekday_name) {
return $this->weekday_initial[$weekday_name];
}
/**
* Retrieve the translated weekday abbreviation.
*
* The weekday abbreviation is retrieved by the translated
* full weekday word.
*
* @since 2.1.0
* @access public
*
* @param string $weekday_name Full translated weekday word
* @return string Translated weekday abbreviation
*/
function get_weekday_abbrev($weekday_name) {
return $this->weekday_abbrev[$weekday_name];
}
/**
* Retrieve the full translated month by month number.
*
* The $month_number parameter has to be a string
* because it must have the '0' in front of any number
* that is less than 10. Starts from '01' and ends at
* '12'.
*
* You can use an integer instead and it will add the
* '0' before the numbers less than 10 for you.
*
* @since 2.1.0
* @access public
*
* @param string|int $month_number '01' through '12'
* @return string Translated full month name
*/
function get_month($month_number) {
return $this->month[zeroise($month_number, 2)];
}
/**
* Retrieve translated version of month abbreviation string.
*
* The $month_name parameter is expected to be the translated or
* translatable version of the month.
*
* @since 2.1.0
* @access public
*
* @param string $month_name Translated month to get abbreviated version
* @return string Translated abbreviated month
*/
function get_month_abbrev($month_name) {
return $this->month_abbrev[$month_name];
}
/**
* Retrieve translated version of meridiem string.
*
* The $meridiem parameter is expected to not be translated.
*
* @since 2.1.0
* @access public
*
* @param string $meridiem Either 'am', 'pm', 'AM', or 'PM'. Not translated version.
* @return string Translated version
*/
function get_meridiem($meridiem) {
return $this->meridiem[$meridiem];
}
/**
* Global variables are deprecated. For backwards compatibility only.
*
* @deprecated For backwards compatibility only.
* @access private
*
* @since 2.1.0
*/
function register_globals() {
$GLOBALS['weekday'] = $this->weekday;
$GLOBALS['weekday_initial'] = $this->weekday_initial;
$GLOBALS['weekday_abbrev'] = $this->weekday_abbrev;
$GLOBALS['month'] = $this->month;
$GLOBALS['month_abbrev'] = $this->month_abbrev;
}
/**
* Constructor which calls helper methods to set up object variables
*
* @uses WP_Locale::init()
* @uses WP_Locale::register_globals()
* @since 2.1.0
*
* @return WP_Locale
*/
function __construct() {
$this->init();
$this->register_globals();
}
/**
* Checks if current locale is RTL.
*
* @since 3.0.0
* @return bool Whether locale is RTL.
*/
function is_rtl() {
return 'rtl' == $this->text_direction;
}
/**
* Register date/time format strings for general POT.
*
* Private, unused method to add some date/time formats translated
* on wp-admin/options-general.php to the general POT that would
* otherwise be added to the admin POT.
*
* @since 3.6.0
*/
function _strings_for_pot() {
/* translators: localized date format, see http://php.net/date */
__( 'F j, Y' );
/* translators: localized time format, see http://php.net/date */
__( 'g:i a' );
/* translators: localized date and time format, see http://php.net/date */
__( 'F j, Y g:i a' );
}
}
/**
* Checks if current locale is RTL.
*
* @since 3.0.0
* @return bool Whether locale is RTL.
*/
function is_rtl() {
global $wp_locale;
return $wp_locale->is_rtl();
}
| 01-wordpress-paypal | trunk/wp-includes/locale.php | PHP | gpl3 | 12,635 |
<?php
/**
* Deprecated functions from WordPress MU and the multisite feature. You shouldn't
* use these functions and look for the alternatives instead. The functions will be
* removed in a later version.
*
* @package WordPress
* @subpackage Deprecated
* @since 3.0.0
*/
/*
* Deprecated functions come here to die.
*/
/**
* Get the "dashboard blog", the blog where users without a blog edit their profile data.
* Dashboard blog functionality was removed in WordPress 3.1, replaced by the user admin.
*
* @since MU
* @deprecated 3.1.0
* @see get_blog_details()
* @return int
*/
function get_dashboard_blog() {
_deprecated_function( __FUNCTION__, '3.1' );
if ( $blog = get_site_option( 'dashboard_blog' ) )
return get_blog_details( $blog );
return get_blog_details( $GLOBALS['current_site']->blog_id );
}
/**
* @since MU
* @deprecated 3.0.0
* @deprecated Use wp_generate_password()
* @see wp_generate_password()
*/
function generate_random_password( $len = 8 ) {
_deprecated_function( __FUNCTION__, '3.0', 'wp_generate_password()' );
return wp_generate_password( $len );
}
/**
* Determine if user is a site admin.
*
* Plugins should use is_multisite() instead of checking if this function exists
* to determine if multisite is enabled.
*
* This function must reside in a file included only if is_multisite() due to
* legacy function_exists() checks to determine if multisite is enabled.
*
* @since MU
* @deprecated 3.0.0
* @deprecated Use is_super_admin()
* @see is_super_admin()
* @see is_multisite()
*
*/
function is_site_admin( $user_login = '' ) {
_deprecated_function( __FUNCTION__, '3.0', 'is_super_admin()' );
if ( empty( $user_login ) ) {
$user_id = get_current_user_id();
if ( !$user_id )
return false;
} else {
$user = get_user_by( 'login', $user_login );
if ( ! $user->exists() )
return false;
$user_id = $user->ID;
}
return is_super_admin( $user_id );
}
if ( !function_exists( 'graceful_fail' ) ) :
/**
* @since MU
* @deprecated 3.0.0
* @deprecated Use wp_die()
* @see wp_die()
*/
function graceful_fail( $message ) {
_deprecated_function( __FUNCTION__, '3.0', 'wp_die()' );
$message = apply_filters( 'graceful_fail', $message );
$message_template = apply_filters( 'graceful_fail_template',
'<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Error!</title>
<style type="text/css">
img {
border: 0;
}
body {
line-height: 1.6em; font-family: Georgia, serif; width: 390px; margin: auto;
text-align: center;
}
.message {
font-size: 22px;
width: 350px;
margin: auto;
}
</style>
</head>
<body>
<p class="message">%s</p>
</body>
</html>' );
die( sprintf( $message_template, $message ) );
}
endif;
/**
* @since MU
* @deprecated 3.0.0
* @deprecated Use get_user_by()
* @see get_user_by()
*/
function get_user_details( $username ) {
_deprecated_function( __FUNCTION__, '3.0', 'get_user_by()' );
return get_user_by('login', $username);
}
/**
* @since MU
* @deprecated 3.0.0
* @deprecated Use clean_post_cache()
* @see clean_post_cache()
*/
function clear_global_post_cache( $post_id ) {
_deprecated_function( __FUNCTION__, '3.0', 'clean_post_cache()' );
}
/**
* @since MU
* @deprecated 3.0.0
* @deprecated Use is_main_site()
* @see is_main_site()
*/
function is_main_blog() {
_deprecated_function( __FUNCTION__, '3.0', 'is_main_site()' );
return is_main_site();
}
/**
* @since MU
* @deprecated 3.0.0
* @deprecated Use is_email()
* @see is_email()
*/
function validate_email( $email, $check_domain = true) {
_deprecated_function( __FUNCTION__, '3.0', 'is_email()' );
return is_email( $email, $check_domain );
}
/**
* @since MU
* @deprecated 3.0.0
* @deprecated No alternative available. For performance reasons this function is not recommended.
*/
function get_blog_list( $start = 0, $num = 10, $deprecated = '' ) {
_deprecated_function( __FUNCTION__, '3.0', 'wp_get_sites()' );
global $wpdb;
$blogs = $wpdb->get_results( $wpdb->prepare("SELECT blog_id, domain, path FROM $wpdb->blogs WHERE site_id = %d AND public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0' ORDER BY registered DESC", $wpdb->siteid), ARRAY_A );
foreach ( (array) $blogs as $details ) {
$blog_list[ $details['blog_id'] ] = $details;
$blog_list[ $details['blog_id'] ]['postcount'] = $wpdb->get_var( "SELECT COUNT(ID) FROM " . $wpdb->get_blog_prefix( $details['blog_id'] ). "posts WHERE post_status='publish' AND post_type='post'" );
}
unset( $blogs );
$blogs = $blog_list;
if ( false == is_array( $blogs ) )
return array();
if ( $num == 'all' )
return array_slice( $blogs, $start, count( $blogs ) );
else
return array_slice( $blogs, $start, $num );
}
/**
* @since MU
* @deprecated 3.0.0
* @deprecated No alternative available. For performance reasons this function is not recommended.
*/
function get_most_active_blogs( $num = 10, $display = true ) {
_deprecated_function( __FUNCTION__, '3.0' );
$blogs = get_blog_list( 0, 'all', false ); // $blog_id -> $details
if ( is_array( $blogs ) ) {
reset( $blogs );
foreach ( (array) $blogs as $key => $details ) {
$most_active[ $details['blog_id'] ] = $details['postcount'];
$blog_list[ $details['blog_id'] ] = $details; // array_slice() removes keys!!
}
arsort( $most_active );
reset( $most_active );
foreach ( (array) $most_active as $key => $details )
$t[ $key ] = $blog_list[ $key ];
unset( $most_active );
$most_active = $t;
}
if ( $display == true ) {
if ( is_array( $most_active ) ) {
reset( $most_active );
foreach ( (array) $most_active as $key => $details ) {
$url = esc_url('http://' . $details['domain'] . $details['path']);
echo '<li>' . $details['postcount'] . " <a href='$url'>$url</a></li>";
}
}
}
return array_slice( $most_active, 0, $num );
}
/**
* Redirect a user based on $_GET or $_POST arguments.
*
* The function looks for redirect arguments in the following order:
* 1) $_GET['ref']
* 2) $_POST['ref']
* 3) $_SERVER['HTTP_REFERER']
* 4) $_GET['redirect']
* 5) $_POST['redirect']
* 6) $url
*
* @since MU
* @deprecated 3.3.0
* @deprecated Use wp_redirect()
* @uses wpmu_admin_redirect_add_updated_param()
*
* @param string $url
*/
function wpmu_admin_do_redirect( $url = '' ) {
_deprecated_function( __FUNCTION__, '3.3' );
$ref = '';
if ( isset( $_GET['ref'] ) )
$ref = $_GET['ref'];
if ( isset( $_POST['ref'] ) )
$ref = $_POST['ref'];
if ( $ref ) {
$ref = wpmu_admin_redirect_add_updated_param( $ref );
wp_redirect( $ref );
exit();
}
if ( empty( $_SERVER['HTTP_REFERER'] ) == false ) {
wp_redirect( $_SERVER['HTTP_REFERER'] );
exit();
}
$url = wpmu_admin_redirect_add_updated_param( $url );
if ( isset( $_GET['redirect'] ) ) {
if ( substr( $_GET['redirect'], 0, 2 ) == 's_' )
$url .= '&action=blogs&s='. esc_html( substr( $_GET['redirect'], 2 ) );
} elseif ( isset( $_POST['redirect'] ) ) {
$url = wpmu_admin_redirect_add_updated_param( $_POST['redirect'] );
}
wp_redirect( $url );
exit();
}
/**
* Adds an 'updated=true' argument to a URL.
*
* @since MU
* @deprecated 3.3.0
* @deprecated Use add_query_arg()
*
* @param string $url
* @return string
*/
function wpmu_admin_redirect_add_updated_param( $url = '' ) {
_deprecated_function( __FUNCTION__, '3.3' );
if ( strpos( $url, 'updated=true' ) === false ) {
if ( strpos( $url, '?' ) === false )
return $url . '?updated=true';
else
return $url . '&updated=true';
}
return $url;
}
/**
* Get a numeric user ID from either an email address or a login.
*
* A numeric string is considered to be an existing user ID
* and is simply returned as such.
*
* @since MU
* @deprecated 3.6.0
* @deprecated Use get_user_by()
* @uses get_user_by()
*
* @param string $string Either an email address or a login.
* @return int
*/
function get_user_id_from_string( $string ) {
_deprecated_function( __FUNCTION__, '3.6', 'get_user_by()' );
if ( is_email( $string ) )
$user = get_user_by( 'email', $string );
elseif ( is_numeric( $string ) )
return $string;
else
$user = get_user_by( 'login', $string );
if ( $user )
return $user->ID;
return 0;
}
/**
* Get a full blog URL, given a domain and a path.
*
* @since MU
* @deprecated 3.7.0
*
* @param string $domain
* @param string $path
* @return string
*/
function get_blogaddress_by_domain( $domain, $path ) {
_deprecated_function( __FUNCTION__, '3.7' );
if ( is_subdomain_install() ) {
$url = "http://" . $domain.$path;
} else {
if ( $domain != $_SERVER['HTTP_HOST'] ) {
$blogname = substr( $domain, 0, strpos( $domain, '.' ) );
$url = 'http://' . substr( $domain, strpos( $domain, '.' ) + 1 ) . $path;
// we're not installing the main blog
if ( $blogname != 'www.' )
$url .= $blogname . '/';
} else { // main blog
$url = 'http://' . $domain . $path;
}
}
return esc_url_raw( $url );
}
| 01-wordpress-paypal | trunk/wp-includes/ms-deprecated.php | PHP | gpl3 | 8,992 |
<?php
/**
* Manages WordPress comments
*
* @package WordPress
* @subpackage Comment
*/
/**
* Checks whether a comment passes internal checks to be allowed to add.
*
* If comment moderation is set in the administration, then all comments,
* regardless of their type and whitelist will be set to false. If the number of
* links exceeds the amount in the administration, then the check fails. If any
* of the parameter contents match the blacklist of words, then the check fails.
*
* If the number of links exceeds the amount in the administration, then the
* check fails. If any of the parameter contents match the blacklist of words,
* then the check fails.
*
* If the comment author was approved before, then the comment is
* automatically whitelisted.
*
* If none of the checks fail, then the failback is to set the check to pass
* (return true).
*
* @since 1.2.0
* @uses $wpdb
*
* @param string $author Comment Author's name
* @param string $email Comment Author's email
* @param string $url Comment Author's URL
* @param string $comment Comment contents
* @param string $user_ip Comment Author's IP address
* @param string $user_agent Comment Author's User Agent
* @param string $comment_type Comment type, either user submitted comment,
* trackback, or pingback
* @return bool Whether the checks passed (true) and the comments should be
* displayed or set to moderated
*/
function check_comment($author, $email, $url, $comment, $user_ip, $user_agent, $comment_type) {
global $wpdb;
if ( 1 == get_option('comment_moderation') )
return false; // If moderation is set to manual
/** This filter is documented in wp-includes/comment-template.php */
$comment = apply_filters( 'comment_text', $comment );
// Check # of external links
if ( $max_links = get_option( 'comment_max_links' ) ) {
$num_links = preg_match_all( '/<a [^>]*href/i', $comment, $out );
/**
* Filter the maximum number of links allowed in a comment.
*
* @since 3.0.0
*
* @param int $num_links The number of links allowed.
* @param string $url Comment author's URL. Included in allowed links total.
*/
$num_links = apply_filters( 'comment_max_links_url', $num_links, $url );
if ( $num_links >= $max_links )
return false;
}
$mod_keys = trim(get_option('moderation_keys'));
if ( !empty($mod_keys) ) {
$words = explode("\n", $mod_keys );
foreach ( (array) $words as $word) {
$word = trim($word);
// Skip empty lines
if ( empty($word) )
continue;
// Do some escaping magic so that '#' chars in the
// spam words don't break things:
$word = preg_quote($word, '#');
$pattern = "#$word#i";
if ( preg_match($pattern, $author) ) return false;
if ( preg_match($pattern, $email) ) return false;
if ( preg_match($pattern, $url) ) return false;
if ( preg_match($pattern, $comment) ) return false;
if ( preg_match($pattern, $user_ip) ) return false;
if ( preg_match($pattern, $user_agent) ) return false;
}
}
// Comment whitelisting:
if ( 1 == get_option('comment_whitelist')) {
if ( 'trackback' != $comment_type && 'pingback' != $comment_type && $author != '' && $email != '' ) {
// expected_slashed ($author, $email)
$ok_to_comment = $wpdb->get_var("SELECT comment_approved FROM $wpdb->comments WHERE comment_author = '$author' AND comment_author_email = '$email' and comment_approved = '1' LIMIT 1");
if ( ( 1 == $ok_to_comment ) &&
( empty($mod_keys) || false === strpos( $email, $mod_keys) ) )
return true;
else
return false;
} else {
return false;
}
}
return true;
}
/**
* Retrieve the approved comments for post $post_id.
*
* @since 2.0.0
* @uses $wpdb
*
* @param int $post_id The ID of the post
* @return array $comments The approved comments
*/
function get_approved_comments($post_id) {
global $wpdb;
return $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '1' ORDER BY comment_date", $post_id));
}
/**
* Retrieves comment data given a comment ID or comment object.
*
* If an object is passed then the comment data will be cached and then returned
* after being passed through a filter. If the comment is empty, then the global
* comment variable will be used, if it is set.
*
* @since 2.0.0
* @uses $wpdb
*
* @param object|string|int $comment Comment to retrieve.
* @param string $output Optional. OBJECT or ARRAY_A or ARRAY_N constants.
* @return object|array|null Depends on $output value.
*/
function get_comment(&$comment, $output = OBJECT) {
global $wpdb;
if ( empty($comment) ) {
if ( isset($GLOBALS['comment']) )
$_comment = & $GLOBALS['comment'];
else
$_comment = null;
} elseif ( is_object($comment) ) {
wp_cache_add($comment->comment_ID, $comment, 'comment');
$_comment = $comment;
} else {
if ( isset($GLOBALS['comment']) && ($GLOBALS['comment']->comment_ID == $comment) ) {
$_comment = & $GLOBALS['comment'];
} elseif ( ! $_comment = wp_cache_get($comment, 'comment') ) {
$_comment = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_ID = %d LIMIT 1", $comment));
if ( ! $_comment )
return null;
wp_cache_add($_comment->comment_ID, $_comment, 'comment');
}
}
/**
* Fires after a comment is retrieved.
*
* @since 2.3.0
*
* @param mixed $_comment Comment data.
*/
$_comment = apply_filters( 'get_comment', $_comment );
if ( $output == OBJECT ) {
return $_comment;
} elseif ( $output == ARRAY_A ) {
$__comment = get_object_vars($_comment);
return $__comment;
} elseif ( $output == ARRAY_N ) {
$__comment = array_values(get_object_vars($_comment));
return $__comment;
} else {
return $_comment;
}
}
/**
* Retrieve a list of comments.
*
* The comment list can be for the blog as a whole or for an individual post.
*
* The list of comment arguments are 'status', 'orderby', 'comment_date_gmt',
* 'order', 'number', 'offset', and 'post_id'.
*
* @since 2.7.0
* @uses $wpdb
*
* @param mixed $args Optional. Array or string of options to override defaults.
* @return array List of comments.
*/
function get_comments( $args = '' ) {
$query = new WP_Comment_Query;
return $query->query( $args );
}
/**
* WordPress Comment Query class.
*
* @since 3.1.0
*/
class WP_Comment_Query {
/**
* Metadata query container
*
* @since 3.5.0
* @access public
* @var object WP_Meta_Query
*/
var $meta_query = false;
/**
* Date query container
*
* @since 3.7.0
* @access public
* @var object WP_Date_Query
*/
var $date_query = false;
/**
* 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,
'post_author' => '',
'post_name' => '',
'post_parent' => '',
'post_status' => '',
'post_type' => '',
'status' => '',
'type' => '',
'user_id' => '',
'search' => '',
'count' => false,
'meta_key' => '',
'meta_value' => '',
'meta_query' => '',
'date_query' => null, // See WP_Date_Query
);
$groupby = '';
$this->query_vars = wp_parse_args( $query_vars, $defaults );
// Parse meta query
$this->meta_query = new WP_Meta_Query();
$this->meta_query->parse_query_vars( $this->query_vars );
/**
* Fires before comments are retrieved.
*
* @since 3.1.0
*
* @param WP_Comment_Query &$this Current instance of WP_Comment_Query, passed by reference.
*/
do_action_ref_array( 'pre_get_comments', array( &$this ) );
extract( $this->query_vars, 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 = microtime();
wp_cache_set( 'last_changed', $last_changed, 'comment' );
}
$cache_key = "get_comments:$key:$last_changed";
if ( $cache = wp_cache_get( $cache_key, 'comment' ) )
return $cache;
$post_id = absint($post_id);
if ( 'hold' == $status )
$approved = "comment_approved = '0'";
elseif ( 'approve' == $status )
$approved = "comment_approved = '1'";
elseif ( ! empty( $status ) && 'all' != $status )
$approved = $wpdb->prepare( "comment_approved = %s", $status );
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);
$allowed_keys = 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',
);
if ( ! empty( $this->query_vars['meta_key'] ) ) {
$allowed_keys[] = $this->query_vars['meta_key'];
$allowed_keys[] = 'meta_value';
$allowed_keys[] = 'meta_value_num';
}
$ordersby = array_intersect( $ordersby, $allowed_keys );
foreach ( $ordersby as $key => $value ) {
if ( $value == $this->query_vars['meta_key'] || $value == 'meta_value' ) {
$ordersby[ $key ] = "$wpdb->commentmeta.meta_value";
} elseif ( $value == 'meta_value_num' ) {
$ordersby[ $key ] = "$wpdb->commentmeta.meta_value+0";
}
}
$orderby = empty( $ordersby ) ? 'comment_date_gmt' : implode(', ', $ordersby);
} else {
$orderby = 'comment_date_gmt';
}
$number = absint($number);
$offset = absint($offset);
if ( !empty($number) ) {
if ( $offset )
$limits = 'LIMIT ' . $offset . ',' . $number;
else
$limits = 'LIMIT ' . $number;
} else {
$limits = '';
}
if ( $count )
$fields = 'COUNT(*)';
else
$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 ( is_array( $user_id ) ) {
$where .= ' AND user_id IN (' . implode( ',', array_map( 'absint', $user_id ) ) . ')';
} elseif ( '' !== $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' ) );
$post_fields = array_filter( compact( array( 'post_author', 'post_name', 'post_parent', 'post_status', 'post_type', ) ) );
if ( ! empty( $post_fields ) ) {
$join = "JOIN $wpdb->posts ON $wpdb->posts.ID = $wpdb->comments.comment_post_ID";
foreach( $post_fields as $field_name => $field_value )
$where .= $wpdb->prepare( " AND {$wpdb->posts}.{$field_name} = %s", $field_value );
}
if ( ! empty( $this->meta_query->queries ) ) {
$clauses = $this->meta_query->get_sql( 'comment', $wpdb->comments, 'comment_ID', $this );
$join .= $clauses['join'];
$where .= $clauses['where'];
$groupby = "{$wpdb->comments}.comment_ID";
}
if ( ! empty( $date_query ) && is_array( $date_query ) ) {
$date_query_object = new WP_Date_Query( $date_query, 'comment_date' );
$where .= $date_query_object->get_sql();
}
$pieces = array( 'fields', 'join', 'where', 'orderby', 'order', 'limits', 'groupby' );
/**
* Filter the comment query clauses.
*
* @since 3.1.0
*
* @param array $pieces A compacted array of comment query clauses.
* @param WP_Comment_Query &$this Current instance of WP_Comment_Query, passed by reference.
*/
$clauses = apply_filters_ref_array( 'comments_clauses', array( compact( $pieces ), &$this ) );
foreach ( $pieces as $piece )
$$piece = isset( $clauses[ $piece ] ) ? $clauses[ $piece ] : '';
if ( $groupby )
$groupby = 'GROUP BY ' . $groupby;
$query = "SELECT $fields FROM $wpdb->comments $join WHERE $where $groupby ORDER BY $orderby $order $limits";
if ( $count )
return $wpdb->get_var( $query );
$comments = $wpdb->get_results( $query );
/**
* Filter the comment query results.
*
* @since 3.1.0
*
* @param array $comments An array of comments.
* @param WP_Comment_Query &$this Current instance of WP_Comment_Query, passed by reference.
*/
$comments = apply_filters_ref_array( 'the_comments', array( $comments, &$this ) );
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) . ')';
}
}
/**
* Retrieve all of the WordPress supported comment statuses.
*
* Comments have a limited set of valid status values, this provides the comment
* status values and descriptions.
*
* @since 2.7.0
*
* @return array List of comment statuses.
*/
function get_comment_statuses() {
$status = array(
'hold' => __('Unapproved'),
/* translators: comment status */
'approve' => _x('Approved', 'adjective'),
/* translators: comment status */
'spam' => _x('Spam', 'adjective'),
);
return $status;
}
/**
* The date the last comment was modified.
*
* @since 1.5.0
* @uses $wpdb
*
* @param string $timezone Which timezone to use in reference to 'gmt', 'blog',
* or 'server' locations.
* @return string Last comment modified date.
*/
function get_lastcommentmodified($timezone = 'server') {
global $wpdb;
static $cache_lastcommentmodified = array();
if ( isset($cache_lastcommentmodified[$timezone]) )
return $cache_lastcommentmodified[$timezone];
$add_seconds_server = date('Z');
switch ( strtolower($timezone)) {
case 'gmt':
$lastcommentmodified = $wpdb->get_var("SELECT comment_date_gmt FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1");
break;
case 'blog':
$lastcommentmodified = $wpdb->get_var("SELECT comment_date FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1");
break;
case 'server':
$lastcommentmodified = $wpdb->get_var($wpdb->prepare("SELECT DATE_ADD(comment_date_gmt, INTERVAL %s SECOND) FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1", $add_seconds_server));
break;
}
$cache_lastcommentmodified[$timezone] = $lastcommentmodified;
return $lastcommentmodified;
}
/**
* The amount of comments in a post or total comments.
*
* A lot like {@link wp_count_comments()}, in that they both return comment
* stats (albeit with different types). The {@link wp_count_comments()} actual
* caches, but this function does not.
*
* @since 2.0.0
* @uses $wpdb
*
* @param int $post_id Optional. Comment amount in post if > 0, else total comments blog wide.
* @return array The amount of spam, approved, awaiting moderation, and total comments.
*/
function get_comment_count( $post_id = 0 ) {
global $wpdb;
$post_id = (int) $post_id;
$where = '';
if ( $post_id > 0 ) {
$where = $wpdb->prepare("WHERE comment_post_ID = %d", $post_id);
}
$totals = (array) $wpdb->get_results("
SELECT comment_approved, COUNT( * ) AS total
FROM {$wpdb->comments}
{$where}
GROUP BY comment_approved
", ARRAY_A);
$comment_count = array(
"approved" => 0,
"awaiting_moderation" => 0,
"spam" => 0,
"total_comments" => 0
);
foreach ( $totals as $row ) {
switch ( $row['comment_approved'] ) {
case 'spam':
$comment_count['spam'] = $row['total'];
$comment_count["total_comments"] += $row['total'];
break;
case 1:
$comment_count['approved'] = $row['total'];
$comment_count['total_comments'] += $row['total'];
break;
case 0:
$comment_count['awaiting_moderation'] = $row['total'];
$comment_count['total_comments'] += $row['total'];
break;
default:
break;
}
}
return $comment_count;
}
//
// Comment meta functions
//
/**
* Add meta data field to a comment.
*
* @since 2.9.0
* @uses add_metadata
* @link http://codex.wordpress.org/Function_Reference/add_comment_meta
*
* @param int $comment_id Comment ID.
* @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 int|bool Meta ID on success, false on failure.
*/
function add_comment_meta($comment_id, $meta_key, $meta_value, $unique = false) {
return add_metadata('comment', $comment_id, $meta_key, $meta_value, $unique);
}
/**
* Remove metadata matching criteria from a comment.
*
* You can match based on the key, or key and value. Removing based on key and
* value, will keep from removing duplicate metadata with the same key. It also
* allows removing all metadata matching key, if needed.
*
* @since 2.9.0
* @uses delete_metadata
* @link http://codex.wordpress.org/Function_Reference/delete_comment_meta
*
* @param int $comment_id comment ID
* @param string $meta_key Metadata name.
* @param mixed $meta_value Optional. Metadata value.
* @return bool True on success, false on failure.
*/
function delete_comment_meta($comment_id, $meta_key, $meta_value = '') {
return delete_metadata('comment', $comment_id, $meta_key, $meta_value);
}
/**
* Retrieve comment meta field for a comment.
*
* @since 2.9.0
* @uses get_metadata
* @link http://codex.wordpress.org/Function_Reference/get_comment_meta
*
* @param int $comment_id Comment ID.
* @param string $key Optional. The meta key to retrieve. By default, returns data for all keys.
* @param bool $single Whether to return a single value.
* @return mixed Will be an array if $single is false. Will be value of meta data field if $single
* is true.
*/
function get_comment_meta($comment_id, $key = '', $single = false) {
return get_metadata('comment', $comment_id, $key, $single);
}
/**
* Update comment meta field based on comment ID.
*
* Use the $prev_value parameter to differentiate between meta fields with the
* same key and comment ID.
*
* If the meta field for the comment does not exist, it will be added.
*
* @since 2.9.0
* @uses update_metadata
* @link http://codex.wordpress.org/Function_Reference/update_comment_meta
*
* @param int $comment_id Comment ID.
* @param string $meta_key Metadata key.
* @param mixed $meta_value Metadata value.
* @param mixed $prev_value Optional. Previous value to check before removing.
* @return int|bool Meta ID if the key didn't exist, true on successful update, false on failure.
*/
function update_comment_meta($comment_id, $meta_key, $meta_value, $prev_value = '') {
return update_metadata('comment', $comment_id, $meta_key, $meta_value, $prev_value);
}
/**
* Sets the cookies used to store an unauthenticated commentator's identity. Typically used
* to recall previous comments by this commentator that are still held in moderation.
*
* @param object $comment Comment object.
* @param object $user Comment author's object.
*
* @since 3.4.0
*/
function wp_set_comment_cookies($comment, $user) {
if ( $user->exists() )
return;
/**
* Filter the lifetime of the comment cookie in seconds.
*
* @since 2.8.0
*
* @param int $seconds Comment cookie lifetime. Default 30000000.
*/
$comment_cookie_lifetime = apply_filters( 'comment_cookie_lifetime', 30000000 );
setcookie('comment_author_' . COOKIEHASH, $comment->comment_author, time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN);
setcookie('comment_author_email_' . COOKIEHASH, $comment->comment_author_email, time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN);
setcookie('comment_author_url_' . COOKIEHASH, esc_url($comment->comment_author_url), time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN);
}
/**
* Sanitizes the cookies sent to the user already.
*
* Will only do anything if the cookies have already been created for the user.
* Mostly used after cookies had been sent to use elsewhere.
*
* @since 2.0.4
*/
function sanitize_comment_cookies() {
if ( isset( $_COOKIE['comment_author_' . COOKIEHASH] ) ) {
/**
* Filter the comment author's name cookie before it is set.
*
* When this filter hook is evaluated in wp_filter_comment(),
* the comment author's name string is passed.
*
* @since 1.5.0
*
* @param string $author_cookie The comment author name cookie.
*/
$comment_author = apply_filters( 'pre_comment_author_name', $_COOKIE['comment_author_' . COOKIEHASH] );
$comment_author = wp_unslash($comment_author);
$comment_author = esc_attr($comment_author);
$_COOKIE['comment_author_' . COOKIEHASH] = $comment_author;
}
if ( isset( $_COOKIE['comment_author_email_' . COOKIEHASH] ) ) {
/**
* Filter the comment author's email cookie before it is set.
*
* When this filter hook is evaluated in wp_filter_comment(),
* the comment author's email string is passed.
*
* @since 1.5.0
*
* @param string $author_email_cookie The comment author email cookie.
*/
$comment_author_email = apply_filters( 'pre_comment_author_email', $_COOKIE['comment_author_email_' . COOKIEHASH] );
$comment_author_email = wp_unslash($comment_author_email);
$comment_author_email = esc_attr($comment_author_email);
$_COOKIE['comment_author_email_'.COOKIEHASH] = $comment_author_email;
}
if ( isset( $_COOKIE['comment_author_url_' . COOKIEHASH] ) ) {
/**
* Filter the comment author's URL cookie before it is set.
*
* When this filter hook is evaluated in wp_filter_comment(),
* the comment author's URL string is passed.
*
* @since 1.5.0
*
* @param string $author_url_cookie The comment author URL cookie.
*/
$comment_author_url = apply_filters( 'pre_comment_author_url', $_COOKIE['comment_author_url_' . COOKIEHASH] );
$comment_author_url = wp_unslash($comment_author_url);
$_COOKIE['comment_author_url_'.COOKIEHASH] = $comment_author_url;
}
}
/**
* Validates whether this comment is allowed to be made.
*
* @since 2.0.0
* @uses $wpdb
*
* @param array $commentdata Contains information on the comment
* @return mixed Signifies the approval status (0|1|'spam')
*/
function wp_allow_comment($commentdata) {
global $wpdb;
extract($commentdata, EXTR_SKIP);
// Simple duplicate check
// expected_slashed ($comment_post_ID, $comment_author, $comment_author_email, $comment_content)
$dupe = $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_parent = %s AND comment_approved != 'trash' AND ( comment_author = %s ", wp_unslash( $comment_post_ID ), wp_unslash( $comment_parent ), wp_unslash( $comment_author ) );
if ( $comment_author_email )
$dupe .= $wpdb->prepare( "OR comment_author_email = %s ", wp_unslash( $comment_author_email ) );
$dupe .= $wpdb->prepare( ") AND comment_content = %s LIMIT 1", wp_unslash( $comment_content ) );
if ( $wpdb->get_var($dupe) ) {
/**
* Fires immediately after a duplicate comment is detected.
*
* @since 3.0.0
*
* @param array $commentdata Comment data.
*/
do_action( 'comment_duplicate_trigger', $commentdata );
if ( defined('DOING_AJAX') )
die( __('Duplicate comment detected; it looks as though you’ve already said that!') );
wp_die( __('Duplicate comment detected; it looks as though you’ve already said that!') );
}
/**
* Fires immediately before a comment is marked approved.
*
* Allows checking for comment flooding.
*
* @since 2.3.0
*
* @param string $comment_author_IP Comment author's IP address.
* @param string $comment_author_email Comment author's email.
* @param string $comment_date_gmt GMT date the comment was posted.
*/
do_action( 'check_comment_flood', $comment_author_IP, $comment_author_email, $comment_date_gmt );
if ( ! empty( $user_id ) ) {
$user = get_userdata( $user_id );
$post_author = $wpdb->get_var($wpdb->prepare("SELECT post_author FROM $wpdb->posts WHERE ID = %d LIMIT 1", $comment_post_ID));
}
if ( isset( $user ) && ( $user_id == $post_author || $user->has_cap( 'moderate_comments' ) ) ) {
// The author and the admins get respect.
$approved = 1;
} else {
// Everyone else's comments will be checked.
if ( check_comment($comment_author, $comment_author_email, $comment_author_url, $comment_content, $comment_author_IP, $comment_agent, $comment_type) )
$approved = 1;
else
$approved = 0;
if ( wp_blacklist_check($comment_author, $comment_author_email, $comment_author_url, $comment_content, $comment_author_IP, $comment_agent) )
$approved = 'spam';
}
/**
* Filter a comment's approval status before it is set.
*
* @since 2.1.0
*
* @param bool|string $approved The approval status. Accepts 1, 0, or 'spam'.
* @param array $commentdata Comment data.
*/
$approved = apply_filters( 'pre_comment_approved', $approved, $commentdata );
return $approved;
}
/**
* Check whether comment flooding is occurring.
*
* Won't run, if current user can manage options, so to not block
* administrators.
*
* @since 2.3.0
* @uses $wpdb
*
* @param string $ip Comment IP.
* @param string $email Comment author email address.
* @param string $date MySQL time string.
*/
function check_comment_flood_db( $ip, $email, $date ) {
global $wpdb;
if ( current_user_can( 'manage_options' ) )
return; // don't throttle admins
$hour_ago = gmdate( 'Y-m-d H:i:s', time() - HOUR_IN_SECONDS );
if ( $lasttime = $wpdb->get_var( $wpdb->prepare( "SELECT `comment_date_gmt` FROM `$wpdb->comments` WHERE `comment_date_gmt` >= %s AND ( `comment_author_IP` = %s OR `comment_author_email` = %s ) ORDER BY `comment_date_gmt` DESC LIMIT 1", $hour_ago, $ip, $email ) ) ) {
$time_lastcomment = mysql2date('U', $lasttime, false);
$time_newcomment = mysql2date('U', $date, false);
/**
* Filter the comment flood status.
*
* @since 2.1.0
*
* @param bool $bool Whether a comment flood is occurring. Default false.
* @param int $time_lastcomment Timestamp of when the last comment was posted.
* @param int $time_newcomment Timestamp of when the new comment was posted.
*/
$flood_die = apply_filters( 'comment_flood_filter', false, $time_lastcomment, $time_newcomment );
if ( $flood_die ) {
/**
* Fires before the comment flood message is triggered.
*
* @since 1.5.0
*
* @param int $time_lastcomment Timestamp of when the last comment was posted.
* @param int $time_newcomment Timestamp of when the new comment was posted.
*/
do_action( 'comment_flood_trigger', $time_lastcomment, $time_newcomment );
if ( defined('DOING_AJAX') )
die( __('You are posting comments too quickly. Slow down.') );
wp_die( __('You are posting comments too quickly. Slow down.'), '', array('response' => 403) );
}
}
}
/**
* Separates an array of comments into an array keyed by comment_type.
*
* @since 2.7.0
*
* @param array $comments Array of comments
* @return array Array of comments keyed by comment_type.
*/
function separate_comments(&$comments) {
$comments_by_type = array('comment' => array(), 'trackback' => array(), 'pingback' => array(), 'pings' => array());
$count = count($comments);
for ( $i = 0; $i < $count; $i++ ) {
$type = $comments[$i]->comment_type;
if ( empty($type) )
$type = 'comment';
$comments_by_type[$type][] = &$comments[$i];
if ( 'trackback' == $type || 'pingback' == $type )
$comments_by_type['pings'][] = &$comments[$i];
}
return $comments_by_type;
}
/**
* Calculate the total number of comment pages.
*
* @since 2.7.0
*
* @uses Walker_Comment
*
* @param array $comments Optional array of comment objects. Defaults to $wp_query->comments
* @param int $per_page Optional comments per page.
* @param boolean $threaded Optional control over flat or threaded comments.
* @return int Number of comment pages.
*/
function get_comment_pages_count( $comments = null, $per_page = null, $threaded = null ) {
global $wp_query;
if ( null === $comments && null === $per_page && null === $threaded && !empty($wp_query->max_num_comment_pages) )
return $wp_query->max_num_comment_pages;
if ( ( ! $comments || ! is_array( $comments ) ) && ! empty( $wp_query->comments ) )
$comments = $wp_query->comments;
if ( empty($comments) )
return 0;
if ( ! get_option( 'page_comments' ) )
return 1;
if ( !isset($per_page) )
$per_page = (int) get_query_var('comments_per_page');
if ( 0 === $per_page )
$per_page = (int) get_option('comments_per_page');
if ( 0 === $per_page )
return 1;
if ( !isset($threaded) )
$threaded = get_option('thread_comments');
if ( $threaded ) {
$walker = new Walker_Comment;
$count = ceil( $walker->get_number_of_root_elements( $comments ) / $per_page );
} else {
$count = ceil( count( $comments ) / $per_page );
}
return $count;
}
/**
* Calculate what page number a comment will appear on for comment paging.
*
* @since 2.7.0
* @uses get_comment() Gets the full comment of the $comment_ID parameter.
* @uses get_option() Get various settings to control function and defaults.
* @uses get_page_of_comment() Used to loop up to top level comment.
*
* @param int $comment_ID Comment ID.
* @param array $args Optional args.
* @return int|null Comment page number or null on error.
*/
function get_page_of_comment( $comment_ID, $args = array() ) {
global $wpdb;
if ( !$comment = get_comment( $comment_ID ) )
return;
$defaults = array( 'type' => 'all', 'page' => '', 'per_page' => '', 'max_depth' => '' );
$args = wp_parse_args( $args, $defaults );
if ( '' === $args['per_page'] && get_option('page_comments') )
$args['per_page'] = get_query_var('comments_per_page');
if ( empty($args['per_page']) ) {
$args['per_page'] = 0;
$args['page'] = 0;
}
if ( $args['per_page'] < 1 )
return 1;
if ( '' === $args['max_depth'] ) {
if ( get_option('thread_comments') )
$args['max_depth'] = get_option('thread_comments_depth');
else
$args['max_depth'] = -1;
}
// Find this comment's top level parent if threading is enabled
if ( $args['max_depth'] > 1 && 0 != $comment->comment_parent )
return get_page_of_comment( $comment->comment_parent, $args );
$allowedtypes = array(
'comment' => '',
'pingback' => 'pingback',
'trackback' => 'trackback',
);
$comtypewhere = ( 'all' != $args['type'] && isset($allowedtypes[$args['type']]) ) ? " AND comment_type = '" . $allowedtypes[$args['type']] . "'" : '';
// Count comments older than this one
$oldercoms = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_parent = 0 AND comment_approved = '1' AND comment_date_gmt < '%s'" . $comtypewhere, $comment->comment_post_ID, $comment->comment_date_gmt ) );
// No older comments? Then it's page #1.
if ( 0 == $oldercoms )
return 1;
// Divide comments older than this one by comments per page to get this comment's page number
return ceil( ( $oldercoms + 1 ) / $args['per_page'] );
}
/**
* Does comment contain blacklisted characters or words.
*
* @since 1.5.0
*
* @param string $author The author of the comment
* @param string $email The email of the comment
* @param string $url The url used in the comment
* @param string $comment The comment content
* @param string $user_ip The comment author IP address
* @param string $user_agent The author's browser user agent
* @return bool True if comment contains blacklisted content, false if comment does not
*/
function wp_blacklist_check($author, $email, $url, $comment, $user_ip, $user_agent) {
/**
* Fires before the comment is tested for blacklisted characters or words.
*
* @since 1.5.0
*
* @param string $author Comment author.
* @param string $email Comment author's email.
* @param string $url Comment author's URL.
* @param string $comment Comment content.
* @param string $user_ip Comment author's IP address.
* @param string $user_agent Comment author's browser user agent.
*/
do_action( 'wp_blacklist_check', $author, $email, $url, $comment, $user_ip, $user_agent );
$mod_keys = trim( get_option('blacklist_keys') );
if ( '' == $mod_keys )
return false; // If moderation keys are empty
$words = explode("\n", $mod_keys );
foreach ( (array) $words as $word ) {
$word = trim($word);
// Skip empty lines
if ( empty($word) ) { continue; }
// Do some escaping magic so that '#' chars in the
// spam words don't break things:
$word = preg_quote($word, '#');
$pattern = "#$word#i";
if (
preg_match($pattern, $author)
|| preg_match($pattern, $email)
|| preg_match($pattern, $url)
|| preg_match($pattern, $comment)
|| preg_match($pattern, $user_ip)
|| preg_match($pattern, $user_agent)
)
return true;
}
return false;
}
/**
* Retrieve total comments for blog or single post.
*
* The properties of the returned object contain the 'moderated', 'approved',
* and spam comments for either the entire blog or single post. Those properties
* contain the amount of comments that match the status. The 'total_comments'
* property contains the integer of total comments.
*
* The comment stats are cached and then retrieved, if they already exist in the
* cache.
*
* @since 2.5.0
*
* @param int $post_id Optional. Post ID.
* @return object Comment stats.
*/
function wp_count_comments( $post_id = 0 ) {
global $wpdb;
$post_id = (int) $post_id;
/**
* Filter the comments count for a given post.
*
* @since 2.7.0
*
* @param array $count An empty array.
* @param int $post_id The post ID.
*/
$stats = apply_filters( 'wp_count_comments', array(), $post_id );
if ( !empty($stats) )
return $stats;
$count = wp_cache_get("comments-{$post_id}", 'counts');
if ( false !== $count )
return $count;
$where = '';
if ( $post_id > 0 )
$where = $wpdb->prepare( "WHERE comment_post_ID = %d", $post_id );
$count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A );
$total = 0;
$approved = array('0' => 'moderated', '1' => 'approved', 'spam' => 'spam', 'trash' => 'trash', 'post-trashed' => 'post-trashed');
foreach ( (array) $count as $row ) {
// Don't count post-trashed toward totals
if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] )
$total += $row['num_comments'];
if ( isset( $approved[$row['comment_approved']] ) )
$stats[$approved[$row['comment_approved']]] = $row['num_comments'];
}
$stats['total_comments'] = $total;
foreach ( $approved as $key ) {
if ( empty($stats[$key]) )
$stats[$key] = 0;
}
$stats = (object) $stats;
wp_cache_set("comments-{$post_id}", $stats, 'counts');
return $stats;
}
/**
* Trashes or deletes a comment.
*
* The comment is moved to trash instead of permanently deleted unless trash is
* disabled, item is already in the trash, or $force_delete is true.
*
* The post comment count will be updated if the comment was approved and has a
* post ID available.
*
* @since 2.0.0
* @uses $wpdb
* @uses wp_transition_comment_status() Passes new and old comment status along with $comment object
*
* @param int $comment_id Comment ID
* @param bool $force_delete Whether to bypass trash and force deletion. Default is false.
* @return bool True on success, false on failure.
*/
function wp_delete_comment($comment_id, $force_delete = false) {
global $wpdb;
if (!$comment = get_comment($comment_id))
return false;
if ( !$force_delete && EMPTY_TRASH_DAYS && !in_array( wp_get_comment_status($comment_id), array( 'trash', 'spam' ) ) )
return wp_trash_comment($comment_id);
/**
* Fires immediately before a comment is deleted from the database.
*
* @since 1.2.0
*
* @param int $comment_id The comment ID.
*/
do_action( 'delete_comment', $comment_id );
// Move children up a level.
$children = $wpdb->get_col( $wpdb->prepare("SELECT comment_ID FROM $wpdb->comments WHERE comment_parent = %d", $comment_id) );
if ( !empty($children) ) {
$wpdb->update($wpdb->comments, array('comment_parent' => $comment->comment_parent), array('comment_parent' => $comment_id));
clean_comment_cache($children);
}
// Delete metadata
$meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->commentmeta WHERE comment_id = %d", $comment_id ) );
foreach ( $meta_ids as $mid )
delete_metadata_by_mid( 'comment', $mid );
if ( ! $wpdb->delete( $wpdb->comments, array( 'comment_ID' => $comment_id ) ) )
return false;
/**
* Fires immediately after a comment is deleted from the database.
*
* @since 2.9.0
*
* @param int $comment_id The comment ID.
*/
do_action( 'deleted_comment', $comment_id );
$post_id = $comment->comment_post_ID;
if ( $post_id && $comment->comment_approved == 1 )
wp_update_comment_count($post_id);
clean_comment_cache($comment_id);
/**
* Fires immediately before changing the comment's status to 'delete'.
*
* @since 1.5.0
*
* @param int $comment_id The comment ID.
* @param string $status The new 'delete' comment status.
*/
do_action( 'wp_set_comment_status', $comment_id, 'delete' );
wp_transition_comment_status('delete', $comment->comment_approved, $comment);
return true;
}
/**
* Moves a comment to the Trash
*
* If trash is disabled, comment is permanently deleted.
*
* @since 2.9.0
*
* @uses wp_delete_comment() if trash is disabled
*
* @param int $comment_id Comment ID.
* @return bool True on success, false on failure.
*/
function wp_trash_comment($comment_id) {
if ( !EMPTY_TRASH_DAYS )
return wp_delete_comment($comment_id, true);
if ( !$comment = get_comment($comment_id) )
return false;
/**
* Fires immediately before a comment is sent to the Trash.
*
* @since 2.9.0
*
* @param int $comment_id The comment ID.
*/
do_action( 'trash_comment', $comment_id );
if ( wp_set_comment_status($comment_id, 'trash') ) {
add_comment_meta($comment_id, '_wp_trash_meta_status', $comment->comment_approved);
add_comment_meta($comment_id, '_wp_trash_meta_time', time() );
/**
* Fires immediately after a comment is sent to Trash.
*
* @since 2.9.0
*
* @param int $comment_id The comment ID.
*/
do_action( 'trashed_comment', $comment_id );
return true;
}
return false;
}
/**
* Removes a comment from the Trash
*
* @since 2.9.0
*
* @param int $comment_id Comment ID.
* @return bool True on success, false on failure.
*/
function wp_untrash_comment($comment_id) {
if ( ! (int)$comment_id )
return false;
/**
* Fires immediately before a comment is restored from the Trash.
*
* @since 2.9.0
*
* @param int $comment_id The comment ID.
*/
do_action( 'untrash_comment', $comment_id );
$status = (string) get_comment_meta($comment_id, '_wp_trash_meta_status', true);
if ( empty($status) )
$status = '0';
if ( wp_set_comment_status($comment_id, $status) ) {
delete_comment_meta($comment_id, '_wp_trash_meta_time');
delete_comment_meta($comment_id, '_wp_trash_meta_status');
/**
* Fires immediately after a comment is restored from the Trash.
*
* @since 2.9.0
*
* @param int $comment_id The comment ID.
*/
do_action( 'untrashed_comment', $comment_id );
return true;
}
return false;
}
/**
* Marks a comment as Spam
*
* @since 2.9.0
*
* @param int $comment_id Comment ID.
* @return bool True on success, false on failure.
*/
function wp_spam_comment($comment_id) {
if ( !$comment = get_comment($comment_id) )
return false;
/**
* Fires immediately before a comment is marked as Spam.
*
* @since 2.9.0
*
* @param int $comment_id The comment ID.
*/
do_action( 'spam_comment', $comment_id );
if ( wp_set_comment_status($comment_id, 'spam') ) {
add_comment_meta($comment_id, '_wp_trash_meta_status', $comment->comment_approved);
/**
* Fires immediately after a comment is marked as Spam.
*
* @since 2.9.0
*
* @param int $comment_id The comment ID.
*/
do_action( 'spammed_comment', $comment_id );
return true;
}
return false;
}
/**
* Removes a comment from the Spam
*
* @since 2.9.0
*
* @param int $comment_id Comment ID.
* @return bool True on success, false on failure.
*/
function wp_unspam_comment($comment_id) {
if ( ! (int)$comment_id )
return false;
/**
* Fires immediately before a comment is unmarked as Spam.
*
* @since 2.9.0
*
* @param int $comment_id The comment ID.
*/
do_action( 'unspam_comment', $comment_id );
$status = (string) get_comment_meta($comment_id, '_wp_trash_meta_status', true);
if ( empty($status) )
$status = '0';
if ( wp_set_comment_status($comment_id, $status) ) {
delete_comment_meta($comment_id, '_wp_trash_meta_status');
/**
* Fires immediately after a comment is unmarked as Spam.
*
* @since 2.9.0
*
* @param int $comment_id The comment ID.
*/
do_action( 'unspammed_comment', $comment_id );
return true;
}
return false;
}
/**
* The status of a comment by ID.
*
* @since 1.0.0
*
* @param int $comment_id Comment ID
* @return string|bool Status might be 'trash', 'approved', 'unapproved', 'spam'. False on failure.
*/
function wp_get_comment_status($comment_id) {
$comment = get_comment($comment_id);
if ( !$comment )
return false;
$approved = $comment->comment_approved;
if ( $approved == null )
return false;
elseif ( $approved == '1' )
return 'approved';
elseif ( $approved == '0' )
return 'unapproved';
elseif ( $approved == 'spam' )
return 'spam';
elseif ( $approved == 'trash' )
return 'trash';
else
return false;
}
/**
* Call hooks for when a comment status transition occurs.
*
* Calls hooks for comment status transitions. If the new comment status is not the same
* as the previous comment status, then two hooks will be ran, the first is
* 'transition_comment_status' with new status, old status, and comment data. The
* next action called is 'comment_OLDSTATUS_to_NEWSTATUS' the NEWSTATUS is the
* $new_status parameter and the OLDSTATUS is $old_status parameter; it has the
* comment data.
*
* The final action will run whether or not the comment statuses are the same. The
* action is named 'comment_NEWSTATUS_COMMENTTYPE', NEWSTATUS is from the $new_status
* parameter and COMMENTTYPE is comment_type comment data.
*
* @since 2.7.0
*
* @param string $new_status New comment status.
* @param string $old_status Previous comment status.
* @param object $comment Comment data.
*/
function wp_transition_comment_status($new_status, $old_status, $comment) {
/*
* Translate raw statuses to human readable formats for the hooks.
* This is not a complete list of comment status, it's only the ones
* that need to be renamed
*/
$comment_statuses = array(
0 => 'unapproved',
'hold' => 'unapproved', // wp_set_comment_status() uses "hold"
1 => 'approved',
'approve' => 'approved', // wp_set_comment_status() uses "approve"
);
if ( isset($comment_statuses[$new_status]) ) $new_status = $comment_statuses[$new_status];
if ( isset($comment_statuses[$old_status]) ) $old_status = $comment_statuses[$old_status];
// Call the hooks
if ( $new_status != $old_status ) {
/**
* Fires when the comment status is in transition.
*
* @since 2.7.0
*
* @param int|string $new_status The new comment status.
* @param int|string $old_status The old comment status.
* @param object $comment The comment data.
*/
do_action( 'transition_comment_status', $new_status, $old_status, $comment );
/**
* Fires when the comment status is in transition from one specific status to another.
*
* The dynamic portions of the hook name, $old_status, and $new_status,
* refer to the old and new comment statuses, respectively.
*
* @since 2.7.0
*
* @param object $comment Comment object.
*/
do_action( "comment_{$old_status}_to_{$new_status}", $comment );
}
/**
* Fires when the status of a specific comment type is in transition.
*
* The dynamic portions of the hook name, $new_status, and $comment->comment_type,
* refer to the new comment status, and the type of comment, respectively.
*
* Typical comment types include an empty string (standard comment), 'pingback',
* or 'trackback'.
*
* @since 2.7.0
*
* @param int $comment_ID The comment ID.
* @param obj $comment Comment object.
*/
do_action( "comment_{$new_status}_{$comment->comment_type}", $comment->comment_ID, $comment );
}
/**
* Get current commenter's name, email, and URL.
*
* Expects cookies content to already be sanitized. User of this function might
* wish to recheck the returned array for validity.
*
* @see sanitize_comment_cookies() Use to sanitize cookies
*
* @since 2.0.4
*
* @return array Comment author, email, url respectively.
*/
function wp_get_current_commenter() {
// Cookies should already be sanitized.
$comment_author = '';
if ( isset($_COOKIE['comment_author_'.COOKIEHASH]) )
$comment_author = $_COOKIE['comment_author_'.COOKIEHASH];
$comment_author_email = '';
if ( isset($_COOKIE['comment_author_email_'.COOKIEHASH]) )
$comment_author_email = $_COOKIE['comment_author_email_'.COOKIEHASH];
$comment_author_url = '';
if ( isset($_COOKIE['comment_author_url_'.COOKIEHASH]) )
$comment_author_url = $_COOKIE['comment_author_url_'.COOKIEHASH];
/**
* Filter the current commenter's name, email, and URL.
*
* @since 3.1.0
*
* @param string $comment_author Comment author's name.
* @param string $comment_author_email Comment author's email.
* @param string $comment_author_url Comment author's URL.
*/
return apply_filters( 'wp_get_current_commenter', compact('comment_author', 'comment_author_email', 'comment_author_url') );
}
/**
* Inserts a comment to the database.
*
* The available comment data key names are 'comment_author_IP', 'comment_date',
* 'comment_date_gmt', 'comment_parent', 'comment_approved', and 'user_id'.
*
* @since 2.0.0
* @uses $wpdb
*
* @param array $commentdata Contains information on the comment.
* @return int The new comment's ID.
*/
function wp_insert_comment($commentdata) {
global $wpdb;
extract(wp_unslash($commentdata), EXTR_SKIP);
if ( ! isset($comment_author_IP) )
$comment_author_IP = '';
if ( ! isset($comment_date) )
$comment_date = current_time('mysql');
if ( ! isset($comment_date_gmt) )
$comment_date_gmt = get_gmt_from_date($comment_date);
if ( ! isset($comment_parent) )
$comment_parent = 0;
if ( ! isset($comment_approved) )
$comment_approved = 1;
if ( ! isset($comment_karma) )
$comment_karma = 0;
if ( ! isset($user_id) )
$user_id = 0;
if ( ! isset($comment_type) )
$comment_type = '';
$data = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_author_IP', 'comment_date', 'comment_date_gmt', 'comment_content', 'comment_karma', 'comment_approved', 'comment_agent', 'comment_type', 'comment_parent', 'user_id');
$wpdb->insert($wpdb->comments, $data);
$id = (int) $wpdb->insert_id;
if ( $comment_approved == 1 )
wp_update_comment_count($comment_post_ID);
$comment = get_comment($id);
/**
* Fires immediately after a comment is inserted into the database.
*
* @since 2.8.0
*
* @param int $id The comment ID.
* @param obj $comment Comment object.
*/
do_action( 'wp_insert_comment', $id, $comment );
wp_cache_set( 'last_changed', microtime(), 'comment' );
return $id;
}
/**
* Filters and sanitizes comment data.
*
* Sets the comment data 'filtered' field to true when finished. This can be
* checked as to whether the comment should be filtered and to keep from
* filtering the same comment more than once.
*
* @since 2.0.0
*
* @param array $commentdata Contains information on the comment.
* @return array Parsed comment information.
*/
function wp_filter_comment($commentdata) {
if ( isset( $commentdata['user_ID'] ) ) {
/**
* Filter the comment author's user id before it is set.
*
* The first time this filter is evaluated, 'user_ID' is checked
* (for back-compat), followed by the standard 'user_id' value.
*
* @since 1.5.0
*
* @param int $user_ID The comment author's user ID.
*/
$commentdata['user_id'] = apply_filters( 'pre_user_id', $commentdata['user_ID'] );
} elseif ( isset( $commentdata['user_id'] ) ) {
/** This filter is documented in wp-includes/comment.php */
$commentdata['user_id'] = apply_filters( 'pre_user_id', $commentdata['user_id'] );
}
/**
* Filter the comment author's browser user agent before it is set.
*
* @since 1.5.0
*
* @param int $comment_agent The comment author's browser user agent.
*/
$commentdata['comment_agent'] = apply_filters( 'pre_comment_user_agent', ( isset( $commentdata['comment_agent'] ) ? $commentdata['comment_agent'] : '' ) );
/** This filter is documented in wp-includes/comment.php */
$commentdata['comment_author'] = apply_filters( 'pre_comment_author_name', $commentdata['comment_author'] );
/**
* Filter the comment content before it is set.
*
* @since 1.5.0
*
* @param int $comment_content The comment content.
*/
$commentdata['comment_content'] = apply_filters( 'pre_comment_content', $commentdata['comment_content'] );
/**
* Filter the comment author's IP before it is set.
*
* @since 1.5.0
*
* @param int $comment_author_ip The comment author's IP.
*/
$commentdata['comment_author_IP'] = apply_filters( 'pre_comment_user_ip', $commentdata['comment_author_IP'] );
/** This filter is documented in wp-includes/comment.php */
$commentdata['comment_author_url'] = apply_filters( 'pre_comment_author_url', $commentdata['comment_author_url'] );
/** This filter is documented in wp-includes/comment.php */
$commentdata['comment_author_email'] = apply_filters( 'pre_comment_author_email', $commentdata['comment_author_email'] );
$commentdata['filtered'] = true;
return $commentdata;
}
/**
* Whether a comment should be blocked because of comment flood.
*
* @since 2.1.0
*
* @param bool $block Whether plugin has already blocked comment.
* @param int $time_lastcomment Timestamp for last comment.
* @param int $time_newcomment Timestamp for new comment.
* @return bool Whether comment should be blocked.
*/
function wp_throttle_comment_flood($block, $time_lastcomment, $time_newcomment) {
if ( $block ) // a plugin has already blocked... we'll let that decision stand
return $block;
if ( ($time_newcomment - $time_lastcomment) < 15 )
return true;
return false;
}
/**
* Adds a new comment to the database.
*
* Filters new comment to ensure that the fields are sanitized and valid before
* inserting comment into database. Calls 'comment_post' action with comment ID
* 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
* @param array $commentdata Contains information on the comment.
* @return int The ID of the comment after adding.
*/
function wp_new_comment( $commentdata ) {
/**
* Filter a comment's data before it is sanitized and inserted into the database.
*
* @since 1.5.0
*
* @param array $commentdata Comment data.
*/
$commentdata = apply_filters( 'preprocess_comment', $commentdata );
$commentdata['comment_post_ID'] = (int) $commentdata['comment_post_ID'];
if ( isset($commentdata['user_ID']) )
$commentdata['user_id'] = $commentdata['user_ID'] = (int) $commentdata['user_ID'];
elseif ( isset($commentdata['user_id']) )
$commentdata['user_id'] = (int) $commentdata['user_id'];
$commentdata['comment_parent'] = isset($commentdata['comment_parent']) ? absint($commentdata['comment_parent']) : 0;
$parent_status = ( 0 < $commentdata['comment_parent'] ) ? wp_get_comment_status($commentdata['comment_parent']) : '';
$commentdata['comment_parent'] = ( 'approved' == $parent_status || 'unapproved' == $parent_status ) ? $commentdata['comment_parent'] : 0;
$commentdata['comment_author_IP'] = preg_replace( '/[^0-9a-fA-F:., ]/', '',$_SERVER['REMOTE_ADDR'] );
$commentdata['comment_agent'] = isset( $_SERVER['HTTP_USER_AGENT'] ) ? substr( $_SERVER['HTTP_USER_AGENT'], 0, 254 ) : '';
$commentdata['comment_date'] = current_time('mysql');
$commentdata['comment_date_gmt'] = current_time('mysql', 1);
$commentdata = wp_filter_comment($commentdata);
$commentdata['comment_approved'] = wp_allow_comment($commentdata);
$comment_ID = wp_insert_comment($commentdata);
/**
* Fires immediately after a comment is inserted into the database.
*
* @since 1.2.0
*
* @param int $comment_ID The comment ID.
* @param int $comment_approved 1 (true) if the comment is approved, 0 (false) if not.
*/
do_action( 'comment_post', $comment_ID, $commentdata['comment_approved'] );
if ( 'spam' !== $commentdata['comment_approved'] ) { // If it's spam save it silently for later crunching
if ( '0' == $commentdata['comment_approved'] ) {
wp_notify_moderator( $comment_ID );
}
// wp_notify_postauthor() checks if notifying the author of their own comment.
// By default, it won't, but filters can override this.
if ( get_option( 'comments_notify' ) && $commentdata['comment_approved'] ) {
wp_notify_postauthor( $comment_ID );
}
}
return $comment_ID;
}
/**
* Sets the status of a comment.
*
* The 'wp_set_comment_status' action is called after the comment is handled.
* If the comment status is not in the list, then false is returned.
*
* @since 1.0.0
* @uses wp_transition_comment_status() Passes new and old comment status along with $comment object
*
* @param int $comment_id Comment ID.
* @param string $comment_status New comment status, either 'hold', 'approve', 'spam', or 'trash'.
* @param bool $wp_error Whether to return a WP_Error object if there is a failure. Default is false.
* @return bool|WP_Error True on success, false or WP_Error on failure.
*/
function wp_set_comment_status($comment_id, $comment_status, $wp_error = false) {
global $wpdb;
$status = '0';
switch ( $comment_status ) {
case 'hold':
case '0':
$status = '0';
break;
case 'approve':
case '1':
$status = '1';
if ( get_option('comments_notify') ) {
wp_notify_postauthor( $comment_id );
}
break;
case 'spam':
$status = 'spam';
break;
case 'trash':
$status = 'trash';
break;
default:
return false;
}
$comment_old = clone get_comment($comment_id);
if ( !$wpdb->update( $wpdb->comments, array('comment_approved' => $status), array('comment_ID' => $comment_id) ) ) {
if ( $wp_error )
return new WP_Error('db_update_error', __('Could not update comment status'), $wpdb->last_error);
else
return false;
}
clean_comment_cache($comment_id);
$comment = get_comment($comment_id);
/**
* Fires after a comment status has been updated in the database.
*
* The hook also fires immediately before comment status transition hooks are fired.
*
* @since 1.5.0
*
* @param int $comment_id The comment ID.
* @param string|bool $comment_status The comment status. Possible values include 'hold',
* 'approve', 'spam', 'trash', or false.
*/
do_action( 'wp_set_comment_status', $comment_id, $comment_status );
wp_transition_comment_status($comment_status, $comment_old->comment_approved, $comment);
wp_update_comment_count($comment->comment_post_ID);
return true;
}
/**
* Updates an existing comment in the database.
*
* Filters the comment and makes sure certain fields are valid before updating.
*
* @since 2.0.0
* @uses $wpdb
* @uses wp_transition_comment_status() Passes new and old comment status along with $comment object
*
* @param array $commentarr Contains information on the comment.
* @return int Comment was updated if value is 1, or was not updated if value is 0.
*/
function wp_update_comment($commentarr) {
global $wpdb;
// First, get all of the original fields
$comment = get_comment($commentarr['comment_ID'], ARRAY_A);
if ( empty( $comment ) )
return 0;
// Escape data pulled from DB.
$comment = wp_slash($comment);
$old_status = $comment['comment_approved'];
// Merge old and new fields with new fields overwriting old ones.
$commentarr = array_merge($comment, $commentarr);
$commentarr = wp_filter_comment( $commentarr );
// Now extract the merged array.
extract(wp_unslash($commentarr), EXTR_SKIP);
/**
* Filter the comment content before it is updated in the database.
*
* @since 1.5.0
*
* @param string $comment_content The comment data.
*/
$comment_content = apply_filters( 'comment_save_pre', $comment_content );
$comment_date_gmt = get_gmt_from_date($comment_date);
if ( !isset($comment_approved) )
$comment_approved = 1;
else if ( 'hold' == $comment_approved )
$comment_approved = 0;
else if ( 'approve' == $comment_approved )
$comment_approved = 1;
$data = compact( 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_parent' );
$rval = $wpdb->update( $wpdb->comments, $data, compact( 'comment_ID' ) );
clean_comment_cache($comment_ID);
wp_update_comment_count($comment_post_ID);
/**
* Fires immediately after a comment is updated in the database.
*
* The hook also fires immediately before comment status transition hooks are fired.
*
* @since 1.2.0
*
* @param int $comment_ID The comment ID.
*/
do_action( 'edit_comment', $comment_ID );
$comment = get_comment($comment_ID);
wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
return $rval;
}
/**
* Whether to defer comment counting.
*
* When setting $defer to true, all post comment counts will not be updated
* until $defer is set to false. When $defer is set to false, then all
* previously deferred updated post comment counts will then be automatically
* updated without having to call wp_update_comment_count() after.
*
* @since 2.5.0
* @staticvar bool $_defer
*
* @param bool $defer
* @return unknown
*/
function wp_defer_comment_counting($defer=null) {
static $_defer = false;
if ( is_bool($defer) ) {
$_defer = $defer;
// flush any deferred counts
if ( !$defer )
wp_update_comment_count( null, true );
}
return $_defer;
}
/**
* Updates the comment count for post(s).
*
* When $do_deferred is false (is by default) and the comments have been set to
* be deferred, the post_id will be added to a queue, which will be updated at a
* later date and only updated once per post ID.
*
* If the comments have not be set up to be deferred, then the post will be
* updated. When $do_deferred is set to true, then all previous deferred post
* IDs will be updated along with the current $post_id.
*
* @since 2.1.0
* @see wp_update_comment_count_now() For what could cause a false return value
*
* @param int $post_id Post ID
* @param bool $do_deferred Whether to process previously deferred post comment counts
* @return bool True on success, false on failure
*/
function wp_update_comment_count($post_id, $do_deferred=false) {
static $_deferred = array();
if ( $do_deferred ) {
$_deferred = array_unique($_deferred);
foreach ( $_deferred as $i => $_post_id ) {
wp_update_comment_count_now($_post_id);
unset( $_deferred[$i] ); /** @todo Move this outside of the foreach and reset $_deferred to an array instead */
}
}
if ( wp_defer_comment_counting() ) {
$_deferred[] = $post_id;
return true;
}
elseif ( $post_id ) {
return wp_update_comment_count_now($post_id);
}
}
/**
* Updates the comment count for the post.
*
* @since 2.5.0
* @uses $wpdb
*
* @param int $post_id Post ID
* @return bool True on success, false on '0' $post_id or if post with ID does not exist.
*/
function wp_update_comment_count_now($post_id) {
global $wpdb;
$post_id = (int) $post_id;
if ( !$post_id )
return false;
if ( !$post = get_post($post_id) )
return false;
$old = (int) $post->comment_count;
$new = (int) $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '1'", $post_id) );
$wpdb->update( $wpdb->posts, array('comment_count' => $new), array('ID' => $post_id) );
clean_post_cache( $post );
/**
* Fires immediately after a post's comment count is updated in the database.
*
* @since 2.3.0
*
* @param int $post_id Post ID.
* @param int $new The new comment count.
* @param int $old The old comment count.
*/
do_action( 'wp_update_comment_count', $post_id, $new, $old );
/** This action is documented in wp-includes/post.php */
do_action( 'edit_post', $post_id, $post );
return true;
}
//
// Ping and trackback functions.
//
/**
* Finds a pingback server URI based on the given URL.
*
* Checks the HTML for the rel="pingback" link and x-pingback headers. It does
* a check for the x-pingback headers first and returns that, if available. The
* check for the rel="pingback" has more overhead than just the header.
*
* @since 1.5.0
*
* @param string $url URL to ping.
* @param int $deprecated Not Used.
* @return bool|string False on failure, string containing URI on success.
*/
function discover_pingback_server_uri( $url, $deprecated = '' ) {
if ( !empty( $deprecated ) )
_deprecated_argument( __FUNCTION__, '2.7' );
$pingback_str_dquote = 'rel="pingback"';
$pingback_str_squote = 'rel=\'pingback\'';
/** @todo Should use Filter Extension or custom preg_match instead. */
$parsed_url = parse_url($url);
if ( ! isset( $parsed_url['host'] ) ) // Not an URL. This should never happen.
return false;
//Do not search for a pingback server on our own uploads
$uploads_dir = wp_upload_dir();
if ( 0 === strpos($url, $uploads_dir['baseurl']) )
return false;
$response = wp_safe_remote_head( $url, array( 'timeout' => 2, 'httpversion' => '1.0' ) );
if ( is_wp_error( $response ) )
return false;
if ( wp_remote_retrieve_header( $response, 'x-pingback' ) )
return wp_remote_retrieve_header( $response, 'x-pingback' );
// Not an (x)html, sgml, or xml page, no use going further.
if ( preg_match('#(image|audio|video|model)/#is', wp_remote_retrieve_header( $response, 'content-type' )) )
return false;
// Now do a GET since we're going to look in the html headers (and we're sure it's not a binary file)
$response = wp_safe_remote_get( $url, array( 'timeout' => 2, 'httpversion' => '1.0' ) );
if ( is_wp_error( $response ) )
return false;
$contents = wp_remote_retrieve_body( $response );
$pingback_link_offset_dquote = strpos($contents, $pingback_str_dquote);
$pingback_link_offset_squote = strpos($contents, $pingback_str_squote);
if ( $pingback_link_offset_dquote || $pingback_link_offset_squote ) {
$quote = ($pingback_link_offset_dquote) ? '"' : '\'';
$pingback_link_offset = ($quote=='"') ? $pingback_link_offset_dquote : $pingback_link_offset_squote;
$pingback_href_pos = @strpos($contents, 'href=', $pingback_link_offset);
$pingback_href_start = $pingback_href_pos+6;
$pingback_href_end = @strpos($contents, $quote, $pingback_href_start);
$pingback_server_url_len = $pingback_href_end - $pingback_href_start;
$pingback_server_url = substr($contents, $pingback_href_start, $pingback_server_url_len);
// We may find rel="pingback" but an incomplete pingback URL
if ( $pingback_server_url_len > 0 ) { // We got it!
return $pingback_server_url;
}
}
return false;
}
/**
* Perform all pingbacks, enclosures, trackbacks, and send to pingback services.
*
* @since 2.1.0
* @uses $wpdb
*/
function do_all_pings() {
global $wpdb;
// Do pingbacks
while ($ping = $wpdb->get_row("SELECT ID, post_content, meta_id FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_pingme' LIMIT 1")) {
delete_metadata_by_mid( 'post', $ping->meta_id );
pingback( $ping->post_content, $ping->ID );
}
// Do Enclosures
while ($enclosure = $wpdb->get_row("SELECT ID, post_content, meta_id FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_encloseme' LIMIT 1")) {
delete_metadata_by_mid( 'post', $enclosure->meta_id );
do_enclose( $enclosure->post_content, $enclosure->ID );
}
// Do Trackbacks
$trackbacks = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE to_ping <> '' AND post_status = 'publish'");
if ( is_array($trackbacks) )
foreach ( $trackbacks as $trackback )
do_trackbacks($trackback);
//Do Update Services/Generic Pings
generic_ping();
}
/**
* Perform trackbacks.
*
* @since 1.5.0
* @uses $wpdb
*
* @param int $post_id Post ID to do trackbacks on.
*/
function do_trackbacks($post_id) {
global $wpdb;
$post = get_post( $post_id );
$to_ping = get_to_ping($post_id);
$pinged = get_pung($post_id);
if ( empty($to_ping) ) {
$wpdb->update($wpdb->posts, array('to_ping' => ''), array('ID' => $post_id) );
return;
}
if ( empty($post->post_excerpt) ) {
/** This filter is documented in wp-admin/post-template.php */
$excerpt = apply_filters( 'the_content', $post->post_content, $post->ID );
} else {
/** This filter is documented in wp-admin/post-template.php */
$excerpt = apply_filters( 'the_excerpt', $post->post_excerpt );
}
$excerpt = str_replace(']]>', ']]>', $excerpt);
$excerpt = wp_html_excerpt($excerpt, 252, '…');
/** This filter is documented in wp-includes/post-template.php */
$post_title = apply_filters( 'the_title', $post->post_title, $post->ID );
$post_title = strip_tags($post_title);
if ( $to_ping ) {
foreach ( (array) $to_ping as $tb_ping ) {
$tb_ping = trim($tb_ping);
if ( !in_array($tb_ping, $pinged) ) {
trackback($tb_ping, $post_title, $excerpt, $post_id);
$pinged[] = $tb_ping;
} else {
$wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET to_ping = TRIM(REPLACE(to_ping, %s, '')) WHERE ID = %d", $tb_ping, $post_id) );
}
}
}
}
/**
* Sends pings to all of the ping site services.
*
* @since 1.2.0
*
* @param int $post_id Post ID. Not actually used.
* @return int Same as Post ID from parameter
*/
function generic_ping($post_id = 0) {
$services = get_option('ping_sites');
$services = explode("\n", $services);
foreach ( (array) $services as $service ) {
$service = trim($service);
if ( '' != $service )
weblog_ping($service);
}
return $post_id;
}
/**
* Pings back the links found in a post.
*
* @since 0.71
* @uses $wp_version
* @uses IXR_Client
*
* @param string $content Post content to check for links.
* @param int $post_ID Post ID.
*/
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();
$pung = get_pung($post_ID);
// Step 1
// Parsing the post, external links (if any) are stored in the $post_links array
$post_links_temp = wp_extract_urls( $content );
// Step 2.
// Walking thru the links array
// first we get rid of links pointing to sites, not to specific files
// Example:
// http://dummy-weblog.org
// http://dummy-weblog.org/
// http://dummy-weblog.org/post.php
// We don't wanna ping first and second types, even if they have a valid <link/>
foreach ( (array) $post_links_temp as $link_test ) :
if ( !in_array($link_test, $pung) && (url_to_postid($link_test) != $post_ID) // If we haven't pung it already and it isn't a link to itself
&& !is_local_attachment($link_test) ) : // Also, let's never ping local attachments.
if ( $test = @parse_url($link_test) ) {
if ( isset($test['query']) )
$post_links[] = $link_test;
elseif ( isset( $test['path'] ) && ( $test['path'] != '/' ) && ( $test['path'] != '' ) )
$post_links[] = $link_test;
}
endif;
endforeach;
$post_links = array_unique( $post_links );
/**
* Fires just before pinging back links found in a post.
*
* @since 2.0.0
*
* @param array &$post_links An array of post links to be checked, passed by reference.
* @param array &$pung Whether a link has already been pinged, passed by reference.
* @param int $post_ID The post ID.
*/
do_action_ref_array( 'pre_ping', array( &$post_links, &$pung, $post_ID ) );
foreach ( (array) $post_links as $pagelinkedto ) {
$pingback_server_url = discover_pingback_server_uri( $pagelinkedto );
if ( $pingback_server_url ) {
@ set_time_limit( 60 );
// Now, the RPC call
$pagelinkedfrom = get_permalink($post_ID);
// using a timeout of 3 seconds should be enough to cover slow servers
$client = new WP_HTTP_IXR_Client($pingback_server_url);
$client->timeout = 3;
/**
* Filter the user agent sent when pinging-back a URL.
*
* @since 2.9.0
*
* @param string $concat_useragent The user agent concatenated with ' -- WordPress/'
* and the WordPress version.
* @param string $useragent The useragent.
* @param string $pingback_server_url The server URL being linked to.
* @param string $pagelinkedto URL of page linked to.
* @param string $pagelinkedfrom URL of page linked from.
*/
$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
$client->debug = false;
if ( $client->query('pingback.ping', $pagelinkedfrom, $pagelinkedto) || ( isset($client->error->code) && 48 == $client->error->code ) ) // Already registered
add_ping( $post_ID, $pagelinkedto );
}
}
}
/**
* Check whether blog is public before returning sites.
*
* @since 2.1.0
*
* @param mixed $sites Will return if blog is public, will not return if not public.
* @return mixed Empty string if blog is not public, returns $sites, if site is public.
*/
function privacy_ping_filter($sites) {
if ( '0' != get_option('blog_public') )
return $sites;
else
return '';
}
/**
* Send a Trackback.
*
* Updates database when sending trackback to prevent duplicates.
*
* @since 0.71
* @uses $wpdb
*
* @param string $trackback_url URL to send trackbacks.
* @param string $title Title of post.
* @param string $excerpt Excerpt of post.
* @param int $ID Post ID.
* @return mixed Database query from update.
*/
function trackback($trackback_url, $title, $excerpt, $ID) {
global $wpdb;
if ( empty($trackback_url) )
return;
$options = array();
$options['timeout'] = 4;
$options['body'] = array(
'title' => $title,
'url' => get_permalink($ID),
'blog_name' => get_option('blogname'),
'excerpt' => $excerpt
);
$response = wp_safe_remote_post( $trackback_url, $options );
if ( is_wp_error( $response ) )
return;
$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) );
}
/**
* Send a pingback.
*
* @since 1.2.0
* @uses $wp_version
* @uses IXR_Client
*
* @param string $server Host of blog to connect to.
* @param string $path Path to send the ping.
*/
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 WP_HTTP_IXR_Client($server, ((!strlen(trim($path)) || ('/' == $path)) ? false : $path));
$client->timeout = 3;
$client->useragent .= ' -- WordPress/'.$wp_version;
// when set to true, this outputs debug messages by itself
$client->debug = false;
$home = trailingslashit( home_url() );
if ( !$client->query('weblogUpdates.extendedPing', get_option('blogname'), $home, get_bloginfo('rss2_url') ) ) // then try a normal ping
$client->query('weblogUpdates.ping', get_option('blogname'), $home);
}
/**
* Default filter attached to pingback_ping_source_uri to validate the pingback's Source URI
*
* @since 3.5.1
* @see wp_http_validate_url()
*
* @param string $source_uri
* @return string
*/
function pingback_ping_source_uri( $source_uri ) {
return (string) wp_http_validate_url( $source_uri );
}
/**
* Default filter attached to xmlrpc_pingback_error.
*
* Returns a generic pingback error code unless the error code is 48,
* which reports that the pingback is already registered.
*
* @since 3.5.1
* @link http://www.hixie.ch/specs/pingback/pingback#TOC3
*
* @param IXR_Error $ixr_error
* @return IXR_Error
*/
function xmlrpc_pingback_error( $ixr_error ) {
if ( $ixr_error->code === 48 )
return $ixr_error;
return new IXR_Error( 0, '' );
}
//
// Cache
//
/**
* Removes comment ID from the comment cache.
*
* @since 2.3.0
*
* @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', microtime(), 'comment' );
}
/**
* Updates the comment cache of given comments.
*
* Will add the comments in $comments to the cache. If comment ID already exists
* in the comment cache then it will not be updated. The comment is added to the
* cache using the comment group with the key using the ID of the comments.
*
* @since 2.3.0
*
* @param array $comments Array of comment row objects
*/
function update_comment_cache($comments) {
foreach ( (array) $comments as $comment )
wp_cache_add($comment->comment_ID, $comment, 'comment');
}
//
// Internal
//
/**
* Close comments on old posts on the fly, without any extra DB queries. Hooked to the_posts.
*
* @access private
* @since 2.7.0
*
* @param object $posts Post data object.
* @param object $query Query object.
* @return object
*/
function _close_comments_for_old_posts( $posts, $query ) {
if ( empty( $posts ) || ! $query->is_singular() || ! get_option( 'close_comments_for_old_posts' ) )
return $posts;
/**
* Filter the list of post types to automatically close comments for.
*
* @since 3.2.0
*
* @param array $post_types An array of registered post types. Default array with 'post'.
*/
$post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) );
if ( ! in_array( $posts[0]->post_type, $post_types ) )
return $posts;
$days_old = (int) get_option( 'close_comments_days_old' );
if ( ! $days_old )
return $posts;
if ( time() - strtotime( $posts[0]->post_date_gmt ) > ( $days_old * DAY_IN_SECONDS ) ) {
$posts[0]->comment_status = 'closed';
$posts[0]->ping_status = 'closed';
}
return $posts;
}
/**
* Close comments on an old post. Hooked to comments_open and pings_open.
*
* @access private
* @since 2.7.0
*
* @param bool $open Comments open or closed
* @param int $post_id Post ID
* @return bool $open
*/
function _close_comments_for_old_post( $open, $post_id ) {
if ( ! $open )
return $open;
if ( !get_option('close_comments_for_old_posts') )
return $open;
$days_old = (int) get_option('close_comments_days_old');
if ( !$days_old )
return $open;
$post = get_post($post_id);
/** This filter is documented in wp-includes/comment.php */
$post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) );
if ( ! in_array( $post->post_type, $post_types ) )
return $open;
if ( time() - strtotime( $post->post_date_gmt ) > ( $days_old * DAY_IN_SECONDS ) )
return false;
return $open;
}
| 01-wordpress-paypal | trunk/wp-includes/comment.php | PHP | gpl3 | 77,129 |
<?php
/**
* WordPress Imagick Image Editor
*
* @package WordPress
* @subpackage Image_Editor
*/
/**
* WordPress Image Editor Class for Image Manipulation through Imagick PHP Module
*
* @since 3.5.0
* @package WordPress
* @subpackage Image_Editor
* @uses WP_Image_Editor Extends class
*/
class WP_Image_Editor_Imagick extends WP_Image_Editor {
protected $image = null; // Imagick Object
function __destruct() {
if ( $this->image instanceof Imagick ) {
// we don't need the original in memory anymore
$this->image->clear();
$this->image->destroy();
}
}
/**
* Checks to see if current environment supports Imagick.
*
* We require Imagick 2.2.0 or greater, based on whether the queryFormats()
* method can be called statically.
*
* @since 3.5.0
* @access public
*
* @return boolean
*/
public static function test( $args = array() ) {
// First, test Imagick's extension and classes.
if ( ! extension_loaded( 'imagick' ) || ! class_exists( 'Imagick' ) || ! class_exists( 'ImagickPixel' ) )
return false;
if ( version_compare( phpversion( 'imagick' ), '2.2.0', '<' ) )
return false;
$required_methods = array(
'clear',
'destroy',
'valid',
'getimage',
'writeimage',
'getimageblob',
'getimagegeometry',
'getimageformat',
'setimageformat',
'setimagecompression',
'setimagecompressionquality',
'setimagepage',
'scaleimage',
'cropimage',
'rotateimage',
'flipimage',
'flopimage',
);
// Now, test for deep requirements within Imagick.
if ( ! defined( 'imagick::COMPRESSION_JPEG' ) )
return false;
if ( array_diff( $required_methods, get_class_methods( 'Imagick' ) ) )
return false;
return true;
}
/**
* Checks to see if editor supports the mime-type specified.
*
* @since 3.5.0
* @access public
*
* @param string $mime_type
* @return boolean
*/
public static function supports_mime_type( $mime_type ) {
$imagick_extension = strtoupper( self::get_extension( $mime_type ) );
if ( ! $imagick_extension )
return false;
// setIteratorIndex is optional unless mime is an animated format.
// Here, we just say no if you are missing it and aren't loading a jpeg.
if ( ! method_exists( 'Imagick', 'setIteratorIndex' ) && $mime_type != 'image/jpeg' )
return false;
try {
return ( (bool) @Imagick::queryFormats( $imagick_extension ) );
}
catch ( Exception $e ) {
return false;
}
}
/**
* Loads image from $this->file into new Imagick Object.
*
* @since 3.5.0
* @access protected
*
* @return boolean|WP_Error True if loaded; WP_Error on failure.
*/
public function load() {
if ( $this->image instanceof Imagick )
return true;
if ( ! is_file( $this->file ) && ! preg_match( '|^https?://|', $this->file ) )
return new WP_Error( 'error_loading_image', __('File doesn’t exist?'), $this->file );
/** This filter is documented in wp-includes/class-wp-image-editor-imagick.php */
// Even though Imagick uses less PHP memory than GD, set higher limit for users that have low PHP.ini limits
@ini_set( 'memory_limit', apply_filters( 'image_memory_limit', WP_MAX_MEMORY_LIMIT ) );
try {
$this->image = new Imagick( $this->file );
if( ! $this->image->valid() )
return new WP_Error( 'invalid_image', __('File is not an image.'), $this->file);
// Select the first frame to handle animated images properly
if ( is_callable( array( $this->image, 'setIteratorIndex' ) ) )
$this->image->setIteratorIndex(0);
$this->mime_type = $this->get_mime_type( $this->image->getImageFormat() );
}
catch ( Exception $e ) {
return new WP_Error( 'invalid_image', $e->getMessage(), $this->file );
}
$updated_size = $this->update_size();
if ( is_wp_error( $updated_size ) )
return $updated_size;
return $this->set_quality( $this->quality );
}
/**
* Sets Image Compression quality on a 1-100% scale.
*
* @since 3.5.0
* @access public
*
* @param int $quality Compression Quality. Range: [1,100]
* @return boolean|WP_Error True if set successfully; WP_Error on failure.
*/
public function set_quality( $quality = null ) {
$quality_result = parent::set_quality( $quality );
if ( is_wp_error( $quality_result ) ) {
return $quality_result;
} else {
$quality = $this->quality;
}
try {
if ( 'image/jpeg' == $this->mime_type ) {
$this->image->setImageCompressionQuality( $quality );
$this->image->setImageCompression( imagick::COMPRESSION_JPEG );
}
else {
$this->image->setImageCompressionQuality( $quality );
}
}
catch ( Exception $e ) {
return new WP_Error( 'image_quality_error', $e->getMessage() );
}
return true;
}
/**
* Sets or updates current image size.
*
* @since 3.5.0
* @access protected
*
* @param int $width
* @param int $height
*/
protected function update_size( $width = null, $height = null ) {
$size = null;
if ( !$width || !$height ) {
try {
$size = $this->image->getImageGeometry();
}
catch ( Exception $e ) {
return new WP_Error( 'invalid_image', __('Could not read image size'), $this->file );
}
}
if ( ! $width )
$width = $size['width'];
if ( ! $height )
$height = $size['height'];
return parent::update_size( $width, $height );
}
/**
* Resizes current image.
*
* At minimum, either a height or width must be provided.
* If one of the two is set to null, the resize will
* maintain aspect ratio according to the provided dimension.
*
* @since 3.5.0
* @access public
*
* @param int|null $max_w Image width.
* @param int|null $max_h Image height.
* @param boolean $crop
* @return boolean|WP_Error
*/
public function resize( $max_w, $max_h, $crop = false ) {
if ( ( $this->size['width'] == $max_w ) && ( $this->size['height'] == $max_h ) )
return true;
$dims = image_resize_dimensions( $this->size['width'], $this->size['height'], $max_w, $max_h, $crop );
if ( ! $dims )
return new WP_Error( 'error_getting_dimensions', __('Could not calculate resized image dimensions') );
list( $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h ) = $dims;
if ( $crop ) {
return $this->crop( $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h );
}
try {
/**
* @TODO: Thumbnail is more efficient, given a newer version of Imagemagick.
* $this->image->thumbnailImage( $dst_w, $dst_h );
*/
$this->image->scaleImage( $dst_w, $dst_h );
}
catch ( Exception $e ) {
return new WP_Error( 'image_resize_error', $e->getMessage() );
}
return $this->update_size( $dst_w, $dst_h );
}
/**
* Resize multiple images from a single source.
*
* @since 3.5.0
* @access public
*
* @param array $sizes {
* An array of image size arrays. Default sizes are 'small', 'medium', 'large'.
*
* Either a height or width must be provided.
* If one of the two is set to null, the resize will
* maintain aspect ratio according to the provided dimension.
*
* @type array $size {
* @type int ['width'] Optional. Image width.
* @type int ['height'] Optional. Image height.
* @type bool $crop Optional. Whether to crop the image. Default false.
* }
* }
* @return array An array of resized images' metadata by size.
*/
public function multi_resize( $sizes ) {
$metadata = array();
$orig_size = $this->size;
$orig_image = $this->image->getImage();
foreach ( $sizes as $size => $size_data ) {
if ( ! $this->image )
$this->image = $orig_image->getImage();
if ( ! isset( $size_data['width'] ) && ! isset( $size_data['height'] ) ) {
continue;
}
if ( ! isset( $size_data['width'] ) ) {
$size_data['width'] = null;
}
if ( ! isset( $size_data['height'] ) ) {
$size_data['height'] = null;
}
if ( ! isset( $size_data['crop'] ) ) {
$size_data['crop'] = false;
}
$resize_result = $this->resize( $size_data['width'], $size_data['height'], $size_data['crop'] );
if( ! is_wp_error( $resize_result ) ) {
$resized = $this->_save( $this->image );
$this->image->clear();
$this->image->destroy();
$this->image = null;
if ( ! is_wp_error( $resized ) && $resized ) {
unset( $resized['path'] );
$metadata[$size] = $resized;
}
}
$this->size = $orig_size;
}
$this->image = $orig_image;
return $metadata;
}
/**
* Crops Image.
*
* @since 3.5.0
* @access public
*
* @param string|int $src The source file or Attachment ID.
* @param int $src_x The start x position to crop from.
* @param int $src_y The start y position to crop from.
* @param int $src_w The width to crop.
* @param int $src_h The height to crop.
* @param int $dst_w Optional. The destination width.
* @param int $dst_h Optional. The destination height.
* @param boolean $src_abs Optional. If the source crop points are absolute.
* @return boolean|WP_Error
*/
public function crop( $src_x, $src_y, $src_w, $src_h, $dst_w = null, $dst_h = null, $src_abs = false ) {
if ( $src_abs ) {
$src_w -= $src_x;
$src_h -= $src_y;
}
try {
$this->image->cropImage( $src_w, $src_h, $src_x, $src_y );
$this->image->setImagePage( $src_w, $src_h, 0, 0);
if ( $dst_w || $dst_h ) {
// If destination width/height isn't specified, use same as
// width/height from source.
if ( ! $dst_w )
$dst_w = $src_w;
if ( ! $dst_h )
$dst_h = $src_h;
$this->image->scaleImage( $dst_w, $dst_h );
return $this->update_size();
}
}
catch ( Exception $e ) {
return new WP_Error( 'image_crop_error', $e->getMessage() );
}
return $this->update_size();
}
/**
* Rotates current image counter-clockwise by $angle.
*
* @since 3.5.0
* @access public
*
* @param float $angle
* @return boolean|WP_Error
*/
public function rotate( $angle ) {
/**
* $angle is 360-$angle because Imagick rotates clockwise
* (GD rotates counter-clockwise)
*/
try {
$this->image->rotateImage( new ImagickPixel('none'), 360-$angle );
// Since this changes the dimensions of the image, update the size.
$result = $this->update_size();
if ( is_wp_error( $result ) )
return $result;
$this->image->setImagePage( $this->size['width'], $this->size['height'], 0, 0 );
}
catch ( Exception $e ) {
return new WP_Error( 'image_rotate_error', $e->getMessage() );
}
return true;
}
/**
* Flips current image.
*
* @since 3.5.0
* @access public
*
* @param boolean $horz Flip along Horizontal Axis
* @param boolean $vert Flip along Vertical Axis
* @returns boolean|WP_Error
*/
public function flip( $horz, $vert ) {
try {
if ( $horz )
$this->image->flipImage();
if ( $vert )
$this->image->flopImage();
}
catch ( Exception $e ) {
return new WP_Error( 'image_flip_error', $e->getMessage() );
}
return true;
}
/**
* Saves current image to file.
*
* @since 3.5.0
* @access public
*
* @param string $destfilename
* @param string $mime_type
* @return array|WP_Error {'path'=>string, 'file'=>string, 'width'=>int, 'height'=>int, 'mime-type'=>string}
*/
public function save( $destfilename = null, $mime_type = null ) {
$saved = $this->_save( $this->image, $destfilename, $mime_type );
if ( ! is_wp_error( $saved ) ) {
$this->file = $saved['path'];
$this->mime_type = $saved['mime-type'];
try {
$this->image->setImageFormat( strtoupper( $this->get_extension( $this->mime_type ) ) );
}
catch ( Exception $e ) {
return new WP_Error( 'image_save_error', $e->getMessage(), $this->file );
}
}
return $saved;
}
protected function _save( $image, $filename = null, $mime_type = null ) {
list( $filename, $extension, $mime_type ) = $this->get_output_format( $filename, $mime_type );
if ( ! $filename )
$filename = $this->generate_filename( null, null, $extension );
try {
// Store initial Format
$orig_format = $this->image->getImageFormat();
$this->image->setImageFormat( strtoupper( $this->get_extension( $mime_type ) ) );
$this->make_image( $filename, array( $image, 'writeImage' ), array( $filename ) );
// Reset original Format
$this->image->setImageFormat( $orig_format );
}
catch ( Exception $e ) {
return new WP_Error( 'image_save_error', $e->getMessage(), $filename );
}
// Set correct file permissions
$stat = stat( dirname( $filename ) );
$perms = $stat['mode'] & 0000666; //same permissions as parent folder, strip off the executable bits
@ chmod( $filename, $perms );
/** This filter is documented in wp-includes/class-wp-image-editor-gd.php */
return array(
'path' => $filename,
'file' => wp_basename( apply_filters( 'image_make_intermediate_size', $filename ) ),
'width' => $this->size['width'],
'height' => $this->size['height'],
'mime-type' => $mime_type,
);
}
/**
* Streams current image to browser.
*
* @since 3.5.0
* @access public
*
* @param string $mime_type
* @return boolean|WP_Error
*/
public function stream( $mime_type = null ) {
list( $filename, $extension, $mime_type ) = $this->get_output_format( null, $mime_type );
try {
// Temporarily change format for stream
$this->image->setImageFormat( strtoupper( $extension ) );
// Output stream of image content
header( "Content-Type: $mime_type" );
print $this->image->getImageBlob();
// Reset Image to original Format
$this->image->setImageFormat( $this->get_extension( $this->mime_type ) );
}
catch ( Exception $e ) {
return new WP_Error( 'image_stream_error', $e->getMessage() );
}
return true;
}
}
| 01-wordpress-paypal | trunk/wp-includes/class-wp-image-editor-imagick.php | PHP | gpl3 | 13,671 |
<?php
/**
* IXR - The Incutio XML-RPC Library
*
* Copyright (c) 2010, Incutio Ltd.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of Incutio Ltd. nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @package IXR
* @since 1.5.0
*
* @copyright Incutio Ltd 2010 (http://www.incutio.com)
* @version 1.7.4 7th September 2010
* @author Simon Willison
* @link http://scripts.incutio.com/xmlrpc/ Site/manual
* @license http://www.opensource.org/licenses/bsd-license.php BSD
*/
/**
* IXR_Value
*
* @package IXR
* @since 1.5.0
*/
class IXR_Value {
var $data;
var $type;
function IXR_Value($data, $type = false)
{
$this->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
foreach ($this->data as $key => $value) {
$this->data[$key] = new IXR_Value($value);
}
}
if ($type == 'array') {
for ($i = 0, $j = count($this->data); $i < $j; $i++) {
$this->data[$i] = new IXR_Value($this->data[$i]);
}
}
}
function calculateType()
{
if ($this->data === true || $this->data === false) {
return 'boolean';
}
if (is_integer($this->data)) {
return 'int';
}
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';
}
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?
if ($this->isStruct($this->data)) {
return 'struct';
} else {
return 'array';
}
}
function getXml()
{
// Return XML for this value
switch ($this->type) {
case 'boolean':
return '<boolean>'.(($this->data) ? '1' : '0').'</boolean>';
break;
case 'int':
return '<int>'.$this->data.'</int>';
break;
case 'double':
return '<double>'.$this->data.'</double>';
break;
case 'string':
return '<string>'.htmlspecialchars($this->data).'</string>';
break;
case 'array':
$return = '<array><data>'."\n";
foreach ($this->data as $item) {
$return .= ' <value>'.$item->getXml()."</value>\n";
}
$return .= '</data></array>';
return $return;
break;
case 'struct':
$return = '<struct>'."\n";
foreach ($this->data as $name => $value) {
$name = htmlspecialchars($name);
$return .= " <member><name>$name</name><value>";
$return .= $value->getXml()."</value></member>\n";
}
$return .= '</struct>';
return $return;
break;
case 'date':
case 'base64':
return $this->data->getXml();
break;
}
return false;
}
/**
* 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) {
return true;
}
$expected++;
}
return false;
}
}
/**
* IXR_MESSAGE
*
* @package IXR
* @since 1.5.0
*
*/
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
var $_currentStructName = array(); // A stack as well
var $_param;
var $_value;
var $_currentTag;
var $_currentTagContents;
// The XML parser
var $_parser;
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
$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)
{
$this->_currentTagContents = '';
$this->currentTag = $tag;
switch($tag) {
case 'methodCall':
case 'methodResponse':
case 'fault':
$this->messageType = $tag;
break;
/* 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();
break;
case 'struct':
$this->_arraystructstypes[] = 'struct';
$this->_arraystructs[] = array();
break;
}
}
function cdata($parser, $cdata)
{
$this->_currentTagContents .= $cdata;
}
function tag_close($parser, $tag)
{
$valueFlag = false;
switch($tag) {
case 'int':
case 'i4':
$value = (int)trim($this->_currentTagContents);
$valueFlag = true;
break;
case 'double':
$value = (double)trim($this->_currentTagContents);
$valueFlag = true;
break;
case 'string':
$value = (string)trim($this->_currentTagContents);
$valueFlag = true;
break;
case 'dateTime.iso8601':
$value = new IXR_Date(trim($this->_currentTagContents));
$valueFlag = true;
break;
case 'value':
// "If no type is indicated, the type is string."
if (trim($this->_currentTagContents) != '') {
$value = (string)$this->_currentTagContents;
$valueFlag = true;
}
break;
case 'boolean':
$value = (boolean)trim($this->_currentTagContents);
$valueFlag = true;
break;
case 'base64':
$value = base64_decode($this->_currentTagContents);
$valueFlag = true;
break;
/* Deal with stacks of arrays and structs */
case 'data':
case 'struct':
$value = array_pop($this->_arraystructs);
array_pop($this->_arraystructstypes);
$valueFlag = true;
break;
case 'member':
array_pop($this->_currentStructName);
break;
case 'name':
$this->_currentStructName[] = trim($this->_currentTagContents);
break;
case 'methodName':
$this->methodName = trim($this->_currentTagContents);
break;
}
if ($valueFlag) {
if (count($this->_arraystructs) > 0) {
// Add value to struct or array
if ($this->_arraystructstypes[count($this->_arraystructstypes)-1] == 'struct') {
// Add to struct
$this->_arraystructs[count($this->_arraystructs)-1][$this->_currentStructName[count($this->_currentStructName)-1]] = $value;
} else {
// Add to array
$this->_arraystructs[count($this->_arraystructs)-1][] = $value;
}
} else {
// Just add as a paramater
$this->params[] = $value;
}
}
$this->_currentTagContents = '';
}
}
/**
* IXR_Server
*
* @package IXR
* @since 1.5.0
*/
class IXR_Server
{
var $data;
var $callbacks = array();
var $message;
var $capabilities;
function IXR_Server($callbacks = false, $data = false, $wait = false)
{
$this->setCapabilities();
if ($callbacks) {
$this->callbacks = $callbacks;
}
$this->setCallbacks();
if (!$wait) {
$this->serve($data);
}
}
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 (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;
}
}
$this->message = new IXR_Message($data);
if (!$this->message->parse()) {
$this->error(-32700, 'parse error. not well formed');
}
if ($this->message->messageType != 'methodCall') {
$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 = <<<EOD
<methodResponse>
<params>
<param>
<value>
$resultxml
</value>
</param>
</params>
</methodResponse>
EOD;
// Send it
$this->output($xml);
}
function call($methodname, $args)
{
if (!$this->hasMethod($methodname)) {
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:') {
// 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.');
}
//Call the method
$result = $this->$method($args);
} else {
// It's a function - does it exist?
if (is_array($method)) {
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.');
}
// Call the function
$result = call_user_func($method, $args);
}
return $result;
}
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)
{
$charset = function_exists('get_option') ? get_option('blog_charset') : '';
if ($charset)
$xml = '<?xml version="1.0" encoding="'.$charset.'"?>'."\n".$xml;
else
$xml = '<?xml version="1.0"?>'."\n".$xml;
$length = strlen($xml);
header('Connection: close');
header('Content-Length: '.$length);
if ($charset)
header('Content-Type: text/xml; charset='.$charset);
else
header('Content-Type: text/xml');
header('Date: '.date('r'));
echo $xml;
exit;
}
function hasMethod($method)
{
return in_array($method, array_keys($this->callbacks));
}
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)
{
return $this->capabilities;
}
function setCallbacks()
{
$this->callbacks['system.getCapabilities'] = 'this:getCapabilities';
$this->callbacks['system.listMethods'] = 'this:listMethods';
$this->callbacks['system.multicall'] = 'this:multiCall';
}
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)
{
// See http://www.xmlrpc.com/discuss/msgReader$1208
$return = array();
foreach ($methodcalls as $call) {
$method = $call['methodName'];
$params = $call['params'];
if ($method == 'system.multicall') {
$result = new IXR_Error(-32600, 'Recursive calls to system.multicall are forbidden');
} else {
$result = $this->call($method, $params);
}
if (is_a($result, 'IXR_Error')) {
$return[] = array(
'faultCode' => $result->code,
'faultString' => $result->message
);
} else {
$return[] = array($result);
}
}
return $return;
}
}
/**
* IXR_Request
*
* @package IXR
* @since 1.5.0
*/
class IXR_Request
{
var $method;
var $args;
var $xml;
function IXR_Request($method, $args)
{
$this->method = $method;
$this->args = $args;
$this->xml = <<<EOD
<?xml version="1.0"?>
<methodCall>
<methodName>{$this->method}</methodName>
<params>
EOD;
foreach ($this->args as $arg) {
$this->xml .= '<param><value>';
$v = new IXR_Value($arg);
$this->xml .= $v->getXml();
$this->xml .= "</value></param>\n";
}
$this->xml .= '</params></methodCall>';
}
function getLength()
{
return strlen($this->xml);
}
function getXml()
{
return $this->xml;
}
}
/**
* IXR_Client
*
* @package IXR
* @since 1.5.0
*
*/
class IXR_Client
{
var $server;
var $port;
var $path;
var $useragent;
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 = 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 = '/';
}
if ( ! empty( $bits['query'] ) ) {
$this->path .= '?' . $bits['query'];
}
} else {
$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);
$length = $request->getLength();
$xml = $request->getXml();
$r = "\r\n";
$request = "POST {$this->path} HTTP/1.0$r";
// 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;
$request .= $xml;
// Now send the request
if ($this->debug) {
echo '<pre class="ixr_request">'.htmlspecialchars($request)."\n</pre>\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');
return false;
}
fputs($fp, $request);
$contents = '';
$debugContents = '';
$gotFirstLine = false;
$gettingHeaders = true;
while (!feof($fp)) {
$line = fgets($fp, 4096);
if (!$gotFirstLine) {
// Check line for '200'
if (strstr($line, '200') === false) {
$this->error = new IXR_Error(-32300, 'transport error - HTTP status code was not 200');
return false;
}
$gotFirstLine = true;
}
if (trim($line) == '') {
$gettingHeaders = false;
}
if (!$gettingHeaders) {
// merged from WP #12559 - remove trim
$contents .= $line;
}
if ($this->debug) {
$debugContents .= $line;
}
}
if ($this->debug) {
echo '<pre class="ixr_response">'.htmlspecialchars($debugContents)."\n</pre>\n\n";
}
// Now parse what we've got back
$this->message = new IXR_Message($contents);
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;
}
function getResponse()
{
// methodResponses can only have one param - return that
return $this->message->params[0];
}
function isError()
{
return (is_object($this->error));
}
function getErrorCode()
{
return $this->error->code;
}
function getErrorMessage()
{
return $this->error->message;
}
}
/**
* IXR_Error
*
* @package IXR
* @since 1.5.0
*/
class IXR_Error
{
var $code;
var $message;
function IXR_Error($code, $message)
{
$this->code = $code;
$this->message = htmlspecialchars($message);
}
function getXml()
{
$xml = <<<EOD
<methodResponse>
<fault>
<value>
<struct>
<member>
<name>faultCode</name>
<value><int>{$this->code}</int></value>
</member>
<member>
<name>faultString</name>
<value><string>{$this->message}</string></value>
</member>
</struct>
</value>
</fault>
</methodResponse>
EOD;
return $xml;
}
}
/**
* IXR_Date
*
* @package IXR
* @since 1.5.0
*/
class IXR_Date {
var $year;
var $month;
var $day;
var $hour;
var $minute;
var $second;
var $timezone;
function IXR_Date($time)
{
// $time can be a PHP timestamp or an ISO one
if (is_numeric($time)) {
$this->parseTimestamp($time);
} else {
$this->parseIso($time);
}
}
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);
$this->timezone = '';
}
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);
$this->timezone = substr($iso, 17);
}
function getIso()
{
return $this->year.$this->month.$this->day.'T'.$this->hour.':'.$this->minute.':'.$this->second.$this->timezone;
}
function getXml()
{
return '<dateTime.iso8601>'.$this->getIso().'</dateTime.iso8601>';
}
function getTimestamp()
{
return mktime($this->hour, $this->minute, $this->second, $this->month, $this->day, $this->year);
}
}
/**
* IXR_Base64
*
* @package IXR
* @since 1.5.0
*/
class IXR_Base64
{
var $data;
function IXR_Base64($data)
{
$this->data = $data;
}
function getXml()
{
return '<base64>'.base64_encode($this->data).'</base64>';
}
}
/**
* IXR_IntrospectionServer
*
* @package IXR
* @since 1.5.0
*/
class IXR_IntrospectionServer extends IXR_Server
{
var $signatures;
var $help;
function IXR_IntrospectionServer()
{
$this->setCallbacks();
$this->setCapabilities();
$this->capabilities['introspection'] = array(
'specUrl' => 'http://xmlrpc.usefulinc.com/doc/reserved.html',
'specVersion' => 1
);
$this->addCallback(
'system.methodSignature',
'this:methodSignature',
array('array', 'string'),
'Returns an array describing the return type and required parameters of a method'
);
$this->addCallback(
'system.getCapabilities',
'this:getCapabilities',
array('struct'),
'Returns a struct describing the XML-RPC specifications supported by this server'
);
$this->addCallback(
'system.listMethods',
'this:listMethods',
array('array'),
'Returns an array of available methods on this server'
);
$this->addCallback(
'system.methodHelp',
'this:methodHelp',
array('string', 'string'),
'Returns a documentation string for the specified method'
);
}
function addCallback($method, $callback, $args, $help)
{
$this->callbacks[$method] = $callback;
$this->signatures[$method] = $args;
$this->help[$method] = $help;
}
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.');
}
$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;
for ($i = 0, $j = count($args); $i < $j; $i++) {
$arg = array_shift($args);
$type = array_shift($signature);
switch ($type) {
case 'int':
case 'i4':
if (is_array($arg) || !is_int($arg)) {
$ok = false;
}
break;
case 'base64':
case 'string':
if (!is_string($arg)) {
$ok = false;
}
break;
case 'boolean':
if ($arg !== false && $arg !== true) {
$ok = false;
}
break;
case 'float':
case 'double':
if (!is_float($arg)) {
$ok = false;
}
break;
case 'date':
case 'dateTime.iso8601':
if (!is_a($arg, 'IXR_Date')) {
$ok = false;
}
break;
}
if (!$ok) {
return new IXR_Error(-32602, 'server error. invalid method parameters');
}
}
// It passed the test - run the "real" method call
return parent::call($methodname, $argsbackup);
}
function methodSignature($method)
{
if (!$this->hasMethod($method)) {
return new IXR_Error(-32601, 'server error. requested method "'.$method.'" not specified.');
}
// We should be returning an array of types
$types = $this->signatures[$method];
$return = array();
foreach ($types as $type) {
switch ($type) {
case 'string':
$return[] = 'string';
break;
case 'int':
case 'i4':
$return[] = 42;
break;
case 'double':
$return[] = 3.1415;
break;
case 'dateTime.iso8601':
$return[] = new IXR_Date(time());
break;
case 'boolean':
$return[] = true;
break;
case 'base64':
$return[] = new IXR_Base64('base64');
break;
case 'array':
$return[] = array('array');
break;
case 'struct':
$return[] = array('struct' => 'struct');
break;
}
}
return $return;
}
function methodHelp($method)
{
return $this->help[$method];
}
}
/**
* IXR_ClientMulticall
*
* @package IXR
* @since 1.5.0
*/
class IXR_ClientMulticall extends IXR_Client
{
var $calls = array();
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()
{
$args = func_get_args();
$methodName = array_shift($args);
$struct = array(
'methodName' => $methodName,
'params' => $args
);
$this->calls[] = $struct;
}
function query()
{
// Prepare multicall, then call the parent::query() method
return parent::query('system.multicall', $this->calls);
}
}
| 01-wordpress-paypal | trunk/wp-includes/class-IXR.php | PHP | gpl3 | 31,812 |
<?php
/**
* mail_fetch/setup.php
*
* Copyright (c) 1999-2011 CDI (cdi@thewebmasters.net) All Rights Reserved
* Modified by Philippe Mingo 2001-2009 mingo@rotedic.com
* An RFC 1939 compliant wrapper class for the POP3 protocol.
*
* Licensed under the GNU GPL. For full terms see the file COPYING.
*
* POP3 class
*
* @copyright 1999-2011 The SquirrelMail Project Team
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @package plugins
* @subpackage mail_fetch
*/
class POP3 {
var $ERROR = ''; // Error string.
var $TIMEOUT = 60; // Default timeout before giving up on a
// network operation.
var $COUNT = -1; // Mailbox msg count
var $BUFFER = 512; // Socket buffer for socket fgets() calls.
// Per RFC 1939 the returned line a POP3
// server can send is 512 bytes.
var $FP = ''; // The connection to the server's
// file descriptor
var $MAILSERVER = ''; // Set this to hard code the server name
var $DEBUG = FALSE; // set to true to echo pop3
// commands and responses to error_log
// this WILL log passwords!
var $BANNER = ''; // Holds the banner returned by the
// pop server - used for apop()
var $ALLOWAPOP = FALSE; // Allow or disallow apop()
// This must be set to true
// manually
function POP3 ( $server = '', $timeout = '' ) {
settype($this->BUFFER,"integer");
if( !empty($server) ) {
// Do not allow programs to alter MAILSERVER
// if it is already specified. They can get around
// this if they -really- want to, so don't count on it.
if(empty($this->MAILSERVER))
$this->MAILSERVER = $server;
}
if(!empty($timeout)) {
settype($timeout,"integer");
$this->TIMEOUT = $timeout;
if (!ini_get('safe_mode'))
set_time_limit($timeout);
}
return true;
}
function update_timer () {
if (!ini_get('safe_mode'))
set_time_limit($this->TIMEOUT);
return true;
}
function connect ($server, $port = 110) {
// Opens a socket to the specified server. Unless overridden,
// port defaults to 110. Returns true on success, false on fail
// If MAILSERVER is set, override $server with it's value
if (!isset($port) || !$port) {$port = 110;}
if(!empty($this->MAILSERVER))
$server = $this->MAILSERVER;
if(empty($server)){
$this->ERROR = "POP3 connect: " . _("No server specified");
unset($this->FP);
return false;
}
$fp = @fsockopen("$server", $port, $errno, $errstr);
if(!$fp) {
$this->ERROR = "POP3 connect: " . _("Error ") . "[$errno] [$errstr]";
unset($this->FP);
return false;
}
socket_set_blocking($fp,-1);
$this->update_timer();
$reply = fgets($fp,$this->BUFFER);
$reply = $this->strip_clf($reply);
if($this->DEBUG)
error_log("POP3 SEND [connect: $server] GOT [$reply]",0);
if(!$this->is_ok($reply)) {
$this->ERROR = "POP3 connect: " . _("Error ") . "[$reply]";
unset($this->FP);
return false;
}
$this->FP = $fp;
$this->BANNER = $this->parse_banner($reply);
return true;
}
function user ($user = "") {
// Sends the USER command, returns true or false
if( empty($user) ) {
$this->ERROR = "POP3 user: " . _("no login ID submitted");
return false;
} elseif(!isset($this->FP)) {
$this->ERROR = "POP3 user: " . _("connection not established");
return false;
} else {
$reply = $this->send_cmd("USER $user");
if(!$this->is_ok($reply)) {
$this->ERROR = "POP3 user: " . _("Error ") . "[$reply]";
return false;
} else
return true;
}
}
function pass ($pass = "") {
// Sends the PASS command, returns # of msgs in mailbox,
// returns false (undef) on Auth failure
if(empty($pass)) {
$this->ERROR = "POP3 pass: " . _("No password submitted");
return false;
} elseif(!isset($this->FP)) {
$this->ERROR = "POP3 pass: " . _("connection not established");
return false;
} else {
$reply = $this->send_cmd("PASS $pass");
if(!$this->is_ok($reply)) {
$this->ERROR = "POP3 pass: " . _("Authentication failed") . " [$reply]";
$this->quit();
return false;
} else {
// Auth successful.
$count = $this->last("count");
$this->COUNT = $count;
return $count;
}
}
}
function apop ($login,$pass) {
// Attempts an APOP login. If this fails, it'll
// try a standard login. YOUR SERVER MUST SUPPORT
// THE USE OF THE APOP COMMAND!
// (apop is optional per rfc1939)
if(!isset($this->FP)) {
$this->ERROR = "POP3 apop: " . _("No connection to server");
return false;
} elseif(!$this->ALLOWAPOP) {
$retVal = $this->login($login,$pass);
return $retVal;
} elseif(empty($login)) {
$this->ERROR = "POP3 apop: " . _("No login ID submitted");
return false;
} elseif(empty($pass)) {
$this->ERROR = "POP3 apop: " . _("No password submitted");
return false;
} else {
$banner = $this->BANNER;
if( (!$banner) or (empty($banner)) ) {
$this->ERROR = "POP3 apop: " . _("No server banner") . ' - ' . _("abort");
$retVal = $this->login($login,$pass);
return $retVal;
} else {
$AuthString = $banner;
$AuthString .= $pass;
$APOPString = md5($AuthString);
$cmd = "APOP $login $APOPString";
$reply = $this->send_cmd($cmd);
if(!$this->is_ok($reply)) {
$this->ERROR = "POP3 apop: " . _("apop authentication failed") . ' - ' . _("abort");
$retVal = $this->login($login,$pass);
return $retVal;
} else {
// Auth successful.
$count = $this->last("count");
$this->COUNT = $count;
return $count;
}
}
}
}
function login ($login = "", $pass = "") {
// Sends both user and pass. Returns # of msgs in mailbox or
// false on failure (or -1, if the error occurs while getting
// the number of messages.)
if( !isset($this->FP) ) {
$this->ERROR = "POP3 login: " . _("No connection to server");
return false;
} else {
$fp = $this->FP;
if( !$this->user( $login ) ) {
// Preserve the error generated by user()
return false;
} else {
$count = $this->pass($pass);
if( (!$count) || ($count == -1) ) {
// Preserve the error generated by last() and pass()
return false;
} else
return $count;
}
}
}
function top ($msgNum, $numLines = "0") {
// Gets the header and first $numLines of the msg body
// returns data in an array with each returned line being
// an array element. If $numLines is empty, returns
// only the header information, and none of the body.
if(!isset($this->FP)) {
$this->ERROR = "POP3 top: " . _("No connection to server");
return false;
}
$this->update_timer();
$fp = $this->FP;
$buffer = $this->BUFFER;
$cmd = "TOP $msgNum $numLines";
fwrite($fp, "TOP $msgNum $numLines\r\n");
$reply = fgets($fp, $buffer);
$reply = $this->strip_clf($reply);
if($this->DEBUG) {
@error_log("POP3 SEND [$cmd] GOT [$reply]",0);
}
if(!$this->is_ok($reply))
{
$this->ERROR = "POP3 top: " . _("Error ") . "[$reply]";
return false;
}
$count = 0;
$MsgArray = array();
$line = fgets($fp,$buffer);
while ( !preg_match('/^\.\r\n/',$line))
{
$MsgArray[$count] = $line;
$count++;
$line = fgets($fp,$buffer);
if(empty($line)) { break; }
}
return $MsgArray;
}
function pop_list ($msgNum = "") {
// If called with an argument, returns that msgs' size in octets
// No argument returns an associative array of undeleted
// msg numbers and their sizes in octets
if(!isset($this->FP))
{
$this->ERROR = "POP3 pop_list: " . _("No connection to server");
return false;
}
$fp = $this->FP;
$Total = $this->COUNT;
if( (!$Total) or ($Total == -1) )
{
return false;
}
if($Total == 0)
{
return array("0","0");
// return -1; // mailbox empty
}
$this->update_timer();
if(!empty($msgNum))
{
$cmd = "LIST $msgNum";
fwrite($fp,"$cmd\r\n");
$reply = fgets($fp,$this->BUFFER);
$reply = $this->strip_clf($reply);
if($this->DEBUG) {
@error_log("POP3 SEND [$cmd] GOT [$reply]",0);
}
if(!$this->is_ok($reply))
{
$this->ERROR = "POP3 pop_list: " . _("Error ") . "[$reply]";
return false;
}
list($junk,$num,$size) = preg_split('/\s+/',$reply);
return $size;
}
$cmd = "LIST";
$reply = $this->send_cmd($cmd);
if(!$this->is_ok($reply))
{
$reply = $this->strip_clf($reply);
$this->ERROR = "POP3 pop_list: " . _("Error ") . "[$reply]";
return false;
}
$MsgArray = array();
$MsgArray[0] = $Total;
for($msgC=1;$msgC <= $Total; $msgC++)
{
if($msgC > $Total) { break; }
$line = fgets($fp,$this->BUFFER);
$line = $this->strip_clf($line);
if(strpos($line, '.') === 0)
{
$this->ERROR = "POP3 pop_list: " . _("Premature end of list");
return false;
}
list($thisMsg,$msgSize) = preg_split('/\s+/',$line);
settype($thisMsg,"integer");
if($thisMsg != $msgC)
{
$MsgArray[$msgC] = "deleted";
}
else
{
$MsgArray[$msgC] = $msgSize;
}
}
return $MsgArray;
}
function get ($msgNum) {
// Retrieve the specified msg number. Returns an array
// where each line of the msg is an array element.
if(!isset($this->FP))
{
$this->ERROR = "POP3 get: " . _("No connection to server");
return false;
}
$this->update_timer();
$fp = $this->FP;
$buffer = $this->BUFFER;
$cmd = "RETR $msgNum";
$reply = $this->send_cmd($cmd);
if(!$this->is_ok($reply))
{
$this->ERROR = "POP3 get: " . _("Error ") . "[$reply]";
return false;
}
$count = 0;
$MsgArray = array();
$line = fgets($fp,$buffer);
while ( !preg_match('/^\.\r\n/',$line))
{
if ( $line{0} == '.' ) { $line = substr($line,1); }
$MsgArray[$count] = $line;
$count++;
$line = fgets($fp,$buffer);
if(empty($line)) { break; }
}
return $MsgArray;
}
function last ( $type = "count" ) {
// Returns the highest msg number in the mailbox.
// returns -1 on error, 0+ on success, if type != count
// results in a popstat() call (2 element array returned)
$last = -1;
if(!isset($this->FP))
{
$this->ERROR = "POP3 last: " . _("No connection to server");
return $last;
}
$reply = $this->send_cmd("STAT");
if(!$this->is_ok($reply))
{
$this->ERROR = "POP3 last: " . _("Error ") . "[$reply]";
return $last;
}
$Vars = preg_split('/\s+/',$reply);
$count = $Vars[1];
$size = $Vars[2];
settype($count,"integer");
settype($size,"integer");
if($type != "count")
{
return array($count,$size);
}
return $count;
}
function reset () {
// Resets the status of the remote server. This includes
// resetting the status of ALL msgs to not be deleted.
// This method automatically closes the connection to the server.
if(!isset($this->FP))
{
$this->ERROR = "POP3 reset: " . _("No connection to server");
return false;
}
$reply = $this->send_cmd("RSET");
if(!$this->is_ok($reply))
{
// The POP3 RSET command -never- gives a -ERR
// response - if it ever does, something truely
// wild is going on.
$this->ERROR = "POP3 reset: " . _("Error ") . "[$reply]";
@error_log("POP3 reset: ERROR [$reply]",0);
}
$this->quit();
return true;
}
function send_cmd ( $cmd = "" )
{
// Sends a user defined command string to the
// POP server and returns the results. Useful for
// non-compliant or custom POP servers.
// Do NOT includ the \r\n as part of your command
// string - it will be appended automatically.
// The return value is a standard fgets() call, which
// will read up to $this->BUFFER bytes of data, until it
// encounters a new line, or EOF, whichever happens first.
// This method works best if $cmd responds with only
// one line of data.
if(!isset($this->FP))
{
$this->ERROR = "POP3 send_cmd: " . _("No connection to server");
return false;
}
if(empty($cmd))
{
$this->ERROR = "POP3 send_cmd: " . _("Empty command string");
return "";
}
$fp = $this->FP;
$buffer = $this->BUFFER;
$this->update_timer();
fwrite($fp,"$cmd\r\n");
$reply = fgets($fp,$buffer);
$reply = $this->strip_clf($reply);
if($this->DEBUG) { @error_log("POP3 SEND [$cmd] GOT [$reply]",0); }
return $reply;
}
function quit() {
// Closes the connection to the POP3 server, deleting
// any msgs marked as deleted.
if(!isset($this->FP))
{
$this->ERROR = "POP3 quit: " . _("connection does not exist");
return false;
}
$fp = $this->FP;
$cmd = "QUIT";
fwrite($fp,"$cmd\r\n");
$reply = fgets($fp,$this->BUFFER);
$reply = $this->strip_clf($reply);
if($this->DEBUG) { @error_log("POP3 SEND [$cmd] GOT [$reply]",0); }
fclose($fp);
unset($this->FP);
return true;
}
function popstat () {
// Returns an array of 2 elements. The number of undeleted
// msgs in the mailbox, and the size of the mbox in octets.
$PopArray = $this->last("array");
if($PopArray == -1) { return false; }
if( (!$PopArray) or (empty($PopArray)) )
{
return false;
}
return $PopArray;
}
function uidl ($msgNum = "")
{
// Returns the UIDL of the msg specified. If called with
// no arguments, returns an associative array where each
// undeleted msg num is a key, and the msg's uidl is the element
// Array element 0 will contain the total number of msgs
if(!isset($this->FP)) {
$this->ERROR = "POP3 uidl: " . _("No connection to server");
return false;
}
$fp = $this->FP;
$buffer = $this->BUFFER;
if(!empty($msgNum)) {
$cmd = "UIDL $msgNum";
$reply = $this->send_cmd($cmd);
if(!$this->is_ok($reply))
{
$this->ERROR = "POP3 uidl: " . _("Error ") . "[$reply]";
return false;
}
list ($ok,$num,$myUidl) = preg_split('/\s+/',$reply);
return $myUidl;
} else {
$this->update_timer();
$UIDLArray = array();
$Total = $this->COUNT;
$UIDLArray[0] = $Total;
if ($Total < 1)
{
return $UIDLArray;
}
$cmd = "UIDL";
fwrite($fp, "UIDL\r\n");
$reply = fgets($fp, $buffer);
$reply = $this->strip_clf($reply);
if($this->DEBUG) { @error_log("POP3 SEND [$cmd] GOT [$reply]",0); }
if(!$this->is_ok($reply))
{
$this->ERROR = "POP3 uidl: " . _("Error ") . "[$reply]";
return false;
}
$line = "";
$count = 1;
$line = fgets($fp,$buffer);
while ( !preg_match('/^\.\r\n/',$line)) {
list ($msg,$msgUidl) = preg_split('/\s+/',$line);
$msgUidl = $this->strip_clf($msgUidl);
if($count == $msg) {
$UIDLArray[$msg] = $msgUidl;
}
else
{
$UIDLArray[$count] = 'deleted';
}
$count++;
$line = fgets($fp,$buffer);
}
}
return $UIDLArray;
}
function delete ($msgNum = "") {
// Flags a specified msg as deleted. The msg will not
// be deleted until a quit() method is called.
if(!isset($this->FP))
{
$this->ERROR = "POP3 delete: " . _("No connection to server");
return false;
}
if(empty($msgNum))
{
$this->ERROR = "POP3 delete: " . _("No msg number submitted");
return false;
}
$reply = $this->send_cmd("DELE $msgNum");
if(!$this->is_ok($reply))
{
$this->ERROR = "POP3 delete: " . _("Command failed ") . "[$reply]";
return false;
}
return true;
}
// *********************************************************
// The following methods are internal to the class.
function is_ok ($cmd = "") {
// Return true or false on +OK or -ERR
if( empty($cmd) )
return false;
else
return( stripos($cmd, '+OK') !== false );
}
function strip_clf ($text = "") {
// Strips \r\n from server responses
if(empty($text))
return $text;
else {
$stripped = str_replace(array("\r","\n"),'',$text);
return $stripped;
}
}
function parse_banner ( $server_text ) {
$outside = true;
$banner = "";
$length = strlen($server_text);
for($count =0; $count < $length; $count++)
{
$digit = substr($server_text,$count,1);
if(!empty($digit)) {
if( (!$outside) && ($digit != '<') && ($digit != '>') )
{
$banner .= $digit;
}
if ($digit == '<')
{
$outside = false;
}
if($digit == '>')
{
$outside = true;
}
}
}
$banner = $this->strip_clf($banner); // Just in case
return "<$banner>";
}
} // End class
// For php4 compatibility
if (!function_exists("stripos")) {
function stripos($haystack, $needle){
return strpos($haystack, stristr( $haystack, $needle ));
}
}
| 01-wordpress-paypal | trunk/wp-includes/class-pop3.php | PHP | gpl3 | 20,748 |
<?php
/**
* WordPress scripts and styles default loader.
*
* Most of the functionality that existed here was moved to
* {@link http://backpress.automattic.com/ BackPress}. WordPress themes and
* plugins will only be concerned about the filters and actions set in this
* file.
*
* Several constants are used to manage the loading, concatenating and compression of scripts and CSS:
* define('SCRIPT_DEBUG', true); loads the development (non-minified) versions of all scripts and CSS, and disables compression and concatenation,
* define('CONCATENATE_SCRIPTS', false); disables compression and concatenation of scripts and CSS,
* define('COMPRESS_SCRIPTS', false); disables compression of scripts,
* define('COMPRESS_CSS', false); disables compression of CSS,
* define('ENFORCE_GZIP', true); forces gzip for compression (default is deflate).
*
* The globals $concatenate_scripts, $compress_scripts and $compress_css can be set by plugins
* to temporarily override the above settings. Also a compression test is run once and the result is saved
* as option 'can_compress_scripts' (0/1). The test will run again if that option is deleted.
*
* @package WordPress
*/
/** BackPress: WordPress Dependencies Class */
require( ABSPATH . WPINC . '/class.wp-dependencies.php' );
/** BackPress: WordPress Scripts Class */
require( ABSPATH . WPINC . '/class.wp-scripts.php' );
/** BackPress: WordPress Scripts Functions */
require( ABSPATH . WPINC . '/functions.wp-scripts.php' );
/** BackPress: WordPress Styles Class */
require( ABSPATH . WPINC . '/class.wp-styles.php' );
/** BackPress: WordPress Styles Functions */
require( ABSPATH . WPINC . '/functions.wp-styles.php' );
/**
* Register all WordPress scripts.
*
* Localizes some of them.
* args order: $scripts->add( 'handle', 'url', 'dependencies', 'query-string', 1 );
* when last arg === 1 queues the script for the footer
*
* @since 2.6.0
*
* @param object $scripts WP_Scripts object.
*/
function wp_default_scripts( &$scripts ) {
include ABSPATH . WPINC . '/version.php'; // include an unmodified $wp_version
$develop_src = false !== strpos( $wp_version, '-src' );
if ( ! defined( 'SCRIPT_DEBUG' ) ) {
define( 'SCRIPT_DEBUG', $develop_src );
}
if ( ! $guessurl = site_url() ) {
$guessed_url = true;
$guessurl = wp_guess_url();
}
$scripts->base_url = $guessurl;
$scripts->content_url = defined('WP_CONTENT_URL')? WP_CONTENT_URL : '';
$scripts->default_version = get_bloginfo( 'version' );
$scripts->default_dirs = array('/wp-admin/js/', '/wp-includes/js/');
$suffix = SCRIPT_DEBUG ? '' : '.min';
$dev_suffix = $develop_src ? '' : '.min';
$scripts->add( 'utils', "/wp-includes/js/utils$suffix.js" );
did_action( 'init' ) && $scripts->localize( 'utils', 'userSettings', array(
'url' => (string) SITECOOKIEPATH,
'uid' => (string) get_current_user_id(),
'time' => (string) time(),
) );
$scripts->add( 'common', "/wp-admin/js/common$suffix.js", array('jquery', 'hoverIntent', 'utils'), false, 1 );
did_action( 'init' ) && $scripts->localize( 'common', 'commonL10n', array(
'warnDelete' => __("You are about to permanently delete the selected items.\n 'Cancel' to stop, 'OK' to delete.")
) );
$scripts->add( 'sack', "/wp-includes/js/tw-sack$suffix.js", array(), '1.6.1', 1 );
$scripts->add( 'quicktags', "/wp-includes/js/quicktags$suffix.js", array(), false, 1 );
did_action( 'init' ) && $scripts->localize( 'quicktags', 'quicktagsL10n', array(
'closeAllOpenTags' => esc_attr(__('Close all open tags')),
'closeTags' => esc_attr(__('close tags')),
'enterURL' => __('Enter the URL'),
'enterImageURL' => __('Enter the URL of the image'),
'enterImageDescription' => __('Enter a description of the image'),
'fullscreen' => __('fullscreen'),
'toggleFullscreen' => esc_attr( __('Toggle fullscreen mode') ),
'textdirection' => esc_attr( __('text direction') ),
'toggleTextdirection' => esc_attr( __('Toggle Editor Text Direction') )
) );
$scripts->add( 'colorpicker', "/wp-includes/js/colorpicker$suffix.js", array('prototype'), '3517m' );
$scripts->add( 'editor', "/wp-admin/js/editor$suffix.js", array('utils','jquery'), false, 1 );
$scripts->add( 'wp-fullscreen', "/wp-admin/js/wp-fullscreen$suffix.js", array('jquery'), false, 1 );
$scripts->add( 'wp-ajax-response', "/wp-includes/js/wp-ajax-response$suffix.js", array('jquery'), false, 1 );
did_action( 'init' ) && $scripts->localize( 'wp-ajax-response', 'wpAjax', array(
'noPerm' => __('You do not have permission to do that.'),
'broken' => __('An unidentified error has occurred.')
) );
$scripts->add( 'wp-pointer', "/wp-includes/js/wp-pointer$suffix.js", array( 'jquery-ui-widget', 'jquery-ui-position' ), '20111129a', 1 );
did_action( 'init' ) && $scripts->localize( 'wp-pointer', 'wpPointerL10n', array(
'dismiss' => __('Dismiss'),
) );
$scripts->add( 'autosave', "/wp-includes/js/autosave$suffix.js", array('schedule', 'wp-ajax-response'), false, 1 );
$scripts->add( 'heartbeat', "/wp-includes/js/heartbeat$suffix.js", array('jquery'), false, 1 );
did_action( 'init' ) && $scripts->localize( 'heartbeat', 'heartbeatSettings',
/**
* Filter the Heartbeat settings.
*
* @since 3.6.0
*
* @param array $settings Heartbeat settings array.
*/
apply_filters( 'heartbeat_settings', array() )
);
$scripts->add( 'wp-auth-check', "/wp-includes/js/wp-auth-check$suffix.js", array('heartbeat'), false, 1 );
did_action( 'init' ) && $scripts->localize( 'wp-auth-check', 'authcheckL10n', array(
'beforeunload' => __('Your session has expired. You can log in again from this page or go to the login page.'),
/**
* Filter the authentication check interval.
*
* @since 3.6.0
*
* @param int $interval The interval in which to check a user's authentication.
* Default 3 minutes in seconds, or 180.
*/
'interval' => apply_filters( 'wp_auth_check_interval', 3 * MINUTE_IN_SECONDS ),
) );
$scripts->add( 'wp-lists', "/wp-includes/js/wp-lists$suffix.js", array( 'wp-ajax-response', 'jquery-color' ), false, 1 );
// WordPress no longer uses or bundles Prototype or script.aculo.us. These are now pulled from an external source.
$scripts->add( 'prototype', '//ajax.googleapis.com/ajax/libs/prototype/1.7.1.0/prototype.js', array(), '1.7.1');
$scripts->add( 'scriptaculous-root', '//ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/scriptaculous.js', array('prototype'), '1.9.0');
$scripts->add( 'scriptaculous-builder', '//ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/builder.js', array('scriptaculous-root'), '1.9.0');
$scripts->add( 'scriptaculous-dragdrop', '//ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/dragdrop.js', array('scriptaculous-builder', 'scriptaculous-effects'), '1.9.0');
$scripts->add( 'scriptaculous-effects', '//ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/effects.js', array('scriptaculous-root'), '1.9.0');
$scripts->add( 'scriptaculous-slider', '//ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/slider.js', array('scriptaculous-effects'), '1.9.0');
$scripts->add( 'scriptaculous-sound', '//ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/sound.js', array( 'scriptaculous-root' ), '1.9.0' );
$scripts->add( 'scriptaculous-controls', '//ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/controls.js', array('scriptaculous-root'), '1.9.0');
$scripts->add( 'scriptaculous', false, array('scriptaculous-dragdrop', 'scriptaculous-slider', 'scriptaculous-controls') );
// not used in core, replaced by Jcrop.js
$scripts->add( 'cropper', '/wp-includes/js/crop/cropper.js', array('scriptaculous-dragdrop') );
// jQuery
$scripts->add( 'jquery', false, array( 'jquery-core', 'jquery-migrate' ), '1.11.0' );
$scripts->add( 'jquery-core', '/wp-includes/js/jquery/jquery.js', array(), '1.11.0' );
$scripts->add( 'jquery-migrate', "/wp-includes/js/jquery/jquery-migrate$suffix.js", array(), '1.2.1' );
// full jQuery UI
$scripts->add( 'jquery-ui-core', '/wp-includes/js/jquery/ui/jquery.ui.core.min.js', array('jquery'), '1.10.4', 1 );
$scripts->add( 'jquery-effects-core', '/wp-includes/js/jquery/ui/jquery.ui.effect.min.js', array('jquery'), '1.10.4', 1 );
$scripts->add( 'jquery-effects-blind', '/wp-includes/js/jquery/ui/jquery.ui.effect-blind.min.js', array('jquery-effects-core'), '1.10.4', 1 );
$scripts->add( 'jquery-effects-bounce', '/wp-includes/js/jquery/ui/jquery.ui.effect-bounce.min.js', array('jquery-effects-core'), '1.10.4', 1 );
$scripts->add( 'jquery-effects-clip', '/wp-includes/js/jquery/ui/jquery.ui.effect-clip.min.js', array('jquery-effects-core'), '1.10.4', 1 );
$scripts->add( 'jquery-effects-drop', '/wp-includes/js/jquery/ui/jquery.ui.effect-drop.min.js', array('jquery-effects-core'), '1.10.4', 1 );
$scripts->add( 'jquery-effects-explode', '/wp-includes/js/jquery/ui/jquery.ui.effect-explode.min.js', array('jquery-effects-core'), '1.10.4', 1 );
$scripts->add( 'jquery-effects-fade', '/wp-includes/js/jquery/ui/jquery.ui.effect-fade.min.js', array('jquery-effects-core'), '1.10.4', 1 );
$scripts->add( 'jquery-effects-fold', '/wp-includes/js/jquery/ui/jquery.ui.effect-fold.min.js', array('jquery-effects-core'), '1.10.4', 1 );
$scripts->add( 'jquery-effects-highlight', '/wp-includes/js/jquery/ui/jquery.ui.effect-highlight.min.js', array('jquery-effects-core'), '1.10.4', 1 );
$scripts->add( 'jquery-effects-pulsate', '/wp-includes/js/jquery/ui/jquery.ui.effect-pulsate.min.js', array('jquery-effects-core'), '1.10.4', 1 );
$scripts->add( 'jquery-effects-scale', '/wp-includes/js/jquery/ui/jquery.ui.effect-scale.min.js', array('jquery-effects-core'), '1.10.4', 1 );
$scripts->add( 'jquery-effects-shake', '/wp-includes/js/jquery/ui/jquery.ui.effect-shake.min.js', array('jquery-effects-core'), '1.10.4', 1 );
$scripts->add( 'jquery-effects-slide', '/wp-includes/js/jquery/ui/jquery.ui.effect-slide.min.js', array('jquery-effects-core'), '1.10.4', 1 );
$scripts->add( 'jquery-effects-transfer', '/wp-includes/js/jquery/ui/jquery.ui.effect-transfer.min.js', array('jquery-effects-core'), '1.10.4', 1 );
$scripts->add( 'jquery-ui-accordion', '/wp-includes/js/jquery/ui/jquery.ui.accordion.min.js', array('jquery-ui-core', 'jquery-ui-widget'), '1.10.4', 1 );
$scripts->add( 'jquery-ui-autocomplete', '/wp-includes/js/jquery/ui/jquery.ui.autocomplete.min.js', array('jquery-ui-core', 'jquery-ui-widget', 'jquery-ui-position', 'jquery-ui-menu'), '1.10.4', 1 );
$scripts->add( 'jquery-ui-button', '/wp-includes/js/jquery/ui/jquery.ui.button.min.js', array('jquery-ui-core', 'jquery-ui-widget'), '1.10.4', 1 );
$scripts->add( 'jquery-ui-datepicker', '/wp-includes/js/jquery/ui/jquery.ui.datepicker.min.js', array('jquery-ui-core'), '1.10.4', 1 );
$scripts->add( 'jquery-ui-dialog', '/wp-includes/js/jquery/ui/jquery.ui.dialog.min.js', array('jquery-ui-resizable', 'jquery-ui-draggable', 'jquery-ui-button', 'jquery-ui-position'), '1.10.4', 1 );
$scripts->add( 'jquery-ui-draggable', '/wp-includes/js/jquery/ui/jquery.ui.draggable.min.js', array('jquery-ui-core', 'jquery-ui-mouse'), '1.10.4', 1 );
$scripts->add( 'jquery-ui-droppable', '/wp-includes/js/jquery/ui/jquery.ui.droppable.min.js', array('jquery-ui-draggable'), '1.10.4', 1 );
$scripts->add( 'jquery-ui-menu', '/wp-includes/js/jquery/ui/jquery.ui.menu.min.js', array( 'jquery-ui-core', 'jquery-ui-widget', 'jquery-ui-position' ), '1.10.4', 1 );
$scripts->add( 'jquery-ui-mouse', '/wp-includes/js/jquery/ui/jquery.ui.mouse.min.js', array('jquery-ui-widget'), '1.10.4', 1 );
$scripts->add( 'jquery-ui-position', '/wp-includes/js/jquery/ui/jquery.ui.position.min.js', array('jquery'), '1.10.4', 1 );
$scripts->add( 'jquery-ui-progressbar', '/wp-includes/js/jquery/ui/jquery.ui.progressbar.min.js', array('jquery-ui-widget'), '1.10.4', 1 );
$scripts->add( 'jquery-ui-resizable', '/wp-includes/js/jquery/ui/jquery.ui.resizable.min.js', array('jquery-ui-core', 'jquery-ui-mouse'), '1.10.4', 1 );
$scripts->add( 'jquery-ui-selectable', '/wp-includes/js/jquery/ui/jquery.ui.selectable.min.js', array('jquery-ui-core', 'jquery-ui-mouse'), '1.10.4', 1 );
$scripts->add( 'jquery-ui-slider', '/wp-includes/js/jquery/ui/jquery.ui.slider.min.js', array('jquery-ui-core', 'jquery-ui-mouse'), '1.10.4', 1 );
$scripts->add( 'jquery-ui-sortable', '/wp-includes/js/jquery/ui/jquery.ui.sortable.min.js', array('jquery-ui-core', 'jquery-ui-mouse'), '1.10.4', 1 );
$scripts->add( 'jquery-ui-spinner', '/wp-includes/js/jquery/ui/jquery.ui.spinner.min.js', array( 'jquery-ui-core', 'jquery-ui-widget', 'jquery-ui-button' ), '1.10.4', 1 );
$scripts->add( 'jquery-ui-tabs', '/wp-includes/js/jquery/ui/jquery.ui.tabs.min.js', array('jquery-ui-core', 'jquery-ui-widget'), '1.10.4', 1 );
$scripts->add( 'jquery-ui-tooltip', '/wp-includes/js/jquery/ui/jquery.ui.tooltip.min.js', array( 'jquery-ui-core', 'jquery-ui-widget', 'jquery-ui-position' ), '1.10.4', 1 );
$scripts->add( 'jquery-ui-widget', '/wp-includes/js/jquery/ui/jquery.ui.widget.min.js', array('jquery'), '1.10.4', 1 );
// deprecated, not used in core, most functionality is included in jQuery 1.3
$scripts->add( 'jquery-form', "/wp-includes/js/jquery/jquery.form$suffix.js", array('jquery'), '3.37.0', 1 );
// jQuery plugins
$scripts->add( 'jquery-color', "/wp-includes/js/jquery/jquery.color.min.js", array('jquery'), '2.1.1', 1 );
$scripts->add( 'suggest', "/wp-includes/js/jquery/suggest$suffix.js", array('jquery'), '1.1-20110113', 1 );
$scripts->add( 'schedule', '/wp-includes/js/jquery/jquery.schedule.js', array('jquery'), '20m', 1 );
$scripts->add( 'jquery-query', "/wp-includes/js/jquery/jquery.query.js", array('jquery'), '2.1.7', 1 );
$scripts->add( 'jquery-serialize-object', "/wp-includes/js/jquery/jquery.serialize-object.js", array('jquery'), '0.2', 1 );
$scripts->add( 'jquery-hotkeys', "/wp-includes/js/jquery/jquery.hotkeys$suffix.js", array('jquery'), '0.0.2m', 1 );
$scripts->add( 'jquery-table-hotkeys', "/wp-includes/js/jquery/jquery.table-hotkeys$suffix.js", array('jquery', 'jquery-hotkeys'), false, 1 );
$scripts->add( 'jquery-touch-punch', "/wp-includes/js/jquery/jquery.ui.touch-punch.js", array('jquery-ui-widget', 'jquery-ui-mouse'), '0.2.2', 1 );
// Masonry v2 depended on jQuery. v3 does not. The older jquery-masonry handle is a shiv.
// It sets jQuery as a dependency, as the theme may have been implicitly loading it this way.
$scripts->add( 'masonry', "/wp-includes/js/masonry.min.js", array(), '3.1.2', 1 );
$scripts->add( 'jquery-masonry', "/wp-includes/js/jquery/jquery.masonry$dev_suffix.js", array( 'jquery', 'masonry' ), '3.1.2', 1 );
$scripts->add( 'thickbox', "/wp-includes/js/thickbox/thickbox.js", array('jquery'), '3.1-20121105', 1 );
did_action( 'init' ) && $scripts->localize( 'thickbox', 'thickboxL10n', array(
'next' => __('Next >'),
'prev' => __('< Prev'),
'image' => __('Image'),
'of' => __('of'),
'close' => __('Close'),
'noiframes' => __('This feature requires inline frames. You have iframes disabled or your browser does not support them.'),
'loadingAnimation' => includes_url('js/thickbox/loadingAnimation.gif'),
) );
$scripts->add( 'jcrop', "/wp-includes/js/jcrop/jquery.Jcrop.min.js", array('jquery'), '0.9.12');
$scripts->add( 'swfobject', "/wp-includes/js/swfobject.js", array(), '2.2-20120417');
// common bits for both uploaders
$max_upload_size = ( (int) ( $max_up = @ini_get('upload_max_filesize') ) < (int) ( $max_post = @ini_get('post_max_size') ) ) ? $max_up : $max_post;
if ( empty($max_upload_size) )
$max_upload_size = __('not configured');
// error message for both plupload and swfupload
$uploader_l10n = array(
'queue_limit_exceeded' => __('You have attempted to queue too many files.'),
'file_exceeds_size_limit' => __('%s exceeds the maximum upload size for this site.'),
'zero_byte_file' => __('This file is empty. Please try another.'),
'invalid_filetype' => __('This file type is not allowed. Please try another.'),
'not_an_image' => __('This file is not an image. Please try another.'),
'image_memory_exceeded' => __('Memory exceeded. Please try another smaller file.'),
'image_dimensions_exceeded' => __('This is larger than the maximum size. Please try another.'),
'default_error' => __('An error occurred in the upload. Please try again later.'),
'missing_upload_url' => __('There was a configuration error. Please contact the server administrator.'),
'upload_limit_exceeded' => __('You may only upload 1 file.'),
'http_error' => __('HTTP error.'),
'upload_failed' => __('Upload failed.'),
'big_upload_failed' => __('Please try uploading this file with the %1$sbrowser uploader%2$s.'),
'big_upload_queued' => __('%s exceeds the maximum upload size for the multi-file uploader when used in your browser.'),
'io_error' => __('IO error.'),
'security_error' => __('Security error.'),
'file_cancelled' => __('File canceled.'),
'upload_stopped' => __('Upload stopped.'),
'dismiss' => __('Dismiss'),
'crunching' => __('Crunching…'),
'deleted' => __('moved to the trash.'),
'error_uploading' => __('“%s” has failed to upload.')
);
$scripts->add( 'plupload', '/wp-includes/js/plupload/plupload.full.min.js', array(), '2.1.1' );
// Back compat handles:
foreach ( array( 'all', 'html5', 'flash', 'silverlight', 'html4' ) as $handle ) {
$scripts->add( "plupload-$handle", false, array( 'plupload' ), '2.1.1' );
}
$scripts->add( 'plupload-handlers', "/wp-includes/js/plupload/handlers$suffix.js", array( 'plupload', 'jquery' ) );
did_action( 'init' ) && $scripts->localize( 'plupload-handlers', 'pluploadL10n', $uploader_l10n );
$scripts->add( 'wp-plupload', "/wp-includes/js/plupload/wp-plupload$suffix.js", array( 'plupload', 'jquery', 'json2', 'media-models' ), false, 1 );
did_action( 'init' ) && $scripts->localize( 'wp-plupload', 'pluploadL10n', $uploader_l10n );
// keep 'swfupload' for back-compat.
$scripts->add( 'swfupload', '/wp-includes/js/swfupload/swfupload.js', array(), '2201-20110113');
$scripts->add( 'swfupload-swfobject', '/wp-includes/js/swfupload/plugins/swfupload.swfobject.js', array('swfupload', 'swfobject'), '2201a');
$scripts->add( 'swfupload-queue', '/wp-includes/js/swfupload/plugins/swfupload.queue.js', array('swfupload'), '2201');
$scripts->add( 'swfupload-speed', '/wp-includes/js/swfupload/plugins/swfupload.speed.js', array('swfupload'), '2201');
$scripts->add( 'swfupload-all', false, array('swfupload', 'swfupload-swfobject', 'swfupload-queue'), '2201');
$scripts->add( 'swfupload-handlers', "/wp-includes/js/swfupload/handlers$suffix.js", array('swfupload-all', 'jquery'), '2201-20110524');
did_action( 'init' ) && $scripts->localize( 'swfupload-handlers', 'swfuploadL10n', $uploader_l10n );
$scripts->add( 'comment-reply', "/wp-includes/js/comment-reply$suffix.js", array(), false, 1 );
$scripts->add( 'json2', "/wp-includes/js/json2$suffix.js", array(), '2011-02-23');
$scripts->add( 'underscore', "/wp-includes/js/underscore$dev_suffix.js", array(), '1.6.0', 1 );
$scripts->add( 'backbone', "/wp-includes/js/backbone$dev_suffix.js", array( 'underscore','jquery' ), '1.1.2', 1 );
$scripts->add( 'wp-util', "/wp-includes/js/wp-util$suffix.js", array('underscore', 'jquery'), false, 1 );
did_action( 'init' ) && $scripts->localize( 'wp-util', '_wpUtilSettings', array(
'ajax' => array(
'url' => admin_url( 'admin-ajax.php', 'relative' ),
),
) );
$scripts->add( 'wp-backbone', "/wp-includes/js/wp-backbone$suffix.js", array('backbone', 'wp-util'), false, 1 );
$scripts->add( 'revisions', "/wp-admin/js/revisions$suffix.js", array( 'wp-backbone', 'jquery-ui-slider', 'hoverIntent' ), false, 1 );
$scripts->add( 'imgareaselect', "/wp-includes/js/imgareaselect/jquery.imgareaselect$suffix.js", array('jquery'), '0.9.10', 1 );
$scripts->add( 'mediaelement', "/wp-includes/js/mediaelement/mediaelement-and-player.min.js", array('jquery'), '2.14.2', 1 );
did_action( 'init' ) && $scripts->localize( 'mediaelement', 'mejsL10n', array(
'language' => get_bloginfo( 'language' ),
'strings' => array(
'Close' => __( 'Close' ),
'Fullscreen' => __( 'Fullscreen' ),
'Download File' => __( 'Download File' ),
'Download Video' => __( 'Download Video' ),
'Play/Pause' => __( 'Play/Pause' ),
'Mute Toggle' => __( 'Mute Toggle' ),
'None' => __( 'None' ),
'Turn off Fullscreen' => __( 'Turn off Fullscreen' ),
'Go Fullscreen' => __( 'Go Fullscreen' ),
'Unmute' => __( 'Unmute' ),
'Mute' => __( 'Mute' ),
'Captions/Subtitles' => __( 'Captions/Subtitles' )
),
) );
$scripts->add( 'wp-mediaelement', "/wp-includes/js/mediaelement/wp-mediaelement.js", array('mediaelement'), false, 1 );
did_action( 'init' ) && $scripts->localize( 'mediaelement', '_wpmejsSettings', array(
'pluginPath' => includes_url( 'js/mediaelement/', 'relative' ),
) );
$scripts->add( 'wp-playlist', "/wp-includes/js/mediaelement/wp-playlist.js", array( 'wp-util', 'backbone', 'mediaelement' ), false, 1 );
$scripts->add( 'zxcvbn-async', "/wp-includes/js/zxcvbn-async$suffix.js", array(), '1.0' );
did_action( 'init' ) && $scripts->localize( 'zxcvbn-async', '_zxcvbnSettings', array(
'src' => empty( $guessed_url ) ? includes_url( '/js/zxcvbn.min.js' ) : $scripts->base_url . '/wp-includes/js/zxcvbn.min.js',
) );
$scripts->add( 'password-strength-meter', "/wp-admin/js/password-strength-meter$suffix.js", array( 'jquery', 'zxcvbn-async' ), false, 1 );
did_action( 'init' ) && $scripts->localize( 'password-strength-meter', 'pwsL10n', array(
'empty' => __('Strength indicator'),
'short' => __('Very weak'),
'bad' => __('Weak'),
/* translators: password strength */
'good' => _x('Medium', 'password strength'),
'strong' => __('Strong'),
'mismatch' => __('Mismatch')
) );
$scripts->add( 'user-profile', "/wp-admin/js/user-profile$suffix.js", array( 'jquery', 'password-strength-meter' ), false, 1 );
$scripts->add( 'user-suggest', "/wp-admin/js/user-suggest$suffix.js", array( 'jquery-ui-autocomplete' ), false, 1 );
$scripts->add( 'admin-bar', "/wp-includes/js/admin-bar$suffix.js", array(), false, 1 );
$scripts->add( 'wplink', "/wp-includes/js/wplink$suffix.js", array( 'jquery' ), false, 1 );
did_action( 'init' ) && $scripts->localize( 'wplink', 'wpLinkL10n', array(
'title' => __('Insert/edit link'),
'update' => __('Update'),
'save' => __('Add Link'),
'noTitle' => __('(no title)'),
'noMatchesFound' => __('No matches found.')
) );
$scripts->add( 'wpdialogs', "/wp-includes/js/wpdialog$suffix.js", array( 'jquery-ui-dialog' ), false, 1 );
$scripts->add( 'word-count', "/wp-admin/js/word-count$suffix.js", array( 'jquery' ), false, 1 );
did_action( 'init' ) && $scripts->localize( 'word-count', 'wordCountL10n', array(
/* translators: If your word count is based on single characters (East Asian characters),
enter 'characters'. Otherwise, enter 'words'. Do not translate into your own language. */
'type' => 'characters' == _x( 'words', 'word count: words or characters?' ) ? 'c' : 'w',
) );
$scripts->add( 'media-upload', "/wp-admin/js/media-upload$suffix.js", array( 'thickbox', 'shortcode' ), false, 1 );
$scripts->add( 'hoverIntent', "/wp-includes/js/hoverIntent$suffix.js", array('jquery'), 'r7', 1 );
$scripts->add( 'customize-base', "/wp-includes/js/customize-base$suffix.js", array( 'jquery', 'json2' ), false, 1 );
$scripts->add( 'customize-loader', "/wp-includes/js/customize-loader$suffix.js", array( 'customize-base' ), false, 1 );
$scripts->add( 'customize-preview', "/wp-includes/js/customize-preview$suffix.js", array( 'customize-base' ), false, 1 );
$scripts->add( 'customize-models', "/wp-includes/js/customize-models.js", array( 'underscore', 'backbone' ), false, 1 );
$scripts->add( 'customize-views', "/wp-includes/js/customize-views.js", array( 'jquery', 'underscore', 'imgareaselect', 'customize-models' ), false, 1 );
$scripts->add( 'customize-controls', "/wp-admin/js/customize-controls$suffix.js", array( 'customize-base' ), false, 1 );
did_action( 'init' ) && $scripts->localize( 'customize-controls', '_wpCustomizeControlsL10n', array(
'activate' => __( 'Save & Activate' ),
'save' => __( 'Save & Publish' ),
'saved' => __( 'Saved' ),
'cancel' => __( 'Cancel' ),
'close' => __( 'Close' ),
'cheatin' => __( 'Cheatin’ uh?' ),
// Used for overriding the file types allowed in plupload.
'allowedFiles' => __( 'Allowed Files' ),
) );
$scripts->add( 'customize-widgets', "/wp-admin/js/customize-widgets$suffix.js", array( 'jquery', 'jquery-ui-sortable', 'jquery-ui-droppable', 'wp-backbone', 'customize-controls' ), false, 1 );
$scripts->add( 'customize-preview-widgets', "/wp-includes/js/customize-preview-widgets$suffix.js", array( 'jquery', 'wp-util', 'customize-preview' ), false, 1 );
$scripts->add( 'accordion', "/wp-admin/js/accordion$suffix.js", array( 'jquery' ), false, 1 );
$scripts->add( 'shortcode', "/wp-includes/js/shortcode$suffix.js", array( 'underscore' ), false, 1 );
$scripts->add( 'media-models', "/wp-includes/js/media-models$suffix.js", array( 'wp-backbone' ), false, 1 );
did_action( 'init' ) && $scripts->localize( 'media-models', '_wpMediaModelsL10n', array(
'settings' => array(
'ajaxurl' => admin_url( 'admin-ajax.php', 'relative' ),
'post' => array( 'id' => 0 ),
),
) );
// To enqueue media-views or media-editor, call wp_enqueue_media().
// Both rely on numerous settings, styles, and templates to operate correctly.
$scripts->add( 'media-views', "/wp-includes/js/media-views$suffix.js", array( 'utils', 'media-models', 'wp-plupload', 'jquery-ui-sortable', 'wp-mediaelement' ), false, 1 );
$scripts->add( 'media-editor', "/wp-includes/js/media-editor$suffix.js", array( 'shortcode', 'media-views' ), false, 1 );
$scripts->add( 'media-audiovideo', "/wp-includes/js/media-audiovideo$suffix.js", array( 'media-editor' ), false, 1 );
$scripts->add( 'mce-view', "/wp-includes/js/mce-view$suffix.js", array( 'shortcode', 'media-models', 'media-audiovideo', 'wp-playlist' ), false, 1 );
if ( is_admin() ) {
$scripts->add( 'admin-tags', "/wp-admin/js/tags$suffix.js", array('jquery', 'wp-ajax-response'), false, 1 );
did_action( 'init' ) && $scripts->localize( 'admin-tags', 'tagsl10n', array(
'noPerm' => __('You do not have permission to do that.'),
'broken' => __('An unidentified error has occurred.')
));
$scripts->add( 'admin-comments', "/wp-admin/js/edit-comments$suffix.js", array('wp-lists', 'quicktags', 'jquery-query'), false, 1 );
did_action( 'init' ) && $scripts->localize( 'admin-comments', 'adminCommentsL10n', array(
'hotkeys_highlight_first' => isset($_GET['hotkeys_highlight_first']),
'hotkeys_highlight_last' => isset($_GET['hotkeys_highlight_last']),
'replyApprove' => __( 'Approve and Reply' ),
'reply' => __( 'Reply' )
) );
$scripts->add( 'xfn', "/wp-admin/js/xfn$suffix.js", array('jquery'), false, 1 );
$scripts->add( 'postbox', "/wp-admin/js/postbox$suffix.js", array('jquery-ui-sortable'), false, 1 );
$scripts->add( 'post', "/wp-admin/js/post$suffix.js", array('suggest', 'wp-lists', 'postbox', 'heartbeat'), false, 1 );
did_action( 'init' ) && $scripts->localize( 'post', 'postL10n', array(
'ok' => __('OK'),
'cancel' => __('Cancel'),
'publishOn' => __('Publish on:'),
'publishOnFuture' => __('Schedule for:'),
'publishOnPast' => __('Published on:'),
/* translators: 1: month, 2: day, 3: year, 4: hour, 5: minute */
'dateFormat' => __('%1$s %2$s, %3$s @ %4$s : %5$s'),
'showcomm' => __('Show more comments'),
'endcomm' => __('No more comments found.'),
'publish' => __('Publish'),
'schedule' => __('Schedule'),
'update' => __('Update'),
'savePending' => __('Save as Pending'),
'saveDraft' => __('Save Draft'),
'private' => __('Private'),
'public' => __('Public'),
'publicSticky' => __('Public, Sticky'),
'password' => __('Password Protected'),
'privatelyPublished' => __('Privately Published'),
'published' => __('Published'),
'comma' => _x( ',', 'tag delimiter' ),
'saveAlert' => __('The changes you made will be lost if you navigate away from this page.'),
'savingText' => __('Saving Draft…'),
) );
$scripts->add( 'link', "/wp-admin/js/link$suffix.js", array( 'wp-lists', 'postbox' ), false, 1 );
$scripts->add( 'comment', "/wp-admin/js/comment$suffix.js", array( 'jquery', 'postbox' ) );
$scripts->add_data( 'comment', 'group', 1 );
did_action( 'init' ) && $scripts->localize( 'comment', 'commentL10n', array(
'submittedOn' => __('Submitted on:')
) );
$scripts->add( 'admin-gallery', "/wp-admin/js/gallery$suffix.js", array( 'jquery-ui-sortable' ) );
$scripts->add( 'admin-widgets', "/wp-admin/js/widgets$suffix.js", array( 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-droppable' ), false, 1 );
$scripts->add( 'theme', "/wp-admin/js/theme$suffix.js", array( 'wp-backbone' ), false, 1 );
$scripts->add( 'inline-edit-post', "/wp-admin/js/inline-edit-post$suffix.js", array( 'jquery', 'suggest', 'heartbeat' ), false, 1 );
did_action( 'init' ) && $scripts->localize( 'inline-edit-post', 'inlineEditL10n', array(
'error' => __('Error while saving the changes.'),
'ntdeltitle' => __('Remove From Bulk Edit'),
'notitle' => __('(no title)'),
'comma' => _x( ',', 'tag delimiter' ),
) );
$scripts->add( 'inline-edit-tax', "/wp-admin/js/inline-edit-tax$suffix.js", array( 'jquery' ), false, 1 );
did_action( 'init' ) && $scripts->localize( 'inline-edit-tax', 'inlineEditL10n', array(
'error' => __('Error while saving the changes.')
) );
$scripts->add( 'plugin-install', "/wp-admin/js/plugin-install$suffix.js", array( 'jquery', 'thickbox' ), false, 1 );
did_action( 'init' ) && $scripts->localize( 'plugin-install', 'plugininstallL10n', array(
'plugin_information' => __('Plugin Information:'),
'ays' => __('Are you sure you want to install this plugin?')
) );
$scripts->add( 'updates', "/wp-admin/js/updates$suffix.js", array( 'jquery' ) );
$scripts->add( 'farbtastic', '/wp-admin/js/farbtastic.js', array('jquery'), '1.2' );
$scripts->add( 'iris', '/wp-admin/js/iris.min.js', array( 'jquery-ui-draggable', 'jquery-ui-slider', 'jquery-touch-punch' ), false, 1 );
$scripts->add( 'wp-color-picker', "/wp-admin/js/color-picker$suffix.js", array( 'iris' ), false, 1 );
did_action( 'init' ) && $scripts->localize( 'wp-color-picker', 'wpColorPickerL10n', array(
'clear' => __( 'Clear' ),
'defaultString' => __( 'Default' ),
'pick' => __( 'Select Color' ),
'current' => __( 'Current Color' ),
) );
$scripts->add( 'dashboard', "/wp-admin/js/dashboard$suffix.js", array( 'jquery', 'admin-comments', 'postbox' ), false, 1 );
$scripts->add( 'list-revisions', "/wp-includes/js/wp-list-revisions$suffix.js" );
$scripts->add( 'media', "/wp-admin/js/media$suffix.js", array( 'jquery' ), false, 1 );
did_action( 'init' ) && $scripts->localize( 'media', 'attachMediaBoxL10n', array(
'error' => __( 'An error has occurred. Please reload the page and try again.' ),
));
$scripts->add( 'image-edit', "/wp-admin/js/image-edit$suffix.js", array('jquery', 'json2', 'imgareaselect'), false, 1 );
did_action( 'init' ) && $scripts->localize( 'image-edit', 'imageEditL10n', array(
'error' => __( 'Could not load the preview image. Please reload the page and try again.' )
));
$scripts->add( 'set-post-thumbnail', "/wp-admin/js/set-post-thumbnail$suffix.js", array( 'jquery' ), false, 1 );
did_action( 'init' ) && $scripts->localize( 'set-post-thumbnail', 'setPostThumbnailL10n', array(
'setThumbnail' => __( 'Use as featured image' ),
'saving' => __( 'Saving...' ),
'error' => __( 'Could not set that as the thumbnail image. Try a different attachment.' ),
'done' => __( 'Done' )
) );
// Navigation Menus
$scripts->add( 'nav-menu', "/wp-admin/js/nav-menu$suffix.js", array( 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-droppable', 'wp-lists', 'postbox' ) );
did_action( 'init' ) && $scripts->localize( 'nav-menu', 'navMenuL10n', array(
'noResultsFound' => _x('No results found.', 'search results'),
'warnDeleteMenu' => __( "You are about to permanently delete this menu. \n 'Cancel' to stop, 'OK' to delete." ),
'saveAlert' => __('The changes you made will be lost if you navigate away from this page.')
) );
$scripts->add( 'custom-header', "/wp-admin/js/custom-header.js", array( 'jquery-masonry' ), false, 1 );
$scripts->add( 'custom-background', "/wp-admin/js/custom-background$suffix.js", array( 'wp-color-picker', 'media-views' ), false, 1 );
$scripts->add( 'media-gallery', "/wp-admin/js/media-gallery$suffix.js", array('jquery'), false, 1 );
$scripts->add( 'svg-painter', '/wp-admin/js/svg-painter.js', array( 'jquery' ), false, 1 );
}
}
/**
* Assign default styles to $styles object.
*
* Nothing is returned, because the $styles parameter is passed by reference.
* Meaning that whatever object is passed will be updated without having to
* reassign the variable that was passed back to the same value. This saves
* memory.
*
* Adding default styles is not the only task, it also assigns the base_url
* property, the default version, and text direction for the object.
*
* @since 2.6.0
*
* @param object $styles
*/
function wp_default_styles( &$styles ) {
include ABSPATH . WPINC . '/version.php'; // include an unmodified $wp_version
if ( ! defined( 'SCRIPT_DEBUG' ) )
define( 'SCRIPT_DEBUG', false !== strpos( $wp_version, '-src' ) );
if ( ! $guessurl = site_url() )
$guessurl = wp_guess_url();
$styles->base_url = $guessurl;
$styles->content_url = defined('WP_CONTENT_URL')? WP_CONTENT_URL : '';
$styles->default_version = get_bloginfo( 'version' );
$styles->text_direction = function_exists( 'is_rtl' ) && is_rtl() ? 'rtl' : 'ltr';
$styles->default_dirs = array('/wp-admin/', '/wp-includes/css/');
$open_sans_font_url = '';
/* translators: If there are characters in your language that are not supported
* by Open Sans, translate this to 'off'. Do not translate into your own language.
*/
if ( 'off' !== _x( 'on', 'Open Sans font: on or off' ) ) {
$subsets = 'latin,latin-ext';
/* translators: To add an additional Open Sans character subset specific to your language,
* translate this to 'greek', 'cyrillic' or 'vietnamese'. Do not translate into your own language.
*/
$subset = _x( 'no-subset', 'Open Sans font: add new subset (greek, cyrillic, vietnamese)' );
if ( 'cyrillic' == $subset ) {
$subsets .= ',cyrillic,cyrillic-ext';
} elseif ( 'greek' == $subset ) {
$subsets .= ',greek,greek-ext';
} elseif ( 'vietnamese' == $subset ) {
$subsets .= ',vietnamese';
}
// Hotlink Open Sans, for now
$open_sans_font_url = "//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,300,400,600&subset=$subsets";
}
// Register a stylesheet for the selected admin color scheme.
$styles->add( 'colors', true, array( 'wp-admin', 'buttons', 'open-sans', 'dashicons' ) );
$suffix = SCRIPT_DEBUG ? '' : '.min';
// Admin CSS
$styles->add( 'wp-admin', "/wp-admin/css/wp-admin$suffix.css", array( 'open-sans', 'dashicons' ) );
$styles->add( 'login', "/wp-admin/css/login$suffix.css", array( 'buttons', 'open-sans', 'dashicons' ) );
$styles->add( 'install', "/wp-admin/css/install$suffix.css", array( 'buttons', 'open-sans' ) );
$styles->add( 'wp-color-picker', "/wp-admin/css/color-picker$suffix.css" );
$styles->add( 'customize-controls', "/wp-admin/css/customize-controls$suffix.css", array( 'wp-admin', 'colors', 'ie', 'imgareaselect' ) );
$styles->add( 'customize-widgets', "/wp-admin/css/customize-widgets$suffix.css", array( 'wp-admin', 'colors' ) );
$styles->add( 'ie', "/wp-admin/css/ie$suffix.css" );
$styles->add_data( 'ie', 'conditional', 'lte IE 7' );
// Common dependencies
$styles->add( 'buttons', "/wp-includes/css/buttons$suffix.css" );
$styles->add( 'dashicons', "/wp-includes/css/dashicons$suffix.css" );
$styles->add( 'open-sans', $open_sans_font_url );
// Includes CSS
$styles->add( 'admin-bar', "/wp-includes/css/admin-bar$suffix.css", array( 'open-sans', 'dashicons' ) );
$styles->add( 'wp-auth-check', "/wp-includes/css/wp-auth-check$suffix.css", array( 'dashicons' ) );
$styles->add( 'editor-buttons', "/wp-includes/css/editor$suffix.css", array( 'dashicons' ) );
$styles->add( 'media-views', "/wp-includes/css/media-views$suffix.css", array( 'buttons', 'dashicons', 'wp-mediaelement' ) );
$styles->add( 'wp-pointer', "/wp-includes/css/wp-pointer$suffix.css", array( 'dashicons' ) );
// External libraries and friends
$styles->add( 'imgareaselect', '/wp-includes/js/imgareaselect/imgareaselect.css', array(), '0.9.8' );
$styles->add( 'wp-jquery-ui-dialog', "/wp-includes/css/jquery-ui-dialog$suffix.css", array( 'dashicons' ) );
$styles->add( 'mediaelement', "/wp-includes/js/mediaelement/mediaelementplayer.min.css", array(), '2.13.0' );
$styles->add( 'wp-mediaelement', "/wp-includes/js/mediaelement/wp-mediaelement.css", array( 'mediaelement' ) );
$styles->add( 'thickbox', '/wp-includes/js/thickbox/thickbox.css', array( 'dashicons' ), '20131201' );
// Deprecated CSS
$styles->add( 'media', "/wp-admin/css/deprecated-media$suffix.css" );
$styles->add( 'farbtastic', '/wp-admin/css/farbtastic.css', array(), '1.3u1' );
$styles->add( 'jcrop', "/wp-includes/js/jcrop/jquery.Jcrop.min.css", array(), '0.9.12' );
$styles->add( 'colors-fresh', false, array( 'wp-admin', 'buttons' ) ); // Old handle.
// RTL CSS
$rtl_styles = array(
// wp-admin
'wp-admin', 'install', 'wp-color-picker', 'customize-controls', 'customize-widgets', 'ie', 'login',
// wp-includes
'buttons', 'admin-bar', 'wp-auth-check', 'editor-buttons', 'media-views', 'wp-pointer',
'wp-jquery-ui-dialog',
// deprecated
'media', 'farbtastic',
);
foreach ( $rtl_styles as $rtl_style ) {
$styles->add_data( $rtl_style, 'rtl', 'replace' );
if ( $suffix ) {
$styles->add_data( $rtl_style, 'suffix', $suffix );
}
}
}
/**
* Reorder JavaScript scripts array to place prototype before jQuery.
*
* @since 2.3.1
*
* @param array $js_array JavaScript scripts array
* @return array Reordered array, if needed.
*/
function wp_prototype_before_jquery( $js_array ) {
if ( false === $prototype = array_search( 'prototype', $js_array, true ) )
return $js_array;
if ( false === $jquery = array_search( 'jquery', $js_array, true ) )
return $js_array;
if ( $prototype < $jquery )
return $js_array;
unset($js_array[$prototype]);
array_splice( $js_array, $jquery, 0, 'prototype' );
return $js_array;
}
/**
* Load localized data on print rather than initialization.
*
* These localizations require information that may not be loaded even by init.
*
* @since 2.5.0
*/
function wp_just_in_time_script_localization() {
wp_localize_script( 'autosave', 'autosaveL10n', array(
'autosaveInterval' => AUTOSAVE_INTERVAL,
'blog_id' => get_current_blog_id(),
) );
}
/**
* Administration Screen CSS for changing the styles.
*
* If installing the 'wp-admin/' directory will be replaced with './'.
*
* The $_wp_admin_css_colors global manages the Administration Screens CSS
* stylesheet that is loaded. The option that is set is 'admin_color' and is the
* color and key for the array. The value for the color key is an object with
* a 'url' parameter that has the URL path to the CSS file.
*
* The query from $src parameter will be appended to the URL that is given from
* the $_wp_admin_css_colors array value URL.
*
* @since 2.6.0
* @uses $_wp_admin_css_colors
*
* @param string $src Source URL.
* @param string $handle Either 'colors' or 'colors-rtl'.
* @return string URL path to CSS stylesheet for Administration Screens.
*/
function wp_style_loader_src( $src, $handle ) {
global $_wp_admin_css_colors;
if ( defined('WP_INSTALLING') )
return preg_replace( '#^wp-admin/#', './', $src );
if ( 'colors' == $handle ) {
$color = get_user_option('admin_color');
if ( empty($color) || !isset($_wp_admin_css_colors[$color]) )
$color = 'fresh';
$color = $_wp_admin_css_colors[$color];
$parsed = parse_url( $src );
$url = $color->url;
if ( ! $url ) {
return false;
}
if ( isset($parsed['query']) && $parsed['query'] ) {
wp_parse_str( $parsed['query'], $qv );
$url = add_query_arg( $qv, $url );
}
return $url;
}
return $src;
}
/**
* Prints the script queue in the HTML head on admin pages.
*
* Postpones the scripts that were queued for the footer.
* print_footer_scripts() is called in the footer to print these scripts.
*
* @since 2.8.0
*
* @see wp_print_scripts()
*/
function print_head_scripts() {
global $wp_scripts, $concatenate_scripts;
if ( ! did_action('wp_print_scripts') ) {
/** This action is documented in wp-includes/functions.wp-scripts.php */
do_action( 'wp_print_scripts' );
}
if ( !is_a($wp_scripts, 'WP_Scripts') )
$wp_scripts = new WP_Scripts();
script_concat_settings();
$wp_scripts->do_concat = $concatenate_scripts;
$wp_scripts->do_head_items();
/**
* Filter whether to print the head scripts.
*
* @since 2.8.0
*
* @param bool $print Whether to print the head scripts. Default true.
*/
if ( apply_filters( 'print_head_scripts', true ) ) {
_print_scripts();
}
$wp_scripts->reset();
return $wp_scripts->done;
}
/**
* Prints the scripts that were queued for the footer or too late for the HTML head.
*
* @since 2.8.0
*/
function print_footer_scripts() {
global $wp_scripts, $concatenate_scripts;
if ( !is_a($wp_scripts, 'WP_Scripts') )
return array(); // No need to run if not instantiated.
script_concat_settings();
$wp_scripts->do_concat = $concatenate_scripts;
$wp_scripts->do_footer_items();
/**
* Filter whether to print the footer scripts.
*
* @since 2.8.0
*
* @param bool $print Whether to print the footer scripts. Default true.
*/
if ( apply_filters( 'print_footer_scripts', true ) ) {
_print_scripts();
}
$wp_scripts->reset();
return $wp_scripts->done;
}
/**
* @internal use
*/
function _print_scripts() {
global $wp_scripts, $compress_scripts;
$zip = $compress_scripts ? 1 : 0;
if ( $zip && defined('ENFORCE_GZIP') && ENFORCE_GZIP )
$zip = 'gzip';
if ( $concat = trim( $wp_scripts->concat, ', ' ) ) {
if ( !empty($wp_scripts->print_code) ) {
echo "\n<script type='text/javascript'>\n";
echo "/* <![CDATA[ */\n"; // not needed in HTML 5
echo $wp_scripts->print_code;
echo "/* ]]> */\n";
echo "</script>\n";
}
$concat = str_split( $concat, 128 );
$concat = 'load%5B%5D=' . implode( '&load%5B%5D=', $concat );
$src = $wp_scripts->base_url . "/wp-admin/load-scripts.php?c={$zip}&" . $concat . '&ver=' . $wp_scripts->default_version;
echo "<script type='text/javascript' src='" . esc_attr($src) . "'></script>\n";
}
if ( !empty($wp_scripts->print_html) )
echo $wp_scripts->print_html;
}
/**
* Prints the script queue in the HTML head on the front end.
*
* Postpones the scripts that were queued for the footer.
* wp_print_footer_scripts() is called in the footer to print these scripts.
*
* @since 2.8.0
*/
function wp_print_head_scripts() {
if ( ! did_action('wp_print_scripts') ) {
/** This action is documented in wp-includes/functions.wp-scripts.php */
do_action( 'wp_print_scripts' );
}
global $wp_scripts;
if ( !is_a($wp_scripts, 'WP_Scripts') )
return array(); // no need to run if nothing is queued
return print_head_scripts();
}
/**
* Private, for use in *_footer_scripts hooks
*
* @since 3.3.0
*/
function _wp_footer_scripts() {
print_late_styles();
print_footer_scripts();
}
/**
* Hooks to print the scripts and styles in the footer.
*
* @since 2.8.0
*/
function wp_print_footer_scripts() {
/**
* Fires when footer scripts are printed.
*
* @since 2.8.0
*/
do_action( 'wp_print_footer_scripts' );
}
/**
* Wrapper for do_action('wp_enqueue_scripts')
*
* Allows plugins to queue scripts for the front end using wp_enqueue_script().
* Runs first in wp_head() where all is_home(), is_page(), etc. functions are available.
*
* @since 2.8.0
*/
function wp_enqueue_scripts() {
/**
* Fires when scripts and styles are enqueued.
*
* @since 2.8.0
*/
do_action( 'wp_enqueue_scripts' );
}
/**
* Prints the styles queue in the HTML head on admin pages.
*
* @since 2.8.0
*/
function print_admin_styles() {
global $wp_styles, $concatenate_scripts, $compress_css;
if ( !is_a($wp_styles, 'WP_Styles') )
$wp_styles = new WP_Styles();
script_concat_settings();
$wp_styles->do_concat = $concatenate_scripts;
$zip = $compress_css ? 1 : 0;
if ( $zip && defined('ENFORCE_GZIP') && ENFORCE_GZIP )
$zip = 'gzip';
$wp_styles->do_items(false);
/**
* Filter whether to print the admin styles.
*
* @since 2.8.0
*
* @param bool $print Whether to print the admin styles. Default true.
*/
if ( apply_filters( 'print_admin_styles', true ) ) {
_print_styles();
}
$wp_styles->reset();
return $wp_styles->done;
}
/**
* Prints the styles that were queued too late for the HTML head.
*
* @since 3.3.0
*/
function print_late_styles() {
global $wp_styles, $concatenate_scripts;
if ( !is_a($wp_styles, 'WP_Styles') )
return;
$wp_styles->do_concat = $concatenate_scripts;
$wp_styles->do_footer_items();
/**
* Filter whether to print the styles queued too late for the HTML head.
*
* @since 3.3.0
*
* @param bool $print Whether to print the 'late' styles. Default true.
*/
if ( apply_filters( 'print_late_styles', true ) ) {
_print_styles();
}
$wp_styles->reset();
return $wp_styles->done;
}
/**
* @internal use
*/
function _print_styles() {
global $wp_styles, $compress_css;
$zip = $compress_css ? 1 : 0;
if ( $zip && defined('ENFORCE_GZIP') && ENFORCE_GZIP )
$zip = 'gzip';
if ( !empty($wp_styles->concat) ) {
$dir = $wp_styles->text_direction;
$ver = $wp_styles->default_version;
$href = $wp_styles->base_url . "/wp-admin/load-styles.php?c={$zip}&dir={$dir}&load=" . trim($wp_styles->concat, ', ') . '&ver=' . $ver;
echo "<link rel='stylesheet' href='" . esc_attr($href) . "' type='text/css' media='all' />\n";
if ( !empty($wp_styles->print_code) ) {
echo "<style type='text/css'>\n";
echo $wp_styles->print_code;
echo "\n</style>\n";
}
}
if ( !empty($wp_styles->print_html) )
echo $wp_styles->print_html;
}
/**
* Determine the concatenation and compression settings for scripts and styles.
*
* @since 2.8.0
*/
function script_concat_settings() {
global $concatenate_scripts, $compress_scripts, $compress_css;
$compressed_output = ( ini_get('zlib.output_compression') || 'ob_gzhandler' == ini_get('output_handler') );
if ( ! isset($concatenate_scripts) ) {
$concatenate_scripts = defined('CONCATENATE_SCRIPTS') ? CONCATENATE_SCRIPTS : true;
if ( ! is_admin() || ( defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ) )
$concatenate_scripts = false;
}
if ( ! isset($compress_scripts) ) {
$compress_scripts = defined('COMPRESS_SCRIPTS') ? COMPRESS_SCRIPTS : true;
if ( $compress_scripts && ( ! get_site_option('can_compress_scripts') || $compressed_output ) )
$compress_scripts = false;
}
if ( ! isset($compress_css) ) {
$compress_css = defined('COMPRESS_CSS') ? COMPRESS_CSS : true;
if ( $compress_css && ( ! get_site_option('can_compress_scripts') || $compressed_output ) )
$compress_css = false;
}
}
add_action( 'wp_default_scripts', 'wp_default_scripts' );
add_filter( 'wp_print_scripts', 'wp_just_in_time_script_localization' );
add_filter( 'print_scripts_array', 'wp_prototype_before_jquery' );
add_action( 'wp_default_styles', 'wp_default_styles' );
add_filter( 'style_loader_src', 'wp_style_loader_src', 10, 2 );
| 01-wordpress-paypal | trunk/wp-includes/script-loader.php | PHP | gpl3 | 47,946 |
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @version 1.3.1
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman
* @author Geoffrey Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
/**
* Date Parser
*
* @package SimplePie
* @subpackage Parsing
*/
class SimplePie_Parse_Date
{
/**
* Input data
*
* @access protected
* @var string
*/
var $date;
/**
* List of days, calendar day name => ordinal day number in the week
*
* @access protected
* @var array
*/
var $day = array(
// English
'mon' => 1,
'monday' => 1,
'tue' => 2,
'tuesday' => 2,
'wed' => 3,
'wednesday' => 3,
'thu' => 4,
'thursday' => 4,
'fri' => 5,
'friday' => 5,
'sat' => 6,
'saturday' => 6,
'sun' => 7,
'sunday' => 7,
// Dutch
'maandag' => 1,
'dinsdag' => 2,
'woensdag' => 3,
'donderdag' => 4,
'vrijdag' => 5,
'zaterdag' => 6,
'zondag' => 7,
// French
'lundi' => 1,
'mardi' => 2,
'mercredi' => 3,
'jeudi' => 4,
'vendredi' => 5,
'samedi' => 6,
'dimanche' => 7,
// German
'montag' => 1,
'dienstag' => 2,
'mittwoch' => 3,
'donnerstag' => 4,
'freitag' => 5,
'samstag' => 6,
'sonnabend' => 6,
'sonntag' => 7,
// Italian
'lunedì' => 1,
'martedì' => 2,
'mercoledì' => 3,
'giovedì' => 4,
'venerdì' => 5,
'sabato' => 6,
'domenica' => 7,
// Spanish
'lunes' => 1,
'martes' => 2,
'miércoles' => 3,
'jueves' => 4,
'viernes' => 5,
'sábado' => 6,
'domingo' => 7,
// Finnish
'maanantai' => 1,
'tiistai' => 2,
'keskiviikko' => 3,
'torstai' => 4,
'perjantai' => 5,
'lauantai' => 6,
'sunnuntai' => 7,
// Hungarian
'hétfő' => 1,
'kedd' => 2,
'szerda' => 3,
'csütörtok' => 4,
'péntek' => 5,
'szombat' => 6,
'vasárnap' => 7,
// Greek
'Δευ' => 1,
'Τρι' => 2,
'Τετ' => 3,
'Πεμ' => 4,
'Παρ' => 5,
'Σαβ' => 6,
'Κυρ' => 7,
);
/**
* List of months, calendar month name => calendar month number
*
* @access protected
* @var array
*/
var $month = array(
// English
'jan' => 1,
'january' => 1,
'feb' => 2,
'february' => 2,
'mar' => 3,
'march' => 3,
'apr' => 4,
'april' => 4,
'may' => 5,
// No long form of May
'jun' => 6,
'june' => 6,
'jul' => 7,
'july' => 7,
'aug' => 8,
'august' => 8,
'sep' => 9,
'september' => 8,
'oct' => 10,
'october' => 10,
'nov' => 11,
'november' => 11,
'dec' => 12,
'december' => 12,
// Dutch
'januari' => 1,
'februari' => 2,
'maart' => 3,
'april' => 4,
'mei' => 5,
'juni' => 6,
'juli' => 7,
'augustus' => 8,
'september' => 9,
'oktober' => 10,
'november' => 11,
'december' => 12,
// French
'janvier' => 1,
'février' => 2,
'mars' => 3,
'avril' => 4,
'mai' => 5,
'juin' => 6,
'juillet' => 7,
'août' => 8,
'septembre' => 9,
'octobre' => 10,
'novembre' => 11,
'décembre' => 12,
// German
'januar' => 1,
'februar' => 2,
'märz' => 3,
'april' => 4,
'mai' => 5,
'juni' => 6,
'juli' => 7,
'august' => 8,
'september' => 9,
'oktober' => 10,
'november' => 11,
'dezember' => 12,
// Italian
'gennaio' => 1,
'febbraio' => 2,
'marzo' => 3,
'aprile' => 4,
'maggio' => 5,
'giugno' => 6,
'luglio' => 7,
'agosto' => 8,
'settembre' => 9,
'ottobre' => 10,
'novembre' => 11,
'dicembre' => 12,
// Spanish
'enero' => 1,
'febrero' => 2,
'marzo' => 3,
'abril' => 4,
'mayo' => 5,
'junio' => 6,
'julio' => 7,
'agosto' => 8,
'septiembre' => 9,
'setiembre' => 9,
'octubre' => 10,
'noviembre' => 11,
'diciembre' => 12,
// Finnish
'tammikuu' => 1,
'helmikuu' => 2,
'maaliskuu' => 3,
'huhtikuu' => 4,
'toukokuu' => 5,
'kesäkuu' => 6,
'heinäkuu' => 7,
'elokuu' => 8,
'suuskuu' => 9,
'lokakuu' => 10,
'marras' => 11,
'joulukuu' => 12,
// Hungarian
'január' => 1,
'február' => 2,
'március' => 3,
'április' => 4,
'május' => 5,
'június' => 6,
'július' => 7,
'augusztus' => 8,
'szeptember' => 9,
'október' => 10,
'november' => 11,
'december' => 12,
// Greek
'Ιαν' => 1,
'Φεβ' => 2,
'Μάώ' => 3,
'Μαώ' => 3,
'Απρ' => 4,
'Μάι' => 5,
'Μαϊ' => 5,
'Μαι' => 5,
'Ιούν' => 6,
'Ιον' => 6,
'Ιούλ' => 7,
'Ιολ' => 7,
'Αύγ' => 8,
'Αυγ' => 8,
'Σεπ' => 9,
'Οκτ' => 10,
'Νοέ' => 11,
'Δεκ' => 12,
);
/**
* List of timezones, abbreviation => offset from UTC
*
* @access protected
* @var array
*/
var $timezone = array(
'ACDT' => 37800,
'ACIT' => 28800,
'ACST' => 34200,
'ACT' => -18000,
'ACWDT' => 35100,
'ACWST' => 31500,
'AEDT' => 39600,
'AEST' => 36000,
'AFT' => 16200,
'AKDT' => -28800,
'AKST' => -32400,
'AMDT' => 18000,
'AMT' => -14400,
'ANAST' => 46800,
'ANAT' => 43200,
'ART' => -10800,
'AZOST' => -3600,
'AZST' => 18000,
'AZT' => 14400,
'BIOT' => 21600,
'BIT' => -43200,
'BOT' => -14400,
'BRST' => -7200,
'BRT' => -10800,
'BST' => 3600,
'BTT' => 21600,
'CAST' => 18000,
'CAT' => 7200,
'CCT' => 23400,
'CDT' => -18000,
'CEDT' => 7200,
'CET' => 3600,
'CGST' => -7200,
'CGT' => -10800,
'CHADT' => 49500,
'CHAST' => 45900,
'CIST' => -28800,
'CKT' => -36000,
'CLDT' => -10800,
'CLST' => -14400,
'COT' => -18000,
'CST' => -21600,
'CVT' => -3600,
'CXT' => 25200,
'DAVT' => 25200,
'DTAT' => 36000,
'EADT' => -18000,
'EAST' => -21600,
'EAT' => 10800,
'ECT' => -18000,
'EDT' => -14400,
'EEST' => 10800,
'EET' => 7200,
'EGT' => -3600,
'EKST' => 21600,
'EST' => -18000,
'FJT' => 43200,
'FKDT' => -10800,
'FKST' => -14400,
'FNT' => -7200,
'GALT' => -21600,
'GEDT' => 14400,
'GEST' => 10800,
'GFT' => -10800,
'GILT' => 43200,
'GIT' => -32400,
'GST' => 14400,
'GST' => -7200,
'GYT' => -14400,
'HAA' => -10800,
'HAC' => -18000,
'HADT' => -32400,
'HAE' => -14400,
'HAP' => -25200,
'HAR' => -21600,
'HAST' => -36000,
'HAT' => -9000,
'HAY' => -28800,
'HKST' => 28800,
'HMT' => 18000,
'HNA' => -14400,
'HNC' => -21600,
'HNE' => -18000,
'HNP' => -28800,
'HNR' => -25200,
'HNT' => -12600,
'HNY' => -32400,
'IRDT' => 16200,
'IRKST' => 32400,
'IRKT' => 28800,
'IRST' => 12600,
'JFDT' => -10800,
'JFST' => -14400,
'JST' => 32400,
'KGST' => 21600,
'KGT' => 18000,
'KOST' => 39600,
'KOVST' => 28800,
'KOVT' => 25200,
'KRAST' => 28800,
'KRAT' => 25200,
'KST' => 32400,
'LHDT' => 39600,
'LHST' => 37800,
'LINT' => 50400,
'LKT' => 21600,
'MAGST' => 43200,
'MAGT' => 39600,
'MAWT' => 21600,
'MDT' => -21600,
'MESZ' => 7200,
'MEZ' => 3600,
'MHT' => 43200,
'MIT' => -34200,
'MNST' => 32400,
'MSDT' => 14400,
'MSST' => 10800,
'MST' => -25200,
'MUT' => 14400,
'MVT' => 18000,
'MYT' => 28800,
'NCT' => 39600,
'NDT' => -9000,
'NFT' => 41400,
'NMIT' => 36000,
'NOVST' => 25200,
'NOVT' => 21600,
'NPT' => 20700,
'NRT' => 43200,
'NST' => -12600,
'NUT' => -39600,
'NZDT' => 46800,
'NZST' => 43200,
'OMSST' => 25200,
'OMST' => 21600,
'PDT' => -25200,
'PET' => -18000,
'PETST' => 46800,
'PETT' => 43200,
'PGT' => 36000,
'PHOT' => 46800,
'PHT' => 28800,
'PKT' => 18000,
'PMDT' => -7200,
'PMST' => -10800,
'PONT' => 39600,
'PST' => -28800,
'PWT' => 32400,
'PYST' => -10800,
'PYT' => -14400,
'RET' => 14400,
'ROTT' => -10800,
'SAMST' => 18000,
'SAMT' => 14400,
'SAST' => 7200,
'SBT' => 39600,
'SCDT' => 46800,
'SCST' => 43200,
'SCT' => 14400,
'SEST' => 3600,
'SGT' => 28800,
'SIT' => 28800,
'SRT' => -10800,
'SST' => -39600,
'SYST' => 10800,
'SYT' => 7200,
'TFT' => 18000,
'THAT' => -36000,
'TJT' => 18000,
'TKT' => -36000,
'TMT' => 18000,
'TOT' => 46800,
'TPT' => 32400,
'TRUT' => 36000,
'TVT' => 43200,
'TWT' => 28800,
'UYST' => -7200,
'UYT' => -10800,
'UZT' => 18000,
'VET' => -14400,
'VLAST' => 39600,
'VLAT' => 36000,
'VOST' => 21600,
'VUT' => 39600,
'WAST' => 7200,
'WAT' => 3600,
'WDT' => 32400,
'WEST' => 3600,
'WFT' => 43200,
'WIB' => 25200,
'WIT' => 32400,
'WITA' => 28800,
'WKST' => 18000,
'WST' => 28800,
'YAKST' => 36000,
'YAKT' => 32400,
'YAPT' => 36000,
'YEKST' => 21600,
'YEKT' => 18000,
);
/**
* Cached PCRE for SimplePie_Parse_Date::$day
*
* @access protected
* @var string
*/
var $day_pcre;
/**
* Cached PCRE for SimplePie_Parse_Date::$month
*
* @access protected
* @var string
*/
var $month_pcre;
/**
* Array of user-added callback methods
*
* @access private
* @var array
*/
var $built_in = array();
/**
* Array of user-added callback methods
*
* @access private
* @var array
*/
var $user = array();
/**
* Create new SimplePie_Parse_Date object, and set self::day_pcre,
* self::month_pcre, and self::built_in
*
* @access private
*/
public function __construct()
{
$this->day_pcre = '(' . implode(array_keys($this->day), '|') . ')';
$this->month_pcre = '(' . implode(array_keys($this->month), '|') . ')';
static $cache;
if (!isset($cache[get_class($this)]))
{
$all_methods = get_class_methods($this);
foreach ($all_methods as $method)
{
if (strtolower(substr($method, 0, 5)) === 'date_')
{
$cache[get_class($this)][] = $method;
}
}
}
foreach ($cache[get_class($this)] as $method)
{
$this->built_in[] = $method;
}
}
/**
* Get the object
*
* @access public
*/
public static function get()
{
static $object;
if (!$object)
{
$object = new SimplePie_Parse_Date;
}
return $object;
}
/**
* Parse a date
*
* @final
* @access public
* @param string $date Date to parse
* @return int Timestamp corresponding to date string, or false on failure
*/
public function parse($date)
{
foreach ($this->user as $method)
{
if (($returned = call_user_func($method, $date)) !== false)
{
return $returned;
}
}
foreach ($this->built_in as $method)
{
if (($returned = call_user_func(array($this, $method), $date)) !== false)
{
return $returned;
}
}
return false;
}
/**
* Add a callback method to parse a date
*
* @final
* @access public
* @param callback $callback
*/
public function add_callback($callback)
{
if (is_callable($callback))
{
$this->user[] = $callback;
}
else
{
trigger_error('User-supplied function must be a valid callback', E_USER_WARNING);
}
}
/**
* Parse a superset of W3C-DTF (allows hyphens and colons to be omitted, as
* well as allowing any of upper or lower case "T", horizontal tabs, or
* spaces to be used as the time seperator (including more than one))
*
* @access protected
* @return int Timestamp
*/
public function date_w3cdtf($date)
{
static $pcre;
if (!$pcre)
{
$year = '([0-9]{4})';
$month = $day = $hour = $minute = $second = '([0-9]{2})';
$decimal = '([0-9]*)';
$zone = '(?:(Z)|([+\-])([0-9]{1,2}):?([0-9]{1,2}))';
$pcre = '/^' . $year . '(?:-?' . $month . '(?:-?' . $day . '(?:[Tt\x09\x20]+' . $hour . '(?::?' . $minute . '(?::?' . $second . '(?:.' . $decimal . ')?)?)?' . $zone . ')?)?)?$/';
}
if (preg_match($pcre, $date, $match))
{
/*
Capturing subpatterns:
1: Year
2: Month
3: Day
4: Hour
5: Minute
6: Second
7: Decimal fraction of a second
8: Zulu
9: Timezone ±
10: Timezone hours
11: Timezone minutes
*/
// Fill in empty matches
for ($i = count($match); $i <= 3; $i++)
{
$match[$i] = '1';
}
for ($i = count($match); $i <= 7; $i++)
{
$match[$i] = '0';
}
// Numeric timezone
if (isset($match[9]) && $match[9] !== '')
{
$timezone = $match[10] * 3600;
$timezone += $match[11] * 60;
if ($match[9] === '-')
{
$timezone = 0 - $timezone;
}
}
else
{
$timezone = 0;
}
// Convert the number of seconds to an integer, taking decimals into account
$second = round($match[6] + $match[7] / pow(10, strlen($match[7])));
return gmmktime($match[4], $match[5], $second, $match[2], $match[3], $match[1]) - $timezone;
}
else
{
return false;
}
}
/**
* Remove RFC822 comments
*
* @access protected
* @param string $data Data to strip comments from
* @return string Comment stripped string
*/
public function remove_rfc2822_comments($string)
{
$string = (string) $string;
$position = 0;
$length = strlen($string);
$depth = 0;
$output = '';
while ($position < $length && ($pos = strpos($string, '(', $position)) !== false)
{
$output .= substr($string, $position, $pos - $position);
$position = $pos + 1;
if ($string[$pos - 1] !== '\\')
{
$depth++;
while ($depth && $position < $length)
{
$position += strcspn($string, '()', $position);
if ($string[$position - 1] === '\\')
{
$position++;
continue;
}
elseif (isset($string[$position]))
{
switch ($string[$position])
{
case '(':
$depth++;
break;
case ')':
$depth--;
break;
}
$position++;
}
else
{
break;
}
}
}
else
{
$output .= '(';
}
}
$output .= substr($string, $position);
return $output;
}
/**
* Parse RFC2822's date format
*
* @access protected
* @return int Timestamp
*/
public function date_rfc2822($date)
{
static $pcre;
if (!$pcre)
{
$wsp = '[\x09\x20]';
$fws = '(?:' . $wsp . '+|' . $wsp . '*(?:\x0D\x0A' . $wsp . '+)+)';
$optional_fws = $fws . '?';
$day_name = $this->day_pcre;
$month = $this->month_pcre;
$day = '([0-9]{1,2})';
$hour = $minute = $second = '([0-9]{2})';
$year = '([0-9]{2,4})';
$num_zone = '([+\-])([0-9]{2})([0-9]{2})';
$character_zone = '([A-Z]{1,5})';
$zone = '(?:' . $num_zone . '|' . $character_zone . ')';
$pcre = '/(?:' . $optional_fws . $day_name . $optional_fws . ',)?' . $optional_fws . $day . $fws . $month . $fws . $year . $fws . $hour . $optional_fws . ':' . $optional_fws . $minute . '(?:' . $optional_fws . ':' . $optional_fws . $second . ')?' . $fws . $zone . '/i';
}
if (preg_match($pcre, $this->remove_rfc2822_comments($date), $match))
{
/*
Capturing subpatterns:
1: Day name
2: Day
3: Month
4: Year
5: Hour
6: Minute
7: Second
8: Timezone ±
9: Timezone hours
10: Timezone minutes
11: Alphabetic timezone
*/
// Find the month number
$month = $this->month[strtolower($match[3])];
// Numeric timezone
if ($match[8] !== '')
{
$timezone = $match[9] * 3600;
$timezone += $match[10] * 60;
if ($match[8] === '-')
{
$timezone = 0 - $timezone;
}
}
// Character timezone
elseif (isset($this->timezone[strtoupper($match[11])]))
{
$timezone = $this->timezone[strtoupper($match[11])];
}
// Assume everything else to be -0000
else
{
$timezone = 0;
}
// Deal with 2/3 digit years
if ($match[4] < 50)
{
$match[4] += 2000;
}
elseif ($match[4] < 1000)
{
$match[4] += 1900;
}
// Second is optional, if it is empty set it to zero
if ($match[7] !== '')
{
$second = $match[7];
}
else
{
$second = 0;
}
return gmmktime($match[5], $match[6], $second, $month, $match[2], $match[4]) - $timezone;
}
else
{
return false;
}
}
/**
* Parse RFC850's date format
*
* @access protected
* @return int Timestamp
*/
public function date_rfc850($date)
{
static $pcre;
if (!$pcre)
{
$space = '[\x09\x20]+';
$day_name = $this->day_pcre;
$month = $this->month_pcre;
$day = '([0-9]{1,2})';
$year = $hour = $minute = $second = '([0-9]{2})';
$zone = '([A-Z]{1,5})';
$pcre = '/^' . $day_name . ',' . $space . $day . '-' . $month . '-' . $year . $space . $hour . ':' . $minute . ':' . $second . $space . $zone . '$/i';
}
if (preg_match($pcre, $date, $match))
{
/*
Capturing subpatterns:
1: Day name
2: Day
3: Month
4: Year
5: Hour
6: Minute
7: Second
8: Timezone
*/
// Month
$month = $this->month[strtolower($match[3])];
// Character timezone
if (isset($this->timezone[strtoupper($match[8])]))
{
$timezone = $this->timezone[strtoupper($match[8])];
}
// Assume everything else to be -0000
else
{
$timezone = 0;
}
// Deal with 2 digit year
if ($match[4] < 50)
{
$match[4] += 2000;
}
else
{
$match[4] += 1900;
}
return gmmktime($match[5], $match[6], $match[7], $month, $match[2], $match[4]) - $timezone;
}
else
{
return false;
}
}
/**
* Parse C99's asctime()'s date format
*
* @access protected
* @return int Timestamp
*/
public function date_asctime($date)
{
static $pcre;
if (!$pcre)
{
$space = '[\x09\x20]+';
$wday_name = $this->day_pcre;
$mon_name = $this->month_pcre;
$day = '([0-9]{1,2})';
$hour = $sec = $min = '([0-9]{2})';
$year = '([0-9]{4})';
$terminator = '\x0A?\x00?';
$pcre = '/^' . $wday_name . $space . $mon_name . $space . $day . $space . $hour . ':' . $min . ':' . $sec . $space . $year . $terminator . '$/i';
}
if (preg_match($pcre, $date, $match))
{
/*
Capturing subpatterns:
1: Day name
2: Month
3: Day
4: Hour
5: Minute
6: Second
7: Year
*/
$month = $this->month[strtolower($match[2])];
return gmmktime($match[4], $match[5], $match[6], $month, $match[3], $match[7]);
}
else
{
return false;
}
}
/**
* Parse dates using strtotime()
*
* @access protected
* @return int Timestamp
*/
public function date_strtotime($date)
{
$strtotime = strtotime($date);
if ($strtotime === -1 || $strtotime === false)
{
return false;
}
else
{
return $strtotime;
}
}
}
| 01-wordpress-paypal | trunk/wp-includes/SimplePie/Parse/Date.php | PHP | gpl3 | 19,683 |
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @version 1.3.1
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman
* @author Geoffrey Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
/**
* Handles `<media:credit>` as defined in Media RSS
*
* Used by {@see SimplePie_Enclosure::get_credit()} and {@see SimplePie_Enclosure::get_credits()}
*
* This class can be overloaded with {@see SimplePie::set_credit_class()}
*
* @package SimplePie
* @subpackage API
*/
class SimplePie_Credit
{
/**
* Credited role
*
* @var string
* @see get_role()
*/
var $role;
/**
* Organizational scheme
*
* @var string
* @see get_scheme()
*/
var $scheme;
/**
* Credited name
*
* @var string
* @see get_name()
*/
var $name;
/**
* Constructor, used to input the data
*
* For documentation on all the parameters, see the corresponding
* properties and their accessors
*/
public function __construct($role = null, $scheme = null, $name = null)
{
$this->role = $role;
$this->scheme = $scheme;
$this->name = $name;
}
/**
* String-ified version
*
* @return string
*/
public function __toString()
{
// There is no $this->data here
return md5(serialize($this));
}
/**
* Get the role of the person receiving credit
*
* @return string|null
*/
public function get_role()
{
if ($this->role !== null)
{
return $this->role;
}
else
{
return null;
}
}
/**
* Get the organizational scheme
*
* @return string|null
*/
public function get_scheme()
{
if ($this->scheme !== null)
{
return $this->scheme;
}
else
{
return null;
}
}
/**
* Get the credited person/entity's name
*
* @return string|null
*/
public function get_name()
{
if ($this->name !== null)
{
return $this->name;
}
else
{
return null;
}
}
}
| 01-wordpress-paypal | trunk/wp-includes/SimplePie/Credit.php | PHP | gpl3 | 3,721 |
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @version 1.3.1
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman
* @author Geoffrey Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
/**
* IRI parser/serialiser/normaliser
*
* @package SimplePie
* @subpackage HTTP
* @author Geoffrey Sneddon
* @author Steve Minutillo
* @author Ryan McCue
* @copyright 2007-2012 Geoffrey Sneddon, Steve Minutillo, Ryan McCue
* @license http://www.opensource.org/licenses/bsd-license.php
*/
class SimplePie_IRI
{
/**
* Scheme
*
* @var string
*/
protected $scheme = null;
/**
* User Information
*
* @var string
*/
protected $iuserinfo = null;
/**
* ihost
*
* @var string
*/
protected $ihost = null;
/**
* Port
*
* @var string
*/
protected $port = null;
/**
* ipath
*
* @var string
*/
protected $ipath = '';
/**
* iquery
*
* @var string
*/
protected $iquery = null;
/**
* ifragment
*
* @var string
*/
protected $ifragment = null;
/**
* Normalization database
*
* Each key is the scheme, each value is an array with each key as the IRI
* part and value as the default value for that part.
*/
protected $normalization = array(
'acap' => array(
'port' => 674
),
'dict' => array(
'port' => 2628
),
'file' => array(
'ihost' => 'localhost'
),
'http' => array(
'port' => 80,
'ipath' => '/'
),
'https' => array(
'port' => 443,
'ipath' => '/'
),
);
/**
* Return the entire IRI when you try and read the object as a string
*
* @return string
*/
public function __toString()
{
return $this->get_iri();
}
/**
* Overload __set() to provide access via properties
*
* @param string $name Property name
* @param mixed $value Property value
*/
public function __set($name, $value)
{
if (method_exists($this, 'set_' . $name))
{
call_user_func(array($this, 'set_' . $name), $value);
}
elseif (
$name === 'iauthority'
|| $name === 'iuserinfo'
|| $name === 'ihost'
|| $name === 'ipath'
|| $name === 'iquery'
|| $name === 'ifragment'
)
{
call_user_func(array($this, 'set_' . substr($name, 1)), $value);
}
}
/**
* Overload __get() to provide access via properties
*
* @param string $name Property name
* @return mixed
*/
public function __get($name)
{
// isset() returns false for null, we don't want to do that
// Also why we use array_key_exists below instead of isset()
$props = get_object_vars($this);
if (
$name === 'iri' ||
$name === 'uri' ||
$name === 'iauthority' ||
$name === 'authority'
)
{
$return = $this->{"get_$name"}();
}
elseif (array_key_exists($name, $props))
{
$return = $this->$name;
}
// host -> ihost
elseif (($prop = 'i' . $name) && array_key_exists($prop, $props))
{
$name = $prop;
$return = $this->$prop;
}
// ischeme -> scheme
elseif (($prop = substr($name, 1)) && array_key_exists($prop, $props))
{
$name = $prop;
$return = $this->$prop;
}
else
{
trigger_error('Undefined property: ' . get_class($this) . '::' . $name, E_USER_NOTICE);
$return = null;
}
if ($return === null && isset($this->normalization[$this->scheme][$name]))
{
return $this->normalization[$this->scheme][$name];
}
else
{
return $return;
}
}
/**
* Overload __isset() to provide access via properties
*
* @param string $name Property name
* @return bool
*/
public function __isset($name)
{
if (method_exists($this, 'get_' . $name) || isset($this->$name))
{
return true;
}
else
{
return false;
}
}
/**
* Overload __unset() to provide access via properties
*
* @param string $name Property name
*/
public function __unset($name)
{
if (method_exists($this, 'set_' . $name))
{
call_user_func(array($this, 'set_' . $name), '');
}
}
/**
* Create a new IRI object, from a specified string
*
* @param string $iri
*/
public function __construct($iri = null)
{
$this->set_iri($iri);
}
/**
* Create a new IRI object by resolving a relative IRI
*
* Returns false if $base is not absolute, otherwise an IRI.
*
* @param IRI|string $base (Absolute) Base IRI
* @param IRI|string $relative Relative IRI
* @return IRI|false
*/
public static function absolutize($base, $relative)
{
if (!($relative instanceof SimplePie_IRI))
{
$relative = new SimplePie_IRI($relative);
}
if (!$relative->is_valid())
{
return false;
}
elseif ($relative->scheme !== null)
{
return clone $relative;
}
else
{
if (!($base instanceof SimplePie_IRI))
{
$base = new SimplePie_IRI($base);
}
if ($base->scheme !== null && $base->is_valid())
{
if ($relative->get_iri() !== '')
{
if ($relative->iuserinfo !== null || $relative->ihost !== null || $relative->port !== null)
{
$target = clone $relative;
$target->scheme = $base->scheme;
}
else
{
$target = new SimplePie_IRI;
$target->scheme = $base->scheme;
$target->iuserinfo = $base->iuserinfo;
$target->ihost = $base->ihost;
$target->port = $base->port;
if ($relative->ipath !== '')
{
if ($relative->ipath[0] === '/')
{
$target->ipath = $relative->ipath;
}
elseif (($base->iuserinfo !== null || $base->ihost !== null || $base->port !== null) && $base->ipath === '')
{
$target->ipath = '/' . $relative->ipath;
}
elseif (($last_segment = strrpos($base->ipath, '/')) !== false)
{
$target->ipath = substr($base->ipath, 0, $last_segment + 1) . $relative->ipath;
}
else
{
$target->ipath = $relative->ipath;
}
$target->ipath = $target->remove_dot_segments($target->ipath);
$target->iquery = $relative->iquery;
}
else
{
$target->ipath = $base->ipath;
if ($relative->iquery !== null)
{
$target->iquery = $relative->iquery;
}
elseif ($base->iquery !== null)
{
$target->iquery = $base->iquery;
}
}
$target->ifragment = $relative->ifragment;
}
}
else
{
$target = clone $base;
$target->ifragment = null;
}
$target->scheme_normalization();
return $target;
}
else
{
return false;
}
}
}
/**
* Parse an IRI into scheme/authority/path/query/fragment segments
*
* @param string $iri
* @return array
*/
protected function parse_iri($iri)
{
$iri = trim($iri, "\x20\x09\x0A\x0C\x0D");
if (preg_match('/^((?P<scheme>[^:\/?#]+):)?(\/\/(?P<authority>[^\/?#]*))?(?P<path>[^?#]*)(\?(?P<query>[^#]*))?(#(?P<fragment>.*))?$/', $iri, $match))
{
if ($match[1] === '')
{
$match['scheme'] = null;
}
if (!isset($match[3]) || $match[3] === '')
{
$match['authority'] = null;
}
if (!isset($match[5]))
{
$match['path'] = '';
}
if (!isset($match[6]) || $match[6] === '')
{
$match['query'] = null;
}
if (!isset($match[8]) || $match[8] === '')
{
$match['fragment'] = null;
}
return $match;
}
else
{
// This can occur when a paragraph is accidentally parsed as a URI
return false;
}
}
/**
* Remove dot segments from a path
*
* @param string $input
* @return string
*/
protected function remove_dot_segments($input)
{
$output = '';
while (strpos($input, './') !== false || strpos($input, '/.') !== false || $input === '.' || $input === '..')
{
// A: If the input buffer begins with a prefix of "../" or "./", then remove that prefix from the input buffer; otherwise,
if (strpos($input, '../') === 0)
{
$input = substr($input, 3);
}
elseif (strpos($input, './') === 0)
{
$input = substr($input, 2);
}
// B: if the input buffer begins with a prefix of "/./" or "/.", where "." is a complete path segment, then replace that prefix with "/" in the input buffer; otherwise,
elseif (strpos($input, '/./') === 0)
{
$input = substr($input, 2);
}
elseif ($input === '/.')
{
$input = '/';
}
// C: if the input buffer begins with a prefix of "/../" or "/..", where ".." is a complete path segment, then replace that prefix with "/" in the input buffer and remove the last segment and its preceding "/" (if any) from the output buffer; otherwise,
elseif (strpos($input, '/../') === 0)
{
$input = substr($input, 3);
$output = substr_replace($output, '', strrpos($output, '/'));
}
elseif ($input === '/..')
{
$input = '/';
$output = substr_replace($output, '', strrpos($output, '/'));
}
// D: if the input buffer consists only of "." or "..", then remove that from the input buffer; otherwise,
elseif ($input === '.' || $input === '..')
{
$input = '';
}
// E: move the first path segment in the input buffer to the end of the output buffer, including the initial "/" character (if any) and any subsequent characters up to, but not including, the next "/" character or the end of the input buffer
elseif (($pos = strpos($input, '/', 1)) !== false)
{
$output .= substr($input, 0, $pos);
$input = substr_replace($input, '', 0, $pos);
}
else
{
$output .= $input;
$input = '';
}
}
return $output . $input;
}
/**
* Replace invalid character with percent encoding
*
* @param string $string Input string
* @param string $extra_chars Valid characters not in iunreserved or
* iprivate (this is ASCII-only)
* @param bool $iprivate Allow iprivate
* @return string
*/
protected function replace_invalid_with_pct_encoding($string, $extra_chars, $iprivate = false)
{
// Normalize as many pct-encoded sections as possible
$string = preg_replace_callback('/(?:%[A-Fa-f0-9]{2})+/', array($this, 'remove_iunreserved_percent_encoded'), $string);
// Replace invalid percent characters
$string = preg_replace('/%(?![A-Fa-f0-9]{2})/', '%25', $string);
// Add unreserved and % to $extra_chars (the latter is safe because all
// pct-encoded sections are now valid).
$extra_chars .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~%';
// Now replace any bytes that aren't allowed with their pct-encoded versions
$position = 0;
$strlen = strlen($string);
while (($position += strspn($string, $extra_chars, $position)) < $strlen)
{
$value = ord($string[$position]);
// Start position
$start = $position;
// By default we are valid
$valid = true;
// No one byte sequences are valid due to the while.
// Two byte sequence:
if (($value & 0xE0) === 0xC0)
{
$character = ($value & 0x1F) << 6;
$length = 2;
$remaining = 1;
}
// Three byte sequence:
elseif (($value & 0xF0) === 0xE0)
{
$character = ($value & 0x0F) << 12;
$length = 3;
$remaining = 2;
}
// Four byte sequence:
elseif (($value & 0xF8) === 0xF0)
{
$character = ($value & 0x07) << 18;
$length = 4;
$remaining = 3;
}
// Invalid byte:
else
{
$valid = false;
$length = 1;
$remaining = 0;
}
if ($remaining)
{
if ($position + $length <= $strlen)
{
for ($position++; $remaining; $position++)
{
$value = ord($string[$position]);
// Check that the byte is valid, then add it to the character:
if (($value & 0xC0) === 0x80)
{
$character |= ($value & 0x3F) << (--$remaining * 6);
}
// If it is invalid, count the sequence as invalid and reprocess the current byte:
else
{
$valid = false;
$position--;
break;
}
}
}
else
{
$position = $strlen - 1;
$valid = false;
}
}
// Percent encode anything invalid or not in ucschar
if (
// Invalid sequences
!$valid
// Non-shortest form sequences are invalid
|| $length > 1 && $character <= 0x7F
|| $length > 2 && $character <= 0x7FF
|| $length > 3 && $character <= 0xFFFF
// Outside of range of ucschar codepoints
// Noncharacters
|| ($character & 0xFFFE) === 0xFFFE
|| $character >= 0xFDD0 && $character <= 0xFDEF
|| (
// Everything else not in ucschar
$character > 0xD7FF && $character < 0xF900
|| $character < 0xA0
|| $character > 0xEFFFD
)
&& (
// Everything not in iprivate, if it applies
!$iprivate
|| $character < 0xE000
|| $character > 0x10FFFD
)
)
{
// If we were a character, pretend we weren't, but rather an error.
if ($valid)
$position--;
for ($j = $start; $j <= $position; $j++)
{
$string = substr_replace($string, sprintf('%%%02X', ord($string[$j])), $j, 1);
$j += 2;
$position += 2;
$strlen += 2;
}
}
}
return $string;
}
/**
* Callback function for preg_replace_callback.
*
* Removes sequences of percent encoded bytes that represent UTF-8
* encoded characters in iunreserved
*
* @param array $match PCRE match
* @return string Replacement
*/
protected function remove_iunreserved_percent_encoded($match)
{
// As we just have valid percent encoded sequences we can just explode
// and ignore the first member of the returned array (an empty string).
$bytes = explode('%', $match[0]);
// Initialize the new string (this is what will be returned) and that
// there are no bytes remaining in the current sequence (unsurprising
// at the first byte!).
$string = '';
$remaining = 0;
// Loop over each and every byte, and set $value to its value
for ($i = 1, $len = count($bytes); $i < $len; $i++)
{
$value = hexdec($bytes[$i]);
// If we're the first byte of sequence:
if (!$remaining)
{
// Start position
$start = $i;
// By default we are valid
$valid = true;
// One byte sequence:
if ($value <= 0x7F)
{
$character = $value;
$length = 1;
}
// Two byte sequence:
elseif (($value & 0xE0) === 0xC0)
{
$character = ($value & 0x1F) << 6;
$length = 2;
$remaining = 1;
}
// Three byte sequence:
elseif (($value & 0xF0) === 0xE0)
{
$character = ($value & 0x0F) << 12;
$length = 3;
$remaining = 2;
}
// Four byte sequence:
elseif (($value & 0xF8) === 0xF0)
{
$character = ($value & 0x07) << 18;
$length = 4;
$remaining = 3;
}
// Invalid byte:
else
{
$valid = false;
$remaining = 0;
}
}
// Continuation byte:
else
{
// Check that the byte is valid, then add it to the character:
if (($value & 0xC0) === 0x80)
{
$remaining--;
$character |= ($value & 0x3F) << ($remaining * 6);
}
// If it is invalid, count the sequence as invalid and reprocess the current byte as the start of a sequence:
else
{
$valid = false;
$remaining = 0;
$i--;
}
}
// If we've reached the end of the current byte sequence, append it to Unicode::$data
if (!$remaining)
{
// Percent encode anything invalid or not in iunreserved
if (
// Invalid sequences
!$valid
// Non-shortest form sequences are invalid
|| $length > 1 && $character <= 0x7F
|| $length > 2 && $character <= 0x7FF
|| $length > 3 && $character <= 0xFFFF
// Outside of range of iunreserved codepoints
|| $character < 0x2D
|| $character > 0xEFFFD
// Noncharacters
|| ($character & 0xFFFE) === 0xFFFE
|| $character >= 0xFDD0 && $character <= 0xFDEF
// Everything else not in iunreserved (this is all BMP)
|| $character === 0x2F
|| $character > 0x39 && $character < 0x41
|| $character > 0x5A && $character < 0x61
|| $character > 0x7A && $character < 0x7E
|| $character > 0x7E && $character < 0xA0
|| $character > 0xD7FF && $character < 0xF900
)
{
for ($j = $start; $j <= $i; $j++)
{
$string .= '%' . strtoupper($bytes[$j]);
}
}
else
{
for ($j = $start; $j <= $i; $j++)
{
$string .= chr(hexdec($bytes[$j]));
}
}
}
}
// If we have any bytes left over they are invalid (i.e., we are
// mid-way through a multi-byte sequence)
if ($remaining)
{
for ($j = $start; $j < $len; $j++)
{
$string .= '%' . strtoupper($bytes[$j]);
}
}
return $string;
}
protected function scheme_normalization()
{
if (isset($this->normalization[$this->scheme]['iuserinfo']) && $this->iuserinfo === $this->normalization[$this->scheme]['iuserinfo'])
{
$this->iuserinfo = null;
}
if (isset($this->normalization[$this->scheme]['ihost']) && $this->ihost === $this->normalization[$this->scheme]['ihost'])
{
$this->ihost = null;
}
if (isset($this->normalization[$this->scheme]['port']) && $this->port === $this->normalization[$this->scheme]['port'])
{
$this->port = null;
}
if (isset($this->normalization[$this->scheme]['ipath']) && $this->ipath === $this->normalization[$this->scheme]['ipath'])
{
$this->ipath = '';
}
if (isset($this->normalization[$this->scheme]['iquery']) && $this->iquery === $this->normalization[$this->scheme]['iquery'])
{
$this->iquery = null;
}
if (isset($this->normalization[$this->scheme]['ifragment']) && $this->ifragment === $this->normalization[$this->scheme]['ifragment'])
{
$this->ifragment = null;
}
}
/**
* Check if the object represents a valid IRI. This needs to be done on each
* call as some things change depending on another part of the IRI.
*
* @return bool
*/
public function is_valid()
{
$isauthority = $this->iuserinfo !== null || $this->ihost !== null || $this->port !== null;
if ($this->ipath !== '' &&
(
$isauthority && (
$this->ipath[0] !== '/' ||
substr($this->ipath, 0, 2) === '//'
) ||
(
$this->scheme === null &&
!$isauthority &&
strpos($this->ipath, ':') !== false &&
(strpos($this->ipath, '/') === false ? true : strpos($this->ipath, ':') < strpos($this->ipath, '/'))
)
)
)
{
return false;
}
return true;
}
/**
* Set the entire IRI. Returns true on success, false on failure (if there
* are any invalid characters).
*
* @param string $iri
* @return bool
*/
public function set_iri($iri)
{
static $cache;
if (!$cache)
{
$cache = array();
}
if ($iri === null)
{
return true;
}
elseif (isset($cache[$iri]))
{
list($this->scheme,
$this->iuserinfo,
$this->ihost,
$this->port,
$this->ipath,
$this->iquery,
$this->ifragment,
$return) = $cache[$iri];
return $return;
}
else
{
$parsed = $this->parse_iri((string) $iri);
if (!$parsed)
{
return false;
}
$return = $this->set_scheme($parsed['scheme'])
&& $this->set_authority($parsed['authority'])
&& $this->set_path($parsed['path'])
&& $this->set_query($parsed['query'])
&& $this->set_fragment($parsed['fragment']);
$cache[$iri] = array($this->scheme,
$this->iuserinfo,
$this->ihost,
$this->port,
$this->ipath,
$this->iquery,
$this->ifragment,
$return);
return $return;
}
}
/**
* Set the scheme. Returns true on success, false on failure (if there are
* any invalid characters).
*
* @param string $scheme
* @return bool
*/
public function set_scheme($scheme)
{
if ($scheme === null)
{
$this->scheme = null;
}
elseif (!preg_match('/^[A-Za-z][0-9A-Za-z+\-.]*$/', $scheme))
{
$this->scheme = null;
return false;
}
else
{
$this->scheme = strtolower($scheme);
}
return true;
}
/**
* Set the authority. Returns true on success, false on failure (if there are
* any invalid characters).
*
* @param string $authority
* @return bool
*/
public function set_authority($authority)
{
static $cache;
if (!$cache)
$cache = array();
if ($authority === null)
{
$this->iuserinfo = null;
$this->ihost = null;
$this->port = null;
return true;
}
elseif (isset($cache[$authority]))
{
list($this->iuserinfo,
$this->ihost,
$this->port,
$return) = $cache[$authority];
return $return;
}
else
{
$remaining = $authority;
if (($iuserinfo_end = strrpos($remaining, '@')) !== false)
{
$iuserinfo = substr($remaining, 0, $iuserinfo_end);
$remaining = substr($remaining, $iuserinfo_end + 1);
}
else
{
$iuserinfo = null;
}
if (($port_start = strpos($remaining, ':', strpos($remaining, ']'))) !== false)
{
if (($port = substr($remaining, $port_start + 1)) === false)
{
$port = null;
}
$remaining = substr($remaining, 0, $port_start);
}
else
{
$port = null;
}
$return = $this->set_userinfo($iuserinfo) &&
$this->set_host($remaining) &&
$this->set_port($port);
$cache[$authority] = array($this->iuserinfo,
$this->ihost,
$this->port,
$return);
return $return;
}
}
/**
* Set the iuserinfo.
*
* @param string $iuserinfo
* @return bool
*/
public function set_userinfo($iuserinfo)
{
if ($iuserinfo === null)
{
$this->iuserinfo = null;
}
else
{
$this->iuserinfo = $this->replace_invalid_with_pct_encoding($iuserinfo, '!$&\'()*+,;=:');
$this->scheme_normalization();
}
return true;
}
/**
* Set the ihost. Returns true on success, false on failure (if there are
* any invalid characters).
*
* @param string $ihost
* @return bool
*/
public function set_host($ihost)
{
if ($ihost === null)
{
$this->ihost = null;
return true;
}
elseif (substr($ihost, 0, 1) === '[' && substr($ihost, -1) === ']')
{
if (SimplePie_Net_IPv6::check_ipv6(substr($ihost, 1, -1)))
{
$this->ihost = '[' . SimplePie_Net_IPv6::compress(substr($ihost, 1, -1)) . ']';
}
else
{
$this->ihost = null;
return false;
}
}
else
{
$ihost = $this->replace_invalid_with_pct_encoding($ihost, '!$&\'()*+,;=');
// Lowercase, but ignore pct-encoded sections (as they should
// remain uppercase). This must be done after the previous step
// as that can add unescaped characters.
$position = 0;
$strlen = strlen($ihost);
while (($position += strcspn($ihost, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ%', $position)) < $strlen)
{
if ($ihost[$position] === '%')
{
$position += 3;
}
else
{
$ihost[$position] = strtolower($ihost[$position]);
$position++;
}
}
$this->ihost = $ihost;
}
$this->scheme_normalization();
return true;
}
/**
* Set the port. Returns true on success, false on failure (if there are
* any invalid characters).
*
* @param string $port
* @return bool
*/
public function set_port($port)
{
if ($port === null)
{
$this->port = null;
return true;
}
elseif (strspn($port, '0123456789') === strlen($port))
{
$this->port = (int) $port;
$this->scheme_normalization();
return true;
}
else
{
$this->port = null;
return false;
}
}
/**
* Set the ipath.
*
* @param string $ipath
* @return bool
*/
public function set_path($ipath)
{
static $cache;
if (!$cache)
{
$cache = array();
}
$ipath = (string) $ipath;
if (isset($cache[$ipath]))
{
$this->ipath = $cache[$ipath][(int) ($this->scheme !== null)];
}
else
{
$valid = $this->replace_invalid_with_pct_encoding($ipath, '!$&\'()*+,;=@:/');
$removed = $this->remove_dot_segments($valid);
$cache[$ipath] = array($valid, $removed);
$this->ipath = ($this->scheme !== null) ? $removed : $valid;
}
$this->scheme_normalization();
return true;
}
/**
* Set the iquery.
*
* @param string $iquery
* @return bool
*/
public function set_query($iquery)
{
if ($iquery === null)
{
$this->iquery = null;
}
else
{
$this->iquery = $this->replace_invalid_with_pct_encoding($iquery, '!$&\'()*+,;=:@/?', true);
$this->scheme_normalization();
}
return true;
}
/**
* Set the ifragment.
*
* @param string $ifragment
* @return bool
*/
public function set_fragment($ifragment)
{
if ($ifragment === null)
{
$this->ifragment = null;
}
else
{
$this->ifragment = $this->replace_invalid_with_pct_encoding($ifragment, '!$&\'()*+,;=:@/?');
$this->scheme_normalization();
}
return true;
}
/**
* Convert an IRI to a URI (or parts thereof)
*
* @return string
*/
public function to_uri($string)
{
static $non_ascii;
if (!$non_ascii)
{
$non_ascii = implode('', range("\x80", "\xFF"));
}
$position = 0;
$strlen = strlen($string);
while (($position += strcspn($string, $non_ascii, $position)) < $strlen)
{
$string = substr_replace($string, sprintf('%%%02X', ord($string[$position])), $position, 1);
$position += 3;
$strlen += 2;
}
return $string;
}
/**
* Get the complete IRI
*
* @return string
*/
public function get_iri()
{
if (!$this->is_valid())
{
return false;
}
$iri = '';
if ($this->scheme !== null)
{
$iri .= $this->scheme . ':';
}
if (($iauthority = $this->get_iauthority()) !== null)
{
$iri .= '//' . $iauthority;
}
if ($this->ipath !== '')
{
$iri .= $this->ipath;
}
elseif (!empty($this->normalization[$this->scheme]['ipath']) && $iauthority !== null && $iauthority !== '')
{
$iri .= $this->normalization[$this->scheme]['ipath'];
}
if ($this->iquery !== null)
{
$iri .= '?' . $this->iquery;
}
if ($this->ifragment !== null)
{
$iri .= '#' . $this->ifragment;
}
return $iri;
}
/**
* Get the complete URI
*
* @return string
*/
public function get_uri()
{
return $this->to_uri($this->get_iri());
}
/**
* Get the complete iauthority
*
* @return string
*/
protected function get_iauthority()
{
if ($this->iuserinfo !== null || $this->ihost !== null || $this->port !== null)
{
$iauthority = '';
if ($this->iuserinfo !== null)
{
$iauthority .= $this->iuserinfo . '@';
}
if ($this->ihost !== null)
{
$iauthority .= $this->ihost;
}
if ($this->port !== null)
{
$iauthority .= ':' . $this->port;
}
return $iauthority;
}
else
{
return null;
}
}
/**
* Get the complete authority
*
* @return string
*/
protected function get_authority()
{
$iauthority = $this->get_iauthority();
if (is_string($iauthority))
return $this->to_uri($iauthority);
else
return $iauthority;
}
}
| 01-wordpress-paypal | trunk/wp-includes/SimplePie/IRI.php | PHP | gpl3 | 28,359 |
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @version 1.3.1
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman
* @author Geoffrey Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
/**
* Handles everything related to enclosures (including Media RSS and iTunes RSS)
*
* Used by {@see SimplePie_Item::get_enclosure()} and {@see SimplePie_Item::get_enclosures()}
*
* This class can be overloaded with {@see SimplePie::set_enclosure_class()}
*
* @package SimplePie
* @subpackage API
*/
class SimplePie_Enclosure
{
/**
* @var string
* @see get_bitrate()
*/
var $bitrate;
/**
* @var array
* @see get_captions()
*/
var $captions;
/**
* @var array
* @see get_categories()
*/
var $categories;
/**
* @var int
* @see get_channels()
*/
var $channels;
/**
* @var SimplePie_Copyright
* @see get_copyright()
*/
var $copyright;
/**
* @var array
* @see get_credits()
*/
var $credits;
/**
* @var string
* @see get_description()
*/
var $description;
/**
* @var int
* @see get_duration()
*/
var $duration;
/**
* @var string
* @see get_expression()
*/
var $expression;
/**
* @var string
* @see get_framerate()
*/
var $framerate;
/**
* @var string
* @see get_handler()
*/
var $handler;
/**
* @var array
* @see get_hashes()
*/
var $hashes;
/**
* @var string
* @see get_height()
*/
var $height;
/**
* @deprecated
* @var null
*/
var $javascript;
/**
* @var array
* @see get_keywords()
*/
var $keywords;
/**
* @var string
* @see get_language()
*/
var $lang;
/**
* @var string
* @see get_length()
*/
var $length;
/**
* @var string
* @see get_link()
*/
var $link;
/**
* @var string
* @see get_medium()
*/
var $medium;
/**
* @var string
* @see get_player()
*/
var $player;
/**
* @var array
* @see get_ratings()
*/
var $ratings;
/**
* @var array
* @see get_restrictions()
*/
var $restrictions;
/**
* @var string
* @see get_sampling_rate()
*/
var $samplingrate;
/**
* @var array
* @see get_thumbnails()
*/
var $thumbnails;
/**
* @var string
* @see get_title()
*/
var $title;
/**
* @var string
* @see get_type()
*/
var $type;
/**
* @var string
* @see get_width()
*/
var $width;
/**
* Constructor, used to input the data
*
* For documentation on all the parameters, see the corresponding
* properties and their accessors
*
* @uses idna_convert If available, this will convert an IDN
*/
public function __construct($link = null, $type = null, $length = null, $javascript = null, $bitrate = null, $captions = null, $categories = null, $channels = null, $copyright = null, $credits = null, $description = null, $duration = null, $expression = null, $framerate = null, $hashes = null, $height = null, $keywords = null, $lang = null, $medium = null, $player = null, $ratings = null, $restrictions = null, $samplingrate = null, $thumbnails = null, $title = null, $width = null)
{
$this->bitrate = $bitrate;
$this->captions = $captions;
$this->categories = $categories;
$this->channels = $channels;
$this->copyright = $copyright;
$this->credits = $credits;
$this->description = $description;
$this->duration = $duration;
$this->expression = $expression;
$this->framerate = $framerate;
$this->hashes = $hashes;
$this->height = $height;
$this->keywords = $keywords;
$this->lang = $lang;
$this->length = $length;
$this->link = $link;
$this->medium = $medium;
$this->player = $player;
$this->ratings = $ratings;
$this->restrictions = $restrictions;
$this->samplingrate = $samplingrate;
$this->thumbnails = $thumbnails;
$this->title = $title;
$this->type = $type;
$this->width = $width;
if (class_exists('idna_convert'))
{
$idn = new idna_convert();
$parsed = SimplePie_Misc::parse_url($link);
$this->link = SimplePie_Misc::compress_parse_url($parsed['scheme'], $idn->encode($parsed['authority']), $parsed['path'], $parsed['query'], $parsed['fragment']);
}
$this->handler = $this->get_handler(); // Needs to load last
}
/**
* String-ified version
*
* @return string
*/
public function __toString()
{
// There is no $this->data here
return md5(serialize($this));
}
/**
* Get the bitrate
*
* @return string|null
*/
public function get_bitrate()
{
if ($this->bitrate !== null)
{
return $this->bitrate;
}
else
{
return null;
}
}
/**
* Get a single caption
*
* @param int $key
* @return SimplePie_Caption|null
*/
public function get_caption($key = 0)
{
$captions = $this->get_captions();
if (isset($captions[$key]))
{
return $captions[$key];
}
else
{
return null;
}
}
/**
* Get all captions
*
* @return array|null Array of {@see SimplePie_Caption} objects
*/
public function get_captions()
{
if ($this->captions !== null)
{
return $this->captions;
}
else
{
return null;
}
}
/**
* Get a single category
*
* @param int $key
* @return SimplePie_Category|null
*/
public function get_category($key = 0)
{
$categories = $this->get_categories();
if (isset($categories[$key]))
{
return $categories[$key];
}
else
{
return null;
}
}
/**
* Get all categories
*
* @return array|null Array of {@see SimplePie_Category} objects
*/
public function get_categories()
{
if ($this->categories !== null)
{
return $this->categories;
}
else
{
return null;
}
}
/**
* Get the number of audio channels
*
* @return int|null
*/
public function get_channels()
{
if ($this->channels !== null)
{
return $this->channels;
}
else
{
return null;
}
}
/**
* Get the copyright information
*
* @return SimplePie_Copyright|null
*/
public function get_copyright()
{
if ($this->copyright !== null)
{
return $this->copyright;
}
else
{
return null;
}
}
/**
* Get a single credit
*
* @param int $key
* @return SimplePie_Credit|null
*/
public function get_credit($key = 0)
{
$credits = $this->get_credits();
if (isset($credits[$key]))
{
return $credits[$key];
}
else
{
return null;
}
}
/**
* Get all credits
*
* @return array|null Array of {@see SimplePie_Credit} objects
*/
public function get_credits()
{
if ($this->credits !== null)
{
return $this->credits;
}
else
{
return null;
}
}
/**
* Get the description of the enclosure
*
* @return string|null
*/
public function get_description()
{
if ($this->description !== null)
{
return $this->description;
}
else
{
return null;
}
}
/**
* Get the duration of the enclosure
*
* @param string $convert Convert seconds into hh:mm:ss
* @return string|int|null 'hh:mm:ss' string if `$convert` was specified, otherwise integer (or null if none found)
*/
public function get_duration($convert = false)
{
if ($this->duration !== null)
{
if ($convert)
{
$time = SimplePie_Misc::time_hms($this->duration);
return $time;
}
else
{
return $this->duration;
}
}
else
{
return null;
}
}
/**
* Get the expression
*
* @return string Probably one of 'sample', 'full', 'nonstop', 'clip'. Defaults to 'full'
*/
public function get_expression()
{
if ($this->expression !== null)
{
return $this->expression;
}
else
{
return 'full';
}
}
/**
* Get the file extension
*
* @return string|null
*/
public function get_extension()
{
if ($this->link !== null)
{
$url = SimplePie_Misc::parse_url($this->link);
if ($url['path'] !== '')
{
return pathinfo($url['path'], PATHINFO_EXTENSION);
}
}
return null;
}
/**
* Get the framerate (in frames-per-second)
*
* @return string|null
*/
public function get_framerate()
{
if ($this->framerate !== null)
{
return $this->framerate;
}
else
{
return null;
}
}
/**
* Get the preferred handler
*
* @return string|null One of 'flash', 'fmedia', 'quicktime', 'wmedia', 'mp3'
*/
public function get_handler()
{
return $this->get_real_type(true);
}
/**
* Get a single hash
*
* @link http://www.rssboard.org/media-rss#media-hash
* @param int $key
* @return string|null Hash as per `media:hash`, prefixed with "$algo:"
*/
public function get_hash($key = 0)
{
$hashes = $this->get_hashes();
if (isset($hashes[$key]))
{
return $hashes[$key];
}
else
{
return null;
}
}
/**
* Get all credits
*
* @return array|null Array of strings, see {@see get_hash()}
*/
public function get_hashes()
{
if ($this->hashes !== null)
{
return $this->hashes;
}
else
{
return null;
}
}
/**
* Get the height
*
* @return string|null
*/
public function get_height()
{
if ($this->height !== null)
{
return $this->height;
}
else
{
return null;
}
}
/**
* Get the language
*
* @link http://tools.ietf.org/html/rfc3066
* @return string|null Language code as per RFC 3066
*/
public function get_language()
{
if ($this->lang !== null)
{
return $this->lang;
}
else
{
return null;
}
}
/**
* Get a single keyword
*
* @param int $key
* @return string|null
*/
public function get_keyword($key = 0)
{
$keywords = $this->get_keywords();
if (isset($keywords[$key]))
{
return $keywords[$key];
}
else
{
return null;
}
}
/**
* Get all keywords
*
* @return array|null Array of strings
*/
public function get_keywords()
{
if ($this->keywords !== null)
{
return $this->keywords;
}
else
{
return null;
}
}
/**
* Get length
*
* @return float Length in bytes
*/
public function get_length()
{
if ($this->length !== null)
{
return $this->length;
}
else
{
return null;
}
}
/**
* Get the URL
*
* @return string|null
*/
public function get_link()
{
if ($this->link !== null)
{
return urldecode($this->link);
}
else
{
return null;
}
}
/**
* Get the medium
*
* @link http://www.rssboard.org/media-rss#media-content
* @return string|null Should be one of 'image', 'audio', 'video', 'document', 'executable'
*/
public function get_medium()
{
if ($this->medium !== null)
{
return $this->medium;
}
else
{
return null;
}
}
/**
* Get the player URL
*
* Typically the same as {@see get_permalink()}
* @return string|null Player URL
*/
public function get_player()
{
if ($this->player !== null)
{
return $this->player;
}
else
{
return null;
}
}
/**
* Get a single rating
*
* @param int $key
* @return SimplePie_Rating|null
*/
public function get_rating($key = 0)
{
$ratings = $this->get_ratings();
if (isset($ratings[$key]))
{
return $ratings[$key];
}
else
{
return null;
}
}
/**
* Get all ratings
*
* @return array|null Array of {@see SimplePie_Rating} objects
*/
public function get_ratings()
{
if ($this->ratings !== null)
{
return $this->ratings;
}
else
{
return null;
}
}
/**
* Get a single restriction
*
* @param int $key
* @return SimplePie_Restriction|null
*/
public function get_restriction($key = 0)
{
$restrictions = $this->get_restrictions();
if (isset($restrictions[$key]))
{
return $restrictions[$key];
}
else
{
return null;
}
}
/**
* Get all restrictions
*
* @return array|null Array of {@see SimplePie_Restriction} objects
*/
public function get_restrictions()
{
if ($this->restrictions !== null)
{
return $this->restrictions;
}
else
{
return null;
}
}
/**
* Get the sampling rate (in kHz)
*
* @return string|null
*/
public function get_sampling_rate()
{
if ($this->samplingrate !== null)
{
return $this->samplingrate;
}
else
{
return null;
}
}
/**
* Get the file size (in MiB)
*
* @return float|null File size in mebibytes (1048 bytes)
*/
public function get_size()
{
$length = $this->get_length();
if ($length !== null)
{
return round($length/1048576, 2);
}
else
{
return null;
}
}
/**
* Get a single thumbnail
*
* @param int $key
* @return string|null Thumbnail URL
*/
public function get_thumbnail($key = 0)
{
$thumbnails = $this->get_thumbnails();
if (isset($thumbnails[$key]))
{
return $thumbnails[$key];
}
else
{
return null;
}
}
/**
* Get all thumbnails
*
* @return array|null Array of thumbnail URLs
*/
public function get_thumbnails()
{
if ($this->thumbnails !== null)
{
return $this->thumbnails;
}
else
{
return null;
}
}
/**
* Get the title
*
* @return string|null
*/
public function get_title()
{
if ($this->title !== null)
{
return $this->title;
}
else
{
return null;
}
}
/**
* Get mimetype of the enclosure
*
* @see get_real_type()
* @return string|null MIME type
*/
public function get_type()
{
if ($this->type !== null)
{
return $this->type;
}
else
{
return null;
}
}
/**
* Get the width
*
* @return string|null
*/
public function get_width()
{
if ($this->width !== null)
{
return $this->width;
}
else
{
return null;
}
}
/**
* Embed the enclosure using `<embed>`
*
* @deprecated Use the second parameter to {@see embed} instead
*
* @param array|string $options See first paramter to {@see embed}
* @return string HTML string to output
*/
public function native_embed($options='')
{
return $this->embed($options, true);
}
/**
* Embed the enclosure using Javascript
*
* `$options` is an array or comma-separated key:value string, with the
* following properties:
*
* - `alt` (string): Alternate content for when an end-user does not have
* the appropriate handler installed or when a file type is
* unsupported. Can be any text or HTML. Defaults to blank.
* - `altclass` (string): If a file type is unsupported, the end-user will
* see the alt text (above) linked directly to the content. That link
* will have this value as its class name. Defaults to blank.
* - `audio` (string): This is an image that should be used as a
* placeholder for audio files before they're loaded (QuickTime-only).
* Can be any relative or absolute URL. Defaults to blank.
* - `bgcolor` (string): The background color for the media, if not
* already transparent. Defaults to `#ffffff`.
* - `height` (integer): The height of the embedded media. Accepts any
* numeric pixel value (such as `360`) or `auto`. Defaults to `auto`,
* and it is recommended that you use this default.
* - `loop` (boolean): Do you want the media to loop when its done?
* Defaults to `false`.
* - `mediaplayer` (string): The location of the included
* `mediaplayer.swf` file. This allows for the playback of Flash Video
* (`.flv`) files, and is the default handler for non-Odeo MP3's.
* Defaults to blank.
* - `video` (string): This is an image that should be used as a
* placeholder for video files before they're loaded (QuickTime-only).
* Can be any relative or absolute URL. Defaults to blank.
* - `width` (integer): The width of the embedded media. Accepts any
* numeric pixel value (such as `480`) or `auto`. Defaults to `auto`,
* and it is recommended that you use this default.
* - `widescreen` (boolean): Is the enclosure widescreen or standard?
* This applies only to video enclosures, and will automatically resize
* the content appropriately. Defaults to `false`, implying 4:3 mode.
*
* Note: Non-widescreen (4:3) mode with `width` and `height` set to `auto`
* will default to 480x360 video resolution. Widescreen (16:9) mode with
* `width` and `height` set to `auto` will default to 480x270 video resolution.
*
* @todo If the dimensions for media:content are defined, use them when width/height are set to 'auto'.
* @param array|string $options Comma-separated key:value list, or array
* @param bool $native Use `<embed>`
* @return string HTML string to output
*/
public function embed($options = '', $native = false)
{
// Set up defaults
$audio = '';
$video = '';
$alt = '';
$altclass = '';
$loop = 'false';
$width = 'auto';
$height = 'auto';
$bgcolor = '#ffffff';
$mediaplayer = '';
$widescreen = false;
$handler = $this->get_handler();
$type = $this->get_real_type();
// Process options and reassign values as necessary
if (is_array($options))
{
extract($options);
}
else
{
$options = explode(',', $options);
foreach($options as $option)
{
$opt = explode(':', $option, 2);
if (isset($opt[0], $opt[1]))
{
$opt[0] = trim($opt[0]);
$opt[1] = trim($opt[1]);
switch ($opt[0])
{
case 'audio':
$audio = $opt[1];
break;
case 'video':
$video = $opt[1];
break;
case 'alt':
$alt = $opt[1];
break;
case 'altclass':
$altclass = $opt[1];
break;
case 'loop':
$loop = $opt[1];
break;
case 'width':
$width = $opt[1];
break;
case 'height':
$height = $opt[1];
break;
case 'bgcolor':
$bgcolor = $opt[1];
break;
case 'mediaplayer':
$mediaplayer = $opt[1];
break;
case 'widescreen':
$widescreen = $opt[1];
break;
}
}
}
}
$mime = explode('/', $type, 2);
$mime = $mime[0];
// Process values for 'auto'
if ($width === 'auto')
{
if ($mime === 'video')
{
if ($height === 'auto')
{
$width = 480;
}
elseif ($widescreen)
{
$width = round((intval($height)/9)*16);
}
else
{
$width = round((intval($height)/3)*4);
}
}
else
{
$width = '100%';
}
}
if ($height === 'auto')
{
if ($mime === 'audio')
{
$height = 0;
}
elseif ($mime === 'video')
{
if ($width === 'auto')
{
if ($widescreen)
{
$height = 270;
}
else
{
$height = 360;
}
}
elseif ($widescreen)
{
$height = round((intval($width)/16)*9);
}
else
{
$height = round((intval($width)/4)*3);
}
}
else
{
$height = 376;
}
}
elseif ($mime === 'audio')
{
$height = 0;
}
// Set proper placeholder value
if ($mime === 'audio')
{
$placeholder = $audio;
}
elseif ($mime === 'video')
{
$placeholder = $video;
}
$embed = '';
// Flash
if ($handler === 'flash')
{
if ($native)
{
$embed .= "<embed src=\"" . $this->get_link() . "\" pluginspage=\"http://adobe.com/go/getflashplayer\" type=\"$type\" quality=\"high\" width=\"$width\" height=\"$height\" bgcolor=\"$bgcolor\" loop=\"$loop\"></embed>";
}
else
{
$embed .= "<script type='text/javascript'>embed_flash('$bgcolor', '$width', '$height', '" . $this->get_link() . "', '$loop', '$type');</script>";
}
}
// Flash Media Player file types.
// Preferred handler for MP3 file types.
elseif ($handler === 'fmedia' || ($handler === 'mp3' && $mediaplayer !== ''))
{
$height += 20;
if ($native)
{
$embed .= "<embed src=\"$mediaplayer\" pluginspage=\"http://adobe.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" quality=\"high\" width=\"$width\" height=\"$height\" wmode=\"transparent\" flashvars=\"file=" . rawurlencode($this->get_link().'?file_extension=.'.$this->get_extension()) . "&autostart=false&repeat=$loop&showdigits=true&showfsbutton=false\"></embed>";
}
else
{
$embed .= "<script type='text/javascript'>embed_flv('$width', '$height', '" . rawurlencode($this->get_link().'?file_extension=.'.$this->get_extension()) . "', '$placeholder', '$loop', '$mediaplayer');</script>";
}
}
// QuickTime 7 file types. Need to test with QuickTime 6.
// Only handle MP3's if the Flash Media Player is not present.
elseif ($handler === 'quicktime' || ($handler === 'mp3' && $mediaplayer === ''))
{
$height += 16;
if ($native)
{
if ($placeholder !== '')
{
$embed .= "<embed type=\"$type\" style=\"cursor:hand; cursor:pointer;\" href=\"" . $this->get_link() . "\" src=\"$placeholder\" width=\"$width\" height=\"$height\" autoplay=\"false\" target=\"myself\" controller=\"false\" loop=\"$loop\" scale=\"aspect\" bgcolor=\"$bgcolor\" pluginspage=\"http://apple.com/quicktime/download/\"></embed>";
}
else
{
$embed .= "<embed type=\"$type\" style=\"cursor:hand; cursor:pointer;\" src=\"" . $this->get_link() . "\" width=\"$width\" height=\"$height\" autoplay=\"false\" target=\"myself\" controller=\"true\" loop=\"$loop\" scale=\"aspect\" bgcolor=\"$bgcolor\" pluginspage=\"http://apple.com/quicktime/download/\"></embed>";
}
}
else
{
$embed .= "<script type='text/javascript'>embed_quicktime('$type', '$bgcolor', '$width', '$height', '" . $this->get_link() . "', '$placeholder', '$loop');</script>";
}
}
// Windows Media
elseif ($handler === 'wmedia')
{
$height += 45;
if ($native)
{
$embed .= "<embed type=\"application/x-mplayer2\" src=\"" . $this->get_link() . "\" autosize=\"1\" width=\"$width\" height=\"$height\" showcontrols=\"1\" showstatusbar=\"0\" showdisplay=\"0\" autostart=\"0\"></embed>";
}
else
{
$embed .= "<script type='text/javascript'>embed_wmedia('$width', '$height', '" . $this->get_link() . "');</script>";
}
}
// Everything else
else $embed .= '<a href="' . $this->get_link() . '" class="' . $altclass . '">' . $alt . '</a>';
return $embed;
}
/**
* Get the real media type
*
* Often, feeds lie to us, necessitating a bit of deeper inspection. This
* converts types to their canonical representations based on the file
* extension
*
* @see get_type()
* @param bool $find_handler Internal use only, use {@see get_handler()} instead
* @return string MIME type
*/
public function get_real_type($find_handler = false)
{
// Mime-types by handler.
$types_flash = array('application/x-shockwave-flash', 'application/futuresplash'); // Flash
$types_fmedia = array('video/flv', 'video/x-flv','flv-application/octet-stream'); // Flash Media Player
$types_quicktime = array('audio/3gpp', 'audio/3gpp2', 'audio/aac', 'audio/x-aac', 'audio/aiff', 'audio/x-aiff', 'audio/mid', 'audio/midi', 'audio/x-midi', 'audio/mp4', 'audio/m4a', 'audio/x-m4a', 'audio/wav', 'audio/x-wav', 'video/3gpp', 'video/3gpp2', 'video/m4v', 'video/x-m4v', 'video/mp4', 'video/mpeg', 'video/x-mpeg', 'video/quicktime', 'video/sd-video'); // QuickTime
$types_wmedia = array('application/asx', 'application/x-mplayer2', 'audio/x-ms-wma', 'audio/x-ms-wax', 'video/x-ms-asf-plugin', 'video/x-ms-asf', 'video/x-ms-wm', 'video/x-ms-wmv', 'video/x-ms-wvx'); // Windows Media
$types_mp3 = array('audio/mp3', 'audio/x-mp3', 'audio/mpeg', 'audio/x-mpeg'); // MP3
if ($this->get_type() !== null)
{
$type = strtolower($this->type);
}
else
{
$type = null;
}
// If we encounter an unsupported mime-type, check the file extension and guess intelligently.
if (!in_array($type, array_merge($types_flash, $types_fmedia, $types_quicktime, $types_wmedia, $types_mp3)))
{
switch (strtolower($this->get_extension()))
{
// Audio mime-types
case 'aac':
case 'adts':
$type = 'audio/acc';
break;
case 'aif':
case 'aifc':
case 'aiff':
case 'cdda':
$type = 'audio/aiff';
break;
case 'bwf':
$type = 'audio/wav';
break;
case 'kar':
case 'mid':
case 'midi':
case 'smf':
$type = 'audio/midi';
break;
case 'm4a':
$type = 'audio/x-m4a';
break;
case 'mp3':
case 'swa':
$type = 'audio/mp3';
break;
case 'wav':
$type = 'audio/wav';
break;
case 'wax':
$type = 'audio/x-ms-wax';
break;
case 'wma':
$type = 'audio/x-ms-wma';
break;
// Video mime-types
case '3gp':
case '3gpp':
$type = 'video/3gpp';
break;
case '3g2':
case '3gp2':
$type = 'video/3gpp2';
break;
case 'asf':
$type = 'video/x-ms-asf';
break;
case 'flv':
$type = 'video/x-flv';
break;
case 'm1a':
case 'm1s':
case 'm1v':
case 'm15':
case 'm75':
case 'mp2':
case 'mpa':
case 'mpeg':
case 'mpg':
case 'mpm':
case 'mpv':
$type = 'video/mpeg';
break;
case 'm4v':
$type = 'video/x-m4v';
break;
case 'mov':
case 'qt':
$type = 'video/quicktime';
break;
case 'mp4':
case 'mpg4':
$type = 'video/mp4';
break;
case 'sdv':
$type = 'video/sd-video';
break;
case 'wm':
$type = 'video/x-ms-wm';
break;
case 'wmv':
$type = 'video/x-ms-wmv';
break;
case 'wvx':
$type = 'video/x-ms-wvx';
break;
// Flash mime-types
case 'spl':
$type = 'application/futuresplash';
break;
case 'swf':
$type = 'application/x-shockwave-flash';
break;
}
}
if ($find_handler)
{
if (in_array($type, $types_flash))
{
return 'flash';
}
elseif (in_array($type, $types_fmedia))
{
return 'fmedia';
}
elseif (in_array($type, $types_quicktime))
{
return 'quicktime';
}
elseif (in_array($type, $types_wmedia))
{
return 'wmedia';
}
elseif (in_array($type, $types_mp3))
{
return 'mp3';
}
else
{
return null;
}
}
else
{
return $type;
}
}
}
| 01-wordpress-paypal | trunk/wp-includes/SimplePie/Enclosure.php | PHP | gpl3 | 27,487 |
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @version 1.3.1
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman
* @author Geoffrey Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
/**
* Handles `<atom:source>`
*
* Used by {@see SimplePie_Item::get_source()}
*
* This class can be overloaded with {@see SimplePie::set_source_class()}
*
* @package SimplePie
* @subpackage API
*/
class SimplePie_Source
{
var $item;
var $data = array();
protected $registry;
public function __construct($item, $data)
{
$this->item = $item;
$this->data = $data;
}
public function set_registry(SimplePie_Registry $registry)
{
$this->registry = $registry;
}
public function __toString()
{
return md5(serialize($this->data));
}
public function get_source_tags($namespace, $tag)
{
if (isset($this->data['child'][$namespace][$tag]))
{
return $this->data['child'][$namespace][$tag];
}
else
{
return null;
}
}
public function get_base($element = array())
{
return $this->item->get_base($element);
}
public function sanitize($data, $type, $base = '')
{
return $this->item->sanitize($data, $type, $base);
}
public function get_item()
{
return $this->item;
}
public function get_title()
{
if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'title'))
{
return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($return[0]['attribs'])), $this->get_base($return[0]));
}
elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'title'))
{
return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($return[0]['attribs'])), $this->get_base($return[0]));
}
elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
}
elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
}
elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
}
elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
else
{
return null;
}
}
public function get_category($key = 0)
{
$categories = $this->get_categories();
if (isset($categories[$key]))
{
return $categories[$key];
}
else
{
return null;
}
}
public function get_categories()
{
$categories = array();
foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'category') as $category)
{
$term = null;
$scheme = null;
$label = null;
if (isset($category['attribs']['']['term']))
{
$term = $this->sanitize($category['attribs']['']['term'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($category['attribs']['']['scheme']))
{
$scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($category['attribs']['']['label']))
{
$label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
}
$categories[] = $this->registry->create('Category', array($term, $scheme, $label));
}
foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'category') as $category)
{
// This is really the label, but keep this as the term also for BC.
// Label will also work on retrieving because that falls back to term.
$term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
if (isset($category['attribs']['']['domain']))
{
$scheme = $this->sanitize($category['attribs']['']['domain'], SIMPLEPIE_CONSTRUCT_TEXT);
}
else
{
$scheme = null;
}
$categories[] = $this->registry->create('Category', array($term, $scheme, null));
}
foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category)
{
$categories[] = $this->registry->create('Category', array($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null));
}
foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'subject') as $category)
{
$categories[] = $this->registry->create('Category', array($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null));
}
if (!empty($categories))
{
return array_unique($categories);
}
else
{
return null;
}
}
public function get_author($key = 0)
{
$authors = $this->get_authors();
if (isset($authors[$key]))
{
return $authors[$key];
}
else
{
return null;
}
}
public function get_authors()
{
$authors = array();
foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author') as $author)
{
$name = null;
$uri = null;
$email = null;
if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']))
{
$name = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']))
{
$uri = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]));
}
if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']))
{
$email = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if ($name !== null || $email !== null || $uri !== null)
{
$authors[] = $this->registry->create('Author', array($name, $uri, $email));
}
}
if ($author = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'author'))
{
$name = null;
$url = null;
$email = null;
if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']))
{
$name = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data']))
{
$url = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]));
}
if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']))
{
$email = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if ($name !== null || $email !== null || $url !== null)
{
$authors[] = $this->registry->create('Author', array($name, $url, $email));
}
}
foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'creator') as $author)
{
$authors[] = $this->registry->create('Author', array($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null));
}
foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'creator') as $author)
{
$authors[] = $this->registry->create('Author', array($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null));
}
foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'author') as $author)
{
$authors[] = $this->registry->create('Author', array($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null));
}
if (!empty($authors))
{
return array_unique($authors);
}
else
{
return null;
}
}
public function get_contributor($key = 0)
{
$contributors = $this->get_contributors();
if (isset($contributors[$key]))
{
return $contributors[$key];
}
else
{
return null;
}
}
public function get_contributors()
{
$contributors = array();
foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'contributor') as $contributor)
{
$name = null;
$uri = null;
$email = null;
if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']))
{
$name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']))
{
$uri = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]));
}
if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']))
{
$email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if ($name !== null || $email !== null || $uri !== null)
{
$contributors[] = $this->registry->create('Author', array($name, $uri, $email));
}
}
foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'contributor') as $contributor)
{
$name = null;
$url = null;
$email = null;
if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']))
{
$name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data']))
{
$url = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]));
}
if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']))
{
$email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if ($name !== null || $email !== null || $url !== null)
{
$contributors[] = $this->registry->create('Author', array($name, $url, $email));
}
}
if (!empty($contributors))
{
return array_unique($contributors);
}
else
{
return null;
}
}
public function get_link($key = 0, $rel = 'alternate')
{
$links = $this->get_links($rel);
if (isset($links[$key]))
{
return $links[$key];
}
else
{
return null;
}
}
/**
* Added for parity between the parent-level and the item/entry-level.
*/
public function get_permalink()
{
return $this->get_link(0);
}
public function get_links($rel = 'alternate')
{
if (!isset($this->data['links']))
{
$this->data['links'] = array();
if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link'))
{
foreach ($links as $link)
{
if (isset($link['attribs']['']['href']))
{
$link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate';
$this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link));
}
}
}
if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link'))
{
foreach ($links as $link)
{
if (isset($link['attribs']['']['href']))
{
$link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate';
$this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link));
}
}
}
if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'link'))
{
$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
}
if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'link'))
{
$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
}
if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link'))
{
$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
}
$keys = array_keys($this->data['links']);
foreach ($keys as $key)
{
if ($this->registry->call('Misc', 'is_isegment_nz_nc', array($key)))
{
if (isset($this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]))
{
$this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]);
$this->data['links'][$key] =& $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key];
}
else
{
$this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key];
}
}
elseif (substr($key, 0, 41) === SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY)
{
$this->data['links'][substr($key, 41)] =& $this->data['links'][$key];
}
$this->data['links'][$key] = array_unique($this->data['links'][$key]);
}
}
if (isset($this->data['links'][$rel]))
{
return $this->data['links'][$rel];
}
else
{
return null;
}
}
public function get_description()
{
if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'subtitle'))
{
return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($return[0]['attribs'])), $this->get_base($return[0]));
}
elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'tagline'))
{
return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($return[0]['attribs'])), $this->get_base($return[0]));
}
elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'description'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
}
elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'description'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
}
elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
}
elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'description'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'summary'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
}
elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
}
else
{
return null;
}
}
public function get_copyright()
{
if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'rights'))
{
return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($return[0]['attribs'])), $this->get_base($return[0]));
}
elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'copyright'))
{
return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($return[0]['attribs'])), $this->get_base($return[0]));
}
elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'copyright'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'rights'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'rights'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
else
{
return null;
}
}
public function get_language()
{
if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'language'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'language'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'language'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
elseif (isset($this->data['xml_lang']))
{
return $this->sanitize($this->data['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT);
}
else
{
return null;
}
}
public function get_latitude()
{
if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat'))
{
return (float) $return[0]['data'];
}
elseif (($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match))
{
return (float) $match[1];
}
else
{
return null;
}
}
public function get_longitude()
{
if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'long'))
{
return (float) $return[0]['data'];
}
elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lon'))
{
return (float) $return[0]['data'];
}
elseif (($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match))
{
return (float) $match[2];
}
else
{
return null;
}
}
public function get_image_url()
{
if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'image'))
{
return $this->sanitize($return[0]['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI);
}
elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'logo'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
}
elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'icon'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
}
else
{
return null;
}
}
}
| 01-wordpress-paypal | trunk/wp-includes/SimplePie/Source.php | PHP | gpl3 | 20,539 |
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @version 1.3.1
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman
* @author Geoffrey Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
/**
* Used for data cleanup and post-processing
*
*
* This class can be overloaded with {@see SimplePie::set_sanitize_class()}
*
* @package SimplePie
* @todo Move to using an actual HTML parser (this will allow tags to be properly stripped, and to switch between HTML and XHTML), this will also make it easier to shorten a string while preserving HTML tags
*/
class SimplePie_Sanitize
{
// Private vars
var $base;
// Options
var $remove_div = true;
var $image_handler = '';
var $strip_htmltags = array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style');
var $encode_instead_of_strip = false;
var $strip_attributes = array('bgsound', 'class', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc');
var $strip_comments = false;
var $output_encoding = 'UTF-8';
var $enable_cache = true;
var $cache_location = './cache';
var $cache_name_function = 'md5';
var $timeout = 10;
var $useragent = '';
var $force_fsockopen = false;
var $replace_url_attributes = null;
public function __construct()
{
// Set defaults
$this->set_url_replacements(null);
}
public function remove_div($enable = true)
{
$this->remove_div = (bool) $enable;
}
public function set_image_handler($page = false)
{
if ($page)
{
$this->image_handler = (string) $page;
}
else
{
$this->image_handler = false;
}
}
public function set_registry(SimplePie_Registry $registry)
{
$this->registry = $registry;
}
public function pass_cache_data($enable_cache = true, $cache_location = './cache', $cache_name_function = 'md5', $cache_class = 'SimplePie_Cache')
{
if (isset($enable_cache))
{
$this->enable_cache = (bool) $enable_cache;
}
if ($cache_location)
{
$this->cache_location = (string) $cache_location;
}
if ($cache_name_function)
{
$this->cache_name_function = (string) $cache_name_function;
}
}
public function pass_file_data($file_class = 'SimplePie_File', $timeout = 10, $useragent = '', $force_fsockopen = false)
{
if ($timeout)
{
$this->timeout = (string) $timeout;
}
if ($useragent)
{
$this->useragent = (string) $useragent;
}
if ($force_fsockopen)
{
$this->force_fsockopen = (string) $force_fsockopen;
}
}
public function strip_htmltags($tags = array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style'))
{
if ($tags)
{
if (is_array($tags))
{
$this->strip_htmltags = $tags;
}
else
{
$this->strip_htmltags = explode(',', $tags);
}
}
else
{
$this->strip_htmltags = false;
}
}
public function encode_instead_of_strip($encode = false)
{
$this->encode_instead_of_strip = (bool) $encode;
}
public function strip_attributes($attribs = array('bgsound', 'class', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc'))
{
if ($attribs)
{
if (is_array($attribs))
{
$this->strip_attributes = $attribs;
}
else
{
$this->strip_attributes = explode(',', $attribs);
}
}
else
{
$this->strip_attributes = false;
}
}
public function strip_comments($strip = false)
{
$this->strip_comments = (bool) $strip;
}
public function set_output_encoding($encoding = 'UTF-8')
{
$this->output_encoding = (string) $encoding;
}
/**
* Set element/attribute key/value pairs of HTML attributes
* containing URLs that need to be resolved relative to the feed
*
* Defaults to |a|@href, |area|@href, |blockquote|@cite, |del|@cite,
* |form|@action, |img|@longdesc, |img|@src, |input|@src, |ins|@cite,
* |q|@cite
*
* @since 1.0
* @param array|null $element_attribute Element/attribute key/value pairs, null for default
*/
public function set_url_replacements($element_attribute = null)
{
if ($element_attribute === null)
{
$element_attribute = array(
'a' => 'href',
'area' => 'href',
'blockquote' => 'cite',
'del' => 'cite',
'form' => 'action',
'img' => array(
'longdesc',
'src'
),
'input' => 'src',
'ins' => 'cite',
'q' => 'cite'
);
}
$this->replace_url_attributes = (array) $element_attribute;
}
public function sanitize($data, $type, $base = '')
{
$data = trim($data);
if ($data !== '' || $type & SIMPLEPIE_CONSTRUCT_IRI)
{
if ($type & SIMPLEPIE_CONSTRUCT_MAYBE_HTML)
{
if (preg_match('/(&(#(x[0-9a-fA-F]+|[0-9]+)|[a-zA-Z0-9]+)|<\/[A-Za-z][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E]*' . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . '>)/', $data))
{
$type |= SIMPLEPIE_CONSTRUCT_HTML;
}
else
{
$type |= SIMPLEPIE_CONSTRUCT_TEXT;
}
}
if ($type & SIMPLEPIE_CONSTRUCT_BASE64)
{
$data = base64_decode($data);
}
if ($type & (SIMPLEPIE_CONSTRUCT_HTML | SIMPLEPIE_CONSTRUCT_XHTML))
{
if (!class_exists('DOMDocument'))
{
$this->registry->call('Misc', 'error', array('DOMDocument not found, unable to use sanitizer', E_USER_WARNING, __FILE__, __LINE__));
return '';
}
$document = new DOMDocument();
$document->encoding = 'UTF-8';
$data = $this->preprocess($data, $type);
set_error_handler(array('SimplePie_Misc', 'silence_errors'));
$document->loadHTML($data);
restore_error_handler();
// Strip comments
if ($this->strip_comments)
{
$xpath = new DOMXPath($document);
$comments = $xpath->query('//comment()');
foreach ($comments as $comment)
{
$comment->parentNode->removeChild($comment);
}
}
// Strip out HTML tags and attributes that might cause various security problems.
// Based on recommendations by Mark Pilgrim at:
// http://diveintomark.org/archives/2003/06/12/how_to_consume_rss_safely
if ($this->strip_htmltags)
{
foreach ($this->strip_htmltags as $tag)
{
$this->strip_tag($tag, $document, $type);
}
}
if ($this->strip_attributes)
{
foreach ($this->strip_attributes as $attrib)
{
$this->strip_attr($attrib, $document);
}
}
// Replace relative URLs
$this->base = $base;
foreach ($this->replace_url_attributes as $element => $attributes)
{
$this->replace_urls($document, $element, $attributes);
}
// If image handling (caching, etc.) is enabled, cache and rewrite all the image tags.
if (isset($this->image_handler) && ((string) $this->image_handler) !== '' && $this->enable_cache)
{
$images = $document->getElementsByTagName('img');
foreach ($images as $img)
{
if ($img->hasAttribute('src'))
{
$image_url = call_user_func($this->cache_name_function, $img->getAttribute('src'));
$cache = $this->registry->call('Cache', 'get_handler', array($this->cache_location, $image_url, 'spi'));
if ($cache->load())
{
$img->setAttribute('src', $this->image_handler . $image_url);
}
else
{
$file = $this->registry->create('File', array($img->getAttribute('src'), $this->timeout, 5, array('X-FORWARDED-FOR' => $_SERVER['REMOTE_ADDR']), $this->useragent, $this->force_fsockopen));
$headers = $file->headers;
if ($file->success && ($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($file->status_code === 200 || $file->status_code > 206 && $file->status_code < 300)))
{
if ($cache->save(array('headers' => $file->headers, 'body' => $file->body)))
{
$img->setAttribute('src', $this->image_handler . $image_url);
}
else
{
trigger_error("$this->cache_location is not writeable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.", E_USER_WARNING);
}
}
}
}
}
}
// Remove the DOCTYPE
// Seems to cause segfaulting if we don't do this
if ($document->firstChild instanceof DOMDocumentType)
{
$document->removeChild($document->firstChild);
}
// Move everything from the body to the root
$real_body = $document->getElementsByTagName('body')->item(0)->childNodes->item(0);
$document->replaceChild($real_body, $document->firstChild);
// Finally, convert to a HTML string
$data = trim($document->saveHTML());
if ($this->remove_div)
{
$data = preg_replace('/^<div' . SIMPLEPIE_PCRE_XML_ATTRIBUTE . '>/', '', $data);
$data = preg_replace('/<\/div>$/', '', $data);
}
else
{
$data = preg_replace('/^<div' . SIMPLEPIE_PCRE_XML_ATTRIBUTE . '>/', '<div>', $data);
}
}
if ($type & SIMPLEPIE_CONSTRUCT_IRI)
{
$absolute = $this->registry->call('Misc', 'absolutize_url', array($data, $base));
if ($absolute !== false)
{
$data = $absolute;
}
}
if ($type & (SIMPLEPIE_CONSTRUCT_TEXT | SIMPLEPIE_CONSTRUCT_IRI))
{
$data = htmlspecialchars($data, ENT_COMPAT, 'UTF-8');
}
if ($this->output_encoding !== 'UTF-8')
{
$data = $this->registry->call('Misc', 'change_encoding', array($data, 'UTF-8', $this->output_encoding));
}
}
return $data;
}
protected function preprocess($html, $type)
{
$ret = '';
if ($type & ~SIMPLEPIE_CONSTRUCT_XHTML)
{
// Atom XHTML constructs are wrapped with a div by default
// Note: No protection if $html contains a stray </div>!
$html = '<div>' . $html . '</div>';
$ret .= '<!DOCTYPE html>';
$content_type = 'text/html';
}
else
{
$ret .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
$content_type = 'application/xhtml+xml';
}
$ret .= '<html><head>';
$ret .= '<meta http-equiv="Content-Type" content="' . $content_type . '; charset=utf-8" />';
$ret .= '</head><body>' . $html . '</body></html>';
return $ret;
}
public function replace_urls($document, $tag, $attributes)
{
if (!is_array($attributes))
{
$attributes = array($attributes);
}
if (!is_array($this->strip_htmltags) || !in_array($tag, $this->strip_htmltags))
{
$elements = $document->getElementsByTagName($tag);
foreach ($elements as $element)
{
foreach ($attributes as $attribute)
{
if ($element->hasAttribute($attribute))
{
$value = $this->registry->call('Misc', 'absolutize_url', array($element->getAttribute($attribute), $this->base));
if ($value !== false)
{
$element->setAttribute($attribute, $value);
}
}
}
}
}
}
public function do_strip_htmltags($match)
{
if ($this->encode_instead_of_strip)
{
if (isset($match[4]) && !in_array(strtolower($match[1]), array('script', 'style')))
{
$match[1] = htmlspecialchars($match[1], ENT_COMPAT, 'UTF-8');
$match[2] = htmlspecialchars($match[2], ENT_COMPAT, 'UTF-8');
return "<$match[1]$match[2]>$match[3]</$match[1]>";
}
else
{
return htmlspecialchars($match[0], ENT_COMPAT, 'UTF-8');
}
}
elseif (isset($match[4]) && !in_array(strtolower($match[1]), array('script', 'style')))
{
return $match[4];
}
else
{
return '';
}
}
protected function strip_tag($tag, $document, $type)
{
$xpath = new DOMXPath($document);
$elements = $xpath->query('body//' . $tag);
if ($this->encode_instead_of_strip)
{
foreach ($elements as $element)
{
$fragment = $document->createDocumentFragment();
// For elements which aren't script or style, include the tag itself
if (!in_array($tag, array('script', 'style')))
{
$text = '<' . $tag;
if ($element->hasAttributes())
{
$attrs = array();
foreach ($element->attributes as $name => $attr)
{
$value = $attr->value;
// In XHTML, empty values should never exist, so we repeat the value
if (empty($value) && ($type & SIMPLEPIE_CONSTRUCT_XHTML))
{
$value = $name;
}
// For HTML, empty is fine
elseif (empty($value) && ($type & SIMPLEPIE_CONSTRUCT_HTML))
{
$attrs[] = $name;
continue;
}
// Standard attribute text
$attrs[] = $name . '="' . $attr->value . '"';
}
$text .= ' ' . implode(' ', $attrs);
}
$text .= '>';
$fragment->appendChild(new DOMText($text));
}
$number = $element->childNodes->length;
for ($i = $number; $i > 0; $i--)
{
$child = $element->childNodes->item(0);
$fragment->appendChild($child);
}
if (!in_array($tag, array('script', 'style')))
{
$fragment->appendChild(new DOMText('</' . $tag . '>'));
}
$element->parentNode->replaceChild($fragment, $element);
}
return;
}
elseif (in_array($tag, array('script', 'style')))
{
foreach ($elements as $element)
{
$element->parentNode->removeChild($element);
}
return;
}
else
{
foreach ($elements as $element)
{
$fragment = $document->createDocumentFragment();
$number = $element->childNodes->length;
for ($i = $number; $i > 0; $i--)
{
$child = $element->childNodes->item(0);
$fragment->appendChild($child);
}
$element->parentNode->replaceChild($fragment, $element);
}
}
}
protected function strip_attr($attrib, $document)
{
$xpath = new DOMXPath($document);
$elements = $xpath->query('//*[@' . $attrib . ']');
foreach ($elements as $element)
{
$element->removeAttribute($attrib);
}
}
}
| 01-wordpress-paypal | trunk/wp-includes/SimplePie/Sanitize.php | PHP | gpl3 | 15,698 |
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @version 1.4-dev
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman
* @author Geoffrey Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
/**
* General SimplePie exception class
*
* @package SimplePie
*/
class SimplePie_Exception extends Exception
{
} | 01-wordpress-paypal | trunk/wp-includes/SimplePie/Exception.php | PHP | gpl3 | 2,187 |
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @version 1.3.1
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman
* @author Geoffrey Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
/**
* Used to create cache objects
*
* This class can be overloaded with {@see SimplePie::set_cache_class()},
* although the preferred way is to create your own handler
* via {@see register()}
*
* @package SimplePie
* @subpackage Caching
*/
class SimplePie_Cache
{
/**
* Cache handler classes
*
* These receive 3 parameters to their constructor, as documented in
* {@see register()}
* @var array
*/
protected static $handlers = array(
'mysql' => 'SimplePie_Cache_MySQL',
'memcache' => 'SimplePie_Cache_Memcache',
);
/**
* Don't call the constructor. Please.
*/
private function __construct() { }
/**
* Create a new SimplePie_Cache object
*
* @param string $location URL location (scheme is used to determine handler)
* @param string $filename Unique identifier for cache object
* @param string $extension 'spi' or 'spc'
* @return SimplePie_Cache_Base Type of object depends on scheme of `$location`
*/
public static function get_handler($location, $filename, $extension)
{
$type = explode(':', $location, 2);
$type = $type[0];
if (!empty(self::$handlers[$type]))
{
$class = self::$handlers[$type];
return new $class($location, $filename, $extension);
}
return new SimplePie_Cache_File($location, $filename, $extension);
}
/**
* Create a new SimplePie_Cache object
*
* @deprecated Use {@see get_handler} instead
*/
public function create($location, $filename, $extension)
{
trigger_error('Cache::create() has been replaced with Cache::get_handler(). Switch to the registry system to use this.', E_USER_DEPRECATED);
return self::get_handler($location, $filename, $extension);
}
/**
* Register a handler
*
* @param string $type DSN type to register for
* @param string $class Name of handler class. Must implement SimplePie_Cache_Base
*/
public static function register($type, $class)
{
self::$handlers[$type] = $class;
}
/**
* Parse a URL into an array
*
* @param string $url
* @return array
*/
public static function parse_URL($url)
{
$params = parse_url($url);
$params['extras'] = array();
if (isset($params['query']))
{
parse_str($params['query'], $params['extras']);
}
return $params;
}
}
| 01-wordpress-paypal | trunk/wp-includes/SimplePie/Cache.php | PHP | gpl3 | 4,296 |
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @version 1.3.1
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman
* @author Geoffrey Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
/**
* Used for fetching remote files and reading local files
*
* Supports HTTP 1.0 via cURL or fsockopen, with spotty HTTP 1.1 support
*
* This class can be overloaded with {@see SimplePie::set_file_class()}
*
* @package SimplePie
* @subpackage HTTP
* @todo Move to properly supporting RFC2616 (HTTP/1.1)
*/
class SimplePie_File
{
var $url;
var $useragent;
var $success = true;
var $headers = array();
var $body;
var $status_code;
var $redirects = 0;
var $error;
var $method = SIMPLEPIE_FILE_SOURCE_NONE;
public function __construct($url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen = false)
{
if (class_exists('idna_convert'))
{
$idn = new idna_convert();
$parsed = SimplePie_Misc::parse_url($url);
$url = SimplePie_Misc::compress_parse_url($parsed['scheme'], $idn->encode($parsed['authority']), $parsed['path'], $parsed['query'], $parsed['fragment']);
}
$this->url = $url;
$this->useragent = $useragent;
if (preg_match('/^http(s)?:\/\//i', $url))
{
if ($useragent === null)
{
$useragent = ini_get('user_agent');
$this->useragent = $useragent;
}
if (!is_array($headers))
{
$headers = array();
}
if (!$force_fsockopen && function_exists('curl_exec'))
{
$this->method = SIMPLEPIE_FILE_SOURCE_REMOTE | SIMPLEPIE_FILE_SOURCE_CURL;
$fp = curl_init();
$headers2 = array();
foreach ($headers as $key => $value)
{
$headers2[] = "$key: $value";
}
if (version_compare(SimplePie_Misc::get_curl_version(), '7.10.5', '>='))
{
curl_setopt($fp, CURLOPT_ENCODING, '');
}
curl_setopt($fp, CURLOPT_URL, $url);
curl_setopt($fp, CURLOPT_HEADER, 1);
curl_setopt($fp, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($fp, CURLOPT_TIMEOUT, $timeout);
curl_setopt($fp, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($fp, CURLOPT_REFERER, $url);
curl_setopt($fp, CURLOPT_USERAGENT, $useragent);
curl_setopt($fp, CURLOPT_HTTPHEADER, $headers2);
if (!ini_get('open_basedir') && !ini_get('safe_mode') && version_compare(SimplePie_Misc::get_curl_version(), '7.15.2', '>='))
{
curl_setopt($fp, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($fp, CURLOPT_MAXREDIRS, $redirects);
}
$this->headers = curl_exec($fp);
if (curl_errno($fp) === 23 || curl_errno($fp) === 61)
{
curl_setopt($fp, CURLOPT_ENCODING, 'none');
$this->headers = curl_exec($fp);
}
if (curl_errno($fp))
{
$this->error = 'cURL error ' . curl_errno($fp) . ': ' . curl_error($fp);
$this->success = false;
}
else
{
$info = curl_getinfo($fp);
curl_close($fp);
$this->headers = explode("\r\n\r\n", $this->headers, $info['redirect_count'] + 1);
$this->headers = array_pop($this->headers);
$parser = new SimplePie_HTTP_Parser($this->headers);
if ($parser->parse())
{
$this->headers = $parser->headers;
$this->body = $parser->body;
$this->status_code = $parser->status_code;
if ((in_array($this->status_code, array(300, 301, 302, 303, 307)) || $this->status_code > 307 && $this->status_code < 400) && isset($this->headers['location']) && $this->redirects < $redirects)
{
$this->redirects++;
$location = SimplePie_Misc::absolutize_url($this->headers['location'], $url);
return $this->__construct($location, $timeout, $redirects, $headers, $useragent, $force_fsockopen);
}
}
}
}
else
{
$this->method = SIMPLEPIE_FILE_SOURCE_REMOTE | SIMPLEPIE_FILE_SOURCE_FSOCKOPEN;
$url_parts = parse_url($url);
$socket_host = $url_parts['host'];
if (isset($url_parts['scheme']) && strtolower($url_parts['scheme']) === 'https')
{
$socket_host = "ssl://$url_parts[host]";
$url_parts['port'] = 443;
}
if (!isset($url_parts['port']))
{
$url_parts['port'] = 80;
}
$fp = @fsockopen($socket_host, $url_parts['port'], $errno, $errstr, $timeout);
if (!$fp)
{
$this->error = 'fsockopen error: ' . $errstr;
$this->success = false;
}
else
{
stream_set_timeout($fp, $timeout);
if (isset($url_parts['path']))
{
if (isset($url_parts['query']))
{
$get = "$url_parts[path]?$url_parts[query]";
}
else
{
$get = $url_parts['path'];
}
}
else
{
$get = '/';
}
$out = "GET $get HTTP/1.1\r\n";
$out .= "Host: $url_parts[host]\r\n";
$out .= "User-Agent: $useragent\r\n";
if (extension_loaded('zlib'))
{
$out .= "Accept-Encoding: x-gzip,gzip,deflate\r\n";
}
if (isset($url_parts['user']) && isset($url_parts['pass']))
{
$out .= "Authorization: Basic " . base64_encode("$url_parts[user]:$url_parts[pass]") . "\r\n";
}
foreach ($headers as $key => $value)
{
$out .= "$key: $value\r\n";
}
$out .= "Connection: Close\r\n\r\n";
fwrite($fp, $out);
$info = stream_get_meta_data($fp);
$this->headers = '';
while (!$info['eof'] && !$info['timed_out'])
{
$this->headers .= fread($fp, 1160);
$info = stream_get_meta_data($fp);
}
if (!$info['timed_out'])
{
$parser = new SimplePie_HTTP_Parser($this->headers);
if ($parser->parse())
{
$this->headers = $parser->headers;
$this->body = $parser->body;
$this->status_code = $parser->status_code;
if ((in_array($this->status_code, array(300, 301, 302, 303, 307)) || $this->status_code > 307 && $this->status_code < 400) && isset($this->headers['location']) && $this->redirects < $redirects)
{
$this->redirects++;
$location = SimplePie_Misc::absolutize_url($this->headers['location'], $url);
return $this->__construct($location, $timeout, $redirects, $headers, $useragent, $force_fsockopen);
}
if (isset($this->headers['content-encoding']))
{
// Hey, we act dumb elsewhere, so let's do that here too
switch (strtolower(trim($this->headers['content-encoding'], "\x09\x0A\x0D\x20")))
{
case 'gzip':
case 'x-gzip':
$decoder = new SimplePie_gzdecode($this->body);
if (!$decoder->parse())
{
$this->error = 'Unable to decode HTTP "gzip" stream';
$this->success = false;
}
else
{
$this->body = $decoder->data;
}
break;
case 'deflate':
if (($decompressed = gzinflate($this->body)) !== false)
{
$this->body = $decompressed;
}
else if (($decompressed = gzuncompress($this->body)) !== false)
{
$this->body = $decompressed;
}
else if (function_exists('gzdecode') && ($decompressed = gzdecode($this->body)) !== false)
{
$this->body = $decompressed;
}
else
{
$this->error = 'Unable to decode HTTP "deflate" stream';
$this->success = false;
}
break;
default:
$this->error = 'Unknown content coding';
$this->success = false;
}
}
}
}
else
{
$this->error = 'fsocket timed out';
$this->success = false;
}
fclose($fp);
}
}
}
else
{
$this->method = SIMPLEPIE_FILE_SOURCE_LOCAL | SIMPLEPIE_FILE_SOURCE_FILE_GET_CONTENTS;
if (!$this->body = file_get_contents($url))
{
$this->error = 'file_get_contents could not read the file';
$this->success = false;
}
}
}
}
| 01-wordpress-paypal | trunk/wp-includes/SimplePie/File.php | PHP | gpl3 | 9,678 |
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @version 1.3.1
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman
* @author Geoffrey Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
/**
* Miscellanous utilities
*
* @package SimplePie
*/
class SimplePie_Misc
{
public static function time_hms($seconds)
{
$time = '';
$hours = floor($seconds / 3600);
$remainder = $seconds % 3600;
if ($hours > 0)
{
$time .= $hours.':';
}
$minutes = floor($remainder / 60);
$seconds = $remainder % 60;
if ($minutes < 10 && $hours > 0)
{
$minutes = '0' . $minutes;
}
if ($seconds < 10)
{
$seconds = '0' . $seconds;
}
$time .= $minutes.':';
$time .= $seconds;
return $time;
}
public static function absolutize_url($relative, $base)
{
$iri = SimplePie_IRI::absolutize(new SimplePie_IRI($base), $relative);
if ($iri === false)
{
return false;
}
return $iri->get_uri();
}
/**
* Get a HTML/XML element from a HTML string
*
* @deprecated Use DOMDocument instead (parsing HTML with regex is bad!)
* @param string $realname Element name (including namespace prefix if applicable)
* @param string $string HTML document
* @return array
*/
public static function get_element($realname, $string)
{
$return = array();
$name = preg_quote($realname, '/');
if (preg_match_all("/<($name)" . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . "(>(.*)<\/$name>|(\/)?>)/siU", $string, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE))
{
for ($i = 0, $total_matches = count($matches); $i < $total_matches; $i++)
{
$return[$i]['tag'] = $realname;
$return[$i]['full'] = $matches[$i][0][0];
$return[$i]['offset'] = $matches[$i][0][1];
if (strlen($matches[$i][3][0]) <= 2)
{
$return[$i]['self_closing'] = true;
}
else
{
$return[$i]['self_closing'] = false;
$return[$i]['content'] = $matches[$i][4][0];
}
$return[$i]['attribs'] = array();
if (isset($matches[$i][2][0]) && preg_match_all('/[\x09\x0A\x0B\x0C\x0D\x20]+([^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3D\x3E]*)(?:[\x09\x0A\x0B\x0C\x0D\x20]*=[\x09\x0A\x0B\x0C\x0D\x20]*(?:"([^"]*)"|\'([^\']*)\'|([^\x09\x0A\x0B\x0C\x0D\x20\x22\x27\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x3E]*)?))?/', ' ' . $matches[$i][2][0] . ' ', $attribs, PREG_SET_ORDER))
{
for ($j = 0, $total_attribs = count($attribs); $j < $total_attribs; $j++)
{
if (count($attribs[$j]) === 2)
{
$attribs[$j][2] = $attribs[$j][1];
}
$return[$i]['attribs'][strtolower($attribs[$j][1])]['data'] = SimplePie_Misc::entities_decode(end($attribs[$j]));
}
}
}
}
return $return;
}
public static function element_implode($element)
{
$full = "<$element[tag]";
foreach ($element['attribs'] as $key => $value)
{
$key = strtolower($key);
$full .= " $key=\"" . htmlspecialchars($value['data']) . '"';
}
if ($element['self_closing'])
{
$full .= ' />';
}
else
{
$full .= ">$element[content]</$element[tag]>";
}
return $full;
}
public static function error($message, $level, $file, $line)
{
if ((ini_get('error_reporting') & $level) > 0)
{
switch ($level)
{
case E_USER_ERROR:
$note = 'PHP Error';
break;
case E_USER_WARNING:
$note = 'PHP Warning';
break;
case E_USER_NOTICE:
$note = 'PHP Notice';
break;
default:
$note = 'Unknown Error';
break;
}
$log_error = true;
if (!function_exists('error_log'))
{
$log_error = false;
}
$log_file = @ini_get('error_log');
if (!empty($log_file) && ('syslog' !== $log_file) && !@is_writable($log_file))
{
$log_error = false;
}
if ($log_error)
{
@error_log("$note: $message in $file on line $line", 0);
}
}
return $message;
}
public static function fix_protocol($url, $http = 1)
{
$url = SimplePie_Misc::normalize_url($url);
$parsed = SimplePie_Misc::parse_url($url);
if ($parsed['scheme'] !== '' && $parsed['scheme'] !== 'http' && $parsed['scheme'] !== 'https')
{
return SimplePie_Misc::fix_protocol(SimplePie_Misc::compress_parse_url('http', $parsed['authority'], $parsed['path'], $parsed['query'], $parsed['fragment']), $http);
}
if ($parsed['scheme'] === '' && $parsed['authority'] === '' && !file_exists($url))
{
return SimplePie_Misc::fix_protocol(SimplePie_Misc::compress_parse_url('http', $parsed['path'], '', $parsed['query'], $parsed['fragment']), $http);
}
if ($http === 2 && $parsed['scheme'] !== '')
{
return "feed:$url";
}
elseif ($http === 3 && strtolower($parsed['scheme']) === 'http')
{
return substr_replace($url, 'podcast', 0, 4);
}
elseif ($http === 4 && strtolower($parsed['scheme']) === 'http')
{
return substr_replace($url, 'itpc', 0, 4);
}
else
{
return $url;
}
}
public static function parse_url($url)
{
$iri = new SimplePie_IRI($url);
return array(
'scheme' => (string) $iri->scheme,
'authority' => (string) $iri->authority,
'path' => (string) $iri->path,
'query' => (string) $iri->query,
'fragment' => (string) $iri->fragment
);
}
public static function compress_parse_url($scheme = '', $authority = '', $path = '', $query = '', $fragment = '')
{
$iri = new SimplePie_IRI('');
$iri->scheme = $scheme;
$iri->authority = $authority;
$iri->path = $path;
$iri->query = $query;
$iri->fragment = $fragment;
return $iri->get_uri();
}
public static function normalize_url($url)
{
$iri = new SimplePie_IRI($url);
return $iri->get_uri();
}
public static function percent_encoding_normalization($match)
{
$integer = hexdec($match[1]);
if ($integer >= 0x41 && $integer <= 0x5A || $integer >= 0x61 && $integer <= 0x7A || $integer >= 0x30 && $integer <= 0x39 || $integer === 0x2D || $integer === 0x2E || $integer === 0x5F || $integer === 0x7E)
{
return chr($integer);
}
else
{
return strtoupper($match[0]);
}
}
/**
* Converts a Windows-1252 encoded string to a UTF-8 encoded string
*
* @static
* @param string $string Windows-1252 encoded string
* @return string UTF-8 encoded string
*/
public static function windows_1252_to_utf8($string)
{
static $convert_table = array("\x80" => "\xE2\x82\xAC", "\x81" => "\xEF\xBF\xBD", "\x82" => "\xE2\x80\x9A", "\x83" => "\xC6\x92", "\x84" => "\xE2\x80\x9E", "\x85" => "\xE2\x80\xA6", "\x86" => "\xE2\x80\xA0", "\x87" => "\xE2\x80\xA1", "\x88" => "\xCB\x86", "\x89" => "\xE2\x80\xB0", "\x8A" => "\xC5\xA0", "\x8B" => "\xE2\x80\xB9", "\x8C" => "\xC5\x92", "\x8D" => "\xEF\xBF\xBD", "\x8E" => "\xC5\xBD", "\x8F" => "\xEF\xBF\xBD", "\x90" => "\xEF\xBF\xBD", "\x91" => "\xE2\x80\x98", "\x92" => "\xE2\x80\x99", "\x93" => "\xE2\x80\x9C", "\x94" => "\xE2\x80\x9D", "\x95" => "\xE2\x80\xA2", "\x96" => "\xE2\x80\x93", "\x97" => "\xE2\x80\x94", "\x98" => "\xCB\x9C", "\x99" => "\xE2\x84\xA2", "\x9A" => "\xC5\xA1", "\x9B" => "\xE2\x80\xBA", "\x9C" => "\xC5\x93", "\x9D" => "\xEF\xBF\xBD", "\x9E" => "\xC5\xBE", "\x9F" => "\xC5\xB8", "\xA0" => "\xC2\xA0", "\xA1" => "\xC2\xA1", "\xA2" => "\xC2\xA2", "\xA3" => "\xC2\xA3", "\xA4" => "\xC2\xA4", "\xA5" => "\xC2\xA5", "\xA6" => "\xC2\xA6", "\xA7" => "\xC2\xA7", "\xA8" => "\xC2\xA8", "\xA9" => "\xC2\xA9", "\xAA" => "\xC2\xAA", "\xAB" => "\xC2\xAB", "\xAC" => "\xC2\xAC", "\xAD" => "\xC2\xAD", "\xAE" => "\xC2\xAE", "\xAF" => "\xC2\xAF", "\xB0" => "\xC2\xB0", "\xB1" => "\xC2\xB1", "\xB2" => "\xC2\xB2", "\xB3" => "\xC2\xB3", "\xB4" => "\xC2\xB4", "\xB5" => "\xC2\xB5", "\xB6" => "\xC2\xB6", "\xB7" => "\xC2\xB7", "\xB8" => "\xC2\xB8", "\xB9" => "\xC2\xB9", "\xBA" => "\xC2\xBA", "\xBB" => "\xC2\xBB", "\xBC" => "\xC2\xBC", "\xBD" => "\xC2\xBD", "\xBE" => "\xC2\xBE", "\xBF" => "\xC2\xBF", "\xC0" => "\xC3\x80", "\xC1" => "\xC3\x81", "\xC2" => "\xC3\x82", "\xC3" => "\xC3\x83", "\xC4" => "\xC3\x84", "\xC5" => "\xC3\x85", "\xC6" => "\xC3\x86", "\xC7" => "\xC3\x87", "\xC8" => "\xC3\x88", "\xC9" => "\xC3\x89", "\xCA" => "\xC3\x8A", "\xCB" => "\xC3\x8B", "\xCC" => "\xC3\x8C", "\xCD" => "\xC3\x8D", "\xCE" => "\xC3\x8E", "\xCF" => "\xC3\x8F", "\xD0" => "\xC3\x90", "\xD1" => "\xC3\x91", "\xD2" => "\xC3\x92", "\xD3" => "\xC3\x93", "\xD4" => "\xC3\x94", "\xD5" => "\xC3\x95", "\xD6" => "\xC3\x96", "\xD7" => "\xC3\x97", "\xD8" => "\xC3\x98", "\xD9" => "\xC3\x99", "\xDA" => "\xC3\x9A", "\xDB" => "\xC3\x9B", "\xDC" => "\xC3\x9C", "\xDD" => "\xC3\x9D", "\xDE" => "\xC3\x9E", "\xDF" => "\xC3\x9F", "\xE0" => "\xC3\xA0", "\xE1" => "\xC3\xA1", "\xE2" => "\xC3\xA2", "\xE3" => "\xC3\xA3", "\xE4" => "\xC3\xA4", "\xE5" => "\xC3\xA5", "\xE6" => "\xC3\xA6", "\xE7" => "\xC3\xA7", "\xE8" => "\xC3\xA8", "\xE9" => "\xC3\xA9", "\xEA" => "\xC3\xAA", "\xEB" => "\xC3\xAB", "\xEC" => "\xC3\xAC", "\xED" => "\xC3\xAD", "\xEE" => "\xC3\xAE", "\xEF" => "\xC3\xAF", "\xF0" => "\xC3\xB0", "\xF1" => "\xC3\xB1", "\xF2" => "\xC3\xB2", "\xF3" => "\xC3\xB3", "\xF4" => "\xC3\xB4", "\xF5" => "\xC3\xB5", "\xF6" => "\xC3\xB6", "\xF7" => "\xC3\xB7", "\xF8" => "\xC3\xB8", "\xF9" => "\xC3\xB9", "\xFA" => "\xC3\xBA", "\xFB" => "\xC3\xBB", "\xFC" => "\xC3\xBC", "\xFD" => "\xC3\xBD", "\xFE" => "\xC3\xBE", "\xFF" => "\xC3\xBF");
return strtr($string, $convert_table);
}
/**
* Change a string from one encoding to another
*
* @param string $data Raw data in $input encoding
* @param string $input Encoding of $data
* @param string $output Encoding you want
* @return string|boolean False if we can't convert it
*/
public static function change_encoding($data, $input, $output)
{
$input = SimplePie_Misc::encoding($input);
$output = SimplePie_Misc::encoding($output);
// We fail to fail on non US-ASCII bytes
if ($input === 'US-ASCII')
{
static $non_ascii_octects = '';
if (!$non_ascii_octects)
{
for ($i = 0x80; $i <= 0xFF; $i++)
{
$non_ascii_octects .= chr($i);
}
}
$data = substr($data, 0, strcspn($data, $non_ascii_octects));
}
// This is first, as behaviour of this is completely predictable
if ($input === 'windows-1252' && $output === 'UTF-8')
{
return SimplePie_Misc::windows_1252_to_utf8($data);
}
// This is second, as behaviour of this varies only with PHP version (the middle part of this expression checks the encoding is supported).
elseif (function_exists('mb_convert_encoding') && ($return = SimplePie_Misc::change_encoding_mbstring($data, $input, $output)))
{
return $return;
}
// This is last, as behaviour of this varies with OS userland and PHP version
elseif (function_exists('iconv') && ($return = SimplePie_Misc::change_encoding_iconv($data, $input, $output)))
{
return $return;
}
// If we can't do anything, just fail
else
{
return false;
}
}
protected static function change_encoding_mbstring($data, $input, $output)
{
if ($input === 'windows-949')
{
$input = 'EUC-KR';
}
if ($output === 'windows-949')
{
$output = 'EUC-KR';
}
if ($input === 'Windows-31J')
{
$input = 'SJIS';
}
if ($output === 'Windows-31J')
{
$output = 'SJIS';
}
// Check that the encoding is supported
if (@mb_convert_encoding("\x80", 'UTF-16BE', $input) === "\x00\x80")
{
return false;
}
if (!in_array($input, mb_list_encodings()))
{
return false;
}
// Let's do some conversion
if ($return = @mb_convert_encoding($data, $output, $input))
{
return $return;
}
return false;
}
protected static function change_encoding_iconv($data, $input, $output)
{
return @iconv($input, $output, $data);
}
/**
* Normalize an encoding name
*
* This is automatically generated by create.php
*
* To generate it, run `php create.php` on the command line, and copy the
* output to replace this function.
*
* @param string $charset Character set to standardise
* @return string Standardised name
*/
public static function encoding($charset)
{
// Normalization from UTS #22
switch (strtolower(preg_replace('/(?:[^a-zA-Z0-9]+|([^0-9])0+)/', '\1', $charset)))
{
case 'adobestandardencoding':
case 'csadobestandardencoding':
return 'Adobe-Standard-Encoding';
case 'adobesymbolencoding':
case 'cshppsmath':
return 'Adobe-Symbol-Encoding';
case 'ami1251':
case 'amiga1251':
return 'Amiga-1251';
case 'ansix31101983':
case 'csat5001983':
case 'csiso99naplps':
case 'isoir99':
case 'naplps':
return 'ANSI_X3.110-1983';
case 'arabic7':
case 'asmo449':
case 'csiso89asmo449':
case 'iso9036':
case 'isoir89':
return 'ASMO_449';
case 'big5':
case 'csbig5':
return 'Big5';
case 'big5hkscs':
return 'Big5-HKSCS';
case 'bocu1':
case 'csbocu1':
return 'BOCU-1';
case 'brf':
case 'csbrf':
return 'BRF';
case 'bs4730':
case 'csiso4unitedkingdom':
case 'gb':
case 'iso646gb':
case 'isoir4':
case 'uk':
return 'BS_4730';
case 'bsviewdata':
case 'csiso47bsviewdata':
case 'isoir47':
return 'BS_viewdata';
case 'cesu8':
case 'cscesu8':
return 'CESU-8';
case 'ca':
case 'csa71':
case 'csaz243419851':
case 'csiso121canadian1':
case 'iso646ca':
case 'isoir121':
return 'CSA_Z243.4-1985-1';
case 'csa72':
case 'csaz243419852':
case 'csiso122canadian2':
case 'iso646ca2':
case 'isoir122':
return 'CSA_Z243.4-1985-2';
case 'csaz24341985gr':
case 'csiso123csaz24341985gr':
case 'isoir123':
return 'CSA_Z243.4-1985-gr';
case 'csiso139csn369103':
case 'csn369103':
case 'isoir139':
return 'CSN_369103';
case 'csdecmcs':
case 'dec':
case 'decmcs':
return 'DEC-MCS';
case 'csiso21german':
case 'de':
case 'din66003':
case 'iso646de':
case 'isoir21':
return 'DIN_66003';
case 'csdkus':
case 'dkus':
return 'dk-us';
case 'csiso646danish':
case 'dk':
case 'ds2089':
case 'iso646dk':
return 'DS_2089';
case 'csibmebcdicatde':
case 'ebcdicatde':
return 'EBCDIC-AT-DE';
case 'csebcdicatdea':
case 'ebcdicatdea':
return 'EBCDIC-AT-DE-A';
case 'csebcdiccafr':
case 'ebcdiccafr':
return 'EBCDIC-CA-FR';
case 'csebcdicdkno':
case 'ebcdicdkno':
return 'EBCDIC-DK-NO';
case 'csebcdicdknoa':
case 'ebcdicdknoa':
return 'EBCDIC-DK-NO-A';
case 'csebcdices':
case 'ebcdices':
return 'EBCDIC-ES';
case 'csebcdicesa':
case 'ebcdicesa':
return 'EBCDIC-ES-A';
case 'csebcdicess':
case 'ebcdicess':
return 'EBCDIC-ES-S';
case 'csebcdicfise':
case 'ebcdicfise':
return 'EBCDIC-FI-SE';
case 'csebcdicfisea':
case 'ebcdicfisea':
return 'EBCDIC-FI-SE-A';
case 'csebcdicfr':
case 'ebcdicfr':
return 'EBCDIC-FR';
case 'csebcdicit':
case 'ebcdicit':
return 'EBCDIC-IT';
case 'csebcdicpt':
case 'ebcdicpt':
return 'EBCDIC-PT';
case 'csebcdicuk':
case 'ebcdicuk':
return 'EBCDIC-UK';
case 'csebcdicus':
case 'ebcdicus':
return 'EBCDIC-US';
case 'csiso111ecmacyrillic':
case 'ecmacyrillic':
case 'isoir111':
case 'koi8e':
return 'ECMA-cyrillic';
case 'csiso17spanish':
case 'es':
case 'iso646es':
case 'isoir17':
return 'ES';
case 'csiso85spanish2':
case 'es2':
case 'iso646es2':
case 'isoir85':
return 'ES2';
case 'cseucpkdfmtjapanese':
case 'eucjp':
case 'extendedunixcodepackedformatforjapanese':
return 'EUC-JP';
case 'cseucfixwidjapanese':
case 'extendedunixcodefixedwidthforjapanese':
return 'Extended_UNIX_Code_Fixed_Width_for_Japanese';
case 'gb18030':
return 'GB18030';
case 'chinese':
case 'cp936':
case 'csgb2312':
case 'csiso58gb231280':
case 'gb2312':
case 'gb231280':
case 'gbk':
case 'isoir58':
case 'ms936':
case 'windows936':
return 'GBK';
case 'cn':
case 'csiso57gb1988':
case 'gb198880':
case 'iso646cn':
case 'isoir57':
return 'GB_1988-80';
case 'csiso153gost1976874':
case 'gost1976874':
case 'isoir153':
case 'stsev35888':
return 'GOST_19768-74';
case 'csiso150':
case 'csiso150greekccitt':
case 'greekccitt':
case 'isoir150':
return 'greek-ccitt';
case 'csiso88greek7':
case 'greek7':
case 'isoir88':
return 'greek7';
case 'csiso18greek7old':
case 'greek7old':
case 'isoir18':
return 'greek7-old';
case 'cshpdesktop':
case 'hpdesktop':
return 'HP-DeskTop';
case 'cshplegal':
case 'hplegal':
return 'HP-Legal';
case 'cshpmath8':
case 'hpmath8':
return 'HP-Math8';
case 'cshppifont':
case 'hppifont':
return 'HP-Pi-font';
case 'cshproman8':
case 'hproman8':
case 'r8':
case 'roman8':
return 'hp-roman8';
case 'hzgb2312':
return 'HZ-GB-2312';
case 'csibmsymbols':
case 'ibmsymbols':
return 'IBM-Symbols';
case 'csibmthai':
case 'ibmthai':
return 'IBM-Thai';
case 'cp37':
case 'csibm37':
case 'ebcdiccpca':
case 'ebcdiccpnl':
case 'ebcdiccpus':
case 'ebcdiccpwt':
case 'ibm37':
return 'IBM037';
case 'cp38':
case 'csibm38':
case 'ebcdicint':
case 'ibm38':
return 'IBM038';
case 'cp273':
case 'csibm273':
case 'ibm273':
return 'IBM273';
case 'cp274':
case 'csibm274':
case 'ebcdicbe':
case 'ibm274':
return 'IBM274';
case 'cp275':
case 'csibm275':
case 'ebcdicbr':
case 'ibm275':
return 'IBM275';
case 'csibm277':
case 'ebcdiccpdk':
case 'ebcdiccpno':
case 'ibm277':
return 'IBM277';
case 'cp278':
case 'csibm278':
case 'ebcdiccpfi':
case 'ebcdiccpse':
case 'ibm278':
return 'IBM278';
case 'cp280':
case 'csibm280':
case 'ebcdiccpit':
case 'ibm280':
return 'IBM280';
case 'cp281':
case 'csibm281':
case 'ebcdicjpe':
case 'ibm281':
return 'IBM281';
case 'cp284':
case 'csibm284':
case 'ebcdiccpes':
case 'ibm284':
return 'IBM284';
case 'cp285':
case 'csibm285':
case 'ebcdiccpgb':
case 'ibm285':
return 'IBM285';
case 'cp290':
case 'csibm290':
case 'ebcdicjpkana':
case 'ibm290':
return 'IBM290';
case 'cp297':
case 'csibm297':
case 'ebcdiccpfr':
case 'ibm297':
return 'IBM297';
case 'cp420':
case 'csibm420':
case 'ebcdiccpar1':
case 'ibm420':
return 'IBM420';
case 'cp423':
case 'csibm423':
case 'ebcdiccpgr':
case 'ibm423':
return 'IBM423';
case 'cp424':
case 'csibm424':
case 'ebcdiccphe':
case 'ibm424':
return 'IBM424';
case '437':
case 'cp437':
case 'cspc8codepage437':
case 'ibm437':
return 'IBM437';
case 'cp500':
case 'csibm500':
case 'ebcdiccpbe':
case 'ebcdiccpch':
case 'ibm500':
return 'IBM500';
case 'cp775':
case 'cspc775baltic':
case 'ibm775':
return 'IBM775';
case '850':
case 'cp850':
case 'cspc850multilingual':
case 'ibm850':
return 'IBM850';
case '851':
case 'cp851':
case 'csibm851':
case 'ibm851':
return 'IBM851';
case '852':
case 'cp852':
case 'cspcp852':
case 'ibm852':
return 'IBM852';
case '855':
case 'cp855':
case 'csibm855':
case 'ibm855':
return 'IBM855';
case '857':
case 'cp857':
case 'csibm857':
case 'ibm857':
return 'IBM857';
case 'ccsid858':
case 'cp858':
case 'ibm858':
case 'pcmultilingual850euro':
return 'IBM00858';
case '860':
case 'cp860':
case 'csibm860':
case 'ibm860':
return 'IBM860';
case '861':
case 'cp861':
case 'cpis':
case 'csibm861':
case 'ibm861':
return 'IBM861';
case '862':
case 'cp862':
case 'cspc862latinhebrew':
case 'ibm862':
return 'IBM862';
case '863':
case 'cp863':
case 'csibm863':
case 'ibm863':
return 'IBM863';
case 'cp864':
case 'csibm864':
case 'ibm864':
return 'IBM864';
case '865':
case 'cp865':
case 'csibm865':
case 'ibm865':
return 'IBM865';
case '866':
case 'cp866':
case 'csibm866':
case 'ibm866':
return 'IBM866';
case 'cp868':
case 'cpar':
case 'csibm868':
case 'ibm868':
return 'IBM868';
case '869':
case 'cp869':
case 'cpgr':
case 'csibm869':
case 'ibm869':
return 'IBM869';
case 'cp870':
case 'csibm870':
case 'ebcdiccproece':
case 'ebcdiccpyu':
case 'ibm870':
return 'IBM870';
case 'cp871':
case 'csibm871':
case 'ebcdiccpis':
case 'ibm871':
return 'IBM871';
case 'cp880':
case 'csibm880':
case 'ebcdiccyrillic':
case 'ibm880':
return 'IBM880';
case 'cp891':
case 'csibm891':
case 'ibm891':
return 'IBM891';
case 'cp903':
case 'csibm903':
case 'ibm903':
return 'IBM903';
case '904':
case 'cp904':
case 'csibbm904':
case 'ibm904':
return 'IBM904';
case 'cp905':
case 'csibm905':
case 'ebcdiccptr':
case 'ibm905':
return 'IBM905';
case 'cp918':
case 'csibm918':
case 'ebcdiccpar2':
case 'ibm918':
return 'IBM918';
case 'ccsid924':
case 'cp924':
case 'ebcdiclatin9euro':
case 'ibm924':
return 'IBM00924';
case 'cp1026':
case 'csibm1026':
case 'ibm1026':
return 'IBM1026';
case 'ibm1047':
return 'IBM1047';
case 'ccsid1140':
case 'cp1140':
case 'ebcdicus37euro':
case 'ibm1140':
return 'IBM01140';
case 'ccsid1141':
case 'cp1141':
case 'ebcdicde273euro':
case 'ibm1141':
return 'IBM01141';
case 'ccsid1142':
case 'cp1142':
case 'ebcdicdk277euro':
case 'ebcdicno277euro':
case 'ibm1142':
return 'IBM01142';
case 'ccsid1143':
case 'cp1143':
case 'ebcdicfi278euro':
case 'ebcdicse278euro':
case 'ibm1143':
return 'IBM01143';
case 'ccsid1144':
case 'cp1144':
case 'ebcdicit280euro':
case 'ibm1144':
return 'IBM01144';
case 'ccsid1145':
case 'cp1145':
case 'ebcdices284euro':
case 'ibm1145':
return 'IBM01145';
case 'ccsid1146':
case 'cp1146':
case 'ebcdicgb285euro':
case 'ibm1146':
return 'IBM01146';
case 'ccsid1147':
case 'cp1147':
case 'ebcdicfr297euro':
case 'ibm1147':
return 'IBM01147';
case 'ccsid1148':
case 'cp1148':
case 'ebcdicinternational500euro':
case 'ibm1148':
return 'IBM01148';
case 'ccsid1149':
case 'cp1149':
case 'ebcdicis871euro':
case 'ibm1149':
return 'IBM01149';
case 'csiso143iecp271':
case 'iecp271':
case 'isoir143':
return 'IEC_P27-1';
case 'csiso49inis':
case 'inis':
case 'isoir49':
return 'INIS';
case 'csiso50inis8':
case 'inis8':
case 'isoir50':
return 'INIS-8';
case 'csiso51iniscyrillic':
case 'iniscyrillic':
case 'isoir51':
return 'INIS-cyrillic';
case 'csinvariant':
case 'invariant':
return 'INVARIANT';
case 'iso2022cn':
return 'ISO-2022-CN';
case 'iso2022cnext':
return 'ISO-2022-CN-EXT';
case 'csiso2022jp':
case 'iso2022jp':
return 'ISO-2022-JP';
case 'csiso2022jp2':
case 'iso2022jp2':
return 'ISO-2022-JP-2';
case 'csiso2022kr':
case 'iso2022kr':
return 'ISO-2022-KR';
case 'cswindows30latin1':
case 'iso88591windows30latin1':
return 'ISO-8859-1-Windows-3.0-Latin-1';
case 'cswindows31latin1':
case 'iso88591windows31latin1':
return 'ISO-8859-1-Windows-3.1-Latin-1';
case 'csisolatin2':
case 'iso88592':
case 'iso885921987':
case 'isoir101':
case 'l2':
case 'latin2':
return 'ISO-8859-2';
case 'cswindows31latin2':
case 'iso88592windowslatin2':
return 'ISO-8859-2-Windows-Latin-2';
case 'csisolatin3':
case 'iso88593':
case 'iso885931988':
case 'isoir109':
case 'l3':
case 'latin3':
return 'ISO-8859-3';
case 'csisolatin4':
case 'iso88594':
case 'iso885941988':
case 'isoir110':
case 'l4':
case 'latin4':
return 'ISO-8859-4';
case 'csisolatincyrillic':
case 'cyrillic':
case 'iso88595':
case 'iso885951988':
case 'isoir144':
return 'ISO-8859-5';
case 'arabic':
case 'asmo708':
case 'csisolatinarabic':
case 'ecma114':
case 'iso88596':
case 'iso885961987':
case 'isoir127':
return 'ISO-8859-6';
case 'csiso88596e':
case 'iso88596e':
return 'ISO-8859-6-E';
case 'csiso88596i':
case 'iso88596i':
return 'ISO-8859-6-I';
case 'csisolatingreek':
case 'ecma118':
case 'elot928':
case 'greek':
case 'greek8':
case 'iso88597':
case 'iso885971987':
case 'isoir126':
return 'ISO-8859-7';
case 'csisolatinhebrew':
case 'hebrew':
case 'iso88598':
case 'iso885981988':
case 'isoir138':
return 'ISO-8859-8';
case 'csiso88598e':
case 'iso88598e':
return 'ISO-8859-8-E';
case 'csiso88598i':
case 'iso88598i':
return 'ISO-8859-8-I';
case 'cswindows31latin5':
case 'iso88599windowslatin5':
return 'ISO-8859-9-Windows-Latin-5';
case 'csisolatin6':
case 'iso885910':
case 'iso8859101992':
case 'isoir157':
case 'l6':
case 'latin6':
return 'ISO-8859-10';
case 'iso885913':
return 'ISO-8859-13';
case 'iso885914':
case 'iso8859141998':
case 'isoceltic':
case 'isoir199':
case 'l8':
case 'latin8':
return 'ISO-8859-14';
case 'iso885915':
case 'latin9':
return 'ISO-8859-15';
case 'iso885916':
case 'iso8859162001':
case 'isoir226':
case 'l10':
case 'latin10':
return 'ISO-8859-16';
case 'iso10646j1':
return 'ISO-10646-J-1';
case 'csunicode':
case 'iso10646ucs2':
return 'ISO-10646-UCS-2';
case 'csucs4':
case 'iso10646ucs4':
return 'ISO-10646-UCS-4';
case 'csunicodeascii':
case 'iso10646ucsbasic':
return 'ISO-10646-UCS-Basic';
case 'csunicodelatin1':
case 'iso10646':
case 'iso10646unicodelatin1':
return 'ISO-10646-Unicode-Latin1';
case 'csiso10646utf1':
case 'iso10646utf1':
return 'ISO-10646-UTF-1';
case 'csiso115481':
case 'iso115481':
case 'isotr115481':
return 'ISO-11548-1';
case 'csiso90':
case 'isoir90':
return 'iso-ir-90';
case 'csunicodeibm1261':
case 'isounicodeibm1261':
return 'ISO-Unicode-IBM-1261';
case 'csunicodeibm1264':
case 'isounicodeibm1264':
return 'ISO-Unicode-IBM-1264';
case 'csunicodeibm1265':
case 'isounicodeibm1265':
return 'ISO-Unicode-IBM-1265';
case 'csunicodeibm1268':
case 'isounicodeibm1268':
return 'ISO-Unicode-IBM-1268';
case 'csunicodeibm1276':
case 'isounicodeibm1276':
return 'ISO-Unicode-IBM-1276';
case 'csiso646basic1983':
case 'iso646basic1983':
case 'ref':
return 'ISO_646.basic:1983';
case 'csiso2intlrefversion':
case 'irv':
case 'iso646irv1983':
case 'isoir2':
return 'ISO_646.irv:1983';
case 'csiso2033':
case 'e13b':
case 'iso20331983':
case 'isoir98':
return 'ISO_2033-1983';
case 'csiso5427cyrillic':
case 'iso5427':
case 'isoir37':
return 'ISO_5427';
case 'iso5427cyrillic1981':
case 'iso54271981':
case 'isoir54':
return 'ISO_5427:1981';
case 'csiso5428greek':
case 'iso54281980':
case 'isoir55':
return 'ISO_5428:1980';
case 'csiso6937add':
case 'iso6937225':
case 'isoir152':
return 'ISO_6937-2-25';
case 'csisotextcomm':
case 'iso69372add':
case 'isoir142':
return 'ISO_6937-2-add';
case 'csiso8859supp':
case 'iso8859supp':
case 'isoir154':
case 'latin125':
return 'ISO_8859-supp';
case 'csiso10367box':
case 'iso10367box':
case 'isoir155':
return 'ISO_10367-box';
case 'csiso15italian':
case 'iso646it':
case 'isoir15':
case 'it':
return 'IT';
case 'csiso13jisc6220jp':
case 'isoir13':
case 'jisc62201969':
case 'jisc62201969jp':
case 'katakana':
case 'x2017':
return 'JIS_C6220-1969-jp';
case 'csiso14jisc6220ro':
case 'iso646jp':
case 'isoir14':
case 'jisc62201969ro':
case 'jp':
return 'JIS_C6220-1969-ro';
case 'csiso42jisc62261978':
case 'isoir42':
case 'jisc62261978':
return 'JIS_C6226-1978';
case 'csiso87jisx208':
case 'isoir87':
case 'jisc62261983':
case 'jisx2081983':
case 'x208':
return 'JIS_C6226-1983';
case 'csiso91jisc62291984a':
case 'isoir91':
case 'jisc62291984a':
case 'jpocra':
return 'JIS_C6229-1984-a';
case 'csiso92jisc62991984b':
case 'iso646jpocrb':
case 'isoir92':
case 'jisc62291984b':
case 'jpocrb':
return 'JIS_C6229-1984-b';
case 'csiso93jis62291984badd':
case 'isoir93':
case 'jisc62291984badd':
case 'jpocrbadd':
return 'JIS_C6229-1984-b-add';
case 'csiso94jis62291984hand':
case 'isoir94':
case 'jisc62291984hand':
case 'jpocrhand':
return 'JIS_C6229-1984-hand';
case 'csiso95jis62291984handadd':
case 'isoir95':
case 'jisc62291984handadd':
case 'jpocrhandadd':
return 'JIS_C6229-1984-hand-add';
case 'csiso96jisc62291984kana':
case 'isoir96':
case 'jisc62291984kana':
return 'JIS_C6229-1984-kana';
case 'csjisencoding':
case 'jisencoding':
return 'JIS_Encoding';
case 'cshalfwidthkatakana':
case 'jisx201':
case 'x201':
return 'JIS_X0201';
case 'csiso159jisx2121990':
case 'isoir159':
case 'jisx2121990':
case 'x212':
return 'JIS_X0212-1990';
case 'csiso141jusib1002':
case 'iso646yu':
case 'isoir141':
case 'js':
case 'jusib1002':
case 'yu':
return 'JUS_I.B1.002';
case 'csiso147macedonian':
case 'isoir147':
case 'jusib1003mac':
case 'macedonian':
return 'JUS_I.B1.003-mac';
case 'csiso146serbian':
case 'isoir146':
case 'jusib1003serb':
case 'serbian':
return 'JUS_I.B1.003-serb';
case 'koi7switched':
return 'KOI7-switched';
case 'cskoi8r':
case 'koi8r':
return 'KOI8-R';
case 'koi8u':
return 'KOI8-U';
case 'csksc5636':
case 'iso646kr':
case 'ksc5636':
return 'KSC5636';
case 'cskz1048':
case 'kz1048':
case 'rk1048':
case 'strk10482002':
return 'KZ-1048';
case 'csiso19latingreek':
case 'isoir19':
case 'latingreek':
return 'latin-greek';
case 'csiso27latingreek1':
case 'isoir27':
case 'latingreek1':
return 'Latin-greek-1';
case 'csiso158lap':
case 'isoir158':
case 'lap':
case 'latinlap':
return 'latin-lap';
case 'csmacintosh':
case 'mac':
case 'macintosh':
return 'macintosh';
case 'csmicrosoftpublishing':
case 'microsoftpublishing':
return 'Microsoft-Publishing';
case 'csmnem':
case 'mnem':
return 'MNEM';
case 'csmnemonic':
case 'mnemonic':
return 'MNEMONIC';
case 'csiso86hungarian':
case 'hu':
case 'iso646hu':
case 'isoir86':
case 'msz77953':
return 'MSZ_7795.3';
case 'csnatsdano':
case 'isoir91':
case 'natsdano':
return 'NATS-DANO';
case 'csnatsdanoadd':
case 'isoir92':
case 'natsdanoadd':
return 'NATS-DANO-ADD';
case 'csnatssefi':
case 'isoir81':
case 'natssefi':
return 'NATS-SEFI';
case 'csnatssefiadd':
case 'isoir82':
case 'natssefiadd':
return 'NATS-SEFI-ADD';
case 'csiso151cuba':
case 'cuba':
case 'iso646cu':
case 'isoir151':
case 'ncnc1081':
return 'NC_NC00-10:81';
case 'csiso69french':
case 'fr':
case 'iso646fr':
case 'isoir69':
case 'nfz62010':
return 'NF_Z_62-010';
case 'csiso25french':
case 'iso646fr1':
case 'isoir25':
case 'nfz620101973':
return 'NF_Z_62-010_(1973)';
case 'csiso60danishnorwegian':
case 'csiso60norwegian1':
case 'iso646no':
case 'isoir60':
case 'no':
case 'ns45511':
return 'NS_4551-1';
case 'csiso61norwegian2':
case 'iso646no2':
case 'isoir61':
case 'no2':
case 'ns45512':
return 'NS_4551-2';
case 'osdebcdicdf3irv':
return 'OSD_EBCDIC_DF03_IRV';
case 'osdebcdicdf41':
return 'OSD_EBCDIC_DF04_1';
case 'osdebcdicdf415':
return 'OSD_EBCDIC_DF04_15';
case 'cspc8danishnorwegian':
case 'pc8danishnorwegian':
return 'PC8-Danish-Norwegian';
case 'cspc8turkish':
case 'pc8turkish':
return 'PC8-Turkish';
case 'csiso16portuguese':
case 'iso646pt':
case 'isoir16':
case 'pt':
return 'PT';
case 'csiso84portuguese2':
case 'iso646pt2':
case 'isoir84':
case 'pt2':
return 'PT2';
case 'cp154':
case 'csptcp154':
case 'cyrillicasian':
case 'pt154':
case 'ptcp154':
return 'PTCP154';
case 'scsu':
return 'SCSU';
case 'csiso10swedish':
case 'fi':
case 'iso646fi':
case 'iso646se':
case 'isoir10':
case 'se':
case 'sen850200b':
return 'SEN_850200_B';
case 'csiso11swedishfornames':
case 'iso646se2':
case 'isoir11':
case 'se2':
case 'sen850200c':
return 'SEN_850200_C';
case 'csiso102t617bit':
case 'isoir102':
case 't617bit':
return 'T.61-7bit';
case 'csiso103t618bit':
case 'isoir103':
case 't61':
case 't618bit':
return 'T.61-8bit';
case 'csiso128t101g2':
case 'isoir128':
case 't101g2':
return 'T.101-G2';
case 'cstscii':
case 'tscii':
return 'TSCII';
case 'csunicode11':
case 'unicode11':
return 'UNICODE-1-1';
case 'csunicode11utf7':
case 'unicode11utf7':
return 'UNICODE-1-1-UTF-7';
case 'csunknown8bit':
case 'unknown8bit':
return 'UNKNOWN-8BIT';
case 'ansix341968':
case 'ansix341986':
case 'ascii':
case 'cp367':
case 'csascii':
case 'ibm367':
case 'iso646irv1991':
case 'iso646us':
case 'isoir6':
case 'us':
case 'usascii':
return 'US-ASCII';
case 'csusdk':
case 'usdk':
return 'us-dk';
case 'utf7':
return 'UTF-7';
case 'utf8':
return 'UTF-8';
case 'utf16':
return 'UTF-16';
case 'utf16be':
return 'UTF-16BE';
case 'utf16le':
return 'UTF-16LE';
case 'utf32':
return 'UTF-32';
case 'utf32be':
return 'UTF-32BE';
case 'utf32le':
return 'UTF-32LE';
case 'csventurainternational':
case 'venturainternational':
return 'Ventura-International';
case 'csventuramath':
case 'venturamath':
return 'Ventura-Math';
case 'csventuraus':
case 'venturaus':
return 'Ventura-US';
case 'csiso70videotexsupp1':
case 'isoir70':
case 'videotexsuppl':
return 'videotex-suppl';
case 'csviqr':
case 'viqr':
return 'VIQR';
case 'csviscii':
case 'viscii':
return 'VISCII';
case 'csshiftjis':
case 'cswindows31j':
case 'mskanji':
case 'shiftjis':
case 'windows31j':
return 'Windows-31J';
case 'iso885911':
case 'tis620':
return 'windows-874';
case 'cseuckr':
case 'csksc56011987':
case 'euckr':
case 'isoir149':
case 'korean':
case 'ksc5601':
case 'ksc56011987':
case 'ksc56011989':
case 'windows949':
return 'windows-949';
case 'windows1250':
return 'windows-1250';
case 'windows1251':
return 'windows-1251';
case 'cp819':
case 'csisolatin1':
case 'ibm819':
case 'iso88591':
case 'iso885911987':
case 'isoir100':
case 'l1':
case 'latin1':
case 'windows1252':
return 'windows-1252';
case 'windows1253':
return 'windows-1253';
case 'csisolatin5':
case 'iso88599':
case 'iso885991989':
case 'isoir148':
case 'l5':
case 'latin5':
case 'windows1254':
return 'windows-1254';
case 'windows1255':
return 'windows-1255';
case 'windows1256':
return 'windows-1256';
case 'windows1257':
return 'windows-1257';
case 'windows1258':
return 'windows-1258';
default:
return $charset;
}
}
public static function get_curl_version()
{
if (is_array($curl = curl_version()))
{
$curl = $curl['version'];
}
elseif (substr($curl, 0, 5) === 'curl/')
{
$curl = substr($curl, 5, strcspn($curl, "\x09\x0A\x0B\x0C\x0D", 5));
}
elseif (substr($curl, 0, 8) === 'libcurl/')
{
$curl = substr($curl, 8, strcspn($curl, "\x09\x0A\x0B\x0C\x0D", 8));
}
else
{
$curl = 0;
}
return $curl;
}
/**
* Strip HTML comments
*
* @param string $data Data to strip comments from
* @return string Comment stripped string
*/
public static function strip_comments($data)
{
$output = '';
while (($start = strpos($data, '<!--')) !== false)
{
$output .= substr($data, 0, $start);
if (($end = strpos($data, '-->', $start)) !== false)
{
$data = substr_replace($data, '', 0, $end + 3);
}
else
{
$data = '';
}
}
return $output . $data;
}
public static function parse_date($dt)
{
$parser = SimplePie_Parse_Date::get();
return $parser->parse($dt);
}
/**
* Decode HTML entities
*
* @deprecated Use DOMDocument instead
* @param string $data Input data
* @return string Output data
*/
public static function entities_decode($data)
{
$decoder = new SimplePie_Decode_HTML_Entities($data);
return $decoder->parse();
}
/**
* Remove RFC822 comments
*
* @param string $data Data to strip comments from
* @return string Comment stripped string
*/
public static function uncomment_rfc822($string)
{
$string = (string) $string;
$position = 0;
$length = strlen($string);
$depth = 0;
$output = '';
while ($position < $length && ($pos = strpos($string, '(', $position)) !== false)
{
$output .= substr($string, $position, $pos - $position);
$position = $pos + 1;
if ($string[$pos - 1] !== '\\')
{
$depth++;
while ($depth && $position < $length)
{
$position += strcspn($string, '()', $position);
if ($string[$position - 1] === '\\')
{
$position++;
continue;
}
elseif (isset($string[$position]))
{
switch ($string[$position])
{
case '(':
$depth++;
break;
case ')':
$depth--;
break;
}
$position++;
}
else
{
break;
}
}
}
else
{
$output .= '(';
}
}
$output .= substr($string, $position);
return $output;
}
public static function parse_mime($mime)
{
if (($pos = strpos($mime, ';')) === false)
{
return trim($mime);
}
else
{
return trim(substr($mime, 0, $pos));
}
}
public static function atom_03_construct_type($attribs)
{
if (isset($attribs['']['mode']) && strtolower(trim($attribs['']['mode']) === 'base64'))
{
$mode = SIMPLEPIE_CONSTRUCT_BASE64;
}
else
{
$mode = SIMPLEPIE_CONSTRUCT_NONE;
}
if (isset($attribs['']['type']))
{
switch (strtolower(trim($attribs['']['type'])))
{
case 'text':
case 'text/plain':
return SIMPLEPIE_CONSTRUCT_TEXT | $mode;
case 'html':
case 'text/html':
return SIMPLEPIE_CONSTRUCT_HTML | $mode;
case 'xhtml':
case 'application/xhtml+xml':
return SIMPLEPIE_CONSTRUCT_XHTML | $mode;
default:
return SIMPLEPIE_CONSTRUCT_NONE | $mode;
}
}
else
{
return SIMPLEPIE_CONSTRUCT_TEXT | $mode;
}
}
public static function atom_10_construct_type($attribs)
{
if (isset($attribs['']['type']))
{
switch (strtolower(trim($attribs['']['type'])))
{
case 'text':
return SIMPLEPIE_CONSTRUCT_TEXT;
case 'html':
return SIMPLEPIE_CONSTRUCT_HTML;
case 'xhtml':
return SIMPLEPIE_CONSTRUCT_XHTML;
default:
return SIMPLEPIE_CONSTRUCT_NONE;
}
}
return SIMPLEPIE_CONSTRUCT_TEXT;
}
public static function atom_10_content_construct_type($attribs)
{
if (isset($attribs['']['type']))
{
$type = strtolower(trim($attribs['']['type']));
switch ($type)
{
case 'text':
return SIMPLEPIE_CONSTRUCT_TEXT;
case 'html':
return SIMPLEPIE_CONSTRUCT_HTML;
case 'xhtml':
return SIMPLEPIE_CONSTRUCT_XHTML;
}
if (in_array(substr($type, -4), array('+xml', '/xml')) || substr($type, 0, 5) === 'text/')
{
return SIMPLEPIE_CONSTRUCT_NONE;
}
else
{
return SIMPLEPIE_CONSTRUCT_BASE64;
}
}
else
{
return SIMPLEPIE_CONSTRUCT_TEXT;
}
}
public static function is_isegment_nz_nc($string)
{
return (bool) preg_match('/^([A-Za-z0-9\-._~\x{A0}-\x{D7FF}\x{F900}-\x{FDCF}\x{FDF0}-\x{FFEF}\x{10000}-\x{1FFFD}\x{20000}-\x{2FFFD}\x{30000}-\x{3FFFD}\x{40000}-\x{4FFFD}\x{50000}-\x{5FFFD}\x{60000}-\x{6FFFD}\x{70000}-\x{7FFFD}\x{80000}-\x{8FFFD}\x{90000}-\x{9FFFD}\x{A0000}-\x{AFFFD}\x{B0000}-\x{BFFFD}\x{C0000}-\x{CFFFD}\x{D0000}-\x{DFFFD}\x{E1000}-\x{EFFFD}!$&\'()*+,;=@]|(%[0-9ABCDEF]{2}))+$/u', $string);
}
public static function space_seperated_tokens($string)
{
$space_characters = "\x20\x09\x0A\x0B\x0C\x0D";
$string_length = strlen($string);
$position = strspn($string, $space_characters);
$tokens = array();
while ($position < $string_length)
{
$len = strcspn($string, $space_characters, $position);
$tokens[] = substr($string, $position, $len);
$position += $len;
$position += strspn($string, $space_characters, $position);
}
return $tokens;
}
/**
* Converts a unicode codepoint to a UTF-8 character
*
* @static
* @param int $codepoint Unicode codepoint
* @return string UTF-8 character
*/
public static function codepoint_to_utf8($codepoint)
{
$codepoint = (int) $codepoint;
if ($codepoint < 0)
{
return false;
}
else if ($codepoint <= 0x7f)
{
return chr($codepoint);
}
else if ($codepoint <= 0x7ff)
{
return chr(0xc0 | ($codepoint >> 6)) . chr(0x80 | ($codepoint & 0x3f));
}
else if ($codepoint <= 0xffff)
{
return chr(0xe0 | ($codepoint >> 12)) . chr(0x80 | (($codepoint >> 6) & 0x3f)) . chr(0x80 | ($codepoint & 0x3f));
}
else if ($codepoint <= 0x10ffff)
{
return chr(0xf0 | ($codepoint >> 18)) . chr(0x80 | (($codepoint >> 12) & 0x3f)) . chr(0x80 | (($codepoint >> 6) & 0x3f)) . chr(0x80 | ($codepoint & 0x3f));
}
else
{
// U+FFFD REPLACEMENT CHARACTER
return "\xEF\xBF\xBD";
}
}
/**
* Similar to parse_str()
*
* Returns an associative array of name/value pairs, where the value is an
* array of values that have used the same name
*
* @static
* @param string $str The input string.
* @return array
*/
public static function parse_str($str)
{
$return = array();
$str = explode('&', $str);
foreach ($str as $section)
{
if (strpos($section, '=') !== false)
{
list($name, $value) = explode('=', $section, 2);
$return[urldecode($name)][] = urldecode($value);
}
else
{
$return[urldecode($section)][] = null;
}
}
return $return;
}
/**
* Detect XML encoding, as per XML 1.0 Appendix F.1
*
* @todo Add support for EBCDIC
* @param string $data XML data
* @param SimplePie_Registry $registry Class registry
* @return array Possible encodings
*/
public static function xml_encoding($data, $registry)
{
// UTF-32 Big Endian BOM
if (substr($data, 0, 4) === "\x00\x00\xFE\xFF")
{
$encoding[] = 'UTF-32BE';
}
// UTF-32 Little Endian BOM
elseif (substr($data, 0, 4) === "\xFF\xFE\x00\x00")
{
$encoding[] = 'UTF-32LE';
}
// UTF-16 Big Endian BOM
elseif (substr($data, 0, 2) === "\xFE\xFF")
{
$encoding[] = 'UTF-16BE';
}
// UTF-16 Little Endian BOM
elseif (substr($data, 0, 2) === "\xFF\xFE")
{
$encoding[] = 'UTF-16LE';
}
// UTF-8 BOM
elseif (substr($data, 0, 3) === "\xEF\xBB\xBF")
{
$encoding[] = 'UTF-8';
}
// UTF-32 Big Endian Without BOM
elseif (substr($data, 0, 20) === "\x00\x00\x00\x3C\x00\x00\x00\x3F\x00\x00\x00\x78\x00\x00\x00\x6D\x00\x00\x00\x6C")
{
if ($pos = strpos($data, "\x00\x00\x00\x3F\x00\x00\x00\x3E"))
{
$parser = $registry->create('XML_Declaration_Parser', array(SimplePie_Misc::change_encoding(substr($data, 20, $pos - 20), 'UTF-32BE', 'UTF-8')));
if ($parser->parse())
{
$encoding[] = $parser->encoding;
}
}
$encoding[] = 'UTF-32BE';
}
// UTF-32 Little Endian Without BOM
elseif (substr($data, 0, 20) === "\x3C\x00\x00\x00\x3F\x00\x00\x00\x78\x00\x00\x00\x6D\x00\x00\x00\x6C\x00\x00\x00")
{
if ($pos = strpos($data, "\x3F\x00\x00\x00\x3E\x00\x00\x00"))
{
$parser = $registry->create('XML_Declaration_Parser', array(SimplePie_Misc::change_encoding(substr($data, 20, $pos - 20), 'UTF-32LE', 'UTF-8')));
if ($parser->parse())
{
$encoding[] = $parser->encoding;
}
}
$encoding[] = 'UTF-32LE';
}
// UTF-16 Big Endian Without BOM
elseif (substr($data, 0, 10) === "\x00\x3C\x00\x3F\x00\x78\x00\x6D\x00\x6C")
{
if ($pos = strpos($data, "\x00\x3F\x00\x3E"))
{
$parser = $registry->create('XML_Declaration_Parser', array(SimplePie_Misc::change_encoding(substr($data, 20, $pos - 10), 'UTF-16BE', 'UTF-8')));
if ($parser->parse())
{
$encoding[] = $parser->encoding;
}
}
$encoding[] = 'UTF-16BE';
}
// UTF-16 Little Endian Without BOM
elseif (substr($data, 0, 10) === "\x3C\x00\x3F\x00\x78\x00\x6D\x00\x6C\x00")
{
if ($pos = strpos($data, "\x3F\x00\x3E\x00"))
{
$parser = $registry->create('XML_Declaration_Parser', array(SimplePie_Misc::change_encoding(substr($data, 20, $pos - 10), 'UTF-16LE', 'UTF-8')));
if ($parser->parse())
{
$encoding[] = $parser->encoding;
}
}
$encoding[] = 'UTF-16LE';
}
// US-ASCII (or superset)
elseif (substr($data, 0, 5) === "\x3C\x3F\x78\x6D\x6C")
{
if ($pos = strpos($data, "\x3F\x3E"))
{
$parser = $registry->create('XML_Declaration_Parser', array(substr($data, 5, $pos - 5)));
if ($parser->parse())
{
$encoding[] = $parser->encoding;
}
}
$encoding[] = 'UTF-8';
}
// Fallback to UTF-8
else
{
$encoding[] = 'UTF-8';
}
return $encoding;
}
public static function output_javascript()
{
if (function_exists('ob_gzhandler'))
{
ob_start('ob_gzhandler');
}
header('Content-type: text/javascript; charset: UTF-8');
header('Cache-Control: must-revalidate');
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 604800) . ' GMT'); // 7 days
?>
function embed_quicktime(type, bgcolor, width, height, link, placeholder, loop) {
if (placeholder != '') {
document.writeln('<embed type="'+type+'" style="cursor:hand; cursor:pointer;" href="'+link+'" src="'+placeholder+'" width="'+width+'" height="'+height+'" autoplay="false" target="myself" controller="false" loop="'+loop+'" scale="aspect" bgcolor="'+bgcolor+'" pluginspage="http://www.apple.com/quicktime/download/"></embed>');
}
else {
document.writeln('<embed type="'+type+'" style="cursor:hand; cursor:pointer;" src="'+link+'" width="'+width+'" height="'+height+'" autoplay="false" target="myself" controller="true" loop="'+loop+'" scale="aspect" bgcolor="'+bgcolor+'" pluginspage="http://www.apple.com/quicktime/download/"></embed>');
}
}
function embed_flash(bgcolor, width, height, link, loop, type) {
document.writeln('<embed src="'+link+'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="'+type+'" quality="high" width="'+width+'" height="'+height+'" bgcolor="'+bgcolor+'" loop="'+loop+'"></embed>');
}
function embed_flv(width, height, link, placeholder, loop, player) {
document.writeln('<embed src="'+player+'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" quality="high" width="'+width+'" height="'+height+'" wmode="transparent" flashvars="file='+link+'&autostart=false&repeat='+loop+'&showdigits=true&showfsbutton=false"></embed>');
}
function embed_wmedia(width, height, link) {
document.writeln('<embed type="application/x-mplayer2" src="'+link+'" autosize="1" width="'+width+'" height="'+height+'" showcontrols="1" showstatusbar="0" showdisplay="0" autostart="0"></embed>');
}
<?php
}
/**
* Get the SimplePie build timestamp
*
* Uses the git index if it exists, otherwise uses the modification time
* of the newest file.
*/
public static function get_build()
{
$root = dirname(dirname(__FILE__));
if (file_exists($root . '/.git/index'))
{
return filemtime($root . '/.git/index');
}
elseif (file_exists($root . '/SimplePie'))
{
$time = 0;
foreach (glob($root . '/SimplePie/*.php') as $file)
{
if (($mtime = filemtime($file)) > $time)
{
$time = $mtime;
}
}
return $time;
}
elseif (file_exists(dirname(__FILE__) . '/Core.php'))
{
return filemtime(dirname(__FILE__) . '/Core.php');
}
else
{
return filemtime(__FILE__);
}
}
/**
* Format debugging information
*/
public static function debug(&$sp)
{
$info = 'SimplePie ' . SIMPLEPIE_VERSION . ' Build ' . SIMPLEPIE_BUILD . "\n";
$info .= 'PHP ' . PHP_VERSION . "\n";
if ($sp->error() !== null)
{
$info .= 'Error occurred: ' . $sp->error() . "\n";
}
else
{
$info .= "No error found.\n";
}
$info .= "Extensions:\n";
$extensions = array('pcre', 'curl', 'zlib', 'mbstring', 'iconv', 'xmlreader', 'xml');
foreach ($extensions as $ext)
{
if (extension_loaded($ext))
{
$info .= " $ext loaded\n";
switch ($ext)
{
case 'pcre':
$info .= ' Version ' . PCRE_VERSION . "\n";
break;
case 'curl':
$version = curl_version();
$info .= ' Version ' . $version['version'] . "\n";
break;
case 'mbstring':
$info .= ' Overloading: ' . mb_get_info('func_overload') . "\n";
break;
case 'iconv':
$info .= ' Version ' . ICONV_VERSION . "\n";
break;
case 'xml':
$info .= ' Version ' . LIBXML_DOTTED_VERSION . "\n";
break;
}
}
else
{
$info .= " $ext not loaded\n";
}
}
return $info;
}
public static function silence_errors($num, $str)
{
// No-op
}
}
| 01-wordpress-paypal | trunk/wp-includes/SimplePie/Misc.php | PHP | gpl3 | 51,550 |
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @version 1.3.1
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman
* @author Geoffrey Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
/**
* Handles `<media:rating>` or `<itunes:explicit>` tags as defined in Media RSS and iTunes RSS respectively
*
* Used by {@see SimplePie_Enclosure::get_rating()} and {@see SimplePie_Enclosure::get_ratings()}
*
* This class can be overloaded with {@see SimplePie::set_rating_class()}
*
* @package SimplePie
* @subpackage API
*/
class SimplePie_Rating
{
/**
* Rating scheme
*
* @var string
* @see get_scheme()
*/
var $scheme;
/**
* Rating value
*
* @var string
* @see get_value()
*/
var $value;
/**
* Constructor, used to input the data
*
* For documentation on all the parameters, see the corresponding
* properties and their accessors
*/
public function __construct($scheme = null, $value = null)
{
$this->scheme = $scheme;
$this->value = $value;
}
/**
* String-ified version
*
* @return string
*/
public function __toString()
{
// There is no $this->data here
return md5(serialize($this));
}
/**
* Get the organizational scheme for the rating
*
* @return string|null
*/
public function get_scheme()
{
if ($this->scheme !== null)
{
return $this->scheme;
}
else
{
return null;
}
}
/**
* Get the value of the rating
*
* @return string|null
*/
public function get_value()
{
if ($this->value !== null)
{
return $this->value;
}
else
{
return null;
}
}
}
| 01-wordpress-paypal | trunk/wp-includes/SimplePie/Rating.php | PHP | gpl3 | 3,451 |
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @version 1.3.1
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman
* @author Geoffrey Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
/**
* Manages all item-related data
*
* Used by {@see SimplePie::get_item()} and {@see SimplePie::get_items()}
*
* This class can be overloaded with {@see SimplePie::set_item_class()}
*
* @package SimplePie
* @subpackage API
*/
class SimplePie_Item
{
/**
* Parent feed
*
* @access private
* @var SimplePie
*/
var $feed;
/**
* Raw data
*
* @access private
* @var array
*/
var $data = array();
/**
* Registry object
*
* @see set_registry
* @var SimplePie_Registry
*/
protected $registry;
/**
* Create a new item object
*
* This is usually used by {@see SimplePie::get_items} and
* {@see SimplePie::get_item}. Avoid creating this manually.
*
* @param SimplePie $feed Parent feed
* @param array $data Raw data
*/
public function __construct($feed, $data)
{
$this->feed = $feed;
$this->data = $data;
}
/**
* Set the registry handler
*
* This is usually used by {@see SimplePie_Registry::create}
*
* @since 1.3
* @param SimplePie_Registry $registry
*/
public function set_registry(SimplePie_Registry $registry)
{
$this->registry = $registry;
}
/**
* Get a string representation of the item
*
* @return string
*/
public function __toString()
{
return md5(serialize($this->data));
}
/**
* Remove items that link back to this before destroying this object
*/
public function __destruct()
{
if ((version_compare(PHP_VERSION, '5.3', '<') || !gc_enabled()) && !ini_get('zend.ze1_compatibility_mode'))
{
unset($this->feed);
}
}
/**
* Get data for an item-level element
*
* This method allows you to get access to ANY element/attribute that is a
* sub-element of the item/entry tag.
*
* See {@see SimplePie::get_feed_tags()} for a description of the return value
*
* @since 1.0
* @see http://simplepie.org/wiki/faq/supported_xml_namespaces
* @param string $namespace The URL of the XML namespace of the elements you're trying to access
* @param string $tag Tag name
* @return array
*/
public function get_item_tags($namespace, $tag)
{
if (isset($this->data['child'][$namespace][$tag]))
{
return $this->data['child'][$namespace][$tag];
}
else
{
return null;
}
}
/**
* Get the base URL value from the parent feed
*
* Uses `<xml:base>`
*
* @param array $element
* @return string
*/
public function get_base($element = array())
{
return $this->feed->get_base($element);
}
/**
* Sanitize feed data
*
* @access private
* @see SimplePie::sanitize()
* @param string $data Data to sanitize
* @param int $type One of the SIMPLEPIE_CONSTRUCT_* constants
* @param string $base Base URL to resolve URLs against
* @return string Sanitized data
*/
public function sanitize($data, $type, $base = '')
{
return $this->feed->sanitize($data, $type, $base);
}
/**
* Get the parent feed
*
* Note: this may not work as you think for multifeeds!
*
* @link http://simplepie.org/faq/typical_multifeed_gotchas#missing_data_from_feed
* @since 1.0
* @return SimplePie
*/
public function get_feed()
{
return $this->feed;
}
/**
* Get the unique identifier for the item
*
* This is usually used when writing code to check for new items in a feed.
*
* Uses `<atom:id>`, `<guid>`, `<dc:identifier>` or the `about` attribute
* for RDF. If none of these are supplied (or `$hash` is true), creates an
* MD5 hash based on the permalink and title. If either of those are not
* supplied, creates a hash based on the full feed data.
*
* @since Beta 2
* @param boolean $hash Should we force using a hash instead of the supplied ID?
* @return string
*/
public function get_id($hash = false)
{
if (!$hash)
{
if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'id'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'id'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'guid'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'identifier'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'identifier'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
elseif (isset($this->data['attribs'][SIMPLEPIE_NAMESPACE_RDF]['about']))
{
return $this->sanitize($this->data['attribs'][SIMPLEPIE_NAMESPACE_RDF]['about'], SIMPLEPIE_CONSTRUCT_TEXT);
}
elseif (($return = $this->get_permalink()) !== null)
{
return $return;
}
elseif (($return = $this->get_title()) !== null)
{
return $return;
}
}
if ($this->get_permalink() !== null || $this->get_title() !== null)
{
return md5($this->get_permalink() . $this->get_title());
}
else
{
return md5(serialize($this->data));
}
}
/**
* Get the title of the item
*
* Uses `<atom:title>`, `<title>` or `<dc:title>`
*
* @since Beta 2 (previously called `get_item_title` since 0.8)
* @return string|null
*/
public function get_title()
{
if (!isset($this->data['title']))
{
if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'title'))
{
$this->data['title'] = $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($return[0]['attribs'])), $this->get_base($return[0]));
}
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'title'))
{
$this->data['title'] = $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($return[0]['attribs'])), $this->get_base($return[0]));
}
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title'))
{
$this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
}
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title'))
{
$this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
}
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title'))
{
$this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
}
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title'))
{
$this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title'))
{
$this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
else
{
$this->data['title'] = null;
}
}
return $this->data['title'];
}
/**
* Get the content for the item
*
* Prefers summaries over full content , but will return full content if a
* summary does not exist.
*
* To prefer full content instead, use {@see get_content}
*
* Uses `<atom:summary>`, `<description>`, `<dc:description>` or
* `<itunes:subtitle>`
*
* @since 0.8
* @param boolean $description_only Should we avoid falling back to the content?
* @return string|null
*/
public function get_description($description_only = false)
{
if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'summary'))
{
return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($return[0]['attribs'])), $this->get_base($return[0]));
}
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'summary'))
{
return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($return[0]['attribs'])), $this->get_base($return[0]));
}
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'description'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
}
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
}
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'description'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'summary'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
}
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'description'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML);
}
elseif (!$description_only)
{
return $this->get_content(true);
}
else
{
return null;
}
}
/**
* Get the content for the item
*
* Prefers full content over summaries, but will return a summary if full
* content does not exist.
*
* To prefer summaries instead, use {@see get_description}
*
* Uses `<atom:content>` or `<content:encoded>` (RSS 1.0 Content Module)
*
* @since 1.0
* @param boolean $content_only Should we avoid falling back to the description?
* @return string|null
*/
public function get_content($content_only = false)
{
if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'content'))
{
return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_content_construct_type', array($return[0]['attribs'])), $this->get_base($return[0]));
}
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'content'))
{
return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($return[0]['attribs'])), $this->get_base($return[0]));
}
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10_MODULES_CONTENT, 'encoded'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
}
elseif (!$content_only)
{
return $this->get_description(true);
}
else
{
return null;
}
}
/**
* Get a category for the item
*
* @since Beta 3 (previously called `get_categories()` since Beta 2)
* @param int $key The category that you want to return. Remember that arrays begin with 0, not 1
* @return SimplePie_Category|null
*/
public function get_category($key = 0)
{
$categories = $this->get_categories();
if (isset($categories[$key]))
{
return $categories[$key];
}
else
{
return null;
}
}
/**
* Get all categories for the item
*
* Uses `<atom:category>`, `<category>` or `<dc:subject>`
*
* @since Beta 3
* @return array|null List of {@see SimplePie_Category} objects
*/
public function get_categories()
{
$categories = array();
foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'category') as $category)
{
$term = null;
$scheme = null;
$label = null;
if (isset($category['attribs']['']['term']))
{
$term = $this->sanitize($category['attribs']['']['term'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($category['attribs']['']['scheme']))
{
$scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($category['attribs']['']['label']))
{
$label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
}
$categories[] = $this->registry->create('Category', array($term, $scheme, $label));
}
foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'category') as $category)
{
// This is really the label, but keep this as the term also for BC.
// Label will also work on retrieving because that falls back to term.
$term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
if (isset($category['attribs']['']['domain']))
{
$scheme = $this->sanitize($category['attribs']['']['domain'], SIMPLEPIE_CONSTRUCT_TEXT);
}
else
{
$scheme = null;
}
$categories[] = $this->registry->create('Category', array($term, $scheme, null));
}
foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category)
{
$categories[] = $this->registry->create('Category', array($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null));
}
foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'subject') as $category)
{
$categories[] = $this->registry->create('Category', array($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null));
}
if (!empty($categories))
{
return array_unique($categories);
}
else
{
return null;
}
}
/**
* Get an author for the item
*
* @since Beta 2
* @param int $key The author that you want to return. Remember that arrays begin with 0, not 1
* @return SimplePie_Author|null
*/
public function get_author($key = 0)
{
$authors = $this->get_authors();
if (isset($authors[$key]))
{
return $authors[$key];
}
else
{
return null;
}
}
/**
* Get a contributor for the item
*
* @since 1.1
* @param int $key The contrbutor that you want to return. Remember that arrays begin with 0, not 1
* @return SimplePie_Author|null
*/
public function get_contributor($key = 0)
{
$contributors = $this->get_contributors();
if (isset($contributors[$key]))
{
return $contributors[$key];
}
else
{
return null;
}
}
/**
* Get all contributors for the item
*
* Uses `<atom:contributor>`
*
* @since 1.1
* @return array|null List of {@see SimplePie_Author} objects
*/
public function get_contributors()
{
$contributors = array();
foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'contributor') as $contributor)
{
$name = null;
$uri = null;
$email = null;
if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']))
{
$name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']))
{
$uri = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]));
}
if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']))
{
$email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if ($name !== null || $email !== null || $uri !== null)
{
$contributors[] = $this->registry->create('Author', array($name, $uri, $email));
}
}
foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'contributor') as $contributor)
{
$name = null;
$url = null;
$email = null;
if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']))
{
$name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data']))
{
$url = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]));
}
if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']))
{
$email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if ($name !== null || $email !== null || $url !== null)
{
$contributors[] = $this->registry->create('Author', array($name, $url, $email));
}
}
if (!empty($contributors))
{
return array_unique($contributors);
}
else
{
return null;
}
}
/**
* Get all authors for the item
*
* Uses `<atom:author>`, `<author>`, `<dc:creator>` or `<itunes:author>`
*
* @since Beta 2
* @return array|null List of {@see SimplePie_Author} objects
*/
public function get_authors()
{
$authors = array();
foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author') as $author)
{
$name = null;
$uri = null;
$email = null;
if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']))
{
$name = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']))
{
$uri = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]));
}
if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']))
{
$email = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if ($name !== null || $email !== null || $uri !== null)
{
$authors[] = $this->registry->create('Author', array($name, $uri, $email));
}
}
if ($author = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'author'))
{
$name = null;
$url = null;
$email = null;
if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']))
{
$name = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data']))
{
$url = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]));
}
if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']))
{
$email = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if ($name !== null || $email !== null || $url !== null)
{
$authors[] = $this->registry->create('Author', array($name, $url, $email));
}
}
if ($author = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'author'))
{
$authors[] = $this->registry->create('Author', array(null, null, $this->sanitize($author[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)));
}
foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'creator') as $author)
{
$authors[] = $this->registry->create('Author', array($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null));
}
foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'creator') as $author)
{
$authors[] = $this->registry->create('Author', array($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null));
}
foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'author') as $author)
{
$authors[] = $this->registry->create('Author', array($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null));
}
if (!empty($authors))
{
return array_unique($authors);
}
elseif (($source = $this->get_source()) && ($authors = $source->get_authors()))
{
return $authors;
}
elseif ($authors = $this->feed->get_authors())
{
return $authors;
}
else
{
return null;
}
}
/**
* Get the copyright info for the item
*
* Uses `<atom:rights>` or `<dc:rights>`
*
* @since 1.1
* @return string
*/
public function get_copyright()
{
if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'rights'))
{
return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($return[0]['attribs'])), $this->get_base($return[0]));
}
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'rights'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'rights'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
else
{
return null;
}
}
/**
* Get the posting date/time for the item
*
* Uses `<atom:published>`, `<atom:updated>`, `<atom:issued>`,
* `<atom:modified>`, `<pubDate>` or `<dc:date>`
*
* Note: obeys PHP's timezone setting. To get a UTC date/time, use
* {@see get_gmdate}
*
* @since Beta 2 (previously called `get_item_date` since 0.8)
*
* @param string $date_format Supports any PHP date format from {@see http://php.net/date} (empty for the raw data)
* @return int|string|null
*/
public function get_date($date_format = 'j F Y, g:i a')
{
if (!isset($this->data['date']))
{
if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'published'))
{
$this->data['date']['raw'] = $return[0]['data'];
}
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'updated'))
{
$this->data['date']['raw'] = $return[0]['data'];
}
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'issued'))
{
$this->data['date']['raw'] = $return[0]['data'];
}
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'created'))
{
$this->data['date']['raw'] = $return[0]['data'];
}
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'modified'))
{
$this->data['date']['raw'] = $return[0]['data'];
}
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'pubDate'))
{
$this->data['date']['raw'] = $return[0]['data'];
}
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'date'))
{
$this->data['date']['raw'] = $return[0]['data'];
}
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'date'))
{
$this->data['date']['raw'] = $return[0]['data'];
}
if (!empty($this->data['date']['raw']))
{
$parser = $this->registry->call('Parse_Date', 'get');
$this->data['date']['parsed'] = $parser->parse($this->data['date']['raw']);
}
else
{
$this->data['date'] = null;
}
}
if ($this->data['date'])
{
$date_format = (string) $date_format;
switch ($date_format)
{
case '':
return $this->sanitize($this->data['date']['raw'], SIMPLEPIE_CONSTRUCT_TEXT);
case 'U':
return $this->data['date']['parsed'];
default:
return date($date_format, $this->data['date']['parsed']);
}
}
else
{
return null;
}
}
/**
* Get the update date/time for the item
*
* Uses `<atom:updated>`
*
* Note: obeys PHP's timezone setting. To get a UTC date/time, use
* {@see get_gmdate}
*
* @param string $date_format Supports any PHP date format from {@see http://php.net/date} (empty for the raw data)
* @return int|string|null
*/
public function get_updated_date($date_format = 'j F Y, g:i a')
{
if (!isset($this->data['updated']))
{
if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'updated'))
{
$this->data['updated']['raw'] = $return[0]['data'];
}
if (!empty($this->data['updated']['raw']))
{
$parser = $this->registry->call('Parse_Date', 'get');
$this->data['updated']['parsed'] = $parser->parse($this->data['date']['raw']);
}
else
{
$this->data['updated'] = null;
}
}
if ($this->data['updated'])
{
$date_format = (string) $date_format;
switch ($date_format)
{
case '':
return $this->sanitize($this->data['updated']['raw'], SIMPLEPIE_CONSTRUCT_TEXT);
case 'U':
return $this->data['updated']['parsed'];
default:
return date($date_format, $this->data['updated']['parsed']);
}
}
else
{
return null;
}
}
/**
* Get the localized posting date/time for the item
*
* Returns the date formatted in the localized language. To display in
* languages other than the server's default, you need to change the locale
* with {@link http://php.net/setlocale setlocale()}. The available
* localizations depend on which ones are installed on your web server.
*
* @since 1.0
*
* @param string $date_format Supports any PHP date format from {@see http://php.net/strftime} (empty for the raw data)
* @return int|string|null
*/
public function get_local_date($date_format = '%c')
{
if (!$date_format)
{
return $this->sanitize($this->get_date(''), SIMPLEPIE_CONSTRUCT_TEXT);
}
elseif (($date = $this->get_date('U')) !== null && $date !== false)
{
return strftime($date_format, $date);
}
else
{
return null;
}
}
/**
* Get the posting date/time for the item (UTC time)
*
* @see get_date
* @param string $date_format Supports any PHP date format from {@see http://php.net/date}
* @return int|string|null
*/
public function get_gmdate($date_format = 'j F Y, g:i a')
{
$date = $this->get_date('U');
if ($date === null)
{
return null;
}
return gmdate($date_format, $date);
}
/**
* Get the update date/time for the item (UTC time)
*
* @see get_updated_date
* @param string $date_format Supports any PHP date format from {@see http://php.net/date}
* @return int|string|null
*/
public function get_updated_gmdate($date_format = 'j F Y, g:i a')
{
$date = $this->get_updated_date('U');
if ($date === null)
{
return null;
}
return gmdate($date_format, $date);
}
/**
* Get the permalink for the item
*
* Returns the first link available with a relationship of "alternate".
* Identical to {@see get_link()} with key 0
*
* @see get_link
* @since 0.8
* @return string|null Permalink URL
*/
public function get_permalink()
{
$link = $this->get_link();
$enclosure = $this->get_enclosure(0);
if ($link !== null)
{
return $link;
}
elseif ($enclosure !== null)
{
return $enclosure->get_link();
}
else
{
return null;
}
}
/**
* Get a single link for the item
*
* @since Beta 3
* @param int $key The link that you want to return. Remember that arrays begin with 0, not 1
* @param string $rel The relationship of the link to return
* @return string|null Link URL
*/
public function get_link($key = 0, $rel = 'alternate')
{
$links = $this->get_links($rel);
if ($links[$key] !== null)
{
return $links[$key];
}
else
{
return null;
}
}
/**
* Get all links for the item
*
* Uses `<atom:link>`, `<link>` or `<guid>`
*
* @since Beta 2
* @param string $rel The relationship of links to return
* @return array|null Links found for the item (strings)
*/
public function get_links($rel = 'alternate')
{
if (!isset($this->data['links']))
{
$this->data['links'] = array();
foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link') as $link)
{
if (isset($link['attribs']['']['href']))
{
$link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate';
$this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link));
}
}
foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link') as $link)
{
if (isset($link['attribs']['']['href']))
{
$link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate';
$this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link));
}
}
if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'link'))
{
$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
}
if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'link'))
{
$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
}
if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link'))
{
$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
}
if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'guid'))
{
if (!isset($links[0]['attribs']['']['isPermaLink']) || strtolower(trim($links[0]['attribs']['']['isPermaLink'])) === 'true')
{
$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
}
}
$keys = array_keys($this->data['links']);
foreach ($keys as $key)
{
if ($this->registry->call('Misc', 'is_isegment_nz_nc', array($key)))
{
if (isset($this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]))
{
$this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]);
$this->data['links'][$key] =& $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key];
}
else
{
$this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key];
}
}
elseif (substr($key, 0, 41) === SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY)
{
$this->data['links'][substr($key, 41)] =& $this->data['links'][$key];
}
$this->data['links'][$key] = array_unique($this->data['links'][$key]);
}
}
if (isset($this->data['links'][$rel]))
{
return $this->data['links'][$rel];
}
else
{
return null;
}
}
/**
* Get an enclosure from the item
*
* Supports the <enclosure> RSS tag, as well as Media RSS and iTunes RSS.
*
* @since Beta 2
* @todo Add ability to prefer one type of content over another (in a media group).
* @param int $key The enclosure that you want to return. Remember that arrays begin with 0, not 1
* @return SimplePie_Enclosure|null
*/
public function get_enclosure($key = 0, $prefer = null)
{
$enclosures = $this->get_enclosures();
if (isset($enclosures[$key]))
{
return $enclosures[$key];
}
else
{
return null;
}
}
/**
* Get all available enclosures (podcasts, etc.)
*
* Supports the <enclosure> RSS tag, as well as Media RSS and iTunes RSS.
*
* At this point, we're pretty much assuming that all enclosures for an item
* are the same content. Anything else is too complicated to
* properly support.
*
* @since Beta 2
* @todo Add support for end-user defined sorting of enclosures by type/handler (so we can prefer the faster-loading FLV over MP4).
* @todo If an element exists at a level, but it's value is empty, we should fall back to the value from the parent (if it exists).
* @return array|null List of SimplePie_Enclosure items
*/
public function get_enclosures()
{
if (!isset($this->data['enclosures']))
{
$this->data['enclosures'] = array();
// Elements
$captions_parent = null;
$categories_parent = null;
$copyrights_parent = null;
$credits_parent = null;
$description_parent = null;
$duration_parent = null;
$hashes_parent = null;
$keywords_parent = null;
$player_parent = null;
$ratings_parent = null;
$restrictions_parent = null;
$thumbnails_parent = null;
$title_parent = null;
// Let's do the channel and item-level ones first, and just re-use them if we need to.
$parent = $this->get_feed();
// CAPTIONS
if ($captions = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'text'))
{
foreach ($captions as $caption)
{
$caption_type = null;
$caption_lang = null;
$caption_startTime = null;
$caption_endTime = null;
$caption_text = null;
if (isset($caption['attribs']['']['type']))
{
$caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($caption['attribs']['']['lang']))
{
$caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($caption['attribs']['']['start']))
{
$caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($caption['attribs']['']['end']))
{
$caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($caption['data']))
{
$caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
$captions_parent[] = $this->registry->create('Caption', array($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text));
}
}
elseif ($captions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'text'))
{
foreach ($captions as $caption)
{
$caption_type = null;
$caption_lang = null;
$caption_startTime = null;
$caption_endTime = null;
$caption_text = null;
if (isset($caption['attribs']['']['type']))
{
$caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($caption['attribs']['']['lang']))
{
$caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($caption['attribs']['']['start']))
{
$caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($caption['attribs']['']['end']))
{
$caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($caption['data']))
{
$caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
$captions_parent[] = $this->registry->create('Caption', array($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text));
}
}
if (is_array($captions_parent))
{
$captions_parent = array_values(array_unique($captions_parent));
}
// CATEGORIES
foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'category') as $category)
{
$term = null;
$scheme = null;
$label = null;
if (isset($category['data']))
{
$term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($category['attribs']['']['scheme']))
{
$scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
}
else
{
$scheme = 'http://search.yahoo.com/mrss/category_schema';
}
if (isset($category['attribs']['']['label']))
{
$label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
}
$categories_parent[] = $this->registry->create('Category', array($term, $scheme, $label));
}
foreach ((array) $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'category') as $category)
{
$term = null;
$scheme = null;
$label = null;
if (isset($category['data']))
{
$term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($category['attribs']['']['scheme']))
{
$scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
}
else
{
$scheme = 'http://search.yahoo.com/mrss/category_schema';
}
if (isset($category['attribs']['']['label']))
{
$label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
}
$categories_parent[] = $this->registry->create('Category', array($term, $scheme, $label));
}
foreach ((array) $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'category') as $category)
{
$term = null;
$scheme = 'http://www.itunes.com/dtds/podcast-1.0.dtd';
$label = null;
if (isset($category['attribs']['']['text']))
{
$label = $this->sanitize($category['attribs']['']['text'], SIMPLEPIE_CONSTRUCT_TEXT);
}
$categories_parent[] = $this->registry->create('Category', array($term, $scheme, $label));
if (isset($category['child'][SIMPLEPIE_NAMESPACE_ITUNES]['category']))
{
foreach ((array) $category['child'][SIMPLEPIE_NAMESPACE_ITUNES]['category'] as $subcategory)
{
if (isset($subcategory['attribs']['']['text']))
{
$label = $this->sanitize($subcategory['attribs']['']['text'], SIMPLEPIE_CONSTRUCT_TEXT);
}
$categories_parent[] = $this->registry->create('Category', array($term, $scheme, $label));
}
}
}
if (is_array($categories_parent))
{
$categories_parent = array_values(array_unique($categories_parent));
}
// COPYRIGHT
if ($copyright = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'copyright'))
{
$copyright_url = null;
$copyright_label = null;
if (isset($copyright[0]['attribs']['']['url']))
{
$copyright_url = $this->sanitize($copyright[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($copyright[0]['data']))
{
$copyright_label = $this->sanitize($copyright[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
$copyrights_parent = $this->registry->create('Copyright', array($copyright_url, $copyright_label));
}
elseif ($copyright = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'copyright'))
{
$copyright_url = null;
$copyright_label = null;
if (isset($copyright[0]['attribs']['']['url']))
{
$copyright_url = $this->sanitize($copyright[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($copyright[0]['data']))
{
$copyright_label = $this->sanitize($copyright[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
$copyrights_parent = $this->registry->create('Copyright', array($copyright_url, $copyright_label));
}
// CREDITS
if ($credits = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'credit'))
{
foreach ($credits as $credit)
{
$credit_role = null;
$credit_scheme = null;
$credit_name = null;
if (isset($credit['attribs']['']['role']))
{
$credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($credit['attribs']['']['scheme']))
{
$credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
}
else
{
$credit_scheme = 'urn:ebu';
}
if (isset($credit['data']))
{
$credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
$credits_parent[] = $this->registry->create('Credit', array($credit_role, $credit_scheme, $credit_name));
}
}
elseif ($credits = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'credit'))
{
foreach ($credits as $credit)
{
$credit_role = null;
$credit_scheme = null;
$credit_name = null;
if (isset($credit['attribs']['']['role']))
{
$credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($credit['attribs']['']['scheme']))
{
$credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
}
else
{
$credit_scheme = 'urn:ebu';
}
if (isset($credit['data']))
{
$credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
$credits_parent[] = $this->registry->create('Credit', array($credit_role, $credit_scheme, $credit_name));
}
}
if (is_array($credits_parent))
{
$credits_parent = array_values(array_unique($credits_parent));
}
// DESCRIPTION
if ($description_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'description'))
{
if (isset($description_parent[0]['data']))
{
$description_parent = $this->sanitize($description_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
}
elseif ($description_parent = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'description'))
{
if (isset($description_parent[0]['data']))
{
$description_parent = $this->sanitize($description_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
}
// DURATION
if ($duration_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'duration'))
{
$seconds = null;
$minutes = null;
$hours = null;
if (isset($duration_parent[0]['data']))
{
$temp = explode(':', $this->sanitize($duration_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
if (sizeof($temp) > 0)
{
$seconds = (int) array_pop($temp);
}
if (sizeof($temp) > 0)
{
$minutes = (int) array_pop($temp);
$seconds += $minutes * 60;
}
if (sizeof($temp) > 0)
{
$hours = (int) array_pop($temp);
$seconds += $hours * 3600;
}
unset($temp);
$duration_parent = $seconds;
}
}
// HASHES
if ($hashes_iterator = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'hash'))
{
foreach ($hashes_iterator as $hash)
{
$value = null;
$algo = null;
if (isset($hash['data']))
{
$value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($hash['attribs']['']['algo']))
{
$algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
}
else
{
$algo = 'md5';
}
$hashes_parent[] = $algo.':'.$value;
}
}
elseif ($hashes_iterator = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'hash'))
{
foreach ($hashes_iterator as $hash)
{
$value = null;
$algo = null;
if (isset($hash['data']))
{
$value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($hash['attribs']['']['algo']))
{
$algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
}
else
{
$algo = 'md5';
}
$hashes_parent[] = $algo.':'.$value;
}
}
if (is_array($hashes_parent))
{
$hashes_parent = array_values(array_unique($hashes_parent));
}
// KEYWORDS
if ($keywords = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'keywords'))
{
if (isset($keywords[0]['data']))
{
$temp = explode(',', $this->sanitize($keywords[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
foreach ($temp as $word)
{
$keywords_parent[] = trim($word);
}
}
unset($temp);
}
elseif ($keywords = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'keywords'))
{
if (isset($keywords[0]['data']))
{
$temp = explode(',', $this->sanitize($keywords[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
foreach ($temp as $word)
{
$keywords_parent[] = trim($word);
}
}
unset($temp);
}
elseif ($keywords = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'keywords'))
{
if (isset($keywords[0]['data']))
{
$temp = explode(',', $this->sanitize($keywords[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
foreach ($temp as $word)
{
$keywords_parent[] = trim($word);
}
}
unset($temp);
}
elseif ($keywords = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'keywords'))
{
if (isset($keywords[0]['data']))
{
$temp = explode(',', $this->sanitize($keywords[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
foreach ($temp as $word)
{
$keywords_parent[] = trim($word);
}
}
unset($temp);
}
if (is_array($keywords_parent))
{
$keywords_parent = array_values(array_unique($keywords_parent));
}
// PLAYER
if ($player_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'player'))
{
if (isset($player_parent[0]['attribs']['']['url']))
{
$player_parent = $this->sanitize($player_parent[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
}
}
elseif ($player_parent = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'player'))
{
if (isset($player_parent[0]['attribs']['']['url']))
{
$player_parent = $this->sanitize($player_parent[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
}
}
// RATINGS
if ($ratings = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'rating'))
{
foreach ($ratings as $rating)
{
$rating_scheme = null;
$rating_value = null;
if (isset($rating['attribs']['']['scheme']))
{
$rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
}
else
{
$rating_scheme = 'urn:simple';
}
if (isset($rating['data']))
{
$rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
$ratings_parent[] = $this->registry->create('Rating', array($rating_scheme, $rating_value));
}
}
elseif ($ratings = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'explicit'))
{
foreach ($ratings as $rating)
{
$rating_scheme = 'urn:itunes';
$rating_value = null;
if (isset($rating['data']))
{
$rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
$ratings_parent[] = $this->registry->create('Rating', array($rating_scheme, $rating_value));
}
}
elseif ($ratings = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'rating'))
{
foreach ($ratings as $rating)
{
$rating_scheme = null;
$rating_value = null;
if (isset($rating['attribs']['']['scheme']))
{
$rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
}
else
{
$rating_scheme = 'urn:simple';
}
if (isset($rating['data']))
{
$rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
$ratings_parent[] = $this->registry->create('Rating', array($rating_scheme, $rating_value));
}
}
elseif ($ratings = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'explicit'))
{
foreach ($ratings as $rating)
{
$rating_scheme = 'urn:itunes';
$rating_value = null;
if (isset($rating['data']))
{
$rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
$ratings_parent[] = $this->registry->create('Rating', array($rating_scheme, $rating_value));
}
}
if (is_array($ratings_parent))
{
$ratings_parent = array_values(array_unique($ratings_parent));
}
// RESTRICTIONS
if ($restrictions = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'restriction'))
{
foreach ($restrictions as $restriction)
{
$restriction_relationship = null;
$restriction_type = null;
$restriction_value = null;
if (isset($restriction['attribs']['']['relationship']))
{
$restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($restriction['attribs']['']['type']))
{
$restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($restriction['data']))
{
$restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
$restrictions_parent[] = $this->registry->create('Restriction', array($restriction_relationship, $restriction_type, $restriction_value));
}
}
elseif ($restrictions = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'block'))
{
foreach ($restrictions as $restriction)
{
$restriction_relationship = 'allow';
$restriction_type = null;
$restriction_value = 'itunes';
if (isset($restriction['data']) && strtolower($restriction['data']) === 'yes')
{
$restriction_relationship = 'deny';
}
$restrictions_parent[] = $this->registry->create('Restriction', array($restriction_relationship, $restriction_type, $restriction_value));
}
}
elseif ($restrictions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'restriction'))
{
foreach ($restrictions as $restriction)
{
$restriction_relationship = null;
$restriction_type = null;
$restriction_value = null;
if (isset($restriction['attribs']['']['relationship']))
{
$restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($restriction['attribs']['']['type']))
{
$restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($restriction['data']))
{
$restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
$restrictions_parent[] = $this->registry->create('Restriction', array($restriction_relationship, $restriction_type, $restriction_value));
}
}
elseif ($restrictions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'block'))
{
foreach ($restrictions as $restriction)
{
$restriction_relationship = 'allow';
$restriction_type = null;
$restriction_value = 'itunes';
if (isset($restriction['data']) && strtolower($restriction['data']) === 'yes')
{
$restriction_relationship = 'deny';
}
$restrictions_parent[] = $this->registry->create('Restriction', array($restriction_relationship, $restriction_type, $restriction_value));
}
}
if (is_array($restrictions_parent))
{
$restrictions_parent = array_values(array_unique($restrictions_parent));
}
else
{
$restrictions_parent = array(new SimplePie_Restriction('allow', null, 'default'));
}
// THUMBNAILS
if ($thumbnails = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'thumbnail'))
{
foreach ($thumbnails as $thumbnail)
{
if (isset($thumbnail['attribs']['']['url']))
{
$thumbnails_parent[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
}
}
}
elseif ($thumbnails = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'thumbnail'))
{
foreach ($thumbnails as $thumbnail)
{
if (isset($thumbnail['attribs']['']['url']))
{
$thumbnails_parent[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
}
}
}
// TITLES
if ($title_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'title'))
{
if (isset($title_parent[0]['data']))
{
$title_parent = $this->sanitize($title_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
}
elseif ($title_parent = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'title'))
{
if (isset($title_parent[0]['data']))
{
$title_parent = $this->sanitize($title_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
}
// Clear the memory
unset($parent);
// Attributes
$bitrate = null;
$channels = null;
$duration = null;
$expression = null;
$framerate = null;
$height = null;
$javascript = null;
$lang = null;
$length = null;
$medium = null;
$samplingrate = null;
$type = null;
$url = null;
$width = null;
// Elements
$captions = null;
$categories = null;
$copyrights = null;
$credits = null;
$description = null;
$hashes = null;
$keywords = null;
$player = null;
$ratings = null;
$restrictions = null;
$thumbnails = null;
$title = null;
// If we have media:group tags, loop through them.
foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'group') as $group)
{
if(isset($group['child']) && isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content']))
{
// If we have media:content tags, loop through them.
foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'] as $content)
{
if (isset($content['attribs']['']['url']))
{
// Attributes
$bitrate = null;
$channels = null;
$duration = null;
$expression = null;
$framerate = null;
$height = null;
$javascript = null;
$lang = null;
$length = null;
$medium = null;
$samplingrate = null;
$type = null;
$url = null;
$width = null;
// Elements
$captions = null;
$categories = null;
$copyrights = null;
$credits = null;
$description = null;
$hashes = null;
$keywords = null;
$player = null;
$ratings = null;
$restrictions = null;
$thumbnails = null;
$title = null;
// Start checking the attributes of media:content
if (isset($content['attribs']['']['bitrate']))
{
$bitrate = $this->sanitize($content['attribs']['']['bitrate'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($content['attribs']['']['channels']))
{
$channels = $this->sanitize($content['attribs']['']['channels'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($content['attribs']['']['duration']))
{
$duration = $this->sanitize($content['attribs']['']['duration'], SIMPLEPIE_CONSTRUCT_TEXT);
}
else
{
$duration = $duration_parent;
}
if (isset($content['attribs']['']['expression']))
{
$expression = $this->sanitize($content['attribs']['']['expression'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($content['attribs']['']['framerate']))
{
$framerate = $this->sanitize($content['attribs']['']['framerate'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($content['attribs']['']['height']))
{
$height = $this->sanitize($content['attribs']['']['height'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($content['attribs']['']['lang']))
{
$lang = $this->sanitize($content['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($content['attribs']['']['fileSize']))
{
$length = ceil($content['attribs']['']['fileSize']);
}
if (isset($content['attribs']['']['medium']))
{
$medium = $this->sanitize($content['attribs']['']['medium'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($content['attribs']['']['samplingrate']))
{
$samplingrate = $this->sanitize($content['attribs']['']['samplingrate'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($content['attribs']['']['type']))
{
$type = $this->sanitize($content['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($content['attribs']['']['width']))
{
$width = $this->sanitize($content['attribs']['']['width'], SIMPLEPIE_CONSTRUCT_TEXT);
}
$url = $this->sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
// Checking the other optional media: elements. Priority: media:content, media:group, item, channel
// CAPTIONS
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text']))
{
foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption)
{
$caption_type = null;
$caption_lang = null;
$caption_startTime = null;
$caption_endTime = null;
$caption_text = null;
if (isset($caption['attribs']['']['type']))
{
$caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($caption['attribs']['']['lang']))
{
$caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($caption['attribs']['']['start']))
{
$caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($caption['attribs']['']['end']))
{
$caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($caption['data']))
{
$caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
$captions[] = $this->registry->create('Caption', array($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text));
}
if (is_array($captions))
{
$captions = array_values(array_unique($captions));
}
}
elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text']))
{
foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption)
{
$caption_type = null;
$caption_lang = null;
$caption_startTime = null;
$caption_endTime = null;
$caption_text = null;
if (isset($caption['attribs']['']['type']))
{
$caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($caption['attribs']['']['lang']))
{
$caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($caption['attribs']['']['start']))
{
$caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($caption['attribs']['']['end']))
{
$caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($caption['data']))
{
$caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
$captions[] = $this->registry->create('Caption', array($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text));
}
if (is_array($captions))
{
$captions = array_values(array_unique($captions));
}
}
else
{
$captions = $captions_parent;
}
// CATEGORIES
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category']))
{
foreach ((array) $content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category)
{
$term = null;
$scheme = null;
$label = null;
if (isset($category['data']))
{
$term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($category['attribs']['']['scheme']))
{
$scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
}
else
{
$scheme = 'http://search.yahoo.com/mrss/category_schema';
}
if (isset($category['attribs']['']['label']))
{
$label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
}
$categories[] = $this->registry->create('Category', array($term, $scheme, $label));
}
}
if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category']))
{
foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category)
{
$term = null;
$scheme = null;
$label = null;
if (isset($category['data']))
{
$term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($category['attribs']['']['scheme']))
{
$scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
}
else
{
$scheme = 'http://search.yahoo.com/mrss/category_schema';
}
if (isset($category['attribs']['']['label']))
{
$label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
}
$categories[] = $this->registry->create('Category', array($term, $scheme, $label));
}
}
if (is_array($categories) && is_array($categories_parent))
{
$categories = array_values(array_unique(array_merge($categories, $categories_parent)));
}
elseif (is_array($categories))
{
$categories = array_values(array_unique($categories));
}
elseif (is_array($categories_parent))
{
$categories = array_values(array_unique($categories_parent));
}
// COPYRIGHTS
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright']))
{
$copyright_url = null;
$copyright_label = null;
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url']))
{
$copyright_url = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data']))
{
$copyright_label = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
$copyrights = $this->registry->create('Copyright', array($copyright_url, $copyright_label));
}
elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright']))
{
$copyright_url = null;
$copyright_label = null;
if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url']))
{
$copyright_url = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data']))
{
$copyright_label = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
$copyrights = $this->registry->create('Copyright', array($copyright_url, $copyright_label));
}
else
{
$copyrights = $copyrights_parent;
}
// CREDITS
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit']))
{
foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit)
{
$credit_role = null;
$credit_scheme = null;
$credit_name = null;
if (isset($credit['attribs']['']['role']))
{
$credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($credit['attribs']['']['scheme']))
{
$credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
}
else
{
$credit_scheme = 'urn:ebu';
}
if (isset($credit['data']))
{
$credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
$credits[] = $this->registry->create('Credit', array($credit_role, $credit_scheme, $credit_name));
}
if (is_array($credits))
{
$credits = array_values(array_unique($credits));
}
}
elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit']))
{
foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit)
{
$credit_role = null;
$credit_scheme = null;
$credit_name = null;
if (isset($credit['attribs']['']['role']))
{
$credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($credit['attribs']['']['scheme']))
{
$credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
}
else
{
$credit_scheme = 'urn:ebu';
}
if (isset($credit['data']))
{
$credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
$credits[] = $this->registry->create('Credit', array($credit_role, $credit_scheme, $credit_name));
}
if (is_array($credits))
{
$credits = array_values(array_unique($credits));
}
}
else
{
$credits = $credits_parent;
}
// DESCRIPTION
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description']))
{
$description = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description']))
{
$description = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
else
{
$description = $description_parent;
}
// HASHES
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash']))
{
foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash)
{
$value = null;
$algo = null;
if (isset($hash['data']))
{
$value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($hash['attribs']['']['algo']))
{
$algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
}
else
{
$algo = 'md5';
}
$hashes[] = $algo.':'.$value;
}
if (is_array($hashes))
{
$hashes = array_values(array_unique($hashes));
}
}
elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash']))
{
foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash)
{
$value = null;
$algo = null;
if (isset($hash['data']))
{
$value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($hash['attribs']['']['algo']))
{
$algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
}
else
{
$algo = 'md5';
}
$hashes[] = $algo.':'.$value;
}
if (is_array($hashes))
{
$hashes = array_values(array_unique($hashes));
}
}
else
{
$hashes = $hashes_parent;
}
// KEYWORDS
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords']))
{
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data']))
{
$temp = explode(',', $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
foreach ($temp as $word)
{
$keywords[] = trim($word);
}
unset($temp);
}
if (is_array($keywords))
{
$keywords = array_values(array_unique($keywords));
}
}
elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords']))
{
if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data']))
{
$temp = explode(',', $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
foreach ($temp as $word)
{
$keywords[] = trim($word);
}
unset($temp);
}
if (is_array($keywords))
{
$keywords = array_values(array_unique($keywords));
}
}
else
{
$keywords = $keywords_parent;
}
// PLAYER
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
{
$player = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
}
elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
{
$player = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
}
else
{
$player = $player_parent;
}
// RATINGS
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating']))
{
foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating)
{
$rating_scheme = null;
$rating_value = null;
if (isset($rating['attribs']['']['scheme']))
{
$rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
}
else
{
$rating_scheme = 'urn:simple';
}
if (isset($rating['data']))
{
$rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
$ratings[] = $this->registry->create('Rating', array($rating_scheme, $rating_value));
}
if (is_array($ratings))
{
$ratings = array_values(array_unique($ratings));
}
}
elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating']))
{
foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating)
{
$rating_scheme = null;
$rating_value = null;
if (isset($rating['attribs']['']['scheme']))
{
$rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
}
else
{
$rating_scheme = 'urn:simple';
}
if (isset($rating['data']))
{
$rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
$ratings[] = $this->registry->create('Rating', array($rating_scheme, $rating_value));
}
if (is_array($ratings))
{
$ratings = array_values(array_unique($ratings));
}
}
else
{
$ratings = $ratings_parent;
}
// RESTRICTIONS
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction']))
{
foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction)
{
$restriction_relationship = null;
$restriction_type = null;
$restriction_value = null;
if (isset($restriction['attribs']['']['relationship']))
{
$restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($restriction['attribs']['']['type']))
{
$restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($restriction['data']))
{
$restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
$restrictions[] = $this->registry->create('Restriction', array($restriction_relationship, $restriction_type, $restriction_value));
}
if (is_array($restrictions))
{
$restrictions = array_values(array_unique($restrictions));
}
}
elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction']))
{
foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction)
{
$restriction_relationship = null;
$restriction_type = null;
$restriction_value = null;
if (isset($restriction['attribs']['']['relationship']))
{
$restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($restriction['attribs']['']['type']))
{
$restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($restriction['data']))
{
$restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
$restrictions[] = $this->registry->create('Restriction', array($restriction_relationship, $restriction_type, $restriction_value));
}
if (is_array($restrictions))
{
$restrictions = array_values(array_unique($restrictions));
}
}
else
{
$restrictions = $restrictions_parent;
}
// THUMBNAILS
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail']))
{
foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail)
{
$thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
}
if (is_array($thumbnails))
{
$thumbnails = array_values(array_unique($thumbnails));
}
}
elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail']))
{
foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail)
{
$thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
}
if (is_array($thumbnails))
{
$thumbnails = array_values(array_unique($thumbnails));
}
}
else
{
$thumbnails = $thumbnails_parent;
}
// TITLES
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title']))
{
$title = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title']))
{
$title = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
else
{
$title = $title_parent;
}
$this->data['enclosures'][] = $this->registry->create('Enclosure', array($url, $type, $length, null, $bitrate, $captions, $categories, $channels, $copyrights, $credits, $description, $duration, $expression, $framerate, $hashes, $height, $keywords, $lang, $medium, $player, $ratings, $restrictions, $samplingrate, $thumbnails, $title, $width));
}
}
}
}
// If we have standalone media:content tags, loop through them.
if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content']))
{
foreach ((array) $this->data['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'] as $content)
{
if (isset($content['attribs']['']['url']) || isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
{
// Attributes
$bitrate = null;
$channels = null;
$duration = null;
$expression = null;
$framerate = null;
$height = null;
$javascript = null;
$lang = null;
$length = null;
$medium = null;
$samplingrate = null;
$type = null;
$url = null;
$width = null;
// Elements
$captions = null;
$categories = null;
$copyrights = null;
$credits = null;
$description = null;
$hashes = null;
$keywords = null;
$player = null;
$ratings = null;
$restrictions = null;
$thumbnails = null;
$title = null;
// Start checking the attributes of media:content
if (isset($content['attribs']['']['bitrate']))
{
$bitrate = $this->sanitize($content['attribs']['']['bitrate'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($content['attribs']['']['channels']))
{
$channels = $this->sanitize($content['attribs']['']['channels'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($content['attribs']['']['duration']))
{
$duration = $this->sanitize($content['attribs']['']['duration'], SIMPLEPIE_CONSTRUCT_TEXT);
}
else
{
$duration = $duration_parent;
}
if (isset($content['attribs']['']['expression']))
{
$expression = $this->sanitize($content['attribs']['']['expression'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($content['attribs']['']['framerate']))
{
$framerate = $this->sanitize($content['attribs']['']['framerate'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($content['attribs']['']['height']))
{
$height = $this->sanitize($content['attribs']['']['height'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($content['attribs']['']['lang']))
{
$lang = $this->sanitize($content['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($content['attribs']['']['fileSize']))
{
$length = ceil($content['attribs']['']['fileSize']);
}
if (isset($content['attribs']['']['medium']))
{
$medium = $this->sanitize($content['attribs']['']['medium'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($content['attribs']['']['samplingrate']))
{
$samplingrate = $this->sanitize($content['attribs']['']['samplingrate'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($content['attribs']['']['type']))
{
$type = $this->sanitize($content['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($content['attribs']['']['width']))
{
$width = $this->sanitize($content['attribs']['']['width'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($content['attribs']['']['url']))
{
$url = $this->sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
}
// Checking the other optional media: elements. Priority: media:content, media:group, item, channel
// CAPTIONS
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text']))
{
foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption)
{
$caption_type = null;
$caption_lang = null;
$caption_startTime = null;
$caption_endTime = null;
$caption_text = null;
if (isset($caption['attribs']['']['type']))
{
$caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($caption['attribs']['']['lang']))
{
$caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($caption['attribs']['']['start']))
{
$caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($caption['attribs']['']['end']))
{
$caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($caption['data']))
{
$caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
$captions[] = $this->registry->create('Caption', array($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text));
}
if (is_array($captions))
{
$captions = array_values(array_unique($captions));
}
}
else
{
$captions = $captions_parent;
}
// CATEGORIES
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category']))
{
foreach ((array) $content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category)
{
$term = null;
$scheme = null;
$label = null;
if (isset($category['data']))
{
$term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($category['attribs']['']['scheme']))
{
$scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
}
else
{
$scheme = 'http://search.yahoo.com/mrss/category_schema';
}
if (isset($category['attribs']['']['label']))
{
$label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
}
$categories[] = $this->registry->create('Category', array($term, $scheme, $label));
}
}
if (is_array($categories) && is_array($categories_parent))
{
$categories = array_values(array_unique(array_merge($categories, $categories_parent)));
}
elseif (is_array($categories))
{
$categories = array_values(array_unique($categories));
}
elseif (is_array($categories_parent))
{
$categories = array_values(array_unique($categories_parent));
}
else
{
$categories = null;
}
// COPYRIGHTS
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright']))
{
$copyright_url = null;
$copyright_label = null;
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url']))
{
$copyright_url = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data']))
{
$copyright_label = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
$copyrights = $this->registry->create('Copyright', array($copyright_url, $copyright_label));
}
else
{
$copyrights = $copyrights_parent;
}
// CREDITS
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit']))
{
foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit)
{
$credit_role = null;
$credit_scheme = null;
$credit_name = null;
if (isset($credit['attribs']['']['role']))
{
$credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($credit['attribs']['']['scheme']))
{
$credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
}
else
{
$credit_scheme = 'urn:ebu';
}
if (isset($credit['data']))
{
$credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
$credits[] = $this->registry->create('Credit', array($credit_role, $credit_scheme, $credit_name));
}
if (is_array($credits))
{
$credits = array_values(array_unique($credits));
}
}
else
{
$credits = $credits_parent;
}
// DESCRIPTION
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description']))
{
$description = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
else
{
$description = $description_parent;
}
// HASHES
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash']))
{
foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash)
{
$value = null;
$algo = null;
if (isset($hash['data']))
{
$value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($hash['attribs']['']['algo']))
{
$algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
}
else
{
$algo = 'md5';
}
$hashes[] = $algo.':'.$value;
}
if (is_array($hashes))
{
$hashes = array_values(array_unique($hashes));
}
}
else
{
$hashes = $hashes_parent;
}
// KEYWORDS
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords']))
{
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data']))
{
$temp = explode(',', $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
foreach ($temp as $word)
{
$keywords[] = trim($word);
}
unset($temp);
}
if (is_array($keywords))
{
$keywords = array_values(array_unique($keywords));
}
}
else
{
$keywords = $keywords_parent;
}
// PLAYER
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
{
$player = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
}
else
{
$player = $player_parent;
}
// RATINGS
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating']))
{
foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating)
{
$rating_scheme = null;
$rating_value = null;
if (isset($rating['attribs']['']['scheme']))
{
$rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
}
else
{
$rating_scheme = 'urn:simple';
}
if (isset($rating['data']))
{
$rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
$ratings[] = $this->registry->create('Rating', array($rating_scheme, $rating_value));
}
if (is_array($ratings))
{
$ratings = array_values(array_unique($ratings));
}
}
else
{
$ratings = $ratings_parent;
}
// RESTRICTIONS
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction']))
{
foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction)
{
$restriction_relationship = null;
$restriction_type = null;
$restriction_value = null;
if (isset($restriction['attribs']['']['relationship']))
{
$restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($restriction['attribs']['']['type']))
{
$restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($restriction['data']))
{
$restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
$restrictions[] = $this->registry->create('Restriction', array($restriction_relationship, $restriction_type, $restriction_value));
}
if (is_array($restrictions))
{
$restrictions = array_values(array_unique($restrictions));
}
}
else
{
$restrictions = $restrictions_parent;
}
// THUMBNAILS
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail']))
{
foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail)
{
$thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
}
if (is_array($thumbnails))
{
$thumbnails = array_values(array_unique($thumbnails));
}
}
else
{
$thumbnails = $thumbnails_parent;
}
// TITLES
if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title']))
{
$title = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
else
{
$title = $title_parent;
}
$this->data['enclosures'][] = $this->registry->create('Enclosure', array($url, $type, $length, null, $bitrate, $captions, $categories, $channels, $copyrights, $credits, $description, $duration, $expression, $framerate, $hashes, $height, $keywords, $lang, $medium, $player, $ratings, $restrictions, $samplingrate, $thumbnails, $title, $width));
}
}
}
foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link') as $link)
{
if (isset($link['attribs']['']['href']) && !empty($link['attribs']['']['rel']) && $link['attribs']['']['rel'] === 'enclosure')
{
// Attributes
$bitrate = null;
$channels = null;
$duration = null;
$expression = null;
$framerate = null;
$height = null;
$javascript = null;
$lang = null;
$length = null;
$medium = null;
$samplingrate = null;
$type = null;
$url = null;
$width = null;
$url = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link));
if (isset($link['attribs']['']['type']))
{
$type = $this->sanitize($link['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($link['attribs']['']['length']))
{
$length = ceil($link['attribs']['']['length']);
}
// Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor
$this->data['enclosures'][] = $this->registry->create('Enclosure', array($url, $type, $length, null, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width));
}
}
foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link') as $link)
{
if (isset($link['attribs']['']['href']) && !empty($link['attribs']['']['rel']) && $link['attribs']['']['rel'] === 'enclosure')
{
// Attributes
$bitrate = null;
$channels = null;
$duration = null;
$expression = null;
$framerate = null;
$height = null;
$javascript = null;
$lang = null;
$length = null;
$medium = null;
$samplingrate = null;
$type = null;
$url = null;
$width = null;
$url = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link));
if (isset($link['attribs']['']['type']))
{
$type = $this->sanitize($link['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($link['attribs']['']['length']))
{
$length = ceil($link['attribs']['']['length']);
}
// Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor
$this->data['enclosures'][] = $this->registry->create('Enclosure', array($url, $type, $length, null, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width));
}
}
if ($enclosure = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'enclosure'))
{
if (isset($enclosure[0]['attribs']['']['url']))
{
// Attributes
$bitrate = null;
$channels = null;
$duration = null;
$expression = null;
$framerate = null;
$height = null;
$javascript = null;
$lang = null;
$length = null;
$medium = null;
$samplingrate = null;
$type = null;
$url = null;
$width = null;
$url = $this->sanitize($enclosure[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($enclosure[0]));
if (isset($enclosure[0]['attribs']['']['type']))
{
$type = $this->sanitize($enclosure[0]['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
}
if (isset($enclosure[0]['attribs']['']['length']))
{
$length = ceil($enclosure[0]['attribs']['']['length']);
}
// Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor
$this->data['enclosures'][] = $this->registry->create('Enclosure', array($url, $type, $length, null, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width));
}
}
if (sizeof($this->data['enclosures']) === 0 && ($url || $type || $length || $bitrate || $captions_parent || $categories_parent || $channels || $copyrights_parent || $credits_parent || $description_parent || $duration_parent || $expression || $framerate || $hashes_parent || $height || $keywords_parent || $lang || $medium || $player_parent || $ratings_parent || $restrictions_parent || $samplingrate || $thumbnails_parent || $title_parent || $width))
{
// Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor
$this->data['enclosures'][] = $this->registry->create('Enclosure', array($url, $type, $length, null, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width));
}
$this->data['enclosures'] = array_values(array_unique($this->data['enclosures']));
}
if (!empty($this->data['enclosures']))
{
return $this->data['enclosures'];
}
else
{
return null;
}
}
/**
* Get the latitude coordinates for the item
*
* Compatible with the W3C WGS84 Basic Geo and GeoRSS specifications
*
* Uses `<geo:lat>` or `<georss:point>`
*
* @since 1.0
* @link http://www.w3.org/2003/01/geo/ W3C WGS84 Basic Geo
* @link http://www.georss.org/ GeoRSS
* @return string|null
*/
public function get_latitude()
{
if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat'))
{
return (float) $return[0]['data'];
}
elseif (($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match))
{
return (float) $match[1];
}
else
{
return null;
}
}
/**
* Get the longitude coordinates for the item
*
* Compatible with the W3C WGS84 Basic Geo and GeoRSS specifications
*
* Uses `<geo:long>`, `<geo:lon>` or `<georss:point>`
*
* @since 1.0
* @link http://www.w3.org/2003/01/geo/ W3C WGS84 Basic Geo
* @link http://www.georss.org/ GeoRSS
* @return string|null
*/
public function get_longitude()
{
if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'long'))
{
return (float) $return[0]['data'];
}
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lon'))
{
return (float) $return[0]['data'];
}
elseif (($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match))
{
return (float) $match[2];
}
else
{
return null;
}
}
/**
* Get the `<atom:source>` for the item
*
* @since 1.1
* @return SimplePie_Source|null
*/
public function get_source()
{
if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'source'))
{
return $this->registry->create('Source', array($this, $return[0]));
}
else
{
return null;
}
}
}
| 01-wordpress-paypal | trunk/wp-includes/SimplePie/Item.php | PHP | gpl3 | 98,299 |
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @version 1.3.1
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman
* @author Geoffrey Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
/**
* Decode HTML Entities
*
* This implements HTML5 as of revision 967 (2007-06-28)
*
* @deprecated Use DOMDocument instead!
* @package SimplePie
*/
class SimplePie_Decode_HTML_Entities
{
/**
* Data to be parsed
*
* @access private
* @var string
*/
var $data = '';
/**
* Currently consumed bytes
*
* @access private
* @var string
*/
var $consumed = '';
/**
* Position of the current byte being parsed
*
* @access private
* @var int
*/
var $position = 0;
/**
* Create an instance of the class with the input data
*
* @access public
* @param string $data Input data
*/
public function __construct($data)
{
$this->data = $data;
}
/**
* Parse the input data
*
* @access public
* @return string Output data
*/
public function parse()
{
while (($this->position = strpos($this->data, '&', $this->position)) !== false)
{
$this->consume();
$this->entity();
$this->consumed = '';
}
return $this->data;
}
/**
* Consume the next byte
*
* @access private
* @return mixed The next byte, or false, if there is no more data
*/
public function consume()
{
if (isset($this->data[$this->position]))
{
$this->consumed .= $this->data[$this->position];
return $this->data[$this->position++];
}
else
{
return false;
}
}
/**
* Consume a range of characters
*
* @access private
* @param string $chars Characters to consume
* @return mixed A series of characters that match the range, or false
*/
public function consume_range($chars)
{
if ($len = strspn($this->data, $chars, $this->position))
{
$data = substr($this->data, $this->position, $len);
$this->consumed .= $data;
$this->position += $len;
return $data;
}
else
{
return false;
}
}
/**
* Unconsume one byte
*
* @access private
*/
public function unconsume()
{
$this->consumed = substr($this->consumed, 0, -1);
$this->position--;
}
/**
* Decode an entity
*
* @access private
*/
public function entity()
{
switch ($this->consume())
{
case "\x09":
case "\x0A":
case "\x0B":
case "\x0B":
case "\x0C":
case "\x20":
case "\x3C":
case "\x26":
case false:
break;
case "\x23":
switch ($this->consume())
{
case "\x78":
case "\x58":
$range = '0123456789ABCDEFabcdef';
$hex = true;
break;
default:
$range = '0123456789';
$hex = false;
$this->unconsume();
break;
}
if ($codepoint = $this->consume_range($range))
{
static $windows_1252_specials = array(0x0D => "\x0A", 0x80 => "\xE2\x82\xAC", 0x81 => "\xEF\xBF\xBD", 0x82 => "\xE2\x80\x9A", 0x83 => "\xC6\x92", 0x84 => "\xE2\x80\x9E", 0x85 => "\xE2\x80\xA6", 0x86 => "\xE2\x80\xA0", 0x87 => "\xE2\x80\xA1", 0x88 => "\xCB\x86", 0x89 => "\xE2\x80\xB0", 0x8A => "\xC5\xA0", 0x8B => "\xE2\x80\xB9", 0x8C => "\xC5\x92", 0x8D => "\xEF\xBF\xBD", 0x8E => "\xC5\xBD", 0x8F => "\xEF\xBF\xBD", 0x90 => "\xEF\xBF\xBD", 0x91 => "\xE2\x80\x98", 0x92 => "\xE2\x80\x99", 0x93 => "\xE2\x80\x9C", 0x94 => "\xE2\x80\x9D", 0x95 => "\xE2\x80\xA2", 0x96 => "\xE2\x80\x93", 0x97 => "\xE2\x80\x94", 0x98 => "\xCB\x9C", 0x99 => "\xE2\x84\xA2", 0x9A => "\xC5\xA1", 0x9B => "\xE2\x80\xBA", 0x9C => "\xC5\x93", 0x9D => "\xEF\xBF\xBD", 0x9E => "\xC5\xBE", 0x9F => "\xC5\xB8");
if ($hex)
{
$codepoint = hexdec($codepoint);
}
else
{
$codepoint = intval($codepoint);
}
if (isset($windows_1252_specials[$codepoint]))
{
$replacement = $windows_1252_specials[$codepoint];
}
else
{
$replacement = SimplePie_Misc::codepoint_to_utf8($codepoint);
}
if (!in_array($this->consume(), array(';', false), true))
{
$this->unconsume();
}
$consumed_length = strlen($this->consumed);
$this->data = substr_replace($this->data, $replacement, $this->position - $consumed_length, $consumed_length);
$this->position += strlen($replacement) - $consumed_length;
}
break;
default:
static $entities = array(
'Aacute' => "\xC3\x81",
'aacute' => "\xC3\xA1",
'Aacute;' => "\xC3\x81",
'aacute;' => "\xC3\xA1",
'Acirc' => "\xC3\x82",
'acirc' => "\xC3\xA2",
'Acirc;' => "\xC3\x82",
'acirc;' => "\xC3\xA2",
'acute' => "\xC2\xB4",
'acute;' => "\xC2\xB4",
'AElig' => "\xC3\x86",
'aelig' => "\xC3\xA6",
'AElig;' => "\xC3\x86",
'aelig;' => "\xC3\xA6",
'Agrave' => "\xC3\x80",
'agrave' => "\xC3\xA0",
'Agrave;' => "\xC3\x80",
'agrave;' => "\xC3\xA0",
'alefsym;' => "\xE2\x84\xB5",
'Alpha;' => "\xCE\x91",
'alpha;' => "\xCE\xB1",
'AMP' => "\x26",
'amp' => "\x26",
'AMP;' => "\x26",
'amp;' => "\x26",
'and;' => "\xE2\x88\xA7",
'ang;' => "\xE2\x88\xA0",
'apos;' => "\x27",
'Aring' => "\xC3\x85",
'aring' => "\xC3\xA5",
'Aring;' => "\xC3\x85",
'aring;' => "\xC3\xA5",
'asymp;' => "\xE2\x89\x88",
'Atilde' => "\xC3\x83",
'atilde' => "\xC3\xA3",
'Atilde;' => "\xC3\x83",
'atilde;' => "\xC3\xA3",
'Auml' => "\xC3\x84",
'auml' => "\xC3\xA4",
'Auml;' => "\xC3\x84",
'auml;' => "\xC3\xA4",
'bdquo;' => "\xE2\x80\x9E",
'Beta;' => "\xCE\x92",
'beta;' => "\xCE\xB2",
'brvbar' => "\xC2\xA6",
'brvbar;' => "\xC2\xA6",
'bull;' => "\xE2\x80\xA2",
'cap;' => "\xE2\x88\xA9",
'Ccedil' => "\xC3\x87",
'ccedil' => "\xC3\xA7",
'Ccedil;' => "\xC3\x87",
'ccedil;' => "\xC3\xA7",
'cedil' => "\xC2\xB8",
'cedil;' => "\xC2\xB8",
'cent' => "\xC2\xA2",
'cent;' => "\xC2\xA2",
'Chi;' => "\xCE\xA7",
'chi;' => "\xCF\x87",
'circ;' => "\xCB\x86",
'clubs;' => "\xE2\x99\xA3",
'cong;' => "\xE2\x89\x85",
'COPY' => "\xC2\xA9",
'copy' => "\xC2\xA9",
'COPY;' => "\xC2\xA9",
'copy;' => "\xC2\xA9",
'crarr;' => "\xE2\x86\xB5",
'cup;' => "\xE2\x88\xAA",
'curren' => "\xC2\xA4",
'curren;' => "\xC2\xA4",
'Dagger;' => "\xE2\x80\xA1",
'dagger;' => "\xE2\x80\xA0",
'dArr;' => "\xE2\x87\x93",
'darr;' => "\xE2\x86\x93",
'deg' => "\xC2\xB0",
'deg;' => "\xC2\xB0",
'Delta;' => "\xCE\x94",
'delta;' => "\xCE\xB4",
'diams;' => "\xE2\x99\xA6",
'divide' => "\xC3\xB7",
'divide;' => "\xC3\xB7",
'Eacute' => "\xC3\x89",
'eacute' => "\xC3\xA9",
'Eacute;' => "\xC3\x89",
'eacute;' => "\xC3\xA9",
'Ecirc' => "\xC3\x8A",
'ecirc' => "\xC3\xAA",
'Ecirc;' => "\xC3\x8A",
'ecirc;' => "\xC3\xAA",
'Egrave' => "\xC3\x88",
'egrave' => "\xC3\xA8",
'Egrave;' => "\xC3\x88",
'egrave;' => "\xC3\xA8",
'empty;' => "\xE2\x88\x85",
'emsp;' => "\xE2\x80\x83",
'ensp;' => "\xE2\x80\x82",
'Epsilon;' => "\xCE\x95",
'epsilon;' => "\xCE\xB5",
'equiv;' => "\xE2\x89\xA1",
'Eta;' => "\xCE\x97",
'eta;' => "\xCE\xB7",
'ETH' => "\xC3\x90",
'eth' => "\xC3\xB0",
'ETH;' => "\xC3\x90",
'eth;' => "\xC3\xB0",
'Euml' => "\xC3\x8B",
'euml' => "\xC3\xAB",
'Euml;' => "\xC3\x8B",
'euml;' => "\xC3\xAB",
'euro;' => "\xE2\x82\xAC",
'exist;' => "\xE2\x88\x83",
'fnof;' => "\xC6\x92",
'forall;' => "\xE2\x88\x80",
'frac12' => "\xC2\xBD",
'frac12;' => "\xC2\xBD",
'frac14' => "\xC2\xBC",
'frac14;' => "\xC2\xBC",
'frac34' => "\xC2\xBE",
'frac34;' => "\xC2\xBE",
'frasl;' => "\xE2\x81\x84",
'Gamma;' => "\xCE\x93",
'gamma;' => "\xCE\xB3",
'ge;' => "\xE2\x89\xA5",
'GT' => "\x3E",
'gt' => "\x3E",
'GT;' => "\x3E",
'gt;' => "\x3E",
'hArr;' => "\xE2\x87\x94",
'harr;' => "\xE2\x86\x94",
'hearts;' => "\xE2\x99\xA5",
'hellip;' => "\xE2\x80\xA6",
'Iacute' => "\xC3\x8D",
'iacute' => "\xC3\xAD",
'Iacute;' => "\xC3\x8D",
'iacute;' => "\xC3\xAD",
'Icirc' => "\xC3\x8E",
'icirc' => "\xC3\xAE",
'Icirc;' => "\xC3\x8E",
'icirc;' => "\xC3\xAE",
'iexcl' => "\xC2\xA1",
'iexcl;' => "\xC2\xA1",
'Igrave' => "\xC3\x8C",
'igrave' => "\xC3\xAC",
'Igrave;' => "\xC3\x8C",
'igrave;' => "\xC3\xAC",
'image;' => "\xE2\x84\x91",
'infin;' => "\xE2\x88\x9E",
'int;' => "\xE2\x88\xAB",
'Iota;' => "\xCE\x99",
'iota;' => "\xCE\xB9",
'iquest' => "\xC2\xBF",
'iquest;' => "\xC2\xBF",
'isin;' => "\xE2\x88\x88",
'Iuml' => "\xC3\x8F",
'iuml' => "\xC3\xAF",
'Iuml;' => "\xC3\x8F",
'iuml;' => "\xC3\xAF",
'Kappa;' => "\xCE\x9A",
'kappa;' => "\xCE\xBA",
'Lambda;' => "\xCE\x9B",
'lambda;' => "\xCE\xBB",
'lang;' => "\xE3\x80\x88",
'laquo' => "\xC2\xAB",
'laquo;' => "\xC2\xAB",
'lArr;' => "\xE2\x87\x90",
'larr;' => "\xE2\x86\x90",
'lceil;' => "\xE2\x8C\x88",
'ldquo;' => "\xE2\x80\x9C",
'le;' => "\xE2\x89\xA4",
'lfloor;' => "\xE2\x8C\x8A",
'lowast;' => "\xE2\x88\x97",
'loz;' => "\xE2\x97\x8A",
'lrm;' => "\xE2\x80\x8E",
'lsaquo;' => "\xE2\x80\xB9",
'lsquo;' => "\xE2\x80\x98",
'LT' => "\x3C",
'lt' => "\x3C",
'LT;' => "\x3C",
'lt;' => "\x3C",
'macr' => "\xC2\xAF",
'macr;' => "\xC2\xAF",
'mdash;' => "\xE2\x80\x94",
'micro' => "\xC2\xB5",
'micro;' => "\xC2\xB5",
'middot' => "\xC2\xB7",
'middot;' => "\xC2\xB7",
'minus;' => "\xE2\x88\x92",
'Mu;' => "\xCE\x9C",
'mu;' => "\xCE\xBC",
'nabla;' => "\xE2\x88\x87",
'nbsp' => "\xC2\xA0",
'nbsp;' => "\xC2\xA0",
'ndash;' => "\xE2\x80\x93",
'ne;' => "\xE2\x89\xA0",
'ni;' => "\xE2\x88\x8B",
'not' => "\xC2\xAC",
'not;' => "\xC2\xAC",
'notin;' => "\xE2\x88\x89",
'nsub;' => "\xE2\x8A\x84",
'Ntilde' => "\xC3\x91",
'ntilde' => "\xC3\xB1",
'Ntilde;' => "\xC3\x91",
'ntilde;' => "\xC3\xB1",
'Nu;' => "\xCE\x9D",
'nu;' => "\xCE\xBD",
'Oacute' => "\xC3\x93",
'oacute' => "\xC3\xB3",
'Oacute;' => "\xC3\x93",
'oacute;' => "\xC3\xB3",
'Ocirc' => "\xC3\x94",
'ocirc' => "\xC3\xB4",
'Ocirc;' => "\xC3\x94",
'ocirc;' => "\xC3\xB4",
'OElig;' => "\xC5\x92",
'oelig;' => "\xC5\x93",
'Ograve' => "\xC3\x92",
'ograve' => "\xC3\xB2",
'Ograve;' => "\xC3\x92",
'ograve;' => "\xC3\xB2",
'oline;' => "\xE2\x80\xBE",
'Omega;' => "\xCE\xA9",
'omega;' => "\xCF\x89",
'Omicron;' => "\xCE\x9F",
'omicron;' => "\xCE\xBF",
'oplus;' => "\xE2\x8A\x95",
'or;' => "\xE2\x88\xA8",
'ordf' => "\xC2\xAA",
'ordf;' => "\xC2\xAA",
'ordm' => "\xC2\xBA",
'ordm;' => "\xC2\xBA",
'Oslash' => "\xC3\x98",
'oslash' => "\xC3\xB8",
'Oslash;' => "\xC3\x98",
'oslash;' => "\xC3\xB8",
'Otilde' => "\xC3\x95",
'otilde' => "\xC3\xB5",
'Otilde;' => "\xC3\x95",
'otilde;' => "\xC3\xB5",
'otimes;' => "\xE2\x8A\x97",
'Ouml' => "\xC3\x96",
'ouml' => "\xC3\xB6",
'Ouml;' => "\xC3\x96",
'ouml;' => "\xC3\xB6",
'para' => "\xC2\xB6",
'para;' => "\xC2\xB6",
'part;' => "\xE2\x88\x82",
'permil;' => "\xE2\x80\xB0",
'perp;' => "\xE2\x8A\xA5",
'Phi;' => "\xCE\xA6",
'phi;' => "\xCF\x86",
'Pi;' => "\xCE\xA0",
'pi;' => "\xCF\x80",
'piv;' => "\xCF\x96",
'plusmn' => "\xC2\xB1",
'plusmn;' => "\xC2\xB1",
'pound' => "\xC2\xA3",
'pound;' => "\xC2\xA3",
'Prime;' => "\xE2\x80\xB3",
'prime;' => "\xE2\x80\xB2",
'prod;' => "\xE2\x88\x8F",
'prop;' => "\xE2\x88\x9D",
'Psi;' => "\xCE\xA8",
'psi;' => "\xCF\x88",
'QUOT' => "\x22",
'quot' => "\x22",
'QUOT;' => "\x22",
'quot;' => "\x22",
'radic;' => "\xE2\x88\x9A",
'rang;' => "\xE3\x80\x89",
'raquo' => "\xC2\xBB",
'raquo;' => "\xC2\xBB",
'rArr;' => "\xE2\x87\x92",
'rarr;' => "\xE2\x86\x92",
'rceil;' => "\xE2\x8C\x89",
'rdquo;' => "\xE2\x80\x9D",
'real;' => "\xE2\x84\x9C",
'REG' => "\xC2\xAE",
'reg' => "\xC2\xAE",
'REG;' => "\xC2\xAE",
'reg;' => "\xC2\xAE",
'rfloor;' => "\xE2\x8C\x8B",
'Rho;' => "\xCE\xA1",
'rho;' => "\xCF\x81",
'rlm;' => "\xE2\x80\x8F",
'rsaquo;' => "\xE2\x80\xBA",
'rsquo;' => "\xE2\x80\x99",
'sbquo;' => "\xE2\x80\x9A",
'Scaron;' => "\xC5\xA0",
'scaron;' => "\xC5\xA1",
'sdot;' => "\xE2\x8B\x85",
'sect' => "\xC2\xA7",
'sect;' => "\xC2\xA7",
'shy' => "\xC2\xAD",
'shy;' => "\xC2\xAD",
'Sigma;' => "\xCE\xA3",
'sigma;' => "\xCF\x83",
'sigmaf;' => "\xCF\x82",
'sim;' => "\xE2\x88\xBC",
'spades;' => "\xE2\x99\xA0",
'sub;' => "\xE2\x8A\x82",
'sube;' => "\xE2\x8A\x86",
'sum;' => "\xE2\x88\x91",
'sup;' => "\xE2\x8A\x83",
'sup1' => "\xC2\xB9",
'sup1;' => "\xC2\xB9",
'sup2' => "\xC2\xB2",
'sup2;' => "\xC2\xB2",
'sup3' => "\xC2\xB3",
'sup3;' => "\xC2\xB3",
'supe;' => "\xE2\x8A\x87",
'szlig' => "\xC3\x9F",
'szlig;' => "\xC3\x9F",
'Tau;' => "\xCE\xA4",
'tau;' => "\xCF\x84",
'there4;' => "\xE2\x88\xB4",
'Theta;' => "\xCE\x98",
'theta;' => "\xCE\xB8",
'thetasym;' => "\xCF\x91",
'thinsp;' => "\xE2\x80\x89",
'THORN' => "\xC3\x9E",
'thorn' => "\xC3\xBE",
'THORN;' => "\xC3\x9E",
'thorn;' => "\xC3\xBE",
'tilde;' => "\xCB\x9C",
'times' => "\xC3\x97",
'times;' => "\xC3\x97",
'TRADE;' => "\xE2\x84\xA2",
'trade;' => "\xE2\x84\xA2",
'Uacute' => "\xC3\x9A",
'uacute' => "\xC3\xBA",
'Uacute;' => "\xC3\x9A",
'uacute;' => "\xC3\xBA",
'uArr;' => "\xE2\x87\x91",
'uarr;' => "\xE2\x86\x91",
'Ucirc' => "\xC3\x9B",
'ucirc' => "\xC3\xBB",
'Ucirc;' => "\xC3\x9B",
'ucirc;' => "\xC3\xBB",
'Ugrave' => "\xC3\x99",
'ugrave' => "\xC3\xB9",
'Ugrave;' => "\xC3\x99",
'ugrave;' => "\xC3\xB9",
'uml' => "\xC2\xA8",
'uml;' => "\xC2\xA8",
'upsih;' => "\xCF\x92",
'Upsilon;' => "\xCE\xA5",
'upsilon;' => "\xCF\x85",
'Uuml' => "\xC3\x9C",
'uuml' => "\xC3\xBC",
'Uuml;' => "\xC3\x9C",
'uuml;' => "\xC3\xBC",
'weierp;' => "\xE2\x84\x98",
'Xi;' => "\xCE\x9E",
'xi;' => "\xCE\xBE",
'Yacute' => "\xC3\x9D",
'yacute' => "\xC3\xBD",
'Yacute;' => "\xC3\x9D",
'yacute;' => "\xC3\xBD",
'yen' => "\xC2\xA5",
'yen;' => "\xC2\xA5",
'yuml' => "\xC3\xBF",
'Yuml;' => "\xC5\xB8",
'yuml;' => "\xC3\xBF",
'Zeta;' => "\xCE\x96",
'zeta;' => "\xCE\xB6",
'zwj;' => "\xE2\x80\x8D",
'zwnj;' => "\xE2\x80\x8C"
);
for ($i = 0, $match = null; $i < 9 && $this->consume() !== false; $i++)
{
$consumed = substr($this->consumed, 1);
if (isset($entities[$consumed]))
{
$match = $consumed;
}
}
if ($match !== null)
{
$this->data = substr_replace($this->data, $entities[$match], $this->position - strlen($consumed) - 1, strlen($match) + 1);
$this->position += strlen($entities[$match]) - strlen($consumed) - 1;
}
break;
}
}
}
| 01-wordpress-paypal | trunk/wp-includes/SimplePie/Decode/HTML/Entities.php | PHP | gpl3 | 17,321 |
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @version 1.3.1
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman
* @author Geoffrey Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
/**
* Handles `<media:text>` captions as defined in Media RSS.
*
* Used by {@see SimplePie_Enclosure::get_caption()} and {@see SimplePie_Enclosure::get_captions()}
*
* This class can be overloaded with {@see SimplePie::set_caption_class()}
*
* @package SimplePie
* @subpackage API
*/
class SimplePie_Caption
{
/**
* Content type
*
* @var string
* @see get_type()
*/
var $type;
/**
* Language
*
* @var string
* @see get_language()
*/
var $lang;
/**
* Start time
*
* @var string
* @see get_starttime()
*/
var $startTime;
/**
* End time
*
* @var string
* @see get_endtime()
*/
var $endTime;
/**
* Caption text
*
* @var string
* @see get_text()
*/
var $text;
/**
* Constructor, used to input the data
*
* For documentation on all the parameters, see the corresponding
* properties and their accessors
*/
public function __construct($type = null, $lang = null, $startTime = null, $endTime = null, $text = null)
{
$this->type = $type;
$this->lang = $lang;
$this->startTime = $startTime;
$this->endTime = $endTime;
$this->text = $text;
}
/**
* String-ified version
*
* @return string
*/
public function __toString()
{
// There is no $this->data here
return md5(serialize($this));
}
/**
* Get the end time
*
* @return string|null Time in the format 'hh:mm:ss.SSS'
*/
public function get_endtime()
{
if ($this->endTime !== null)
{
return $this->endTime;
}
else
{
return null;
}
}
/**
* Get the language
*
* @link http://tools.ietf.org/html/rfc3066
* @return string|null Language code as per RFC 3066
*/
public function get_language()
{
if ($this->lang !== null)
{
return $this->lang;
}
else
{
return null;
}
}
/**
* Get the start time
*
* @return string|null Time in the format 'hh:mm:ss.SSS'
*/
public function get_starttime()
{
if ($this->startTime !== null)
{
return $this->startTime;
}
else
{
return null;
}
}
/**
* Get the text of the caption
*
* @return string|null
*/
public function get_text()
{
if ($this->text !== null)
{
return $this->text;
}
else
{
return null;
}
}
/**
* Get the content type (not MIME type)
*
* @return string|null Either 'text' or 'html'
*/
public function get_type()
{
if ($this->type !== null)
{
return $this->type;
}
else
{
return null;
}
}
}
| 01-wordpress-paypal | trunk/wp-includes/SimplePie/Caption.php | PHP | gpl3 | 4,510 |
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @version 1.3.1
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman
* @author Geoffrey Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
/**
* Handles creating objects and calling methods
*
* Access this via {@see SimplePie::get_registry()}
*
* @package SimplePie
*/
class SimplePie_Registry
{
/**
* Default class mapping
*
* Overriding classes *must* subclass these.
*
* @var array
*/
protected $default = array(
'Cache' => 'SimplePie_Cache',
'Locator' => 'SimplePie_Locator',
'Parser' => 'SimplePie_Parser',
'File' => 'SimplePie_File',
'Sanitize' => 'SimplePie_Sanitize',
'Item' => 'SimplePie_Item',
'Author' => 'SimplePie_Author',
'Category' => 'SimplePie_Category',
'Enclosure' => 'SimplePie_Enclosure',
'Caption' => 'SimplePie_Caption',
'Copyright' => 'SimplePie_Copyright',
'Credit' => 'SimplePie_Credit',
'Rating' => 'SimplePie_Rating',
'Restriction' => 'SimplePie_Restriction',
'Content_Type_Sniffer' => 'SimplePie_Content_Type_Sniffer',
'Source' => 'SimplePie_Source',
'Misc' => 'SimplePie_Misc',
'XML_Declaration_Parser' => 'SimplePie_XML_Declaration_Parser',
'Parse_Date' => 'SimplePie_Parse_Date',
);
/**
* Class mapping
*
* @see register()
* @var array
*/
protected $classes = array();
/**
* Legacy classes
*
* @see register()
* @var array
*/
protected $legacy = array();
/**
* Constructor
*
* No-op
*/
public function __construct() { }
/**
* Register a class
*
* @param string $type See {@see $default} for names
* @param string $class Class name, must subclass the corresponding default
* @param bool $legacy Whether to enable legacy support for this class
* @return bool Successfulness
*/
public function register($type, $class, $legacy = false)
{
if (!is_subclass_of($class, $this->default[$type]))
{
return false;
}
$this->classes[$type] = $class;
if ($legacy)
{
$this->legacy[] = $class;
}
return true;
}
/**
* Get the class registered for a type
*
* Where possible, use {@see create()} or {@see call()} instead
*
* @param string $type
* @return string|null
*/
public function get_class($type)
{
if (!empty($this->classes[$type]))
{
return $this->classes[$type];
}
if (!empty($this->default[$type]))
{
return $this->default[$type];
}
return null;
}
/**
* Create a new instance of a given type
*
* @param string $type
* @param array $parameters Parameters to pass to the constructor
* @return object Instance of class
*/
public function &create($type, $parameters = array())
{
$class = $this->get_class($type);
if (in_array($class, $this->legacy))
{
switch ($type)
{
case 'locator':
// Legacy: file, timeout, useragent, file_class, max_checked_feeds, content_type_sniffer_class
// Specified: file, timeout, useragent, max_checked_feeds
$replacement = array($this->get_class('file'), $parameters[3], $this->get_class('content_type_sniffer'));
array_splice($parameters, 3, 1, $replacement);
break;
}
}
if (!method_exists($class, '__construct'))
{
$instance = new $class;
}
else
{
$reflector = new ReflectionClass($class);
$instance = $reflector->newInstanceArgs($parameters);
}
if (method_exists($instance, 'set_registry'))
{
$instance->set_registry($this);
}
return $instance;
}
/**
* Call a static method for a type
*
* @param string $type
* @param string $method
* @param array $parameters
* @return mixed
*/
public function &call($type, $method, $parameters = array())
{
$class = $this->get_class($type);
if (in_array($class, $this->legacy))
{
switch ($type)
{
case 'Cache':
// For backwards compatibility with old non-static
// Cache::create() methods
if ($method === 'get_handler')
{
$result = @call_user_func_array(array($class, 'create'), $parameters);
return $result;
}
break;
}
}
$result = call_user_func_array(array($class, $method), $parameters);
return $result;
}
} | 01-wordpress-paypal | trunk/wp-includes/SimplePie/Registry.php | PHP | gpl3 | 5,991 |
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @version 1.3.1
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman
* @author Geoffrey Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
/**
* Used for feed auto-discovery
*
*
* This class can be overloaded with {@see SimplePie::set_locator_class()}
*
* @package SimplePie
*/
class SimplePie_Locator
{
var $useragent;
var $timeout;
var $file;
var $local = array();
var $elsewhere = array();
var $cached_entities = array();
var $http_base;
var $base;
var $base_location = 0;
var $checked_feeds = 0;
var $max_checked_feeds = 10;
protected $registry;
public function __construct(SimplePie_File $file, $timeout = 10, $useragent = null, $max_checked_feeds = 10)
{
$this->file = $file;
$this->useragent = $useragent;
$this->timeout = $timeout;
$this->max_checked_feeds = $max_checked_feeds;
if (class_exists('DOMDocument'))
{
$this->dom = new DOMDocument();
set_error_handler(array('SimplePie_Misc', 'silence_errors'));
$this->dom->loadHTML($this->file->body);
restore_error_handler();
}
else
{
$this->dom = null;
}
}
public function set_registry(SimplePie_Registry $registry)
{
$this->registry = $registry;
}
public function find($type = SIMPLEPIE_LOCATOR_ALL, &$working)
{
if ($this->is_feed($this->file))
{
return $this->file;
}
if ($this->file->method & SIMPLEPIE_FILE_SOURCE_REMOTE)
{
$sniffer = $this->registry->create('Content_Type_Sniffer', array($this->file));
if ($sniffer->get_type() !== 'text/html')
{
return null;
}
}
if ($type & ~SIMPLEPIE_LOCATOR_NONE)
{
$this->get_base();
}
if ($type & SIMPLEPIE_LOCATOR_AUTODISCOVERY && $working = $this->autodiscovery())
{
return $working[0];
}
if ($type & (SIMPLEPIE_LOCATOR_LOCAL_EXTENSION | SIMPLEPIE_LOCATOR_LOCAL_BODY | SIMPLEPIE_LOCATOR_REMOTE_EXTENSION | SIMPLEPIE_LOCATOR_REMOTE_BODY) && $this->get_links())
{
if ($type & SIMPLEPIE_LOCATOR_LOCAL_EXTENSION && $working = $this->extension($this->local))
{
return $working;
}
if ($type & SIMPLEPIE_LOCATOR_LOCAL_BODY && $working = $this->body($this->local))
{
return $working;
}
if ($type & SIMPLEPIE_LOCATOR_REMOTE_EXTENSION && $working = $this->extension($this->elsewhere))
{
return $working;
}
if ($type & SIMPLEPIE_LOCATOR_REMOTE_BODY && $working = $this->body($this->elsewhere))
{
return $working;
}
}
return null;
}
public function is_feed($file)
{
if ($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE)
{
$sniffer = $this->registry->create('Content_Type_Sniffer', array($file));
$sniffed = $sniffer->get_type();
if (in_array($sniffed, array('application/rss+xml', 'application/rdf+xml', 'text/rdf', 'application/atom+xml', 'text/xml', 'application/xml')))
{
return true;
}
else
{
return false;
}
}
elseif ($file->method & SIMPLEPIE_FILE_SOURCE_LOCAL)
{
return true;
}
else
{
return false;
}
}
public function get_base()
{
if ($this->dom === null)
{
throw new SimplePie_Exception('DOMDocument not found, unable to use locator');
}
$this->http_base = $this->file->url;
$this->base = $this->http_base;
$elements = $this->dom->getElementsByTagName('base');
foreach ($elements as $element)
{
if ($element->hasAttribute('href'))
{
$base = $this->registry->call('Misc', 'absolutize_url', array(trim($element->getAttribute('href')), $this->http_base));
if ($base === false)
{
continue;
}
$this->base = $base;
$this->base_location = method_exists($element, 'getLineNo') ? $element->getLineNo() : 0;
break;
}
}
}
public function autodiscovery()
{
$done = array();
$feeds = array();
$feeds = array_merge($feeds, $this->search_elements_by_tag('link', $done, $feeds));
$feeds = array_merge($feeds, $this->search_elements_by_tag('a', $done, $feeds));
$feeds = array_merge($feeds, $this->search_elements_by_tag('area', $done, $feeds));
if (!empty($feeds))
{
return array_values($feeds);
}
else
{
return null;
}
}
protected function search_elements_by_tag($name, &$done, $feeds)
{
if ($this->dom === null)
{
throw new SimplePie_Exception('DOMDocument not found, unable to use locator');
}
$links = $this->dom->getElementsByTagName($name);
foreach ($links as $link)
{
if ($this->checked_feeds === $this->max_checked_feeds)
{
break;
}
if ($link->hasAttribute('href') && $link->hasAttribute('rel'))
{
$rel = array_unique($this->registry->call('Misc', 'space_seperated_tokens', array(strtolower($link->getAttribute('rel')))));
$line = method_exists($link, 'getLineNo') ? $link->getLineNo() : 1;
if ($this->base_location < $line)
{
$href = $this->registry->call('Misc', 'absolutize_url', array(trim($link->getAttribute('href')), $this->base));
}
else
{
$href = $this->registry->call('Misc', 'absolutize_url', array(trim($link->getAttribute('href')), $this->http_base));
}
if ($href === false)
{
continue;
}
if (!in_array($href, $done) && in_array('feed', $rel) || (in_array('alternate', $rel) && !in_array('stylesheet', $rel) && $link->hasAttribute('type') && in_array(strtolower($this->registry->call('Misc', 'parse_mime', array($link->getAttribute('type')))), array('application/rss+xml', 'application/atom+xml'))) && !isset($feeds[$href]))
{
$this->checked_feeds++;
$headers = array(
'Accept' => 'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1',
);
$feed = $this->registry->create('File', array($href, $this->timeout, 5, $headers, $this->useragent));
if ($feed->success && ($feed->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($feed->status_code === 200 || $feed->status_code > 206 && $feed->status_code < 300)) && $this->is_feed($feed))
{
$feeds[$href] = $feed;
}
}
$done[] = $href;
}
}
return $feeds;
}
public function get_links()
{
if ($this->dom === null)
{
throw new SimplePie_Exception('DOMDocument not found, unable to use locator');
}
$links = $this->dom->getElementsByTagName('a');
foreach ($links as $link)
{
if ($link->hasAttribute('href'))
{
$href = trim($link->getAttribute('href'));
$parsed = $this->registry->call('Misc', 'parse_url', array($href));
if ($parsed['scheme'] === '' || preg_match('/^(http(s)|feed)?$/i', $parsed['scheme']))
{
if (method_exists($link, 'getLineNo') && $this->base_location < $link->getLineNo())
{
$href = $this->registry->call('Misc', 'absolutize_url', array(trim($link->getAttribute('href')), $this->base));
}
else
{
$href = $this->registry->call('Misc', 'absolutize_url', array(trim($link->getAttribute('href')), $this->http_base));
}
if ($href === false)
{
continue;
}
$current = $this->registry->call('Misc', 'parse_url', array($this->file->url));
if ($parsed['authority'] === '' || $parsed['authority'] === $current['authority'])
{
$this->local[] = $href;
}
else
{
$this->elsewhere[] = $href;
}
}
}
}
$this->local = array_unique($this->local);
$this->elsewhere = array_unique($this->elsewhere);
if (!empty($this->local) || !empty($this->elsewhere))
{
return true;
}
return null;
}
public function extension(&$array)
{
foreach ($array as $key => $value)
{
if ($this->checked_feeds === $this->max_checked_feeds)
{
break;
}
if (in_array(strtolower(strrchr($value, '.')), array('.rss', '.rdf', '.atom', '.xml')))
{
$this->checked_feeds++;
$headers = array(
'Accept' => 'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1',
);
$feed = $this->registry->create('File', array($value, $this->timeout, 5, $headers, $this->useragent));
if ($feed->success && ($feed->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($feed->status_code === 200 || $feed->status_code > 206 && $feed->status_code < 300)) && $this->is_feed($feed))
{
return $feed;
}
else
{
unset($array[$key]);
}
}
}
return null;
}
public function body(&$array)
{
foreach ($array as $key => $value)
{
if ($this->checked_feeds === $this->max_checked_feeds)
{
break;
}
if (preg_match('/(rss|rdf|atom|xml)/i', $value))
{
$this->checked_feeds++;
$headers = array(
'Accept' => 'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1',
);
$feed = $this->registry->create('File', array($value, $this->timeout, 5, null, $this->useragent));
if ($feed->success && ($feed->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($feed->status_code === 200 || $feed->status_code > 206 && $feed->status_code < 300)) && $this->is_feed($feed))
{
return $feed;
}
else
{
unset($array[$key]);
}
}
}
return null;
}
}
| 01-wordpress-paypal | trunk/wp-includes/SimplePie/Locator.php | PHP | gpl3 | 11,185 |
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @version 1.3.1
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman
* @author Geoffrey Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
/**
* Manages all category-related data
*
* Used by {@see SimplePie_Item::get_category()} and {@see SimplePie_Item::get_categories()}
*
* This class can be overloaded with {@see SimplePie::set_category_class()}
*
* @package SimplePie
* @subpackage API
*/
class SimplePie_Category
{
/**
* Category identifier
*
* @var string
* @see get_term
*/
var $term;
/**
* Categorization scheme identifier
*
* @var string
* @see get_scheme()
*/
var $scheme;
/**
* Human readable label
*
* @var string
* @see get_label()
*/
var $label;
/**
* Constructor, used to input the data
*
* @param string $term
* @param string $scheme
* @param string $label
*/
public function __construct($term = null, $scheme = null, $label = null)
{
$this->term = $term;
$this->scheme = $scheme;
$this->label = $label;
}
/**
* String-ified version
*
* @return string
*/
public function __toString()
{
// There is no $this->data here
return md5(serialize($this));
}
/**
* Get the category identifier
*
* @return string|null
*/
public function get_term()
{
if ($this->term !== null)
{
return $this->term;
}
else
{
return null;
}
}
/**
* Get the categorization scheme identifier
*
* @return string|null
*/
public function get_scheme()
{
if ($this->scheme !== null)
{
return $this->scheme;
}
else
{
return null;
}
}
/**
* Get the human readable label
*
* @return string|null
*/
public function get_label()
{
if ($this->label !== null)
{
return $this->label;
}
else
{
return $this->get_term();
}
}
}
| 01-wordpress-paypal | trunk/wp-includes/SimplePie/Category.php | PHP | gpl3 | 3,707 |
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @version 1.3.1
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman
* @author Geoffrey Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
/**
* Decode 'gzip' encoded HTTP data
*
* @package SimplePie
* @subpackage HTTP
* @link http://www.gzip.org/format.txt
*/
class SimplePie_gzdecode
{
/**
* Compressed data
*
* @access private
* @var string
* @see gzdecode::$data
*/
var $compressed_data;
/**
* Size of compressed data
*
* @access private
* @var int
*/
var $compressed_size;
/**
* Minimum size of a valid gzip string
*
* @access private
* @var int
*/
var $min_compressed_size = 18;
/**
* Current position of pointer
*
* @access private
* @var int
*/
var $position = 0;
/**
* Flags (FLG)
*
* @access private
* @var int
*/
var $flags;
/**
* Uncompressed data
*
* @access public
* @see gzdecode::$compressed_data
* @var string
*/
var $data;
/**
* Modified time
*
* @access public
* @var int
*/
var $MTIME;
/**
* Extra Flags
*
* @access public
* @var int
*/
var $XFL;
/**
* Operating System
*
* @access public
* @var int
*/
var $OS;
/**
* Subfield ID 1
*
* @access public
* @see gzdecode::$extra_field
* @see gzdecode::$SI2
* @var string
*/
var $SI1;
/**
* Subfield ID 2
*
* @access public
* @see gzdecode::$extra_field
* @see gzdecode::$SI1
* @var string
*/
var $SI2;
/**
* Extra field content
*
* @access public
* @see gzdecode::$SI1
* @see gzdecode::$SI2
* @var string
*/
var $extra_field;
/**
* Original filename
*
* @access public
* @var string
*/
var $filename;
/**
* Human readable comment
*
* @access public
* @var string
*/
var $comment;
/**
* Don't allow anything to be set
*
* @param string $name
* @param mixed $value
*/
public function __set($name, $value)
{
trigger_error("Cannot write property $name", E_USER_ERROR);
}
/**
* Set the compressed string and related properties
*
* @param string $data
*/
public function __construct($data)
{
$this->compressed_data = $data;
$this->compressed_size = strlen($data);
}
/**
* Decode the GZIP stream
*
* @return bool Successfulness
*/
public function parse()
{
if ($this->compressed_size >= $this->min_compressed_size)
{
// Check ID1, ID2, and CM
if (substr($this->compressed_data, 0, 3) !== "\x1F\x8B\x08")
{
return false;
}
// Get the FLG (FLaGs)
$this->flags = ord($this->compressed_data[3]);
// FLG bits above (1 << 4) are reserved
if ($this->flags > 0x1F)
{
return false;
}
// Advance the pointer after the above
$this->position += 4;
// MTIME
$mtime = substr($this->compressed_data, $this->position, 4);
// Reverse the string if we're on a big-endian arch because l is the only signed long and is machine endianness
if (current(unpack('S', "\x00\x01")) === 1)
{
$mtime = strrev($mtime);
}
$this->MTIME = current(unpack('l', $mtime));
$this->position += 4;
// Get the XFL (eXtra FLags)
$this->XFL = ord($this->compressed_data[$this->position++]);
// Get the OS (Operating System)
$this->OS = ord($this->compressed_data[$this->position++]);
// Parse the FEXTRA
if ($this->flags & 4)
{
// Read subfield IDs
$this->SI1 = $this->compressed_data[$this->position++];
$this->SI2 = $this->compressed_data[$this->position++];
// SI2 set to zero is reserved for future use
if ($this->SI2 === "\x00")
{
return false;
}
// Get the length of the extra field
$len = current(unpack('v', substr($this->compressed_data, $this->position, 2)));
$this->position += 2;
// Check the length of the string is still valid
$this->min_compressed_size += $len + 4;
if ($this->compressed_size >= $this->min_compressed_size)
{
// Set the extra field to the given data
$this->extra_field = substr($this->compressed_data, $this->position, $len);
$this->position += $len;
}
else
{
return false;
}
}
// Parse the FNAME
if ($this->flags & 8)
{
// Get the length of the filename
$len = strcspn($this->compressed_data, "\x00", $this->position);
// Check the length of the string is still valid
$this->min_compressed_size += $len + 1;
if ($this->compressed_size >= $this->min_compressed_size)
{
// Set the original filename to the given string
$this->filename = substr($this->compressed_data, $this->position, $len);
$this->position += $len + 1;
}
else
{
return false;
}
}
// Parse the FCOMMENT
if ($this->flags & 16)
{
// Get the length of the comment
$len = strcspn($this->compressed_data, "\x00", $this->position);
// Check the length of the string is still valid
$this->min_compressed_size += $len + 1;
if ($this->compressed_size >= $this->min_compressed_size)
{
// Set the original comment to the given string
$this->comment = substr($this->compressed_data, $this->position, $len);
$this->position += $len + 1;
}
else
{
return false;
}
}
// Parse the FHCRC
if ($this->flags & 2)
{
// Check the length of the string is still valid
$this->min_compressed_size += $len + 2;
if ($this->compressed_size >= $this->min_compressed_size)
{
// Read the CRC
$crc = current(unpack('v', substr($this->compressed_data, $this->position, 2)));
// Check the CRC matches
if ((crc32(substr($this->compressed_data, 0, $this->position)) & 0xFFFF) === $crc)
{
$this->position += 2;
}
else
{
return false;
}
}
else
{
return false;
}
}
// Decompress the actual data
if (($this->data = gzinflate(substr($this->compressed_data, $this->position, -8))) === false)
{
return false;
}
else
{
$this->position = $this->compressed_size - 8;
}
// Check CRC of data
$crc = current(unpack('V', substr($this->compressed_data, $this->position, 4)));
$this->position += 4;
/*if (extension_loaded('hash') && sprintf('%u', current(unpack('V', hash('crc32b', $this->data)))) !== sprintf('%u', $crc))
{
return false;
}*/
// Check ISIZE of data
$isize = current(unpack('V', substr($this->compressed_data, $this->position, 4)));
$this->position += 4;
if (sprintf('%u', strlen($this->data) & 0xFFFFFFFF) !== sprintf('%u', $isize))
{
return false;
}
// Wow, against all odds, we've actually got a valid gzip string
return true;
}
else
{
return false;
}
}
}
| 01-wordpress-paypal | trunk/wp-includes/SimplePie/gzdecode.php | PHP | gpl3 | 8,572 |
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @version 1.3.1
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman
* @author Geoffrey Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
/**
* Handles `<media:restriction>` as defined in Media RSS
*
* Used by {@see SimplePie_Enclosure::get_restriction()} and {@see SimplePie_Enclosure::get_restrictions()}
*
* This class can be overloaded with {@see SimplePie::set_restriction_class()}
*
* @package SimplePie
* @subpackage API
*/
class SimplePie_Restriction
{
/**
* Relationship ('allow'/'deny')
*
* @var string
* @see get_relationship()
*/
var $relationship;
/**
* Type of restriction
*
* @var string
* @see get_type()
*/
var $type;
/**
* Restricted values
*
* @var string
* @see get_value()
*/
var $value;
/**
* Constructor, used to input the data
*
* For documentation on all the parameters, see the corresponding
* properties and their accessors
*/
public function __construct($relationship = null, $type = null, $value = null)
{
$this->relationship = $relationship;
$this->type = $type;
$this->value = $value;
}
/**
* String-ified version
*
* @return string
*/
public function __toString()
{
// There is no $this->data here
return md5(serialize($this));
}
/**
* Get the relationship
*
* @return string|null Either 'allow' or 'deny'
*/
public function get_relationship()
{
if ($this->relationship !== null)
{
return $this->relationship;
}
else
{
return null;
}
}
/**
* Get the type
*
* @return string|null
*/
public function get_type()
{
if ($this->type !== null)
{
return $this->type;
}
else
{
return null;
}
}
/**
* Get the list of restricted things
*
* @return string|null
*/
public function get_value()
{
if ($this->value !== null)
{
return $this->value;
}
else
{
return null;
}
}
}
| 01-wordpress-paypal | trunk/wp-includes/SimplePie/Restriction.php | PHP | gpl3 | 3,800 |