Compare commits
79 Commits
2.5-branch
...
2.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f1345e0d1c | ||
|
|
ab32166864 | ||
|
|
81a13c27f5 | ||
|
|
dc5e0fe929 | ||
|
|
f45b44194e | ||
|
|
e9a0c47a63 | ||
|
|
edeb3e0868 | ||
|
|
79e3d24c60 | ||
|
|
fa3e76d676 | ||
|
|
a885d5be4f | ||
|
|
99346e897a | ||
|
|
bdbafbe8a9 | ||
|
|
3eaa92b8c5 | ||
|
|
182c409c58 | ||
|
|
c3fc60a2ee | ||
|
|
9532679648 | ||
|
|
65ffc78548 | ||
|
|
76ad2cc5e6 | ||
|
|
ec0efa21b5 | ||
|
|
cc6a998e20 | ||
|
|
c22a4ed9f1 | ||
|
|
1f0a61fd73 | ||
|
|
2795b2e9d2 | ||
|
|
b1a9963671 | ||
|
|
cfb41a5ad1 | ||
|
|
0e212e9a85 | ||
|
|
765fc389ce | ||
|
|
72045b52b8 | ||
|
|
a78ebdcccb | ||
|
|
ef3400be6e | ||
|
|
061bad455b | ||
|
|
68866e9571 | ||
|
|
2240947c82 | ||
|
|
c973ad1d0e | ||
|
|
8382333b7f | ||
|
|
f2e57bf305 | ||
|
|
2e7433967d | ||
|
|
e0c548de57 | ||
|
|
dd3e81b07c | ||
|
|
d7a6781cc6 | ||
|
|
aa19ffe126 | ||
|
|
6f2a4b74a9 | ||
|
|
6ecf459918 | ||
|
|
5a547001ee | ||
|
|
e2e4ea32da | ||
|
|
5964d5f48a | ||
|
|
b7cfc5c173 | ||
|
|
276c2f7b94 | ||
|
|
67bd2acaf9 | ||
|
|
a4c00744ff | ||
|
|
41a9ec3b9a | ||
|
|
73d48439f8 | ||
|
|
041af31c32 | ||
|
|
407b07f2a7 | ||
|
|
77fb8f7ac6 | ||
|
|
0003f83892 | ||
|
|
79bfe4e9d0 | ||
|
|
4143d41188 | ||
|
|
5a58316eb0 | ||
|
|
4bbdc94490 | ||
|
|
f59d101bd8 | ||
|
|
e3748ee830 | ||
|
|
800477a81b | ||
|
|
e159d212e8 | ||
|
|
6cbf98b1b7 | ||
|
|
a822a3cf5c | ||
|
|
13dd0b74e7 | ||
|
|
11675fb3fc | ||
|
|
9fadff8d4b | ||
|
|
15d3bf89ce | ||
|
|
6298c5b93c | ||
|
|
8bffc54b84 | ||
|
|
bb55b9ecc0 | ||
|
|
bac405380f | ||
|
|
fb198a068a | ||
|
|
e1127ba7ba | ||
|
|
c6684fd4aa | ||
|
|
a9b5bc0f13 | ||
|
|
bcbe992d05 |
@@ -8,7 +8,7 @@
|
||||
<body>
|
||||
<h1 id="logo" style="text-align: center">
|
||||
<img alt="WordPress" src="wp-admin/images/wordpress-logo.png" />
|
||||
<br /> Version 2.1
|
||||
<br /> Version 2.2
|
||||
</h1>
|
||||
<p style="text-align: center">Semantic Personal Publishing Platform</p>
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
<h1>Upgrading</h1>
|
||||
<p>Before you upgrade anything, make sure you have backup copies of any files you may have modified such as <code>index.php</code>.</p>
|
||||
<h2>Upgrading from any previous WordPress to 2.1:</h2>
|
||||
<h2>Upgrading from any previous WordPress to 2.2:</h2>
|
||||
<ol>
|
||||
<li>Delete your old WP files, saving ones you've modified.</li>
|
||||
<li>Upload the new files.</li>
|
||||
|
||||
@@ -121,18 +121,11 @@ function wp_insert_category($catarr) {
|
||||
else
|
||||
$links_private = 0;
|
||||
|
||||
if ( empty($type) )
|
||||
$type = TAXONOMY_CATEGORY;
|
||||
|
||||
// Let's check if we have this category already, if so just do an update
|
||||
if ( !$update && $cat_ID = category_object_exists( $category_nicename ) )
|
||||
$update = true;
|
||||
|
||||
if (!$update) {
|
||||
$wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_description, category_parent, links_private, posts_private, type) VALUES ('0', '$cat_name', '$category_nicename', '$category_description', '$category_parent', '$links_private', '$posts_private', '$type')");
|
||||
$wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_description, category_parent, links_private, posts_private) VALUES ('0', '$cat_name', '$category_nicename', '$category_description', '$category_parent', '$links_private', '$posts_private')");
|
||||
$cat_ID = (int) $wpdb->insert_id;
|
||||
} else {
|
||||
$wpdb->query ("UPDATE $wpdb->categories SET cat_name = '$cat_name', category_nicename = '$category_nicename', category_description = '$category_description', category_parent = '$category_parent', links_private = '$links_private', posts_private = '$posts_private', type = '$type' WHERE cat_ID = '$cat_ID'");
|
||||
$wpdb->query ("UPDATE $wpdb->categories SET cat_name = '$cat_name', category_nicename = '$category_nicename', category_description = '$category_description', category_parent = '$category_parent', links_private = '$links_private', posts_private = '$posts_private' WHERE cat_ID = '$cat_ID'");
|
||||
}
|
||||
|
||||
if ( $category_nicename == '' ) {
|
||||
@@ -198,18 +191,15 @@ function wp_delete_category($cat_ID) {
|
||||
|
||||
$parent = $category->category_parent;
|
||||
|
||||
// Delete the category if it is not also a tag.
|
||||
if ( 0 == ($category->type & TAXONOMY_TAG) ) {
|
||||
if ( !$wpdb->query("DELETE FROM $wpdb->categories WHERE cat_ID = '$cat_ID'") )
|
||||
return 0;
|
||||
} else {
|
||||
$wpdb->query("UPDATE $wpdb->categories SET type = type & ~" . TAXONOMY_CATEGORY . " WHERE cat_ID = '$cat_ID'");
|
||||
}
|
||||
// Delete the category
|
||||
if ( !$wpdb->query("DELETE FROM $wpdb->categories WHERE cat_ID = '$cat_ID'") )
|
||||
return 0;
|
||||
|
||||
// Update children to point to new parent
|
||||
$wpdb->query("UPDATE $wpdb->categories SET category_parent = '$parent' WHERE category_parent = '$cat_ID'");
|
||||
|
||||
// Only set posts and links to the default category if they're not in another category already
|
||||
$posts = $wpdb->get_col("SELECT post_id FROM $wpdb->post2cat WHERE category_id='$cat_ID' AND rel_type = 'category'");
|
||||
$posts = $wpdb->get_col("SELECT post_id FROM $wpdb->post2cat WHERE category_id='$cat_ID'");
|
||||
foreach ( (array) $posts as $post_id ) {
|
||||
$cats = wp_get_post_categories($post_id);
|
||||
if ( 1 == count($cats) )
|
||||
@@ -235,18 +225,8 @@ function wp_delete_category($cat_ID) {
|
||||
}
|
||||
|
||||
function wp_create_category($cat_name) {
|
||||
if ( $id = category_exists($cat_name) )
|
||||
return $id;
|
||||
$cat_array = array('cat_name' => $cat_name, 'type' => TAXONOMY_CATEGORY);
|
||||
|
||||
if ( $id = category_object_exists($cat_name) ) {
|
||||
$category = get_category($id);
|
||||
$cat_array['type'] = $category->type | $cat_array['type'];
|
||||
$cat_array['cat_ID'] = $id;
|
||||
return wp_update_category($cat_array);
|
||||
} else {
|
||||
return wp_insert_category($cat_array);
|
||||
}
|
||||
$cat_array = compact('cat_name');
|
||||
return wp_insert_category($cat_array);
|
||||
}
|
||||
|
||||
function wp_create_categories($categories, $post_id = '') {
|
||||
@@ -265,44 +245,12 @@ function wp_create_categories($categories, $post_id = '') {
|
||||
return $cat_ids;
|
||||
}
|
||||
|
||||
function category_object_exists($cat_name) {
|
||||
global $wpdb;
|
||||
if (!$category_nicename = sanitize_title($cat_name))
|
||||
return 0;
|
||||
|
||||
return (int) $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE category_nicename = '$category_nicename'");
|
||||
}
|
||||
|
||||
function category_exists($cat_name) {
|
||||
global $wpdb;
|
||||
if (!$category_nicename = sanitize_title($cat_name))
|
||||
return 0;
|
||||
|
||||
return (int) $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE category_nicename = '$category_nicename' AND ( type & " . TAXONOMY_CATEGORY . " != 0 )");
|
||||
}
|
||||
|
||||
function tag_exists($tag_name) {
|
||||
global $wpdb;
|
||||
if (! $tag_nicename = sanitize_title($tag_name))
|
||||
return 0;
|
||||
|
||||
return (int) $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE category_nicename = '$tag_nicename' AND ( type & " . TAXONOMY_TAG . " != 0 )");
|
||||
}
|
||||
|
||||
function wp_create_tag($tag_name) {
|
||||
if ( $id = tag_exists($tag_name) )
|
||||
return $id;
|
||||
$tag_array = array('cat_name' => $tag_name, 'type' => TAXONOMY_TAG);
|
||||
|
||||
if ( $id = category_object_exists($tag_name) ) {
|
||||
$category = get_category($id);
|
||||
$tag_array['type'] = $category->type | $tag_array['type'];
|
||||
$tag_array['cat_ID'] = $id;
|
||||
$id = wp_update_category($tag_array);
|
||||
return $id;
|
||||
} else {
|
||||
return wp_insert_category($tag_array);
|
||||
}
|
||||
return (int) $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE category_nicename = '$category_nicename'");
|
||||
}
|
||||
|
||||
function wp_delete_user($id, $reassign = 'novalue') {
|
||||
|
||||
@@ -647,7 +647,7 @@ function checked( $checked, $current) {
|
||||
|
||||
function return_categories_list( $parent = 0 ) {
|
||||
global $wpdb;
|
||||
return $wpdb->get_col( "SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent AND ( type & " . TAXONOMY_CATEGORY . " != 0 ) AND ( link_count = 0 OR category_count != 0 ) ORDER BY category_count DESC" );
|
||||
return $wpdb->get_col( "SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent AND ( link_count = 0 OR category_count != 0 OR ( link_count = 0 AND category_count = 0 ) ) ORDER BY category_count DESC" );
|
||||
}
|
||||
|
||||
function sort_cats( $cat1, $cat2 ) {
|
||||
@@ -657,29 +657,6 @@ function sort_cats( $cat1, $cat2 ) {
|
||||
return strcasecmp( $cat1['cat_name'], $cat2['cat_name'] );
|
||||
}
|
||||
|
||||
function get_tags_to_edit( $post_id ) {
|
||||
global $wpdb;
|
||||
|
||||
$post_id = (int) $post_id;
|
||||
if ( !$post_id )
|
||||
return false;
|
||||
|
||||
$tags = $wpdb->get_results( "
|
||||
SELECT category_id, cat_name
|
||||
FROM $wpdb->categories, $wpdb->post2cat
|
||||
WHERE $wpdb->post2cat.category_id = cat_ID AND $wpdb->post2cat.post_id = '$post_id' AND rel_type = 'tag'
|
||||
" );
|
||||
if ( !$tags )
|
||||
return false;
|
||||
|
||||
foreach ( $tags as $tag )
|
||||
$tag_names[] = $tag->cat_name;
|
||||
$tags_to_edit = join( ', ', $tag_names );
|
||||
$tags_to_edit = attribute_escape( $tags_to_edit );
|
||||
$tags_to_edit = apply_filters( 'tags_to_edit', $tags_to_edit );
|
||||
return $tags_to_edit;
|
||||
}
|
||||
|
||||
function get_nested_categories( $default = 0, $parent = 0 ) {
|
||||
global $post_ID, $link_id, $mode, $wpdb;
|
||||
|
||||
@@ -687,7 +664,7 @@ function get_nested_categories( $default = 0, $parent = 0 ) {
|
||||
$checked_categories = $wpdb->get_col( "
|
||||
SELECT category_id
|
||||
FROM $wpdb->categories, $wpdb->post2cat
|
||||
WHERE $wpdb->post2cat.category_id = cat_ID AND $wpdb->post2cat.post_id = '$post_ID' AND rel_type = 'category'
|
||||
WHERE $wpdb->post2cat.category_id = cat_ID AND $wpdb->post2cat.post_id = '$post_ID'
|
||||
" );
|
||||
|
||||
if ( count( $checked_categories ) == 0 ) {
|
||||
@@ -744,7 +721,7 @@ function dropdown_categories( $default = 0 ) {
|
||||
|
||||
function return_link_categories_list( $parent = 0 ) {
|
||||
global $wpdb;
|
||||
return $wpdb->get_col( "SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent AND ( type & " . TAXONOMY_CATEGORY . " != 0 ) AND ( category_count = 0 OR link_count != 0 ) ORDER BY link_count DESC" );
|
||||
return $wpdb->get_col( "SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent AND ( category_count = 0 OR link_count != 0 OR ( link_count = 0 AND category_count = 0 ) ) ORDER BY link_count DESC" );
|
||||
}
|
||||
|
||||
function get_nested_link_categories( $default = 0, $parent = 0 ) {
|
||||
@@ -2025,6 +2002,7 @@ function wp_import_upload_form( $action ) {
|
||||
?>
|
||||
<form enctype="multipart/form-data" id="import-upload-form" method="post" action="<?php echo attribute_escape($action) ?>">
|
||||
<p>
|
||||
<?php wp_nonce_field('import-upload'); ?>
|
||||
<label for="upload"><?php _e( 'Choose a file from your computer:' ); ?></label> (<?php printf( __('Maximum size: %s' ), $size ); ?> )
|
||||
<input type="file" id="upload" name="import" size="25" />
|
||||
<input type="hidden" name="action" value="save" />
|
||||
|
||||
@@ -118,15 +118,6 @@ cat_rows();
|
||||
</div>
|
||||
|
||||
<?php include('edit-category-form.php'); ?>
|
||||
|
||||
<div class="wrap">
|
||||
<h3><?php _e('Importers & Converters'); ?></h3>
|
||||
|
||||
<ul>
|
||||
<li><a href="admin.php?import=wp-cat2tag"><?php _e('Selectively convert categories to tags'); ?></a></li>
|
||||
<li><a href="admin.php?import=utw"><?php _e('Import Ultimate Tag Warrior tags'); ?></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php
|
||||
|
||||
@@ -1,323 +1,332 @@
|
||||
<?php
|
||||
|
||||
class Custom_Image_Header {
|
||||
var $admin_header_callback;
|
||||
|
||||
function Custom_Image_Header($admin_header_callback) {
|
||||
$this->admin_header_callback = $admin_header_callback;
|
||||
}
|
||||
|
||||
function init() {
|
||||
$page = add_theme_page(__('Custom Image Header'), __('Custom Image Header'), 'edit_themes', 'custom-header', array(&$this, 'admin_page'));
|
||||
|
||||
add_action("admin_print_scripts-$page", array(&$this, 'js_includes'));
|
||||
add_action("admin_head-$page", array(&$this, 'js'), 50);
|
||||
add_action("admin_head-$page", $this->admin_header_callback, 51);
|
||||
}
|
||||
|
||||
function js_includes() {
|
||||
wp_enqueue_script('cropper');
|
||||
wp_enqueue_script('colorpicker');
|
||||
}
|
||||
|
||||
function js() {
|
||||
|
||||
if ( isset( $_POST['textcolor'] ) ) {
|
||||
if ( 'blank' == $_POST['textcolor'] ) {
|
||||
set_theme_mod('header_textcolor', 'blank');
|
||||
} else {
|
||||
$color = preg_replace('/[^0-9a-fA-F]/', '', $_POST['textcolor']);
|
||||
if ( strlen($color) == 6 || strlen($color) == 3 )
|
||||
set_theme_mod('header_textcolor', $color);
|
||||
}
|
||||
}
|
||||
if ( isset($_POST['resetheader']) )
|
||||
remove_theme_mods();
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
|
||||
function onEndCrop( coords, dimensions ) {
|
||||
$( 'x1' ).value = coords.x1;
|
||||
$( 'y1' ).value = coords.y1;
|
||||
$( 'x2' ).value = coords.x2;
|
||||
$( 'y2' ).value = coords.y2;
|
||||
$( 'width' ).value = dimensions.width;
|
||||
$( 'height' ).value = dimensions.height;
|
||||
}
|
||||
|
||||
// with a supplied ratio
|
||||
Event.observe(
|
||||
window,
|
||||
'load',
|
||||
function() {
|
||||
var xinit = <?php echo HEADER_IMAGE_WIDTH; ?>;
|
||||
var yinit = <?php echo HEADER_IMAGE_HEIGHT; ?>;
|
||||
var ratio = xinit / yinit;
|
||||
var ximg = $('upload').width;
|
||||
var yimg = $('upload').height;
|
||||
if ( yimg < yinit || ximg < xinit ) {
|
||||
if ( ximg / yimg > ratio ) {
|
||||
yinit = yimg;
|
||||
xinit = yinit * ratio;
|
||||
} else {
|
||||
xinit = ximg;
|
||||
yinit = xinit / ratio;
|
||||
}
|
||||
}
|
||||
new Cropper.Img(
|
||||
'upload',
|
||||
{
|
||||
ratioDim: { x: xinit, y: yinit },
|
||||
displayOnInit: true,
|
||||
onEndCrop: onEndCrop
|
||||
}
|
||||
)
|
||||
}
|
||||
);
|
||||
|
||||
var cp = new ColorPicker();
|
||||
|
||||
function pickColor(color) {
|
||||
$('name').style.color = color;
|
||||
$('desc').style.color = color;
|
||||
$('textcolor').value = color;
|
||||
}
|
||||
function PopupWindow_hidePopup(magicword) {
|
||||
if ( magicword != 'prettyplease' )
|
||||
return false;
|
||||
if (this.divName != null) {
|
||||
if (this.use_gebi) {
|
||||
document.getElementById(this.divName).style.visibility = "hidden";
|
||||
}
|
||||
else if (this.use_css) {
|
||||
document.all[this.divName].style.visibility = "hidden";
|
||||
}
|
||||
else if (this.use_layers) {
|
||||
document.layers[this.divName].visibility = "hidden";
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (this.popupWindow && !this.popupWindow.closed) {
|
||||
this.popupWindow.close();
|
||||
this.popupWindow = null;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function colorSelect(t,p) {
|
||||
if ( cp.p == p && document.getElementById(cp.divName).style.visibility != "hidden" ) {
|
||||
cp.hidePopup('prettyplease');
|
||||
} else {
|
||||
cp.p = p;
|
||||
cp.select(t,p);
|
||||
}
|
||||
}
|
||||
function colorDefault() {
|
||||
pickColor('<?php echo HEADER_TEXTCOLOR; ?>');
|
||||
}
|
||||
|
||||
function hide_text() {
|
||||
$('name').style.display = 'none';
|
||||
$('desc').style.display = 'none';
|
||||
$('pickcolor').style.display = 'none';
|
||||
$('defaultcolor').style.display = 'none';
|
||||
$('textcolor').value = 'blank';
|
||||
$('hidetext').value = '<?php _e('Show Text'); ?>';
|
||||
// $('hidetext').onclick = 'show_text()';
|
||||
Event.observe( $('hidetext'), 'click', show_text );
|
||||
}
|
||||
|
||||
function show_text() {
|
||||
$('name').style.display = 'block';
|
||||
$('desc').style.display = 'block';
|
||||
$('pickcolor').style.display = 'inline';
|
||||
$('defaultcolor').style.display = 'inline';
|
||||
$('textcolor').value = '<?php echo HEADER_TEXTCOLOR; ?>';
|
||||
$('hidetext').value = '<?php _e('Hide Text'); ?>';
|
||||
Event.stopObserving( $('hidetext'), 'click', show_text );
|
||||
Event.observe( $('hidetext'), 'click', hide_text );
|
||||
}
|
||||
|
||||
<?php if ( 'blank' == get_theme_mod('header_textcolor', HEADER_TEXTCOLOR) ) { ?>
|
||||
Event.observe( window, 'load', hide_text );
|
||||
<?php } ?>
|
||||
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
function step_1() {
|
||||
if ( $_GET['updated'] ) { ?>
|
||||
<div id="message" class="updated fade">
|
||||
<p><?php _e('Header updated.') ?></p>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<div class="wrap">
|
||||
<h2><?php _e('Your Header Image'); ?></h2>
|
||||
<p><?php _e('This is your header image. You can change the text color or upload and crop a new image.'); ?></p>
|
||||
|
||||
<div id="headimg" style="background: url(<?php header_image() ?>) no-repeat;">
|
||||
<h1><a onclick="return false;" href="<?php bloginfo('url'); ?>" title="<?php bloginfo('name'); ?>" id="name"><?php bloginfo('name'); ?></a></h1>
|
||||
<div id="desc"><?php bloginfo('description');?></div>
|
||||
</div>
|
||||
<?php if ( !defined( 'NO_HEADER_TEXT' ) ) { ?>
|
||||
<form method="post" action="<?php echo get_option('siteurl') ?>/wp-admin/themes.php?page=custom-header&updated=true">
|
||||
<input type="button" value="<?php _e('Hide Text'); ?>" onclick="hide_text()" id="hidetext" />
|
||||
<input type="button" value="<?php _e('Select a Text Color'); ?>" onclick="colorSelect($('textcolor'), 'pickcolor')" id="pickcolor" /><input type="button" value="<?php _e('Use Original Color'); ?>" onclick="colorDefault()" id="defaultcolor" />
|
||||
<input type="hidden" name="textcolor" id="textcolor" value="#<?php header_textcolor() ?>" /><input name="submit" type="submit" value="<?php _e('Save Changes'); ?> »" /></form>
|
||||
<?php } ?>
|
||||
|
||||
<div id="colorPickerDiv" style="z-index: 100;background:#eee;border:1px solid #ccc;position:absolute;visibility:hidden;"> </div>
|
||||
</div>
|
||||
<div class="wrap">
|
||||
<h2><?php _e('Upload New Header Image'); ?></h2><p><?php _e('Here you can upload a custom header image to be shown at the top of your blog instead of the default one. On the next screen you will be able to crop the image.'); ?></p>
|
||||
<p><?php printf(__('Images of exactly <strong>%1$d x %2$d pixels</strong> will be used as-is.'), HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT); ?></p>
|
||||
|
||||
<form enctype="multipart/form-data" id="uploadForm" method="POST" action="<?php echo attribute_escape(add_query_arg('step', 2)) ?>" style="margin: auto; width: 50%;">
|
||||
<label for="upload"><?php _e('Choose an image from your computer:'); ?></label><br /><input type="file" id="upload" name="import" />
|
||||
<input type="hidden" name="action" value="save" />
|
||||
<p class="submit">
|
||||
<input type="submit" value="<?php _e('Upload'); ?> »" />
|
||||
</p>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
<?php if ( get_theme_mod('header_image') || get_theme_mod('header_textcolor') ) : ?>
|
||||
<div class="wrap">
|
||||
<h2><?php _e('Reset Header Image and Color'); ?></h2>
|
||||
<p><?php _e('This will restore the original header image and color. You will not be able to retrieve any customizations.') ?></p>
|
||||
<form method="post" action="<?php echo attribute_escape(add_query_arg('step', 1)) ?>">
|
||||
<input type="submit" name="resetheader" value="<?php _e('Restore Original Header'); ?>" />
|
||||
</form>
|
||||
</div>
|
||||
<?php endif;
|
||||
|
||||
}
|
||||
|
||||
function step_2() {
|
||||
$overrides = array('test_form' => false);
|
||||
$file = wp_handle_upload($_FILES['import'], $overrides);
|
||||
|
||||
if ( isset($file['error']) )
|
||||
die( $file['error'] );
|
||||
|
||||
$url = $file['url'];
|
||||
$file = $file['file'];
|
||||
$filename = basename($file);
|
||||
|
||||
// Construct the object array
|
||||
$object = array(
|
||||
'post_title' => $filename,
|
||||
'post_content' => $url,
|
||||
'post_mime_type' => 'import',
|
||||
'guid' => $url);
|
||||
|
||||
// Save the data
|
||||
$id = wp_insert_attachment($object, $file);
|
||||
|
||||
$upload = array('file' => $file, 'id' => $id);
|
||||
|
||||
list($width, $height, $type, $attr) = getimagesize( $file );
|
||||
|
||||
if ( $width == HEADER_IMAGE_WIDTH && $height == HEADER_IMAGE_HEIGHT ) {
|
||||
set_theme_mod('header_image', $url);
|
||||
$header = apply_filters('wp_create_file_in_uploads', $file, $id); // For replication
|
||||
return $this->finished();
|
||||
} elseif ( $width > HEADER_IMAGE_WIDTH ) {
|
||||
$oitar = $width / HEADER_IMAGE_WIDTH;
|
||||
$image = wp_crop_image($file, 0, 0, $width, $height, HEADER_IMAGE_WIDTH, $height / $oitar, false, str_replace(basename($file), 'midsize-'.basename($file), $file));
|
||||
$image = apply_filters('wp_create_file_in_uploads', $image, $id); // For replication
|
||||
|
||||
$url = str_replace(basename($url), basename($image), $url);
|
||||
$width = $width / $oitar;
|
||||
$height = $height / $oitar;
|
||||
} else {
|
||||
$oitar = 1;
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="wrap">
|
||||
|
||||
<form method="POST" action="<?php echo attribute_escape(add_query_arg('step', 3)) ?>">
|
||||
|
||||
<p><?php _e('Choose the part of the image you want to use as your header.'); ?></p>
|
||||
<div id="testWrap">
|
||||
<img src="<?php echo $url; ?>" id="upload" width="<?php echo $width; ?>" height="<?php echo $height; ?>" />
|
||||
</div>
|
||||
|
||||
<p class="submit">
|
||||
<input type="hidden" name="x1" id="x1" />
|
||||
<input type="hidden" name="y1" id="y1" />
|
||||
<input type="hidden" name="x2" id="x2" />
|
||||
<input type="hidden" name="y2" id="y2" />
|
||||
<input type="hidden" name="width" id="width" />
|
||||
<input type="hidden" name="height" id="height" />
|
||||
<input type="hidden" name="attachment_id" id="attachment_id" value="<?php echo $id; ?>" />
|
||||
<input type="hidden" name="oitar" id="oitar" value="<?php echo $oitar; ?>" />
|
||||
<input type="submit" value="<?php _e('Crop Header »'); ?>" />
|
||||
</p>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
function step_3() {
|
||||
if ( $_POST['oitar'] > 1 ) {
|
||||
$_POST['x1'] = $_POST['x1'] * $_POST['oitar'];
|
||||
$_POST['y1'] = $_POST['y1'] * $_POST['oitar'];
|
||||
$_POST['width'] = $_POST['width'] * $_POST['oitar'];
|
||||
$_POST['height'] = $_POST['height'] * $_POST['oitar'];
|
||||
}
|
||||
|
||||
$header = wp_crop_image($_POST['attachment_id'], $_POST['x1'], $_POST['y1'], $_POST['width'], $_POST['height'], HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT);
|
||||
$header = apply_filters('wp_create_file_in_uploads', $header); // For replication
|
||||
|
||||
$parent = get_post($_POST['attachment_id']);
|
||||
|
||||
$parent_url = $parent->guid;
|
||||
|
||||
$url = str_replace(basename($parent_url), basename($header), $parent_url);
|
||||
|
||||
set_theme_mod('header_image', $url);
|
||||
|
||||
// cleanup
|
||||
$file = get_attached_file( $_POST['attachment_id'] );
|
||||
$medium = str_replace(basename($file), 'midsize-'.basename($file), $file);
|
||||
@unlink( apply_filters( 'wp_delete_file', $medium ) );
|
||||
wp_delete_attachment( $_POST['attachment_id'] );
|
||||
|
||||
return $this->finished();
|
||||
}
|
||||
|
||||
function finished() {
|
||||
?>
|
||||
<div class="wrap">
|
||||
<h2><?php _e('Header complete!'); ?></h2>
|
||||
|
||||
<p><?php _e('Visit your site and you should see the new header now.'); ?></p>
|
||||
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
function admin_page() {
|
||||
if ( !isset( $_GET['step'] ) )
|
||||
$step = 1;
|
||||
else
|
||||
$step = (int) $_GET['step'];
|
||||
|
||||
if ( 1 == $step ) {
|
||||
$this->step_1();
|
||||
} elseif ( 2 == $step ) {
|
||||
$this->step_2();
|
||||
} elseif ( 3 == $step ) {
|
||||
$this->step_3();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
|
||||
class Custom_Image_Header {
|
||||
var $admin_header_callback;
|
||||
|
||||
function Custom_Image_Header($admin_header_callback) {
|
||||
$this->admin_header_callback = $admin_header_callback;
|
||||
}
|
||||
|
||||
function init() {
|
||||
$page = add_theme_page(__('Custom Image Header'), __('Custom Image Header'), 'edit_themes', 'custom-header', array(&$this, 'admin_page'));
|
||||
|
||||
add_action("admin_print_scripts-$page", array(&$this, 'js_includes'));
|
||||
add_action("admin_head-$page", array(&$this, 'js'), 50);
|
||||
add_action("admin_head-$page", $this->admin_header_callback, 51);
|
||||
}
|
||||
|
||||
function js_includes() {
|
||||
wp_enqueue_script('cropper');
|
||||
wp_enqueue_script('colorpicker');
|
||||
}
|
||||
|
||||
function js() {
|
||||
|
||||
if ( isset( $_POST['textcolor'] ) ) {
|
||||
check_admin_referer('custom-header');
|
||||
if ( 'blank' == $_POST['textcolor'] ) {
|
||||
set_theme_mod('header_textcolor', 'blank');
|
||||
} else {
|
||||
$color = preg_replace('/[^0-9a-fA-F]/', '', $_POST['textcolor']);
|
||||
if ( strlen($color) == 6 || strlen($color) == 3 )
|
||||
set_theme_mod('header_textcolor', $color);
|
||||
}
|
||||
}
|
||||
if ( isset($_POST['resetheader']) ) {
|
||||
check_admin_referer('custom-header');
|
||||
remove_theme_mods();
|
||||
}
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
|
||||
function onEndCrop( coords, dimensions ) {
|
||||
$( 'x1' ).value = coords.x1;
|
||||
$( 'y1' ).value = coords.y1;
|
||||
$( 'x2' ).value = coords.x2;
|
||||
$( 'y2' ).value = coords.y2;
|
||||
$( 'width' ).value = dimensions.width;
|
||||
$( 'height' ).value = dimensions.height;
|
||||
}
|
||||
|
||||
// with a supplied ratio
|
||||
Event.observe(
|
||||
window,
|
||||
'load',
|
||||
function() {
|
||||
var xinit = <?php echo HEADER_IMAGE_WIDTH; ?>;
|
||||
var yinit = <?php echo HEADER_IMAGE_HEIGHT; ?>;
|
||||
var ratio = xinit / yinit;
|
||||
var ximg = $('upload').width;
|
||||
var yimg = $('upload').height;
|
||||
if ( yimg < yinit || ximg < xinit ) {
|
||||
if ( ximg / yimg > ratio ) {
|
||||
yinit = yimg;
|
||||
xinit = yinit * ratio;
|
||||
} else {
|
||||
xinit = ximg;
|
||||
yinit = xinit / ratio;
|
||||
}
|
||||
}
|
||||
new Cropper.Img(
|
||||
'upload',
|
||||
{
|
||||
ratioDim: { x: xinit, y: yinit },
|
||||
displayOnInit: true,
|
||||
onEndCrop: onEndCrop
|
||||
}
|
||||
)
|
||||
}
|
||||
);
|
||||
|
||||
var cp = new ColorPicker();
|
||||
|
||||
function pickColor(color) {
|
||||
$('name').style.color = color;
|
||||
$('desc').style.color = color;
|
||||
$('textcolor').value = color;
|
||||
}
|
||||
function PopupWindow_hidePopup(magicword) {
|
||||
if ( magicword != 'prettyplease' )
|
||||
return false;
|
||||
if (this.divName != null) {
|
||||
if (this.use_gebi) {
|
||||
document.getElementById(this.divName).style.visibility = "hidden";
|
||||
}
|
||||
else if (this.use_css) {
|
||||
document.all[this.divName].style.visibility = "hidden";
|
||||
}
|
||||
else if (this.use_layers) {
|
||||
document.layers[this.divName].visibility = "hidden";
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (this.popupWindow && !this.popupWindow.closed) {
|
||||
this.popupWindow.close();
|
||||
this.popupWindow = null;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function colorSelect(t,p) {
|
||||
if ( cp.p == p && document.getElementById(cp.divName).style.visibility != "hidden" ) {
|
||||
cp.hidePopup('prettyplease');
|
||||
} else {
|
||||
cp.p = p;
|
||||
cp.select(t,p);
|
||||
}
|
||||
}
|
||||
function colorDefault() {
|
||||
pickColor('<?php echo HEADER_TEXTCOLOR; ?>');
|
||||
}
|
||||
|
||||
function hide_text() {
|
||||
$('name').style.display = 'none';
|
||||
$('desc').style.display = 'none';
|
||||
$('pickcolor').style.display = 'none';
|
||||
$('defaultcolor').style.display = 'none';
|
||||
$('textcolor').value = 'blank';
|
||||
$('hidetext').value = '<?php _e('Show Text'); ?>';
|
||||
// $('hidetext').onclick = 'show_text()';
|
||||
Event.observe( $('hidetext'), 'click', show_text );
|
||||
}
|
||||
|
||||
function show_text() {
|
||||
$('name').style.display = 'block';
|
||||
$('desc').style.display = 'block';
|
||||
$('pickcolor').style.display = 'inline';
|
||||
$('defaultcolor').style.display = 'inline';
|
||||
$('textcolor').value = '<?php echo HEADER_TEXTCOLOR; ?>';
|
||||
$('hidetext').value = '<?php _e('Hide Text'); ?>';
|
||||
Event.stopObserving( $('hidetext'), 'click', show_text );
|
||||
Event.observe( $('hidetext'), 'click', hide_text );
|
||||
}
|
||||
|
||||
<?php if ( 'blank' == get_theme_mod('header_textcolor', HEADER_TEXTCOLOR) ) { ?>
|
||||
Event.observe( window, 'load', hide_text );
|
||||
<?php } ?>
|
||||
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
function step_1() {
|
||||
if ( $_GET['updated'] ) { ?>
|
||||
<div id="message" class="updated fade">
|
||||
<p><?php _e('Header updated.') ?></p>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<div class="wrap">
|
||||
<h2><?php _e('Your Header Image'); ?></h2>
|
||||
<p><?php _e('This is your header image. You can change the text color or upload and crop a new image.'); ?></p>
|
||||
|
||||
<div id="headimg" style="background: url(<?php clean_url(header_image()) ?>) no-repeat;">
|
||||
<h1><a onclick="return false;" href="<?php bloginfo('url'); ?>" title="<?php bloginfo('name'); ?>" id="name"><?php bloginfo('name'); ?></a></h1>
|
||||
<div id="desc"><?php bloginfo('description');?></div>
|
||||
</div>
|
||||
<?php if ( !defined( 'NO_HEADER_TEXT' ) ) { ?>
|
||||
<form method="post" action="<?php echo get_option('siteurl') ?>/wp-admin/themes.php?page=custom-header&updated=true">
|
||||
<input type="button" value="<?php _e('Hide Text'); ?>" onclick="hide_text()" id="hidetext" />
|
||||
<input type="button" value="<?php _e('Select a Text Color'); ?>" onclick="colorSelect($('textcolor'), 'pickcolor')" id="pickcolor" /><input type="button" value="<?php _e('Use Original Color'); ?>" onclick="colorDefault()" id="defaultcolor" />
|
||||
<?php wp_nonce_field('custom-header') ?>
|
||||
<input type="hidden" name="textcolor" id="textcolor" value="#<?php attribute_escape(header_textcolor()) ?>" /><input name="submit" type="submit" value="<?php _e('Save Changes'); ?> »" /></form>
|
||||
<?php } ?>
|
||||
|
||||
<div id="colorPickerDiv" style="z-index: 100;background:#eee;border:1px solid #ccc;position:absolute;visibility:hidden;"> </div>
|
||||
</div>
|
||||
<div class="wrap">
|
||||
<h2><?php _e('Upload New Header Image'); ?></h2><p><?php _e('Here you can upload a custom header image to be shown at the top of your blog instead of the default one. On the next screen you will be able to crop the image.'); ?></p>
|
||||
<p><?php printf(__('Images of exactly <strong>%1$d x %2$d pixels</strong> will be used as-is.'), HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT); ?></p>
|
||||
|
||||
<form enctype="multipart/form-data" id="uploadForm" method="POST" action="<?php echo attribute_escape(add_query_arg('step', 2)) ?>" style="margin: auto; width: 50%;">
|
||||
<label for="upload"><?php _e('Choose an image from your computer:'); ?></label><br /><input type="file" id="upload" name="import" />
|
||||
<input type="hidden" name="action" value="save" />
|
||||
<?php wp_nonce_field('custom-header') ?>
|
||||
<p class="submit">
|
||||
<input type="submit" value="<?php _e('Upload'); ?> »" />
|
||||
</p>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
<?php if ( get_theme_mod('header_image') || get_theme_mod('header_textcolor') ) : ?>
|
||||
<div class="wrap">
|
||||
<h2><?php _e('Reset Header Image and Color'); ?></h2>
|
||||
<p><?php _e('This will restore the original header image and color. You will not be able to retrieve any customizations.') ?></p>
|
||||
<form method="post" action="<?php echo attribute_escape(add_query_arg('step', 1)) ?>">
|
||||
<?php wp_nonce_field('custom-header'); ?>
|
||||
<input type="submit" name="resetheader" value="<?php _e('Restore Original Header'); ?>" />
|
||||
</form>
|
||||
</div>
|
||||
<?php endif;
|
||||
|
||||
}
|
||||
|
||||
function step_2() {
|
||||
check_admin_referer('custom-header');
|
||||
$overrides = array('test_form' => false);
|
||||
$file = wp_handle_upload($_FILES['import'], $overrides);
|
||||
|
||||
if ( isset($file['error']) )
|
||||
die( $file['error'] );
|
||||
|
||||
$url = $file['url'];
|
||||
$file = $file['file'];
|
||||
$filename = basename($file);
|
||||
|
||||
// Construct the object array
|
||||
$object = array(
|
||||
'post_title' => $filename,
|
||||
'post_content' => $url,
|
||||
'post_mime_type' => 'import',
|
||||
'guid' => $url);
|
||||
|
||||
// Save the data
|
||||
$id = wp_insert_attachment($object, $file);
|
||||
|
||||
$upload = array('file' => $file, 'id' => $id);
|
||||
|
||||
list($width, $height, $type, $attr) = getimagesize( $file );
|
||||
|
||||
if ( $width == HEADER_IMAGE_WIDTH && $height == HEADER_IMAGE_HEIGHT ) {
|
||||
set_theme_mod('header_image', clean_url($url));
|
||||
$header = apply_filters('wp_create_file_in_uploads', $file, $id); // For replication
|
||||
return $this->finished();
|
||||
} elseif ( $width > HEADER_IMAGE_WIDTH ) {
|
||||
$oitar = $width / HEADER_IMAGE_WIDTH;
|
||||
$image = wp_crop_image($file, 0, 0, $width, $height, HEADER_IMAGE_WIDTH, $height / $oitar, false, str_replace(basename($file), 'midsize-'.basename($file), $file));
|
||||
$image = apply_filters('wp_create_file_in_uploads', $image, $id); // For replication
|
||||
|
||||
$url = str_replace(basename($url), basename($image), $url);
|
||||
$width = $width / $oitar;
|
||||
$height = $height / $oitar;
|
||||
} else {
|
||||
$oitar = 1;
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="wrap">
|
||||
|
||||
<form method="POST" action="<?php echo attribute_escape(add_query_arg('step', 3)) ?>">
|
||||
|
||||
<p><?php _e('Choose the part of the image you want to use as your header.'); ?></p>
|
||||
<div id="testWrap">
|
||||
<img src="<?php echo $url; ?>" id="upload" width="<?php echo $width; ?>" height="<?php echo $height; ?>" />
|
||||
</div>
|
||||
|
||||
<p class="submit">
|
||||
<input type="hidden" name="x1" id="x1" />
|
||||
<input type="hidden" name="y1" id="y1" />
|
||||
<input type="hidden" name="x2" id="x2" />
|
||||
<input type="hidden" name="y2" id="y2" />
|
||||
<input type="hidden" name="width" id="width" />
|
||||
<input type="hidden" name="height" id="height" />
|
||||
<input type="hidden" name="attachment_id" id="attachment_id" value="<?php echo $id; ?>" />
|
||||
<input type="hidden" name="oitar" id="oitar" value="<?php echo $oitar; ?>" />
|
||||
<?php wp_nonce_field('custom-header') ?>
|
||||
<input type="submit" value="<?php _e('Crop Header »'); ?>" />
|
||||
</p>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
function step_3() {
|
||||
check_admin_referer('custom-header');
|
||||
if ( $_POST['oitar'] > 1 ) {
|
||||
$_POST['x1'] = $_POST['x1'] * $_POST['oitar'];
|
||||
$_POST['y1'] = $_POST['y1'] * $_POST['oitar'];
|
||||
$_POST['width'] = $_POST['width'] * $_POST['oitar'];
|
||||
$_POST['height'] = $_POST['height'] * $_POST['oitar'];
|
||||
}
|
||||
|
||||
$header = wp_crop_image($_POST['attachment_id'], $_POST['x1'], $_POST['y1'], $_POST['width'], $_POST['height'], HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT);
|
||||
$header = apply_filters('wp_create_file_in_uploads', $header); // For replication
|
||||
|
||||
$parent = get_post($_POST['attachment_id']);
|
||||
|
||||
$parent_url = $parent->guid;
|
||||
|
||||
$url = str_replace(basename($parent_url), basename($header), $parent_url);
|
||||
|
||||
set_theme_mod('header_image', $url);
|
||||
|
||||
// cleanup
|
||||
$file = get_attached_file( $_POST['attachment_id'] );
|
||||
$medium = str_replace(basename($file), 'midsize-'.basename($file), $file);
|
||||
@unlink( apply_filters( 'wp_delete_file', $medium ) );
|
||||
wp_delete_attachment( $_POST['attachment_id'] );
|
||||
|
||||
return $this->finished();
|
||||
}
|
||||
|
||||
function finished() {
|
||||
?>
|
||||
<div class="wrap">
|
||||
<h2><?php _e('Header complete!'); ?></h2>
|
||||
|
||||
<p><?php _e('Visit your site and you should see the new header now.'); ?></p>
|
||||
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
function admin_page() {
|
||||
if ( !isset( $_GET['step'] ) )
|
||||
$step = 1;
|
||||
else
|
||||
$step = (int) $_GET['step'];
|
||||
|
||||
if ( 1 == $step ) {
|
||||
$this->step_1();
|
||||
} elseif ( 2 == $step ) {
|
||||
$this->step_2();
|
||||
} elseif ( 3 == $step ) {
|
||||
$this->step_3();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -159,10 +159,6 @@ endforeach;
|
||||
<?php echo $form_pingback ?>
|
||||
<?php echo $form_prevstatus ?>
|
||||
|
||||
<fieldset id="tagdiv">
|
||||
<legend><?php _e('Tags (separate multiple tags with commas: cats, pet food, dogs)'); ?></legend>
|
||||
<div><input type="text" name="tags_input" id="tags-input" size="30" tabindex="3" value="<?php echo get_tags_to_edit( $post_ID ); ?>" /></div>
|
||||
</fieldset>
|
||||
|
||||
<p class="submit">
|
||||
<span id="autosave"></span>
|
||||
|
||||
@@ -743,10 +743,11 @@ class Blogger_Import {
|
||||
|
||||
// Step 9: Congratulate the user
|
||||
function congrats() {
|
||||
$blog = (int) $_GET['blog'];
|
||||
echo '<h1>'.__('Congratulations!').'</h1><p>'.__('Now that you have imported your Blogger blog into WordPress, what are you going to do? Here are some suggestions:').'</p><ul><li>'.__('That was hard work! Take a break.').'</li>';
|
||||
if ( count($this->import['blogs']) > 1 )
|
||||
echo '<li>'.__('In case you haven\'t done it already, you can import the posts from your other blogs:'). $this->show_blogs() . '</li>';
|
||||
if ( $n = count($this->import['blogs'][$_GET['blog']]['newusers']) )
|
||||
if ( $n = count($this->import['blogs'][$blog]['newusers']) )
|
||||
echo '<li>'.sprintf(__('Go to <a href="%s" target="%s">Authors & Users</a>, where you can modify the new user(s) or delete them. If you want to make all of the imported posts yours, you will be given that option when you delete the new authors.'), 'users.php', '_parent').'</li>';
|
||||
echo '<li>'.__('For security, click the link below to reset this importer.').'</li>';
|
||||
echo '</ul>';
|
||||
@@ -765,6 +766,7 @@ class Blogger_Import {
|
||||
|
||||
if ( isset( $_REQUEST['blog'] ) ) {
|
||||
$blog = is_array($_REQUEST['blog']) ? array_shift( array_keys( $_REQUEST['blog'] ) ) : $_REQUEST['blog'];
|
||||
$blog = (int) $blog;
|
||||
$this->import_blog( $blog );
|
||||
} elseif ( isset($_GET['token']) )
|
||||
$this->auth();
|
||||
|
||||
@@ -147,8 +147,9 @@ class Dotclear_Import {
|
||||
echo '<div class="narrow"><p>'.__('Howdy! This importer allows you to extract posts from a DotClear database into your blog. Mileage may vary.').'</p>';
|
||||
echo '<p>'.__('Your DotClear Configuration settings are as follows:').'</p>';
|
||||
echo '<form action="admin.php?import=dotclear&step=1" method="post">';
|
||||
wp_nonce_field('import-dotclear');
|
||||
$this->db_form();
|
||||
echo '<p class="submit"><input type="submit" name="submit" value="'.__('Import Categories').' »" /></p>';
|
||||
echo '<p class="submit"><input type="submit" name="submit" value="'.attribute_escape(__('Import Categories »')).'" /></p>';
|
||||
echo '</form></div>';
|
||||
}
|
||||
|
||||
@@ -558,7 +559,8 @@ class Dotclear_Import {
|
||||
|
||||
|
||||
echo '<form action="admin.php?import=dotclear&step=2" method="post">';
|
||||
printf('<input type="submit" name="submit" value="%s" />', __('Import Users'));
|
||||
wp_nonce_field('import-dotclear');
|
||||
printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Import Users')));
|
||||
echo '</form>';
|
||||
|
||||
}
|
||||
@@ -570,7 +572,8 @@ class Dotclear_Import {
|
||||
$this->users2wp($users);
|
||||
|
||||
echo '<form action="admin.php?import=dotclear&step=3" method="post">';
|
||||
printf('<input type="submit" name="submit" value="%s" />', __('Import Posts'));
|
||||
wp_nonce_field('import-dotclear');
|
||||
printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Import Posts')));
|
||||
echo '</form>';
|
||||
}
|
||||
|
||||
@@ -581,7 +584,8 @@ class Dotclear_Import {
|
||||
$this->posts2wp($posts);
|
||||
|
||||
echo '<form action="admin.php?import=dotclear&step=4" method="post">';
|
||||
printf('<input type="submit" name="submit" value="%s" />', __('Import Comments'));
|
||||
wp_nonce_field('import-dotclear');
|
||||
printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Import Comments')));
|
||||
echo '</form>';
|
||||
}
|
||||
|
||||
@@ -592,7 +596,8 @@ class Dotclear_Import {
|
||||
$this->comments2wp($comments);
|
||||
|
||||
echo '<form action="admin.php?import=dotclear&step=5" method="post">';
|
||||
printf('<input type="submit" name="submit" value="%s" />', __('Import Links'));
|
||||
wp_nonce_field('import-dotclear');
|
||||
printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Import Links')));
|
||||
echo '</form>';
|
||||
}
|
||||
|
||||
@@ -604,7 +609,8 @@ class Dotclear_Import {
|
||||
add_option('dc_links', $links);
|
||||
|
||||
echo '<form action="admin.php?import=dotclear&step=6" method="post">';
|
||||
printf('<input type="submit" name="submit" value="%s" />', __('Finish'));
|
||||
wp_nonce_field('import-dotclear');
|
||||
printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Finish')));
|
||||
echo '</form>';
|
||||
}
|
||||
|
||||
@@ -667,42 +673,44 @@ class Dotclear_Import {
|
||||
|
||||
if ( $step > 0 )
|
||||
{
|
||||
check_admin_referer('import-dotclear');
|
||||
|
||||
if($_POST['dbuser'])
|
||||
{
|
||||
if(get_option('dcuser'))
|
||||
delete_option('dcuser');
|
||||
add_option('dcuser',$_POST['dbuser']);
|
||||
add_option('dcuser', sanitize_user($_POST['dbuser'], true));
|
||||
}
|
||||
if($_POST['dbpass'])
|
||||
{
|
||||
if(get_option('dcpass'))
|
||||
delete_option('dcpass');
|
||||
add_option('dcpass',$_POST['dbpass']);
|
||||
add_option('dcpass', sanitize_user($_POST['dbpass'], true));
|
||||
}
|
||||
|
||||
if($_POST['dbname'])
|
||||
{
|
||||
if(get_option('dcname'))
|
||||
delete_option('dcname');
|
||||
add_option('dcname',$_POST['dbname']);
|
||||
add_option('dcname', sanitize_user($_POST['dbname'], true));
|
||||
}
|
||||
if($_POST['dbhost'])
|
||||
{
|
||||
if(get_option('dchost'))
|
||||
delete_option('dchost');
|
||||
add_option('dchost',$_POST['dbhost']);
|
||||
add_option('dchost', sanitize_user($_POST['dbhost'], true));
|
||||
}
|
||||
if($_POST['dccharset'])
|
||||
{
|
||||
if(get_option('dccharset'))
|
||||
delete_option('dccharset');
|
||||
add_option('dccharset',$_POST['dccharset']);
|
||||
add_option('dccharset', sanitize_user($_POST['dccharset'], true));
|
||||
}
|
||||
if($_POST['dbprefix'])
|
||||
{
|
||||
if(get_option('dcdbprefix'))
|
||||
delete_option('dcdbprefix');
|
||||
add_option('dcdbprefix',$_POST['dbprefix']);
|
||||
add_option('dcdbprefix', sanitize_user($_POST['dbprefix'], true));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ class GM_Import {
|
||||
<form name="stepOne" method="get">
|
||||
<input type="hidden" name="import" value="greymatter" />
|
||||
<input type="hidden" name="step" value="1" />
|
||||
<?php wp_nonce_field('import-greymatter'); ?>
|
||||
<h3><?php _e('Second step: GreyMatter details:') ?></h3>
|
||||
<p><table cellpadding="0">
|
||||
<tr>
|
||||
@@ -87,10 +88,12 @@ class GM_Import {
|
||||
}
|
||||
|
||||
if (!chdir($archivespath))
|
||||
wp_die(sprintf(__("Wrong path, %s\ndoesn't exist\non the server"), $archivespath));
|
||||
wp_die(__("Wrong path, the path to the GM entries does not exist on the server"));
|
||||
|
||||
if (!chdir($gmpath))
|
||||
wp_die(sprintf(__("Wrong path, %s\ndoesn't exist\non the server"), $gmpath));
|
||||
wp_die(__("Wrong path, the path to the GM files does not exist on the server"));
|
||||
|
||||
$lastentry = (int) $lastentry;
|
||||
|
||||
$this->header();
|
||||
?>
|
||||
@@ -297,6 +300,7 @@ class GM_Import {
|
||||
$this->greet();
|
||||
break;
|
||||
case 1:
|
||||
check_admin_referer('import-greymatter');
|
||||
$this->import();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -153,6 +153,7 @@ class LJ_Import {
|
||||
$this->greet();
|
||||
break;
|
||||
case 1 :
|
||||
check_admin_referer('import-upload');
|
||||
$this->import();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -147,6 +147,7 @@ class MT_Import {
|
||||
$authors = $this->get_mt_authors();
|
||||
echo '<ol id="authors">';
|
||||
echo '<form action="?import=mt&step=2&id=' . $this->id . '" method="post">';
|
||||
wp_nonce_field('import-mt');
|
||||
$j = -1;
|
||||
foreach ($authors as $author) {
|
||||
++ $j;
|
||||
@@ -417,9 +418,11 @@ class MT_Import {
|
||||
$this->greet();
|
||||
break;
|
||||
case 1 :
|
||||
check_admin_referer('import-upload');
|
||||
$this->select_authors();
|
||||
break;
|
||||
case 2:
|
||||
check_admin_referer('import-mt');
|
||||
$this->import();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -156,6 +156,7 @@ class RSS_Import {
|
||||
$this->greet();
|
||||
break;
|
||||
case 1 :
|
||||
check_admin_referer('import-upload');
|
||||
$this->import();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -56,8 +56,9 @@ class Textpattern_Import {
|
||||
echo '<p>'.__('This has not been tested on previous versions of Textpattern. Mileage may vary.').'</p>';
|
||||
echo '<p>'.__('Your Textpattern Configuration settings are as follows:').'</p>';
|
||||
echo '<form action="admin.php?import=textpattern&step=1" method="post">';
|
||||
wp_nonce_field('import-textpattern');
|
||||
$this->db_form();
|
||||
echo '<p class="submit"><input type="submit" name="submit" value="'.__('Import Categories').' »" /></p>';
|
||||
echo '<p class="submit"><input type="submit" name="submit" value="'.attribute_escape(__('Import Categories »')).'" /></p>';
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
}
|
||||
@@ -483,7 +484,8 @@ class Textpattern_Import {
|
||||
|
||||
|
||||
echo '<form action="admin.php?import=textpattern&step=2" method="post">';
|
||||
printf('<input type="submit" name="submit" value="%s" />', __('Import Users'));
|
||||
wp_nonce_field('import-textpattern');
|
||||
printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Import Users')));
|
||||
echo '</form>';
|
||||
|
||||
}
|
||||
@@ -495,7 +497,8 @@ class Textpattern_Import {
|
||||
$this->users2wp($users);
|
||||
|
||||
echo '<form action="admin.php?import=textpattern&step=3" method="post">';
|
||||
printf('<input type="submit" name="submit" value="%s" />', __('Import Posts'));
|
||||
wp_nonce_field('import-textpattern');
|
||||
printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Import Posts')));
|
||||
echo '</form>';
|
||||
}
|
||||
|
||||
@@ -506,7 +509,8 @@ class Textpattern_Import {
|
||||
$this->posts2wp($posts);
|
||||
|
||||
echo '<form action="admin.php?import=textpattern&step=4" method="post">';
|
||||
printf('<input type="submit" name="submit" value="%s" />', __('Import Comments'));
|
||||
wp_nonce_field('import-textpattern');
|
||||
printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Import Comments')));
|
||||
echo '</form>';
|
||||
}
|
||||
|
||||
@@ -517,7 +521,8 @@ class Textpattern_Import {
|
||||
$this->comments2wp($comments);
|
||||
|
||||
echo '<form action="admin.php?import=textpattern&step=5" method="post">';
|
||||
printf('<input type="submit" name="submit" value="%s" />', __('Import Links'));
|
||||
wp_nonce_field('import-textpattern');
|
||||
printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Import Links')));
|
||||
echo '</form>';
|
||||
}
|
||||
|
||||
@@ -529,7 +534,8 @@ class Textpattern_Import {
|
||||
add_option('txp_links', $links);
|
||||
|
||||
echo '<form action="admin.php?import=textpattern&step=6" method="post">';
|
||||
printf('<input type="submit" name="submit" value="%s" />', __('Finish'));
|
||||
wp_nonce_field('import-textpattern');
|
||||
printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Finish')));
|
||||
echo '</form>';
|
||||
}
|
||||
|
||||
@@ -590,36 +596,38 @@ class Textpattern_Import {
|
||||
|
||||
if ( $step > 0 )
|
||||
{
|
||||
check_admin_referer('import-textpattern');
|
||||
|
||||
if($_POST['dbuser'])
|
||||
{
|
||||
if(get_option('txpuser'))
|
||||
delete_option('txpuser');
|
||||
add_option('txpuser',$_POST['dbuser']);
|
||||
add_option('txpuser', sanitize_user($_POST['dbuser'], true));
|
||||
}
|
||||
if($_POST['dbpass'])
|
||||
{
|
||||
if(get_option('txppass'))
|
||||
delete_option('txppass');
|
||||
add_option('txppass',$_POST['dbpass']);
|
||||
add_option('txppass', sanitize_user($_POST['dbpass'], true));
|
||||
}
|
||||
|
||||
if($_POST['dbname'])
|
||||
{
|
||||
if(get_option('txpname'))
|
||||
delete_option('txpname');
|
||||
add_option('txpname',$_POST['dbname']);
|
||||
add_option('txpname', sanitize_user($_POST['dbname'], true));
|
||||
}
|
||||
if($_POST['dbhost'])
|
||||
{
|
||||
if(get_option('txphost'))
|
||||
delete_option('txphost');
|
||||
add_option('txphost',$_POST['dbhost']);
|
||||
add_option('txphost', sanitize_user($_POST['dbhost'], true));
|
||||
}
|
||||
if($_POST['dbprefix'])
|
||||
{
|
||||
if(get_option('tpre'))
|
||||
delete_option('tpre');
|
||||
add_option('tpre',$_POST['dbprefix']);
|
||||
add_option('tpre', sanitize_user($_POST['dbprefix']));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,270 +0,0 @@
|
||||
<?php
|
||||
|
||||
class UTW_Import {
|
||||
|
||||
function header() {
|
||||
echo '<div class="wrap">';
|
||||
echo '<h2>'.__('Import Ultimate Tag Warrior').'</h2>';
|
||||
echo '<p>'.__('Steps may take a few minutes depending on the size of your database. Please be patient.').'<br /><br /></p>';
|
||||
}
|
||||
|
||||
function footer() {
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
function greet() {
|
||||
echo '<div class="narrow">';
|
||||
echo '<p>'.__('Howdy! This imports tags from an existing Ultimate Tag Warrior 3 installation into this blog using the new WordPress native tagging structure.').'</p>';
|
||||
echo '<p>'.__('This has not been tested on any other versions of Ultimate Tag Warrior. Mileage may vary.').'</p>';
|
||||
echo '<p>'.__('To accommodate larger databases for those tag-crazy authors out there, we have made this into an easy 5-step program to help you kick that nasty UTW habit. Just keep clicking along and we will let you know when you are in the clear!').'</p>';
|
||||
echo '<p><strong>'.__('Don’t be stupid - backup your database before proceeding!').'</strong></p>';
|
||||
echo '<form action="admin.php?import=utw&step=1" method="post">';
|
||||
echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 1 »').'" /></p>';
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
|
||||
function dispatch () {
|
||||
if ( empty( $_GET['step'] ) ) {
|
||||
$step = 0;
|
||||
} else {
|
||||
$step = (int) $_GET['step'];
|
||||
}
|
||||
|
||||
// load the header
|
||||
$this->header();
|
||||
|
||||
switch ( $step ) {
|
||||
case 0 :
|
||||
$this->greet();
|
||||
break;
|
||||
case 1 :
|
||||
$this->import_tags();
|
||||
break;
|
||||
case 2 :
|
||||
$this->import_posts();
|
||||
break;
|
||||
case 3:
|
||||
$this->import_t2p();
|
||||
break;
|
||||
case 4:
|
||||
$this->cleanup_import();
|
||||
break;
|
||||
}
|
||||
|
||||
// load the footer
|
||||
$this->footer();
|
||||
}
|
||||
|
||||
|
||||
function import_tags ( ) {
|
||||
echo '<div class="narrow">';
|
||||
echo '<p><h3>'.__('Reading UTW Tags…').'</h3></p>';
|
||||
|
||||
$tags = $this->get_utw_tags();
|
||||
|
||||
// if we didn't get any tags back, that's all there is folks!
|
||||
if ( !is_array($tags) ) {
|
||||
echo '<p>' . __('No Tags Found!') . '</p>';
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
|
||||
// if there's an existing entry, delete it
|
||||
if ( get_option('utwimp_tags') ) {
|
||||
delete_option('utwimp_tags');
|
||||
}
|
||||
|
||||
add_option('utwimp_tags', $tags);
|
||||
|
||||
|
||||
$count = count($tags);
|
||||
|
||||
echo '<p>' . sprintf( __('Done! <strong>%s</strong> tags were read.'), $count ) . '<br /></p>';
|
||||
echo '<p>' . __('The following tags were found:') . '</p>';
|
||||
|
||||
echo '<ul>';
|
||||
|
||||
foreach ( $tags as $tag_id => $tag_name ) {
|
||||
|
||||
echo '<li>' . $tag_name . '</li>';
|
||||
|
||||
}
|
||||
|
||||
echo '</ul>';
|
||||
|
||||
echo '<br />';
|
||||
|
||||
echo '<p>' . __('If you don’t want to import any of these tags, you should delete them from the UTW tag management page and then re-run this import.') . '</p>';
|
||||
|
||||
|
||||
}
|
||||
|
||||
echo '<form action="admin.php?import=utw&step=2" method="post">';
|
||||
echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 2 »').'" /></p>';
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
|
||||
function import_posts ( ) {
|
||||
echo '<div class="narrow">';
|
||||
echo '<p><h3>'.__('Reading UTW Post Tags…').'</h3></p>';
|
||||
|
||||
// read in all the UTW tag -> post settings
|
||||
$posts = $this->get_utw_posts();
|
||||
|
||||
// if we didn't get any tags back, that's all there is folks!
|
||||
if ( !is_array($posts) ) {
|
||||
echo '<p>' . __('No posts were found to have tags!') . '</p>';
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
|
||||
// if there's an existing entry, delete it
|
||||
if ( get_option('utwimp_posts') ) {
|
||||
delete_option('utwimp_posts');
|
||||
}
|
||||
|
||||
add_option('utwimp_posts', $posts);
|
||||
|
||||
|
||||
$count = count($posts);
|
||||
|
||||
echo '<p>' . sprintf( __('Done! <strong>%s</strong> tag to post relationships were read.'), $count ) . '<br /></p>';
|
||||
|
||||
}
|
||||
|
||||
echo '<form action="admin.php?import=utw&step=3" method="post">';
|
||||
echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 3 »').'" /></p>';
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
|
||||
function import_t2p ( ) {
|
||||
|
||||
echo '<div class="narrow">';
|
||||
echo '<p><h3>'.__('Adding Tags to Posts…').'</h3></p>';
|
||||
|
||||
// run that funky magic!
|
||||
$tags_added = $this->tag2post();
|
||||
|
||||
echo '<p>' . sprintf( __('Done! <strong>%s</strong> tags where added!'), $tags_added ) . '<br /></p>';
|
||||
|
||||
echo '<form action="admin.php?import=utw&step=4" method="post">';
|
||||
echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 4 »').'" /></p>';
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
|
||||
function get_utw_tags ( ) {
|
||||
|
||||
global $wpdb;
|
||||
|
||||
// read in all the tags from the UTW tags table: should be wp_tags
|
||||
$tags_query = "SELECT tag_id, tag FROM " . $wpdb->prefix . "tags";
|
||||
|
||||
$tags = $wpdb->get_results($tags_query);
|
||||
|
||||
// rearrange these tags into something we can actually use
|
||||
foreach ( $tags as $tag ) {
|
||||
|
||||
$new_tags[$tag->tag_id] = $tag->tag;
|
||||
|
||||
}
|
||||
|
||||
return $new_tags;
|
||||
|
||||
}
|
||||
|
||||
function get_utw_posts ( ) {
|
||||
|
||||
global $wpdb;
|
||||
|
||||
// read in all the posts from the UTW post->tag table: should be wp_post2tag
|
||||
$posts_query = "SELECT tag_id, post_id FROM " . $wpdb->prefix . "post2tag";
|
||||
|
||||
$posts = $wpdb->get_results($posts_query);
|
||||
|
||||
return $posts;
|
||||
|
||||
}
|
||||
|
||||
|
||||
function tag2post ( ) {
|
||||
|
||||
// get the tags and posts we imported in the last 2 steps
|
||||
$tags = get_option('utwimp_tags');
|
||||
$posts = get_option('utwimp_posts');
|
||||
|
||||
// null out our results
|
||||
$tags_added = 0;
|
||||
|
||||
// loop through each post and add its tags to the db
|
||||
foreach ( $posts as $this_post ) {
|
||||
|
||||
$the_post = (int) $this_post->post_id;
|
||||
$the_tag = (int) $this_post->tag_id;
|
||||
|
||||
// what's the tag name for that id?
|
||||
$the_tag = $tags[$the_tag];
|
||||
|
||||
// screw it, just try to add the tag
|
||||
wp_add_post_tags($the_post, $the_tag);
|
||||
|
||||
$tags_added++;
|
||||
|
||||
}
|
||||
|
||||
// that's it, all posts should be linked to their tags properly, pending any errors we just spit out!
|
||||
return $tags_added;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
function cleanup_import ( ) {
|
||||
|
||||
delete_option('utwimp_tags');
|
||||
delete_option('utwimp_posts');
|
||||
|
||||
$this->done();
|
||||
|
||||
}
|
||||
|
||||
|
||||
function done ( ) {
|
||||
|
||||
echo '<div class="narrow">';
|
||||
echo '<p><h3>'.__('Import Complete!').'</h3></p>';
|
||||
|
||||
echo '<p>' . __('OK, so we lied about this being a 5-step program! You’re done!') . '</p>';
|
||||
|
||||
echo '<p>' . __('Now wasn’t that easy?') . '</p>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
|
||||
function UTW_Import ( ) {
|
||||
|
||||
// Nothing.
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// create the import object
|
||||
$utw_import = new UTW_Import();
|
||||
|
||||
// add it to the import page!
|
||||
register_importer('utw', 'Ultimate Tag Warrior', __('Import Ultimate Tag Warrior tags into the new native tagging structure.'), array($utw_import, 'dispatch'));
|
||||
|
||||
?>
|
||||
@@ -65,7 +65,7 @@ class WP_Import {
|
||||
$this->mtnames[$this->j] = $author; //add that new mt author name to an array
|
||||
$user_id = username_exists($this->newauthornames[$this->j]); //check if the new author name defined by the user is a pre-existing wp user
|
||||
if (!$user_id) { //banging my head against the desk now.
|
||||
if ($newauthornames[$this->j] == 'left_blank') { //check if the user does not want to change the authorname
|
||||
if ($this->newauthornames[$this->j] == 'left_blank') { //check if the user does not want to change the authorname
|
||||
$user_id = wp_create_user($author, $pass);
|
||||
$this->newauthornames[$this->j] = $author; //now we have a name, in the place of left_blank.
|
||||
} else {
|
||||
@@ -84,19 +84,40 @@ class WP_Import {
|
||||
|
||||
function get_entries() {
|
||||
set_magic_quotes_runtime(0);
|
||||
$importdata = file($this->file); // Read the file into an array
|
||||
$importdata = implode('', $importdata); // squish it
|
||||
$importdata = preg_replace("/(\r\n|\n|\r)/", "\n", $importdata);
|
||||
preg_match_all('|<item>(.*?)</item>|is', $importdata, $this->posts);
|
||||
$this->posts = $this->posts[1];
|
||||
$importdata = array_map('rtrim', file($this->file)); // Read the file into an array
|
||||
|
||||
$this->posts = array();
|
||||
$this->categories = array();
|
||||
$num = 0;
|
||||
$doing_entry = false;
|
||||
foreach ($importdata as $importline) {
|
||||
if ( false !== strpos($importline, '<wp:category>') ) {
|
||||
preg_match('|<wp:category>(.*?)</wp:category>|is', $importline, $category);
|
||||
$this->categories[] = $category[1];
|
||||
continue;
|
||||
}
|
||||
if ( false !== strpos($importline, '<item>') ) {
|
||||
$this->posts[$num] = '';
|
||||
$doing_entry = true;
|
||||
continue;
|
||||
}
|
||||
if ( false !== strpos($importline, '</item>') ) {
|
||||
$num++;
|
||||
$doing_entry = false;
|
||||
continue;
|
||||
}
|
||||
if ( $doing_entry ) {
|
||||
$this->posts[$num] .= $importline . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->posts as $post) {
|
||||
$post_ID = (int) $this->get_tag( $post, 'wp:post_id' );
|
||||
if ($post_ID)
|
||||
if ($post_ID) {
|
||||
$this->posts_processed[$post_ID][0] = &$post;
|
||||
$this->posts_processed[$post_ID][1] = 0;
|
||||
}
|
||||
}
|
||||
preg_match_all('|<wp:category>(.*?)</wp:category>|is', $importdata, $this->categories);
|
||||
$this->categories = $this->categories[1];
|
||||
}
|
||||
|
||||
function get_wp_authors() {
|
||||
@@ -159,6 +180,7 @@ class WP_Import {
|
||||
$authors = $this->get_wp_authors();
|
||||
echo '<ol id="authors">';
|
||||
echo '<form action="?import=wordpress&step=2&id=' . $this->id . '" method="post">';
|
||||
wp_nonce_field('import-wordpress');
|
||||
$j = -1;
|
||||
foreach ($authors as $author) {
|
||||
++ $j;
|
||||
@@ -363,9 +385,11 @@ class WP_Import {
|
||||
$this->greet();
|
||||
break;
|
||||
case 1 :
|
||||
check_admin_referer('import-upload');
|
||||
$this->select_authors();
|
||||
break;
|
||||
case 2:
|
||||
check_admin_referer('import-wordpress');
|
||||
$this->import();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1,226 +0,0 @@
|
||||
<?php
|
||||
|
||||
class WP_Categories_to_Tags {
|
||||
var $categories_to_convert = array();
|
||||
var $all_categories = array();
|
||||
|
||||
function header() {
|
||||
print '<div class="wrap">';
|
||||
print '<h2>' . __('Convert Categories to Tags') . '</h2>';
|
||||
}
|
||||
|
||||
function footer() {
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
function populate_all_categories() {
|
||||
global $wpdb;
|
||||
|
||||
$this->all_categories = $wpdb->get_results("SELECT * FROM $wpdb->categories WHERE (type & ~ " . TAXONOMY_TAG . ") != 0 AND category_count > 0 ORDER BY cat_name ASC");
|
||||
}
|
||||
|
||||
function welcome() {
|
||||
$this->populate_all_categories();
|
||||
|
||||
print '<div class="narrow">';
|
||||
|
||||
if (count($this->all_categories) > 0) {
|
||||
print '<p>' . __('Howdy! This converter allows you to selectively convert existing categories to tags. To get started, check the checkboxes of the categories you wish to be converted, then click the Convert button.') . '</p>';
|
||||
print '<p>' . __('Keep in mind that if you convert a category with child categories, those child categories get their parent setting removed, so they\'re in the root.') . '</p>';
|
||||
|
||||
$this->categories_form();
|
||||
} else {
|
||||
print '<p>'.__('You have no categories to convert!').'</p>';
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
function categories_form() {
|
||||
print '<form action="admin.php?import=wp-cat2tag&step=2" method="post">';
|
||||
print '<ul style="list-style:none">';
|
||||
|
||||
$hier = _get_category_hierarchy();
|
||||
|
||||
foreach ($this->all_categories as $category) {
|
||||
if ((int) $category->category_parent == 0) {
|
||||
print '<li><label><input type="checkbox" name="cats_to_convert[]" value="' . intval($category->cat_ID) . '" /> ' . $category->cat_name . ' (' . $category->category_count . ')</label>';
|
||||
|
||||
if (isset($hier[$category->cat_ID])) {
|
||||
$this->_category_children($category, $hier);
|
||||
}
|
||||
|
||||
print '</li>';
|
||||
}
|
||||
}
|
||||
|
||||
print '</ul>';
|
||||
|
||||
print '<p class="submit"><input type="submit" name="maybe_convert_all_cats" value="' . __('Convert All Categories') . '" /> <input type="submit" name="submit" value="' . __('Convert »') . '" /></p>';
|
||||
print '</form>';
|
||||
}
|
||||
|
||||
function _category_children($parent, $hier) {
|
||||
print '<ul style="list-style:none">';
|
||||
|
||||
foreach ($hier[$parent->cat_ID] as $child_id) {
|
||||
$child =& get_category($child_id);
|
||||
|
||||
print '<li><label><input type="checkbox" name="cats_to_convert[]" value="' . intval($child->cat_ID) . '" /> ' . $child->cat_name . ' (' . $child->category_count . ')</label>';
|
||||
|
||||
if (isset($hier[$child->cat_ID])) {
|
||||
$this->_category_children($child, $hier);
|
||||
}
|
||||
|
||||
print '</li>';
|
||||
}
|
||||
|
||||
print '</ul>';
|
||||
}
|
||||
|
||||
function _category_exists($cat_id) {
|
||||
global $wpdb;
|
||||
|
||||
$cat_id = (int) $cat_id;
|
||||
|
||||
$maybe_exists = $wpdb->get_results("SELECT cat_ID from $wpdb->categories WHERE cat_ID = '$cat_id'");
|
||||
|
||||
if (count($maybe_exists) > 0) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function convert_them() {
|
||||
global $wpdb;
|
||||
|
||||
if (!isset($_POST['cats_to_convert']) || !is_array($_POST['cats_to_convert'])) {
|
||||
print '<div class="narrow">';
|
||||
print '<p>' . sprintf(__('Uh, oh. Something didn\'t work. Please <a href="%s">try again</a>.'), 'admin.php?import=wp-cat2tag') . '</p>';
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
$this->categories_to_convert = $_POST['cats_to_convert'];
|
||||
$hier = _get_category_hierarchy();
|
||||
|
||||
print '<ul>';
|
||||
|
||||
foreach ($this->categories_to_convert as $cat_id) {
|
||||
$cat_id = (int) $cat_id;
|
||||
|
||||
print '<li>' . __('Converting category') . ' #' . $cat_id . '... ';
|
||||
|
||||
if (!$this->_category_exists($cat_id)) {
|
||||
_e('Category doesn\'t exist!');
|
||||
} else {
|
||||
$category =& get_category($cat_id);
|
||||
|
||||
if ($category->link_count > 0) {
|
||||
$type = $category->type | TAXONOMY_TAG;
|
||||
} else {
|
||||
$type = TAXONOMY_TAG;
|
||||
}
|
||||
|
||||
// Set the category itself to $type from above
|
||||
$wpdb->query("UPDATE $wpdb->categories SET type = '$type' WHERE cat_ID = '{$category->cat_ID}'");
|
||||
|
||||
// Set relationships in post2cat to 'tag', category_count becomes tag_count
|
||||
$wpdb->query("UPDATE $wpdb->post2cat SET rel_type = 'tag' WHERE category_ID = '{$category->cat_ID}'");
|
||||
$wpdb->query("UPDATE $wpdb->categories SET tag_count = '{$category->category_count}', category_count = '0' WHERE cat_ID = '{$category->cat_ID}'");
|
||||
|
||||
// Set all parents to 0 (root-level) if their parent was the converted tag
|
||||
$wpdb->query("UPDATE $wpdb->categories SET category_parent = 0 WHERE category_parent = '{$category->cat_ID}'");
|
||||
|
||||
// Clean the cache
|
||||
clean_category_cache($category->cat_ID);
|
||||
|
||||
_e('Converted successfully.');
|
||||
}
|
||||
|
||||
print '</li>';
|
||||
}
|
||||
|
||||
print '</ul>';
|
||||
}
|
||||
|
||||
function convert_all_confirm() {
|
||||
print '<div class="narrow">';
|
||||
|
||||
print '<h3>' . __('Confirm') . '</h3>';
|
||||
|
||||
print '<p>' . __('You are about to convert all categories to tags. Are you sure you want to continue?') . '</p>';
|
||||
|
||||
print '<form action="admin.php?import=wp-cat2tag" method="post">';
|
||||
print '<p style="text-align:center" class="submit"><input type="submit" value="' . __('Yes') . '" name="yes_convert_all_cats" /> <input type="submit" value="' . __('No') . '" name="no_dont_do_it" /></p>';
|
||||
print '</form>';
|
||||
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
function convert_all() {
|
||||
global $wpdb;
|
||||
|
||||
$cats = $wpdb->get_results("SELECT * FROM $wpdb->categories WHERE (type & ~ " . TAXONOMY_TAG . ") != 0 AND category_count > 0");
|
||||
|
||||
$_POST['cats_to_convert'] = array();
|
||||
|
||||
foreach ($cats as $cat) {
|
||||
$_POST['cats_to_convert'][] = $cat->cat_ID;
|
||||
}
|
||||
|
||||
$this->convert_them();
|
||||
}
|
||||
|
||||
function init() {
|
||||
echo '<!--'; print_r($_POST); print_r($_GET); echo '-->';
|
||||
|
||||
if (isset($_POST['maybe_convert_all_cats'])) {
|
||||
$step = 3;
|
||||
} elseif (isset($_POST['yes_convert_all_cats'])) {
|
||||
$step = 4;
|
||||
} elseif (isset($_POST['no_dont_do_it'])) {
|
||||
die('no_dont_do_it');
|
||||
} else {
|
||||
$step = (isset($_GET['step'])) ? (int) $_GET['step'] : 1;
|
||||
}
|
||||
|
||||
$this->header();
|
||||
|
||||
if (!current_user_can('manage_categories')) {
|
||||
print '<div class="narrow">';
|
||||
print '<p>' . __('Cheatin’ uh?') . '</p>';
|
||||
print '</div>';
|
||||
} else {
|
||||
switch ($step) {
|
||||
case 1 :
|
||||
$this->welcome();
|
||||
break;
|
||||
|
||||
case 2 :
|
||||
$this->convert_them();
|
||||
break;
|
||||
|
||||
case 3 :
|
||||
$this->convert_all_confirm();
|
||||
break;
|
||||
|
||||
case 4 :
|
||||
$this->convert_all();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$this->footer();
|
||||
}
|
||||
|
||||
function WP_Categories_to_Tags() {
|
||||
// Do nothing.
|
||||
}
|
||||
}
|
||||
|
||||
$wp_cat2tag_importer = new WP_Categories_to_Tags();
|
||||
|
||||
register_importer('wp-cat2tag', __('Categories to Tags Converter'), __('Convert existing categories to tags, selectively.'), array(&$wp_cat2tag_importer, 'init'));
|
||||
|
||||
?>
|
||||
@@ -93,7 +93,12 @@ foreach ($categories as $category) {
|
||||
}
|
||||
|
||||
if ( isset($opml_url) && $opml_url != '' ) {
|
||||
$opml = wp_remote_fopen($opml_url);
|
||||
if ( $blogrolling === true ) {
|
||||
$opml = wp_remote_fopen($opml_url);
|
||||
} else {
|
||||
$opml = file_get_contents($opml_url);
|
||||
}
|
||||
|
||||
include_once('link-parse-opml.php');
|
||||
|
||||
$link_count = count($names);
|
||||
@@ -118,6 +123,7 @@ else
|
||||
} // end else
|
||||
|
||||
if ( ! $blogrolling )
|
||||
apply_filters( 'wp_delete_file', $opml_url);
|
||||
@unlink($opml_url);
|
||||
?>
|
||||
</div>
|
||||
|
||||
@@ -180,7 +180,7 @@ if ( $links ) {
|
||||
break;
|
||||
default:
|
||||
?>
|
||||
<td><?php do_action('manage_link_custom_column', $column_name, $id); ?></td>
|
||||
<td><?php do_action('manage_link_custom_column', $column_name, $link->link_id); ?></td>
|
||||
<?php
|
||||
break;
|
||||
|
||||
|
||||
@@ -69,6 +69,8 @@ $submenu['plugins.php'][10] = array(__('Plugin Editor'), 'edit_plugins', 'plugin
|
||||
$submenu['themes.php'][5] = array(__('Themes'), 'switch_themes', 'themes.php');
|
||||
$submenu['themes.php'][10] = array(__('Theme Editor'), 'edit_themes', 'theme-editor.php');
|
||||
|
||||
do_action('_admin_menu');
|
||||
|
||||
// Create list of page plugin hook names.
|
||||
foreach ($menu as $menu_page) {
|
||||
$admin_page_hooks[$menu_page[2]] = sanitize_title($menu_page[0]);
|
||||
|
||||
@@ -97,7 +97,7 @@ endfor;
|
||||
|
||||
<p class="submit"><input type="submit" name="Submit" value="<?php _e('Update Options »') ?>" />
|
||||
<input type="hidden" name="action" value="update" />
|
||||
<input type="hidden" name="page_options" value="blogname,blogdescription,siteurl,admin_email,users_can_register,gmt_offset,date_format,time_format,home,start_of_week,comment_registration,default_role" />
|
||||
<input type="hidden" name="page_options" value="<?php if ( ! defined( 'WP_SITEURL' ) ) echo 'siteurl,'; if ( ! defined( 'WP_HOME' ) ) echo 'home,'; ?>blogname,blogdescription,admin_email,users_can_register,gmt_offset,date_format,time_format,start_of_week,comment_registration,default_role" />
|
||||
</p>
|
||||
</form>
|
||||
|
||||
|
||||
@@ -73,18 +73,10 @@ if ( isset($_POST['permalink_structure']) || isset($_POST['category_base']) ) {
|
||||
$category_base = preg_replace('#/+#', '/', '/' . $_POST['category_base']);
|
||||
$wp_rewrite->set_category_base($category_base);
|
||||
}
|
||||
|
||||
if ( isset($_POST['tag_base']) ) {
|
||||
$tag_base = $_POST['tag_base'];
|
||||
if (! empty($tag_base) )
|
||||
$tag_base = preg_replace('#/+#', '/', '/' . $_POST['tag_base']);
|
||||
$wp_rewrite->set_tag_base($tag_base);
|
||||
}
|
||||
}
|
||||
|
||||
$permalink_structure = get_option('permalink_structure');
|
||||
$category_base = get_option('category_base');
|
||||
$tag_base = get_option( 'tag_base' );
|
||||
|
||||
if ( (!file_exists($home_path.'.htaccess') && is_writable($home_path)) || is_writable($home_path.'.htaccess') )
|
||||
$writable = true;
|
||||
@@ -167,9 +159,6 @@ checked="checked"
|
||||
<?php endif; ?>
|
||||
<p>
|
||||
<?php _e('Category base'); ?>: <input name="category_base" type="text" class="code" value="<?php echo attribute_escape($category_base); ?>" size="30" />
|
||||
</p>
|
||||
<p>
|
||||
<?php _e('Tag base'); ?>: <input name="tag_base" type="text" class="code" value="<?php echo attribute_escape($tag_base); ?>" size="30" />
|
||||
</p>
|
||||
<p class="submit">
|
||||
<input type="submit" name="submit" value="<?php _e('Update Permalink Structure »') ?>" />
|
||||
|
||||
@@ -175,6 +175,8 @@ function upgrade_all() {
|
||||
upgrade_110();
|
||||
upgrade_130();
|
||||
}
|
||||
|
||||
maybe_disable_automattic_widgets();
|
||||
|
||||
if ( $wp_current_db_version < 3308 )
|
||||
upgrade_160();
|
||||
@@ -657,7 +659,15 @@ function get_alloptions_110() {
|
||||
// Version of get_option that is private to install/upgrade.
|
||||
function __get_option($setting) {
|
||||
global $wpdb;
|
||||
|
||||
|
||||
if ( $setting == 'home' && defined( 'WP_HOME' ) ) {
|
||||
return preg_replace( '|/+$|', '', constant( 'WP_HOME' ) );
|
||||
}
|
||||
|
||||
if ( $setting == 'siteurl' && defined( 'WP_SITEURL' ) ) {
|
||||
return preg_replace( '|/+$|', '', constant( 'WP_SITEURL' ) );
|
||||
}
|
||||
|
||||
$option = $wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = '$setting'");
|
||||
|
||||
if ( 'home' == $setting && '' == $option )
|
||||
@@ -1099,4 +1109,16 @@ function wp_check_mysql_version() {
|
||||
die(sprintf(__('<strong>ERROR</strong>: WordPress %s requires MySQL 4.0.0 or higher'), $wp_version));
|
||||
}
|
||||
|
||||
?>
|
||||
function maybe_disable_automattic_widgets() {
|
||||
$plugins = __get_option( 'active_plugins' );
|
||||
|
||||
foreach ( (array) $plugins as $plugin ) {
|
||||
if ( basename( $plugin ) == 'widgets.php' ) {
|
||||
array_splice( $plugins, array_search( $plugin, $plugins ), 1 );
|
||||
update_option( 'active_plugins', $plugins );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -18,10 +18,8 @@ $wp_queries="CREATE TABLE $wpdb->categories (
|
||||
category_parent bigint(20) NOT NULL default '0',
|
||||
category_count bigint(20) NOT NULL default '0',
|
||||
link_count bigint(20) NOT NULL default '0',
|
||||
tag_count bigint(20) NOT NULL default '0',
|
||||
posts_private tinyint(1) NOT NULL default '0',
|
||||
links_private tinyint(1) NOT NULL default '0',
|
||||
type tinyint NOT NULL default '1',
|
||||
PRIMARY KEY (cat_ID),
|
||||
KEY category_nicename (category_nicename)
|
||||
) $charset_collate;
|
||||
@@ -90,7 +88,6 @@ CREATE TABLE $wpdb->post2cat (
|
||||
rel_id bigint(20) NOT NULL auto_increment,
|
||||
post_id bigint(20) NOT NULL default '0',
|
||||
category_id bigint(20) NOT NULL default '0',
|
||||
rel_type varchar(64) NOT NULL default 'category',
|
||||
PRIMARY KEY (rel_id),
|
||||
KEY post_id (post_id,category_id)
|
||||
) $charset_collate;
|
||||
@@ -243,9 +240,6 @@ function populate_options() {
|
||||
add_option('default_link_category', 2);
|
||||
add_option('show_on_front', 'posts');
|
||||
|
||||
// 2.2
|
||||
add_option('tag_base');
|
||||
|
||||
// Delete unused options
|
||||
$unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog', '_wpnonce', '_wp_http_referer', 'Update', 'action', 'rich_editing');
|
||||
foreach ($unusedoptions as $option) :
|
||||
|
||||
@@ -44,6 +44,7 @@ body > #upload-menu { border-bottom: 7px solid #fff; }
|
||||
}
|
||||
|
||||
#upload-menu li #current-tab-nav {
|
||||
background: #f9fcfe;
|
||||
float: left;
|
||||
padding: 5px 5px 0 0;
|
||||
margin-left: -5px;
|
||||
|
||||
@@ -104,8 +104,8 @@ foreach ( $wp_upload_tabs as $t => $tab_array ) { // We've already done the curr
|
||||
$per = 10;
|
||||
}
|
||||
$page_links = paginate_links( array(
|
||||
'base' => 'users.php?%_%',
|
||||
'format' => 'paged=%#%',
|
||||
'base' => add_query_arg( 'paged', '%#%' ),
|
||||
'format' => '',
|
||||
'total' => ceil($total / $per),
|
||||
'current' => $paged ? $paged : 1,
|
||||
'prev_text' => '«',
|
||||
|
||||
39
wp-admin/widgets-rtl.css
Normal file
39
wp-admin/widgets-rtl.css
Normal file
@@ -0,0 +1,39 @@
|
||||
#sbreset, #lastmodule, #palettediv .module, .dropzone, .dropzone ul { float: right; }
|
||||
|
||||
* .module, #lastmodule { text-align: right; }
|
||||
|
||||
* html #palettediv ul { padding: 0 10px 0 0; }
|
||||
|
||||
#palettediv ul { padding: 0 10px 0 0; }
|
||||
|
||||
* .handle, #lastmodule span {
|
||||
border-right: 1px solid #f2f2f2;
|
||||
border-left: 1px solid #e8e8e8;
|
||||
}
|
||||
|
||||
#sbadmin p.submit {
|
||||
padding-right: 0;
|
||||
padding-left: 10px;
|
||||
clear: right;
|
||||
}
|
||||
|
||||
#palettediv .module, #lastmodule, .dropzone {
|
||||
margin-right: auto;
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
* .popper {
|
||||
right: auto;
|
||||
left: 3px;
|
||||
background-position: 5px 0;
|
||||
}
|
||||
|
||||
.controlcloser {
|
||||
right: auto;
|
||||
left: 8px;
|
||||
}
|
||||
|
||||
#shadow {
|
||||
left: auto;
|
||||
right: 0px;
|
||||
}
|
||||
213
wp-admin/widgets.css
Normal file
213
wp-admin/widgets.css
Normal file
@@ -0,0 +1,213 @@
|
||||
body {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
#sbadmin #zones {
|
||||
-moz-user-select: none;
|
||||
-khtml-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
#sbreset {
|
||||
float: left;
|
||||
margin: 1px 0;
|
||||
}
|
||||
|
||||
.dropzone {
|
||||
float: left;
|
||||
margin-right: 10px;
|
||||
padding: 5px;
|
||||
border: 1px solid #bbb;
|
||||
background-color: #f0f8ff;
|
||||
}
|
||||
|
||||
.dropzone h3 {
|
||||
text-align: center;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.dropzone ul {
|
||||
list-style-type: none;
|
||||
width: 240px;
|
||||
float: left;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
* .module, #lastmodule {
|
||||
width: 238px;
|
||||
padding: 0;
|
||||
margin: 5px 0;
|
||||
cursor: move;
|
||||
display: block;
|
||||
border: 1px solid #ccc;
|
||||
background-color: #fbfbfb;
|
||||
text-align: left;
|
||||
line-height: 25px;
|
||||
}
|
||||
|
||||
* .handle, #lastmodule span {
|
||||
display: block;
|
||||
width: 216px;
|
||||
padding: 0 10px;
|
||||
border-top: 1px solid #f2f2f2;
|
||||
border-right: 1px solid #e8e8e8;
|
||||
border-bottom: 1px solid #e8e8e8;
|
||||
border-left: 1px solid #f2f2f2;
|
||||
}
|
||||
|
||||
* .popper {
|
||||
margin: 0;
|
||||
display: inline;
|
||||
position: absolute;
|
||||
top: 3px;
|
||||
right: 3px;
|
||||
overflow: hidden;
|
||||
text-align: center;
|
||||
height: 16px;
|
||||
font-size: 18px;
|
||||
line-height: 14px;
|
||||
cursor: pointer;
|
||||
padding: 0 3px 1px;
|
||||
border-top: 4px solid #6da6d1;
|
||||
background: url( images/fade-butt.png ) -5px 0px;
|
||||
}
|
||||
|
||||
* html .popper {
|
||||
padding: 1px 6px 0;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
#sbadmin p.submit {
|
||||
padding-right: 10px;
|
||||
clear: left;
|
||||
}
|
||||
|
||||
.placematt {
|
||||
position: absolute;
|
||||
cursor: default;
|
||||
margin: 10px 0 0;
|
||||
padding: 0;
|
||||
width: 238px;
|
||||
background-color: #ffe;
|
||||
}
|
||||
|
||||
* html .placematt {
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
.placematt h4 {
|
||||
text-align: center;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.placematt span {
|
||||
padding: 0 10px 10px;
|
||||
text-align: justify;
|
||||
}
|
||||
|
||||
#palettediv {
|
||||
border: 1px solid #bbb;
|
||||
background-color: #f0f8ff;
|
||||
height: 180px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
#palettediv h3 {
|
||||
text-align: center;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
#palettediv ul {
|
||||
padding: 0 0 0 10px;
|
||||
}
|
||||
|
||||
#palettediv .module, #lastmodule {
|
||||
margin-right: 10px;
|
||||
float: left;
|
||||
width: 120px;
|
||||
}
|
||||
|
||||
#palettediv .handle, #lastmodule span {
|
||||
height: 40px;
|
||||
font-size: 90%;
|
||||
width: 110px;
|
||||
padding: 0 5px;
|
||||
}
|
||||
|
||||
#palettediv .popper {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
#lastmodule {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
* html #palettediv ul {
|
||||
margin: 0;
|
||||
padding: 0 0 0 10px;
|
||||
}
|
||||
|
||||
* html #palettediv .module {
|
||||
float: none;
|
||||
display: inline;
|
||||
}
|
||||
|
||||
#controls {
|
||||
height: 0px;
|
||||
}
|
||||
|
||||
.control {
|
||||
position: absolute;
|
||||
display: block;
|
||||
background: #f9fcfe;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.controlhandle {
|
||||
cursor: move;
|
||||
background-color: #6da6d1;
|
||||
border-bottom: 2px solid #448abd;
|
||||
color: #333;
|
||||
display: block;
|
||||
margin: 0 0 5px;
|
||||
padding: 4px;
|
||||
font-size: 120%;
|
||||
}
|
||||
|
||||
.controlcloser {
|
||||
cursor: pointer;
|
||||
font-size: 120%;
|
||||
display: block;
|
||||
position: absolute;
|
||||
top: 2px;
|
||||
right: 8px;
|
||||
padding: 0 3px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.controlform {
|
||||
margin: 20px 30px;
|
||||
}
|
||||
|
||||
.controlform p {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.control .checkbox {
|
||||
border: none;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#shadow {
|
||||
background: black;
|
||||
display: none;
|
||||
position: absolute;
|
||||
top: 0px;
|
||||
left: 0px;
|
||||
width: 100%;
|
||||
}
|
||||
381
wp-admin/widgets.php
Normal file
381
wp-admin/widgets.php
Normal file
@@ -0,0 +1,381 @@
|
||||
<?php
|
||||
|
||||
require_once 'admin.php';
|
||||
|
||||
if ( ! current_user_can('edit_themes') )
|
||||
wp_die( __( 'Cheatin’ uh?' ));
|
||||
|
||||
wp_enqueue_script( 'scriptaculous-effects' );
|
||||
wp_enqueue_script( 'scriptaculous-dragdrop' );
|
||||
|
||||
function wp_widgets_admin_head() {
|
||||
global $wp_registered_sidebars, $wp_registered_widgets, $wp_registered_widget_controls;
|
||||
|
||||
define( 'WP_WIDGETS_WIDTH', 1 + 262 * ( count( $wp_registered_sidebars ) ) );
|
||||
define( 'WP_WIDGETS_HEIGHT', 35 * ( count( $wp_registered_widgets ) ) );
|
||||
?>
|
||||
<link rel="stylesheet" href="widgets.css?version=<?php bloginfo('version'); ?>" type="text/css" />
|
||||
<style type="text/css">
|
||||
.dropzone ul { height: <?php echo constant( 'WP_WIDGETS_HEIGHT' ); ?>px; }
|
||||
#sbadmin #zones { width: <?php echo constant( 'WP_WIDGETS_WIDTH' ); ?>px; }
|
||||
</style>
|
||||
<?php
|
||||
if ( get_bloginfo( 'text_direction' ) == 'rtl' ) {
|
||||
?>
|
||||
<link rel="stylesheet" href="widgets-rtl.css?version=<?php bloginfo('version'); ?>" type="text/css" />
|
||||
<?php
|
||||
}
|
||||
|
||||
$cols = array();
|
||||
foreach ( $wp_registered_sidebars as $index => $sidebar ) {
|
||||
$cols[] = '\'' . $index . '\'';
|
||||
}
|
||||
$cols = implode( ', ', $cols );
|
||||
|
||||
$widgets = array();
|
||||
foreach ( $wp_registered_widgets as $name => $widget ) {
|
||||
$widgets[] = '\'' . $widget['id'] . '\'';
|
||||
}
|
||||
$widgets = implode( ', ', $widgets );
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
// <![CDATA[
|
||||
var cols = [<?php echo $cols; ?>];
|
||||
var widgets = [<?php echo $widgets; ?>];
|
||||
var controldims = new Array;
|
||||
<?php foreach ( $wp_registered_widget_controls as $name => $widget ) : ?>
|
||||
controldims['<?php echo $widget['id']; ?>control'] = new Array;
|
||||
controldims['<?php echo $widget['id']; ?>control']['width'] = <?php echo (int) $widget['width']; ?>;
|
||||
controldims['<?php echo $widget['id']; ?>control']['height'] = <?php echo (int) $widget['height']; ?>;
|
||||
<?php endforeach; ?>
|
||||
function initWidgets() {
|
||||
<?php foreach ( $wp_registered_widget_controls as $name => $widget ) : ?>
|
||||
$('<?php echo $widget['id']; ?>popper').onclick = function() {popControl('<?php echo $widget['id']; ?>control');};
|
||||
$('<?php echo $widget['id']; ?>closer').onclick = function() {unpopControl('<?php echo $widget['id']; ?>control');};
|
||||
new Draggable('<?php echo $widget['id']; ?>control', {revert:false,handle:'controlhandle',starteffect:function(){},endeffect:function(){},change:function(o){dragChange(o);}});
|
||||
if ( true && window.opera )
|
||||
$('<?php echo $widget['id']; ?>control').style.border = '1px solid #bbb';
|
||||
<?php endforeach; ?>
|
||||
if ( true && window.opera )
|
||||
$('shadow').style.background = 'transparent';
|
||||
new Effect.Opacity('shadow', {to:0.0});
|
||||
widgets.map(function(o) {o='widgetprefix-'+o; Position.absolutize(o); Position.relativize(o);} );
|
||||
$A(Draggables.drags).map(function(o) {o.startDrag(null); o.finishDrag(null);});
|
||||
for ( var n in Draggables.drags ) {
|
||||
if ( Draggables.drags[n].element.id == 'lastmodule' ) {
|
||||
Draggables.drags[n].destroy();
|
||||
break;
|
||||
}
|
||||
}
|
||||
resetPaletteHeight();
|
||||
}
|
||||
function resetDroppableHeights() {
|
||||
var max = 6;
|
||||
cols.map(function(o) {var c = $(o).childNodes.length; if ( c > max ) max = c;} );
|
||||
var height = 35 * ( max + 1);
|
||||
cols.map(function(o) {h = (($(o).childNodes.length + 1) * 35); $(o).style.height = (h > 280 ? h : 280) + 'px';} );
|
||||
}
|
||||
function resetPaletteHeight() {
|
||||
var p = $('palette'), pd = $('palettediv'), last = $('lastmodule');
|
||||
p.appendChild(last);
|
||||
if ( Draggables.activeDraggable && last.id == Draggables.activeDraggable.element.id )
|
||||
last = last.previousSibling;
|
||||
var y1 = Position.cumulativeOffset(last)[1] + last.offsetHeight;
|
||||
var y2 = Position.cumulativeOffset(pd)[1] + pd.offsetHeight;
|
||||
var dy = y1 - y2;
|
||||
pd.style.height = (pd.offsetHeight + dy + 9) + "px";
|
||||
}
|
||||
function maxHeight(elm) {
|
||||
htmlheight = document.body.parentNode.clientHeight;
|
||||
bodyheight = document.body.clientHeight;
|
||||
var height = htmlheight > bodyheight ? htmlheight : bodyheight;
|
||||
$(elm).style.height = height + 'px';
|
||||
}
|
||||
function dragChange(o) {
|
||||
el = o.element ? o.element : $(o);
|
||||
var p = Position.page(el);
|
||||
var right = p[0];
|
||||
var top = p[1];
|
||||
var left = $('shadow').offsetWidth - (el.offsetWidth + right);
|
||||
var bottom = $('shadow').offsetHeight - (el.offsetHeight + top);
|
||||
if ( right < 1 ) el.style.left = 0;
|
||||
if ( top < 1 ) el.style.top = 0;
|
||||
if ( left < 1 ) el.style.left = (left + right) + 'px';
|
||||
if ( bottom < 1 ) el.style.top = (top + bottom) + 'px';
|
||||
}
|
||||
function popControl(elm) {
|
||||
el = $(elm);
|
||||
el.style.width = controldims[elm]['width'] + 'px';
|
||||
el.style.height = controldims[elm]['height'] + 'px';
|
||||
var x = ( document.body.clientWidth - controldims[elm]['width'] ) / 2;
|
||||
var y = ( document.body.parentNode.clientHeight - controldims[elm]['height'] ) / 2;
|
||||
el.style.position = 'absolute';
|
||||
el.style.right = '' + x + 'px';
|
||||
el.style.top = '' + y + 'px';
|
||||
el.style.zIndex = 1000;
|
||||
el.className='control';
|
||||
$('shadow').onclick = function() {unpopControl(elm);};
|
||||
window.onresize = function(){maxHeight('shadow');dragChange(elm);};
|
||||
popShadow();
|
||||
}
|
||||
function popShadow() {
|
||||
maxHeight('shadow');
|
||||
var shadow = $('shadow');
|
||||
shadow.style.zIndex = 999;
|
||||
shadow.style.display = 'block';
|
||||
new Effect.Opacity('shadow', {duration:0.5, from:0.0, to:0.2});
|
||||
}
|
||||
function unpopShadow() {
|
||||
new Effect.Opacity('shadow', {to:0.0});
|
||||
$('shadow').style.display = 'none';
|
||||
}
|
||||
function unpopControl(el) {
|
||||
$(el).className='hidden';
|
||||
unpopShadow();
|
||||
}
|
||||
function serializeAll() {
|
||||
<?php foreach ( $wp_registered_sidebars as $index => $sidebar ) : ?>
|
||||
$('<?php echo $index; ?>order').value = Sortable.serialize('<?php echo $index; ?>');
|
||||
<?php endforeach; ?>
|
||||
}
|
||||
function updateAll() {
|
||||
resetDroppableHeights();
|
||||
resetPaletteHeight();
|
||||
cols.map(function(o){
|
||||
var pm = $(o+'placematt');
|
||||
if ( $(o).childNodes.length == 0 ) {
|
||||
pm.style.display = 'block';
|
||||
Position.absolutize(o+'placematt');
|
||||
} else {
|
||||
pm.style.display = 'none';
|
||||
}
|
||||
});
|
||||
}
|
||||
function noSelection(event) {
|
||||
if ( document.selection ) {
|
||||
var range = document.selection.createRange();
|
||||
range.collapse(false);
|
||||
range.select();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
addLoadEvent(updateAll);
|
||||
addLoadEvent(initWidgets);
|
||||
Event.observe(window, 'resize', resetPaletteHeight);
|
||||
// ]]>
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
add_action( 'admin_head', 'wp_widgets_admin_head' );
|
||||
do_action( 'sidebar_admin_setup' );
|
||||
|
||||
function wp_widget_draggable( $name ) {
|
||||
global $wp_registered_widgets, $wp_registered_widget_controls;
|
||||
|
||||
if ( !isset( $wp_registered_widgets[$name] ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$sanitized_name = sanitize_title( $wp_registered_widgets[$name]['id'] );
|
||||
$link_title = __( 'Configure' );
|
||||
$popper = ( isset( $wp_registered_widget_controls[$name] ) )
|
||||
? ' <div class="popper" id="' . $sanitized_name . 'popper" title="' . $link_title . '">≡</div>'
|
||||
: '';
|
||||
|
||||
$output = '<li class="module" id="widgetprefix-%1$s"><span class="handle">%2$s</span></li>';
|
||||
|
||||
printf( $output, $sanitized_name, $wp_registered_widgets[$name]['name'] . $popper );
|
||||
}
|
||||
|
||||
$title = __( 'Widgets' );
|
||||
$parent_file = 'themes.php';
|
||||
|
||||
require_once 'admin-header.php';
|
||||
|
||||
if ( count( $wp_registered_sidebars ) < 1 ) {
|
||||
?>
|
||||
<div class="wrap">
|
||||
<h2><?php _e( 'No Sidebars Defined' ); ?></h2>
|
||||
|
||||
<p><?php _e( 'You are seeing this message because the theme you are currently using isn’t widget-aware, meaning that it has no sidebars that you are able to change. For information on making your theme widget-aware, please <a href="http://automattic.com/code/widgets/themes/">follow these instructions</a>.' ); /* TODO: article on codex */; ?></p>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
require_once 'admin-footer.php';
|
||||
exit;
|
||||
}
|
||||
|
||||
$sidebars_widgets = wp_get_sidebars_widgets();
|
||||
|
||||
if ( empty( $sidebars_widgets ) ) {
|
||||
$sidebars_widgets = wp_get_widget_defaults();
|
||||
}
|
||||
|
||||
if ( isset( $_POST['action'] ) ) {
|
||||
check_admin_referer( 'widgets-save-widget-order' );
|
||||
|
||||
switch ( $_POST['action'] ) {
|
||||
case 'default' :
|
||||
$sidebars_widgets = wp_get_widget_defaults();
|
||||
wp_set_sidebars_widgets( $sidebars_widgets );
|
||||
break;
|
||||
|
||||
case 'save_widget_order' :
|
||||
$sidebars_widgets = array();
|
||||
|
||||
foreach ( $wp_registered_sidebars as $index => $sidebar ) {
|
||||
$postindex = $index . 'order';
|
||||
|
||||
parse_str( $_POST[$postindex], $order );
|
||||
|
||||
$new_order = $order[$index];
|
||||
|
||||
if ( is_array( $new_order ) ) {
|
||||
foreach ( $new_order as $sanitized_name ) {
|
||||
foreach ( $wp_registered_widgets as $name => $widget ) {
|
||||
if ( $sanitized_name == $widget['id'] ) {
|
||||
$sidebars_widgets[$index][] = $name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wp_set_sidebars_widgets( $sidebars_widgets );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ksort( $wp_registered_widgets );
|
||||
|
||||
$inactive_widgets = array();
|
||||
|
||||
foreach ( $wp_registered_widgets as $name => $widget ) {
|
||||
$is_active = false;
|
||||
|
||||
foreach ( $wp_registered_sidebars as $index => $sidebar ) {
|
||||
if ( is_array( $sidebars_widgets[$index] ) && in_array( $name, $sidebars_widgets[$index] ) ) {
|
||||
$is_active = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !$is_active ) {
|
||||
$inactive_widgets[] = $name;
|
||||
}
|
||||
}
|
||||
|
||||
$containers = array( 'palette' );
|
||||
|
||||
foreach ( $wp_registered_sidebars as $index => $sidebar ) {
|
||||
$containers[] = $index;
|
||||
}
|
||||
|
||||
$c_string = '';
|
||||
|
||||
foreach ( $containers as $container ) {
|
||||
$c_string .= '"' . $container . '",';
|
||||
}
|
||||
|
||||
$c_string = substr( $c_string, 0, -1 );
|
||||
|
||||
if ( isset( $_POST['action'] ) ) {
|
||||
?>
|
||||
<div class="fade updated" id="message">
|
||||
<p><?php printf( __( 'Sidebar updated. <a href="%s">View site »</a>' ), get_bloginfo( 'url' ) . '/' ); ?></p>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<div class="wrap">
|
||||
<h2><?php _e( 'Sidebar Arrangement' ); ?></h2>
|
||||
|
||||
<p><?php _e( 'You can drag and drop widgets onto your sidebar below.' ); ?></p>
|
||||
|
||||
<form id="sbadmin" method="post" onsubmit="serializeAll();">
|
||||
<div id="zones">
|
||||
<?php
|
||||
foreach ( $wp_registered_sidebars as $index => $sidebar ) {
|
||||
?>
|
||||
<input type="hidden" id="<?php echo $index; ?>order" name="<?php echo $index; ?>order" value="" />
|
||||
|
||||
<div class="dropzone">
|
||||
<h3><?php echo $sidebar['name']; ?></h3>
|
||||
|
||||
<div id="<?php echo $index; ?>placematt" class="module placematt">
|
||||
<span class="handle">
|
||||
<h4><?php _e( 'Default Sidebar' ); ?></h4>
|
||||
<?php _e( 'Your theme will display its usual sidebar when this box is empty. Dragging widgets into this box will replace the usual sidebar with your customized sidebar.' ); ?>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<ul id="<?php echo $index; ?>">
|
||||
<?php
|
||||
if ( is_array( $sidebars_widgets[$index] ) ) {
|
||||
foreach ( $sidebars_widgets[$index] as $name ) {
|
||||
wp_widget_draggable( $name );
|
||||
}
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<br class="clear" />
|
||||
|
||||
</div>
|
||||
|
||||
<div id="palettediv">
|
||||
<h3><?php _e( 'Available Widgets' ); ?></h3>
|
||||
|
||||
<ul id="palette">
|
||||
<?php
|
||||
foreach ( $inactive_widgets as $name ) {
|
||||
wp_widget_draggable( $name );
|
||||
}
|
||||
?>
|
||||
<li id="lastmodule"><span></span></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
// <![CDATA[
|
||||
<?php foreach ( $containers as $container ) { ?>
|
||||
Sortable.create("<?php echo $container; ?>", {
|
||||
dropOnEmpty: true, containment: [<?php echo $c_string; ?>],
|
||||
handle: 'handle', constraint: false, onUpdate: updateAll,
|
||||
format: /^widgetprefix-(.*)$/
|
||||
});
|
||||
<?php } ?>
|
||||
// ]]>
|
||||
</script>
|
||||
|
||||
<p class="submit">
|
||||
<?php wp_nonce_field( 'widgets-save-widget-order' ); ?>
|
||||
<input type="hidden" name="action" id="action" value="save_widget_order" />
|
||||
<input type="submit" value="<?php _e( 'Save Changes »' ); ?>" />
|
||||
</p>
|
||||
|
||||
<div id="controls">
|
||||
<?php foreach ( $wp_registered_widget_controls as $name => $widget ) { ?>
|
||||
<div class="hidden" id="<?php echo $widget['id']; ?>control">
|
||||
<span class="controlhandle"><?php echo $widget['name']; ?></span>
|
||||
<span id="<?php echo $widget['id']; ?>closer" class="controlcloser">×</span>
|
||||
<div class="controlform">
|
||||
<?php call_user_func_array( $widget['callback'], $widget['params'] ); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<br class="clear" />
|
||||
</div>
|
||||
|
||||
<div id="shadow"> </div>
|
||||
|
||||
<?php do_action( 'sidebar_admin_page' ); ?>
|
||||
|
||||
<?php require_once 'admin-footer.php'; ?>
|
||||
@@ -538,7 +538,7 @@ input.disabled, textarea.disabled {
|
||||
border: none;
|
||||
}
|
||||
|
||||
#postdiv, #titlediv, #guiddiv, #tagdiv {
|
||||
#postdiv, #titlediv, #guiddiv {
|
||||
margin: 0 8px 0 0;
|
||||
padding: 0;
|
||||
}
|
||||
@@ -558,7 +558,7 @@ input.disabled, textarea.disabled {
|
||||
line-height: 140%;
|
||||
}
|
||||
|
||||
#titlediv input, #guiddiv input, #tagdiv input {
|
||||
#titlediv input, #guiddiv input {
|
||||
margin: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ if ( !file_exists( dirname(__FILE__) . '/wp-config.php') ) {
|
||||
|
||||
require_once( dirname(__FILE__) . '/wp-includes/classes.php');
|
||||
require_once( dirname(__FILE__) . '/wp-includes/functions.php');
|
||||
require_once( dirname(__FILE__) . '/wp-includes/plugin.php');
|
||||
wp_die("There doesn't seem to be a <code>wp-config.php</code> file. I need this before we can get started. Need more help? <a href='http://codex.wordpress.org/Editing_wp-config.php'>We got it</a>. You can <a href='{$path}setup-config.php'>create a <code>wp-config.php</code> file through a web interface</a>, but this doesn't work for all server setups. The safest way is to manually create the file.", "WordPress › Error");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
<?php
|
||||
// ** MySQL settings ** //
|
||||
define('DB_NAME', 'putyourdbnamehere'); // The name of the database
|
||||
define('DB_USER', 'usernamehere'); // Your MySQL username
|
||||
define('DB_PASSWORD', 'yourpasswordhere'); // ...and password
|
||||
define('DB_HOST', 'localhost'); // 99% chance you won't need to change this value
|
||||
define('DB_CHARSET', 'utf8');
|
||||
define('DB_COLLATE', '');
|
||||
|
||||
// You can have multiple installations in one database if you give each a unique prefix
|
||||
$table_prefix = 'wp_'; // Only numbers, letters, and underscores please!
|
||||
|
||||
// Change this to localize WordPress. A corresponding MO file for the
|
||||
// chosen language must be installed to wp-content/languages.
|
||||
// For example, install de.mo to wp-content/languages and set WPLANG to 'de'
|
||||
// to enable German language support.
|
||||
define ('WPLANG', '');
|
||||
|
||||
/* That's all, stop editing! Happy blogging. */
|
||||
|
||||
define('ABSPATH', dirname(__FILE__).'/');
|
||||
require_once(ABSPATH.'wp-settings.php');
|
||||
?>
|
||||
<?php
|
||||
// ** MySQL settings ** //
|
||||
define('DB_NAME', 'putyourdbnamehere'); // The name of the database
|
||||
define('DB_USER', 'usernamehere'); // Your MySQL username
|
||||
define('DB_PASSWORD', 'yourpasswordhere'); // ...and password
|
||||
define('DB_HOST', 'localhost'); // 99% chance you won't need to change this value
|
||||
define('DB_CHARSET', 'utf8');
|
||||
define('DB_COLLATE', '');
|
||||
|
||||
// You can have multiple installations in one database if you give each a unique prefix
|
||||
$table_prefix = 'wp_'; // Only numbers, letters, and underscores please!
|
||||
|
||||
// Change this to localize WordPress. A corresponding MO file for the
|
||||
// chosen language must be installed to wp-content/languages.
|
||||
// For example, install de.mo to wp-content/languages and set WPLANG to 'de'
|
||||
// to enable German language support.
|
||||
define ('WPLANG', '');
|
||||
|
||||
/* That's all, stop editing! Happy blogging. */
|
||||
|
||||
define('ABSPATH', dirname(__FILE__).'/');
|
||||
require_once(ABSPATH.'wp-settings.php');
|
||||
?>
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
<?php
|
||||
// Silence is golden.
|
||||
<?php
|
||||
// Silence is golden.
|
||||
?>
|
||||
@@ -8,7 +8,7 @@ get_header();
|
||||
|
||||
<div class="post" id="post-<?php the_ID(); ?>">
|
||||
<h3 class="storytitle"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3>
|
||||
<div class="meta"><?php _e("Filed under:"); ?> <?php the_category(',') ?> — <?php the_tags(__('Tags: '), ', ', ' — '); ?> <?php the_author() ?> @ <?php the_time() ?> <?php edit_post_link(__('Edit This')); ?></div>
|
||||
<div class="meta"><?php _e("Filed under:"); ?> <?php the_category(',') ?> — <?php the_author() ?> @ <?php the_time() ?> <?php edit_post_link(__('Edit This')); ?></div>
|
||||
|
||||
<div class="storycontent">
|
||||
<?php the_content(__('(more...)')); ?>
|
||||
|
||||
@@ -1,25 +1,29 @@
|
||||
<?php get_header(); ?>
|
||||
|
||||
<div id="content" class="narrowcolumn">
|
||||
<?php is_tag(); ?>
|
||||
|
||||
<?php if (have_posts()) : ?>
|
||||
|
||||
<?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
|
||||
<?php /* If this is a category archive */ if (is_category()) { ?>
|
||||
<?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
|
||||
<?php /* If this is a category archive */ if (is_category()) { ?>
|
||||
<h2 class="pagetitle">Archive for the ‘<?php single_cat_title(); ?>’ Category</h2>
|
||||
<?php /* If this is a tag archive */ } elseif( is_tag() ) { ?>
|
||||
<h2 class="pagetitle">Posts Tagged ‘<?php single_cat_title(); ?>’</h2>
|
||||
|
||||
<?php /* If this is a daily archive */ } elseif (is_day()) { ?>
|
||||
<h2 class="pagetitle">Archive for <?php the_time('F jS, Y'); ?></h2>
|
||||
<?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
|
||||
|
||||
<?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
|
||||
<h2 class="pagetitle">Archive for <?php the_time('F, Y'); ?></h2>
|
||||
<?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
|
||||
|
||||
<?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
|
||||
<h2 class="pagetitle">Archive for <?php the_time('Y'); ?></h2>
|
||||
|
||||
<?php /* If this is an author archive */ } elseif (is_author()) { ?>
|
||||
<h2 class="pagetitle">Author Archive</h2>
|
||||
<?php /* If this is a paged archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?>
|
||||
|
||||
<?php /* If this is a paged archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?>
|
||||
<h2 class="pagetitle">Blog Archives</h2>
|
||||
<?php } ?>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
|
||||
<div class="navigation">
|
||||
@@ -36,7 +40,7 @@
|
||||
<?php the_content() ?>
|
||||
</div>
|
||||
|
||||
<p class="postmetadata"><?php the_tags('Tags: ', ', ', '<br />'); ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?> <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p>
|
||||
<p class="postmetadata">Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?> <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
if ($_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password) { // and it doesn't match the cookie
|
||||
?>
|
||||
|
||||
<p class="nocomments">This post is password protected. Enter the password to view comments.<p>
|
||||
<p class="nocomments">This post is password protected. Enter the password to view comments.</p>
|
||||
|
||||
<?php
|
||||
return;
|
||||
|
||||
@@ -82,6 +82,7 @@ add_action('admin_menu', 'kubrick_add_theme_page');
|
||||
function kubrick_add_theme_page() {
|
||||
if ( $_GET['page'] == basename(__FILE__) ) {
|
||||
if ( 'save' == $_REQUEST['action'] ) {
|
||||
check_admin_referer('kubrick-header');
|
||||
if ( isset($_REQUEST['njform']) ) {
|
||||
if ( isset($_REQUEST['defaults']) ) {
|
||||
delete_option('kubrick_header_image');
|
||||
@@ -90,13 +91,14 @@ function kubrick_add_theme_page() {
|
||||
} else {
|
||||
if ( '' == $_REQUEST['njfontcolor'] )
|
||||
delete_option('kubrick_header_color');
|
||||
else
|
||||
update_option('kubrick_header_color', $_REQUEST['njfontcolor']);
|
||||
|
||||
else {
|
||||
$fontcolor = preg_replace('/^.*(#[0-9a-fA-F]{6})?.*$/', '$1', $_REQUEST['njfontcolor']);
|
||||
update_option('kubrick_header_color', $fontcolor);
|
||||
}
|
||||
if ( preg_match('/[0-9A-F]{6}|[0-9A-F]{3}/i', $_REQUEST['njuppercolor'], $uc) && preg_match('/[0-9A-F]{6}|[0-9A-F]{3}/i', $_REQUEST['njlowercolor'], $lc) ) {
|
||||
$uc = ( strlen($uc[0]) == 3 ) ? $uc[0]{0}.$uc[0]{0}.$uc[0]{1}.$uc[0]{1}.$uc[0]{2}.$uc[0]{2} : $uc[0];
|
||||
$lc = ( strlen($lc[0]) == 3 ) ? $lc[0]{0}.$lc[0]{0}.$lc[0]{1}.$lc[0]{1}.$lc[0]{2}.$lc[0]{2} : $lc[0];
|
||||
update_option('kubrick_header_image', "header-img.php?upper=$uc&lower=$lc");
|
||||
update_option('kubrick_header_image', "header-img.php?upper=$uc&lower=$lc");
|
||||
}
|
||||
|
||||
if ( isset($_REQUEST['toggledisplay']) ) {
|
||||
@@ -109,20 +111,27 @@ function kubrick_add_theme_page() {
|
||||
} else {
|
||||
|
||||
if ( isset($_REQUEST['headerimage']) ) {
|
||||
check_admin_referer('kubrick-header');
|
||||
if ( '' == $_REQUEST['headerimage'] )
|
||||
delete_option('kubrick_header_image');
|
||||
else
|
||||
update_option('kubrick_header_image', $_REQUEST['headerimage']);
|
||||
else {
|
||||
$headerimage = preg_replace('/^.*?(header-img.php\?upper=[0-9a-fA-F]{6}&lower=[0-9a-fA-F]{6})?.*$/', '$1', $_REQUEST['headerimage']);
|
||||
update_option('kubrick_header_image', $headerimage);
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset($_REQUEST['fontcolor']) ) {
|
||||
check_admin_referer('kubrick-header');
|
||||
if ( '' == $_REQUEST['fontcolor'] )
|
||||
delete_option('kubrick_header_color');
|
||||
else
|
||||
update_option('kubrick_header_color', $_REQUEST['fontcolor']);
|
||||
else {
|
||||
$fontcolor = preg_replace('/^.*?(#[0-9a-fA-F]{6})?.*$/', '$1', $_REQUEST['fontcolor']);
|
||||
update_option('kubrick_header_color', $fontcolor);
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset($_REQUEST['fontdisplay']) ) {
|
||||
check_admin_referer('kubrick-header');
|
||||
if ( '' == $_REQUEST['fontdisplay'] || 'inline' == $_REQUEST['fontdisplay'] )
|
||||
delete_option('kubrick_header_display');
|
||||
else
|
||||
@@ -135,7 +144,7 @@ function kubrick_add_theme_page() {
|
||||
}
|
||||
add_action('admin_head', 'kubrick_theme_page_head');
|
||||
}
|
||||
add_theme_page('Customize Header', 'Header Image and Color', 'edit_themes', basename(__FILE__), 'kubrick_theme_page');
|
||||
add_theme_page(__('Customize Header'), __('Header Image and Color'), 'edit_themes', basename(__FILE__), 'kubrick_theme_page');
|
||||
}
|
||||
|
||||
function kubrick_theme_page_head() {
|
||||
@@ -148,7 +157,7 @@ function kubrick_theme_page_head() {
|
||||
kUpdate(ColorPicker_targetInput.id);
|
||||
}
|
||||
function PopupWindow_populate(contents) {
|
||||
contents += '<br /><p style="text-align:center;margin-top:0px;"><input type="button" value="Close Color Picker" onclick="cp.hidePopup(\'prettyplease\')"></input></p>';
|
||||
contents += '<br /><p style="text-align:center;margin-top:0px;"><input type="button" value="<?php echo attribute_escape(__('Close Color Picker')); ?>" onclick="cp.hidePopup(\'prettyplease\')"></input></p>';
|
||||
this.contents = contents;
|
||||
this.populated = false;
|
||||
}
|
||||
@@ -233,13 +242,13 @@ function kubrick_theme_page_head() {
|
||||
document.getElementById('headerimg').style.display = document.getElementById('fontdisplay').value;
|
||||
}
|
||||
function kRevert() {
|
||||
document.getElementById('headerimage').value = '<?php echo kubrick_header_image(); ?>';
|
||||
document.getElementById('advuppercolor').value = document.getElementById('uppercolor').value = '#<?php echo kubrick_upper_color(); ?>';
|
||||
document.getElementById('advlowercolor').value = document.getElementById('lowercolor').value = '#<?php echo kubrick_lower_color(); ?>';
|
||||
document.getElementById('header').style.background = 'url("<?php echo kubrick_header_image_url(); ?>") center no-repeat';
|
||||
document.getElementById('headerimage').value = '<?php echo js_escape(kubrick_header_image()); ?>';
|
||||
document.getElementById('advuppercolor').value = document.getElementById('uppercolor').value = '#<?php echo js_escape(kubrick_upper_color()); ?>';
|
||||
document.getElementById('advlowercolor').value = document.getElementById('lowercolor').value = '#<?php echo js_escape(kubrick_lower_color()); ?>';
|
||||
document.getElementById('header').style.background = 'url("<?php echo js_escape(kubrick_header_image_url()); ?>") center no-repeat';
|
||||
document.getElementById('header').style.color = '';
|
||||
document.getElementById('advfontcolor').value = document.getElementById('fontcolor').value = '<?php echo kubrick_header_color_string(); ?>';
|
||||
document.getElementById('fontdisplay').value = '<?php echo kubrick_header_display_string(); ?>';
|
||||
document.getElementById('advfontcolor').value = document.getElementById('fontcolor').value = '<?php echo js_escape(kubrick_header_color_string()); ?>';
|
||||
document.getElementById('fontdisplay').value = '<?php echo js_escape(kubrick_header_display_string()); ?>';
|
||||
document.getElementById('headerimg').style.display = document.getElementById('fontdisplay').value;
|
||||
}
|
||||
function kInit() {
|
||||
@@ -345,11 +354,11 @@ function kubrick_theme_page_head() {
|
||||
}
|
||||
|
||||
function kubrick_theme_page() {
|
||||
if ( $_REQUEST['saved'] ) echo '<div id="message" class="updated fade"><p><strong>Options saved.</strong></p></div>';
|
||||
if ( $_REQUEST['saved'] ) echo '<div id="message" class="updated fade"><p><strong>'.__('Options saved.').'</strong></p></div>';
|
||||
?>
|
||||
<div class='wrap'>
|
||||
<div id="kubrick-header">
|
||||
<h2>Header Image and Color</h2>
|
||||
<h2><?php _e('Header Image and Color'); ?></h2>
|
||||
<div id="headwrap">
|
||||
<div id="header">
|
||||
<div id="headerimg">
|
||||
@@ -361,41 +370,44 @@ function kubrick_theme_page() {
|
||||
<br />
|
||||
<div id="nonJsForm">
|
||||
<form method="post" action="">
|
||||
<div class="zerosize"><input type="submit" name="defaultsubmit" value="Save" /></div>
|
||||
<label for="njfontcolor">Font Color:</label><input type="text" name="njfontcolor" id="njfontcolor" value="<?php echo kubrick_header_color(); ?>" /> Any CSS color (<code>red</code> or <code>#FF0000</code> or <code>rgb(255, 0, 0)</code>)<br />
|
||||
<label for="njuppercolor">Upper Color:</label><input type="text" name="njuppercolor" id="njuppercolor" value="#<?php echo kubrick_upper_color(); ?>" /> HEX only (<code>#FF0000</code> or <code>#F00</code>)<br />
|
||||
<label for="njlowercolor">Lower Color:</label><input type="text" name="njlowercolor" id="njlowercolor" value="#<?php echo kubrick_lower_color(); ?>" /> HEX only (<code>#FF0000</code> or <code>#F00</code>)<br />
|
||||
<input type="hidden" name="hi" id="hi" value="<?php echo kubrick_header_image(); ?>" />
|
||||
<input type="submit" name="toggledisplay" id="toggledisplay" value="Toggle Text" />
|
||||
<input type="submit" name="defaults" value="Use Defaults" />
|
||||
<input type="submit" class="defbutton" name="submitform" value=" Save " />
|
||||
<?php wp_nonce_field('kubrick-header'); ?>
|
||||
<div class="zerosize"><input type="submit" name="defaultsubmit" value="<?php echo attribute_escape(__('Save')); ?>" /></div>
|
||||
<label for="njfontcolor"><?php _e('Font Color:'); ?></label><input type="text" name="njfontcolor" id="njfontcolor" value="<?php echo attribute_escape(kubrick_header_color()); ?>" /> <?php printf(__('Any CSS color (%s or %s or %s)'), '<code>red</code>', '<code>#FF0000</code>', '<code>rgb(255, 0, 0)</code>'); ?><br />
|
||||
<label for="njuppercolor"><?php _e('Upper Color:'); ?></label><input type="text" name="njuppercolor" id="njuppercolor" value="#<?php echo attribute_escape(kubrick_upper_color()); ?>" /> <?php printf(__('HEX only (%s or %s)'), '<code>#FF0000</code>', '<code>#F00</code>'); ?><br />
|
||||
<label for="njlowercolor"><?php _e('Lower Color:'); ?></label><input type="text" name="njlowercolor" id="njlowercolor" value="#<?php echo attribute_escape(kubrick_lower_color()); ?>" /> <?php printf(__('HEX only (%s or %s)'), '<code>#FF0000</code>', '<code>#F00</code>'); ?><br />
|
||||
<input type="hidden" name="hi" id="hi" value="<?php echo attribute_escape(kubrick_header_image()); ?>" />
|
||||
<input type="submit" name="toggledisplay" id="toggledisplay" value="<?php echo attribute_escape(__('Toggle Text')); ?>" />
|
||||
<input type="submit" name="defaults" value="<?php echo attribute_escape(__('Use Defaults')); ?>" />
|
||||
<input type="submit" class="defbutton" name="submitform" value=" <?php _e('Save'); ?> " />
|
||||
<input type="hidden" name="action" value="save" />
|
||||
<input type="hidden" name="njform" value="true" />
|
||||
</form>
|
||||
</div>
|
||||
<div id="jsForm">
|
||||
<form style="display:inline;" method="post" name="hicolor" id="hicolor" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
|
||||
<input type="button" onclick="tgt=document.getElementById('fontcolor');colorSelect(tgt,'pick1');return false;" name="pick1" id="pick1" value="Font Color"></input>
|
||||
<input type="button" onclick="tgt=document.getElementById('uppercolor');colorSelect(tgt,'pick2');return false;" name="pick2" id="pick2" value="Upper Color"></input>
|
||||
<input type="button" onclick="tgt=document.getElementById('lowercolor');colorSelect(tgt,'pick3');return false;" name="pick3" id="pick3" value="Lower Color"></input>
|
||||
<input type="button" name="revert" value="Revert" onclick="kRevert()" />
|
||||
<input type="button" value="Advanced" onclick="toggleAdvanced()" />
|
||||
<?php wp_nonce_field('kubrick-header'); ?>
|
||||
<input type="button" onclick="tgt=document.getElementById('fontcolor');colorSelect(tgt,'pick1');return false;" name="pick1" id="pick1" value="<?php echo attribute_escape(__('Font Color')); ?>"></input>
|
||||
<input type="button" onclick="tgt=document.getElementById('uppercolor');colorSelect(tgt,'pick2');return false;" name="pick2" id="pick2" value="<?php echo attribute_escape(__('Upper Color')); ?>"></input>
|
||||
<input type="button" onclick="tgt=document.getElementById('lowercolor');colorSelect(tgt,'pick3');return false;" name="pick3" id="pick3" value="<?php echo attribute_escape(__('Lower Color')); ?>"></input>
|
||||
<input type="button" name="revert" value="<?php echo attribute_escape(__('Revert')); ?>" onclick="kRevert()" />
|
||||
<input type="button" value="<?php echo attribute_escape(__('Advanced')); ?>" onclick="toggleAdvanced()" />
|
||||
<input type="hidden" name="action" value="save" />
|
||||
<input type="hidden" name="fontdisplay" id="fontdisplay" value="<?php echo kubrick_header_display(); ?>" />
|
||||
<input type="hidden" name="fontcolor" id="fontcolor" value="<?php echo kubrick_header_color(); ?>" />
|
||||
<input type="hidden" name="uppercolor" id="uppercolor" value="<?php echo kubrick_upper_color(); ?>" />
|
||||
<input type="hidden" name="lowercolor" id="lowercolor" value="<?php echo kubrick_lower_color(); ?>" />
|
||||
<input type="hidden" name="headerimage" id="headerimage" value="<?php echo kubrick_header_image(); ?>" />
|
||||
<p class="submit"><input type="submit" name="submitform" class="defbutton" value="<?php _e('Update Header »'); ?>" onclick="cp.hidePopup('prettyplease')" /></p>
|
||||
<input type="hidden" name="fontdisplay" id="fontdisplay" value="<?php echo attribute_escape(kubrick_header_display()); ?>" />
|
||||
<input type="hidden" name="fontcolor" id="fontcolor" value="<?php echo attribute_escape(kubrick_header_color()); ?>" />
|
||||
<input type="hidden" name="uppercolor" id="uppercolor" value="<?php echo attribute_escape(kubrick_upper_color()); ?>" />
|
||||
<input type="hidden" name="lowercolor" id="lowercolor" value="<?php echo attribute_escape(kubrick_lower_color()); ?>" />
|
||||
<input type="hidden" name="headerimage" id="headerimage" value="<?php echo attribute_escape(kubrick_header_image()); ?>" />
|
||||
<p class="submit"><input type="submit" name="submitform" class="defbutton" value="<?php echo attribute_escape(__('Update Header »')); ?>" onclick="cp.hidePopup('prettyplease')" /></p>
|
||||
</form>
|
||||
<div id="colorPickerDiv" style="z-index: 100;background:#eee;border:1px solid #ccc;position:absolute;visibility:hidden;"> </div>
|
||||
<div id="advanced">
|
||||
<form id="jsAdvanced" style="display:none;" action="">
|
||||
<label for="advfontcolor">Font Color (CSS): </label><input type="text" id="advfontcolor" onchange="advUpdate(this.value, 'fontcolor')" value="<?php echo kubrick_header_color(); ?>" /><br />
|
||||
<label for="advuppercolor">Upper Color (HEX): </label><input type="text" id="advuppercolor" onchange="advUpdate(this.value, 'uppercolor')" value="#<?php echo kubrick_upper_color(); ?>" /><br />
|
||||
<label for="advlowercolor">Lower Color (HEX): </label><input type="text" id="advlowercolor" onchange="advUpdate(this.value, 'lowercolor')" value="#<?php echo kubrick_lower_color(); ?>" /><br />
|
||||
<input type="button" name="default" value="Select Default Colors" onclick="kDefaults()" /><br />
|
||||
<input type="button" onclick="toggleDisplay();return false;" name="pick" id="pick" value="Toggle Text Display"></input><br />
|
||||
<?php wp_nonce_field('kubrick-header'); ?>
|
||||
<label for="advfontcolor"><?php _e('Font Color (CSS):'); ?> </label><input type="text" id="advfontcolor" onchange="advUpdate(this.value, 'fontcolor')" value="<?php echo attribute_escape(kubrick_header_color()); ?>" /><br />
|
||||
<label for="advuppercolor"><?php _e('Upper Color (HEX):');?> </label><input type="text" id="advuppercolor" onchange="advUpdate(this.value, 'uppercolor')" value="#<?php echo attribute_escape(kubrick_upper_color()); ?>" /><br />
|
||||
<label for="advlowercolor"><?php _e('Lower Color (HEX):'); ?> </label><input type="text" id="advlowercolor" onchange="advUpdate(this.value, 'lowercolor')" value="#<?php echo attribute_escape(kubrick_lower_color()); ?>" /><br />
|
||||
<input type="button" name="default" value="<?php echo attribute_escape(__('Select Default Colors')); ?>" onclick="kDefaults()" /><br />
|
||||
<input type="button" onclick="toggleDisplay();return false;" name="pick" id="pick" value="<?php echo attribute_escape(__('Toggle Text Display')); ?>"></input><br />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<?php the_content('Read the rest of this entry »'); ?>
|
||||
</div>
|
||||
|
||||
<p class="postmetadata"><?php the_tags('Tags: ', ', ', '<br />'); ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?> <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p>
|
||||
<p class="postmetadata">Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?> <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p>
|
||||
</div>
|
||||
|
||||
<?php endwhile; ?>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<h3 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h3>
|
||||
<small><?php the_time('l, F jS, Y') ?></small>
|
||||
|
||||
<p class="postmetadata"><?php the_tags('Tags: ', ', ', '<br />'); ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?> <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p>
|
||||
<p class="postmetadata">Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?> <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p>
|
||||
</div>
|
||||
|
||||
<?php endwhile; ?>
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
<?php the_content('<p class="serif">Read the rest of this entry »</p>'); ?>
|
||||
|
||||
<?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
|
||||
<?php the_tags( '<p>Tags: ', ', ', '</p>'); ?>
|
||||
|
||||
<p class="postmetadata alt">
|
||||
<small>
|
||||
|
||||
@@ -272,90 +272,6 @@ function wp_list_categories($args = '') {
|
||||
echo apply_filters('wp_list_categories', $output);
|
||||
}
|
||||
|
||||
function wp_tag_cloud( $args = '' ) {
|
||||
$defaults = array(
|
||||
'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45,
|
||||
'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC',
|
||||
'exclude' => '', 'include' => ''
|
||||
);
|
||||
$args = wp_parse_args( $args, $defaults );
|
||||
|
||||
$tags = get_tags( array_merge($args, array('orderby' => 'count', 'order' => 'DESC')) ); // Always query top tags
|
||||
|
||||
if ( empty($tags) )
|
||||
return;
|
||||
|
||||
$return = wp_generate_tag_cloud( $tags, $args ); // Here's where those top tags get sorted according to $args
|
||||
echo apply_filters( 'wp_tag_cloud', $return, $args );
|
||||
}
|
||||
|
||||
// $tags = prefetched tag array ( get_tags() )
|
||||
// $args['format'] = 'flat' => whitespace separated, 'list' => UL, 'array' => array()
|
||||
// $args['orderby'] = 'name', 'count'
|
||||
function wp_generate_tag_cloud( $tags, $args = '' ) {
|
||||
global $wp_rewrite;
|
||||
$defaults = array(
|
||||
'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45,
|
||||
'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC'
|
||||
);
|
||||
$args = wp_parse_args( $args, $defaults );
|
||||
extract($args);
|
||||
|
||||
if ( !$tags )
|
||||
return;
|
||||
$counts = $tag_links = array();
|
||||
foreach ( (array) $tags as $tag ) {
|
||||
$counts[$tag->cat_name] = $tag->tag_count;
|
||||
$tag_links[$tag->cat_name] = get_tag_link( $tag->cat_ID );
|
||||
}
|
||||
|
||||
$min_count = min($counts);
|
||||
$spread = max($counts) - $min_count;
|
||||
if ( $spread <= 0 )
|
||||
$spread = 1;
|
||||
$font_spread = $largest - $smallest;
|
||||
if ( $font_spread <= 0 )
|
||||
$font_spread = 1;
|
||||
$font_step = $font_spread / $spread;
|
||||
|
||||
// SQL cannot save you; this is a second (potentially different) sort on a subset of data.
|
||||
if ( 'name' == $orderby )
|
||||
uksort($counts, 'strnatcasecmp');
|
||||
else
|
||||
asort($counts);
|
||||
|
||||
if ( 'DESC' == $order )
|
||||
$counts = array_reverse( $tag_counts, true );
|
||||
|
||||
$a = array();
|
||||
|
||||
$rel = ( is_object($wp_rewrite) && $wp_rewrite->using_permalinks() ) ? ' rel="tag"' : '';
|
||||
|
||||
foreach ( $counts as $tag => $count ) {
|
||||
$tag_link = clean_url($tag_links[$tag]);
|
||||
$tag = str_replace(' ', ' ', wp_specialchars( $tag ));
|
||||
$a[] = "<a href='$tag_link' title='" . attribute_escape( sprintf( __('%d topics'), $count ) ) . "'$rel style='font-size: " .
|
||||
( $smallest + ( ( $count - $min_count ) * $font_step ) )
|
||||
. "$unit;'>$tag</a>";
|
||||
}
|
||||
|
||||
switch ( $format ) :
|
||||
case 'array' :
|
||||
$return =& $a;
|
||||
break;
|
||||
case 'list' :
|
||||
$return = "<ul class='wp-tag-cloud'>\n\t<li>";
|
||||
$return .= join("</li>\n\t<li>", $a);
|
||||
$return .= "</li>\n</ul>\n";
|
||||
break;
|
||||
default :
|
||||
$return = join("\n", $a);
|
||||
break;
|
||||
endswitch;
|
||||
|
||||
return apply_filters( 'wp_generate_tag_cloud', $return, $tags, $args );
|
||||
}
|
||||
|
||||
//
|
||||
// Helper functions
|
||||
//
|
||||
@@ -372,63 +288,4 @@ function walk_category_dropdown_tree() {
|
||||
return call_user_func_array(array(&$walker, 'walk'), $args);
|
||||
}
|
||||
|
||||
//
|
||||
// Tags
|
||||
//
|
||||
|
||||
function get_tag_link( $tag_id ) {
|
||||
global $wp_rewrite;
|
||||
$catlink = $wp_rewrite->get_tag_permastruct();
|
||||
|
||||
$category = &get_category($tag_id);
|
||||
$category_nicename = $category->category_nicename;
|
||||
|
||||
if ( empty($catlink) ) {
|
||||
$file = get_option('home') . '/';
|
||||
$catlink = $file . '?tag=' . $category_nicename;
|
||||
} else {
|
||||
|
||||
$catlink = str_replace('%tag%', $category_nicename, $catlink);
|
||||
$catlink = get_option('home') . user_trailingslashit($catlink, 'category');
|
||||
}
|
||||
return apply_filters('tag_link', $catlink, $tag_id);
|
||||
}
|
||||
|
||||
function get_the_tags( $id = 0 ) {
|
||||
global $post;
|
||||
|
||||
$id = (int) $id;
|
||||
|
||||
if ( ! $id && ! in_the_loop() )
|
||||
return false; // in-the-loop function
|
||||
|
||||
if ( !$id )
|
||||
$id = (int) $post->ID;
|
||||
|
||||
$tags = wp_get_post_tags( $id );
|
||||
$tags = apply_filters( 'get_the_tags', $tags );
|
||||
if ( empty( $tags ) )
|
||||
return false;
|
||||
return $tags;
|
||||
}
|
||||
|
||||
function the_tags( $before = 'Tags: ', $sep = ', ', $after = '' ) {
|
||||
$tags = get_the_tags();
|
||||
|
||||
if ( empty( $tags ) )
|
||||
return false;
|
||||
|
||||
$tag_list = $before;
|
||||
foreach ( $tags as $tag )
|
||||
$tag_links[] = '<a href="' . get_tag_link($tag->cat_ID) . '">' . $tag->cat_name . '</a>';
|
||||
|
||||
$tag_links = join( $sep, $tag_links );
|
||||
$tag_links = apply_filters( 'the_tags', $tag_links );
|
||||
$tag_list .= $tag_links;
|
||||
|
||||
$tag_list .= $after;
|
||||
|
||||
echo $tag_list;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
<?php
|
||||
|
||||
define('TAXONOMY_CATEGORY', 1);
|
||||
define('TAXONOMY_TAG', 2);
|
||||
|
||||
function get_all_category_ids() {
|
||||
global $wpdb;
|
||||
|
||||
@@ -80,12 +77,8 @@ function &get_categories($args = '') {
|
||||
$where .= ' AND link_count > 0';
|
||||
else
|
||||
$where .= ' AND category_count > 0';
|
||||
} else {
|
||||
$where .= ' AND ( type & ' . TAXONOMY_CATEGORY . ' != 0 ) ';
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ( !empty($number) )
|
||||
$number = 'LIMIT ' . $number;
|
||||
else
|
||||
@@ -213,15 +206,6 @@ function get_category_by_path($category_path, $full_match = true, $output = OBJE
|
||||
return NULL;
|
||||
}
|
||||
|
||||
function get_category_by_slug( $slug ) {
|
||||
global $wpdb;
|
||||
$slug = sanitize_title( $slug );
|
||||
if ( empty( $slug ) )
|
||||
return false;
|
||||
$category = $wpdb->get_var( "SELECT * FROM $wpdb->categories WHERE category_nicename = '$slug' " );
|
||||
return get_category( $category );
|
||||
}
|
||||
|
||||
// Get the ID of a category from its name
|
||||
function get_cat_ID($cat_name='General') {
|
||||
global $wpdb;
|
||||
@@ -267,9 +251,9 @@ function &_get_cat_children($category_id, $categories) {
|
||||
return array();
|
||||
|
||||
$category_list = array();
|
||||
$children = _get_category_hierarchy();
|
||||
$has_children = _get_category_hierarchy();
|
||||
|
||||
if ( ( 0 != $category_id ) && ! isset($children[$category_id]) )
|
||||
if ( ( 0 != $category_id ) && ! isset($has_children[$category_id]) )
|
||||
return array();
|
||||
|
||||
foreach ( $categories as $category ) {
|
||||
@@ -279,9 +263,9 @@ function &_get_cat_children($category_id, $categories) {
|
||||
if ( $category->category_parent == $category_id ) {
|
||||
$category_list[] = $category;
|
||||
|
||||
if ( !isset($children[$category->cat_ID]) )
|
||||
if ( !isset($has_children[$category->cat_ID]) )
|
||||
continue;
|
||||
|
||||
|
||||
if ( $children = _get_cat_children($category->cat_ID, $categories) )
|
||||
$category_list = array_merge($category_list, $children);
|
||||
}
|
||||
@@ -344,86 +328,4 @@ function _get_category_hierarchy() {
|
||||
|
||||
return $children;
|
||||
}
|
||||
|
||||
// Tags
|
||||
|
||||
function &get_tags($args = '') {
|
||||
global $wpdb, $category_links;
|
||||
|
||||
$defaults = array('orderby' => 'name', 'order' => 'ASC',
|
||||
'hide_empty' => true, 'exclude' => '', 'include' => '',
|
||||
'number' => '');
|
||||
$args = wp_parse_args( $args, $defaults );
|
||||
if ( 'count' == $args['orderby'] )
|
||||
$args['orderby'] = 'tag_count';
|
||||
else
|
||||
$args['orderby'] = "cat_" . $args['orderby']; // restricts order by to cat_ID and cat_name fields
|
||||
$args['number'] = (int) $args['number'];
|
||||
extract($args);
|
||||
|
||||
$key = md5( serialize( $args ) );
|
||||
if ( $cache = wp_cache_get( 'get_tags', 'category' ) )
|
||||
if ( isset( $cache[ $key ] ) )
|
||||
return apply_filters('get_tags', $cache[$key], $args);
|
||||
|
||||
$where = 'cat_ID > 0';
|
||||
$inclusions = '';
|
||||
if ( !empty($include) ) {
|
||||
$child_of = 0; //ignore child_of and exclude params if using include
|
||||
$exclude = '';
|
||||
$incategories = preg_split('/[\s,]+/',$include);
|
||||
if ( count($incategories) ) {
|
||||
foreach ( $incategories as $incat ) {
|
||||
if (empty($inclusions))
|
||||
$inclusions = ' AND ( cat_ID = ' . intval($incat) . ' ';
|
||||
else
|
||||
$inclusions .= ' OR cat_ID = ' . intval($incat) . ' ';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($inclusions))
|
||||
$inclusions .= ')';
|
||||
$where .= $inclusions;
|
||||
|
||||
$exclusions = '';
|
||||
if ( !empty($exclude) ) {
|
||||
$excategories = preg_split('/[\s,]+/',$exclude);
|
||||
if ( count($excategories) ) {
|
||||
foreach ( $excategories as $excat ) {
|
||||
if (empty($exclusions))
|
||||
$exclusions = ' AND ( cat_ID <> ' . intval($excat) . ' ';
|
||||
else
|
||||
$exclusions .= ' AND cat_ID <> ' . intval($excat) . ' ';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($exclusions))
|
||||
$exclusions .= ')';
|
||||
$exclusions = apply_filters('list_tags_exclusions', $exclusions, $args );
|
||||
$where .= $exclusions;
|
||||
|
||||
if ( $hide_empty )
|
||||
$where .= ' AND tag_count > 0';
|
||||
|
||||
$where .= ' AND ( type & ' . TAXONOMY_TAG . ' != 0 ) ';
|
||||
|
||||
if ( !empty($number) )
|
||||
$number = 'LIMIT ' . $number;
|
||||
else
|
||||
$number = '';
|
||||
|
||||
$tags = $wpdb->get_results("SELECT * FROM $wpdb->categories WHERE $where ORDER BY $orderby $order $number");
|
||||
|
||||
if ( empty($tags) )
|
||||
return array();
|
||||
|
||||
$cache[ $key ] = $tags;
|
||||
wp_cache_set( 'get_tags', $cache, 'category' );
|
||||
|
||||
$tags = apply_filters('get_tags', $tags, $args);
|
||||
return $tags;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
class WP {
|
||||
var $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 'withoutcomments', 's', 'search', 'exact', 'sentence', 'debug', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'tag', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview', 'robots');
|
||||
var $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 'withoutcomments', 's', 'search', 'exact', 'sentence', 'debug', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview', 'robots');
|
||||
|
||||
var $private_query_vars = array('offset', 'posts_per_page', 'posts_per_archive_page', 'what_to_show', 'showposts', 'nopaging', 'post_type');
|
||||
var $extra_query_vars = array();
|
||||
|
||||
@@ -173,4 +173,7 @@ add_action('sanitize_comment_cookies', 'sanitize_comment_cookies');
|
||||
add_action('admin_print_scripts', 'wp_print_scripts', 20);
|
||||
add_action('mce_options', '_mce_set_direction');
|
||||
add_action('init', 'smilies_init', 5);
|
||||
?>
|
||||
add_action( 'plugins_loaded', 'wp_maybe_load_widgets', 0 );
|
||||
add_action( 'shutdown', 'wp_ob_end_flush_all', 1);
|
||||
|
||||
?>
|
||||
@@ -602,7 +602,7 @@ function update_post_cache(&$posts) {
|
||||
}
|
||||
|
||||
function clean_post_cache($id) {
|
||||
global $post_cache, $post_meta_cache, $category_cache, $tag_cache, $blog_id;
|
||||
global $post_cache, $post_meta_cache, $category_cache, $blog_id;
|
||||
|
||||
if ( isset( $post_cache[$blog_id][$id] ) )
|
||||
unset( $post_cache[$blog_id][$id] );
|
||||
@@ -612,9 +612,6 @@ function clean_post_cache($id) {
|
||||
|
||||
if ( isset( $category_cache[$blog_id][$id]) )
|
||||
unset ( $category_cache[$blog_id][$id] );
|
||||
|
||||
if ( isset( $tag_cache[$blog_id][$id]) )
|
||||
unset ( $tag_cache[$blog_id][$id] );
|
||||
}
|
||||
|
||||
function update_page_cache(&$pages) {
|
||||
@@ -641,7 +638,7 @@ function clean_page_cache($id) {
|
||||
}
|
||||
|
||||
function update_post_category_cache($post_ids) {
|
||||
global $wpdb, $category_cache, $tag_cache, $blog_id;
|
||||
global $wpdb, $category_cache, $blog_id;
|
||||
|
||||
if ( empty($post_ids) )
|
||||
return;
|
||||
@@ -662,21 +659,17 @@ function update_post_category_cache($post_ids) {
|
||||
return;
|
||||
$post_id_list = join( ',', $post_id_array ); // with already cached stuff removed
|
||||
|
||||
$dogs = $wpdb->get_results("SELECT post_id, category_id, rel_type FROM $wpdb->post2cat WHERE post_id IN ($post_id_list)");
|
||||
$dogs = $wpdb->get_results("SELECT post_id, category_id FROM $wpdb->post2cat WHERE post_id IN ($post_id_list)");
|
||||
|
||||
if ( empty($dogs) )
|
||||
return;
|
||||
|
||||
foreach ($dogs as $catt) {
|
||||
if ( 'category' == $catt->rel_type )
|
||||
$category_cache[$blog_id][$catt->post_id][$catt->category_id] = &get_category($catt->category_id);
|
||||
elseif ( 'tag' == $catt->rel_type )
|
||||
$tag_cache[$blog_id][$catt->post_id][$catt->category_id] = &get_category($catt->category_id);
|
||||
}
|
||||
foreach ($dogs as $catt)
|
||||
$category_cache[$blog_id][$catt->post_id][$catt->category_id] = &get_category($catt->category_id);
|
||||
}
|
||||
|
||||
function update_post_caches(&$posts) {
|
||||
global $post_cache, $category_cache, $post_meta_cache, $tag_cache;
|
||||
global $post_cache, $category_cache, $post_meta_cache;
|
||||
global $wpdb, $blog_id;
|
||||
|
||||
// No point in doing all this work if we didn't match any posts.
|
||||
@@ -922,10 +915,17 @@ function status_header( $header ) {
|
||||
elseif ( 410 == $header )
|
||||
$text = 'Gone';
|
||||
|
||||
if ( version_compare(phpversion(), '4.3.0', '>=') )
|
||||
@header("HTTP/1.1 $header $text", true, $header);
|
||||
else
|
||||
@header("HTTP/1.1 $header $text");
|
||||
$protocol = $_SERVER["SERVER_PROTOCOL"];
|
||||
if ( ('HTTP/1.1' != $protocol) && ('HTTP/1.0' != $protocol) )
|
||||
$protocol = 'HTTP/1.0';
|
||||
$status_header = "$protocol $header $text";
|
||||
$status_header = apply_filters('status_header', $status_header, $header, $text, $protocol);
|
||||
|
||||
if ( version_compare( phpversion(), '4.3.0', '>=' ) ) {
|
||||
return @header( $status_header, true, $header );
|
||||
} else {
|
||||
return @header( $status_header );
|
||||
}
|
||||
}
|
||||
|
||||
function nocache_headers() {
|
||||
@@ -1339,15 +1339,18 @@ function wp_die( $message, $title = '' ) {
|
||||
$message = "<p>$message</p>";
|
||||
}
|
||||
|
||||
if (strpos($_SERVER['PHP_SELF'], 'wp-admin') !== false)
|
||||
$admin_dir = '';
|
||||
else
|
||||
$admin_dir = 'wp-admin/';
|
||||
|
||||
if ( !did_action('admin_head') ) :
|
||||
header('Content-Type: text/html; charset=utf-8');
|
||||
|
||||
if ( empty($title) )
|
||||
$title = __('WordPress › Error');
|
||||
|
||||
if (strpos($_SERVER['PHP_SELF'], 'wp-admin') !== false)
|
||||
$admin_dir = '';
|
||||
else
|
||||
$admin_dir = 'wp-admin/';
|
||||
|
||||
|
||||
?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
@@ -1362,6 +1365,7 @@ if ( ( $wp_locale ) && ('rtl' == $wp_locale->text_direction) ) : ?>
|
||||
<?php endif; ?>
|
||||
</head>
|
||||
<body>
|
||||
<?php endif; ?>
|
||||
<h1 id="logo"><img alt="WordPress" src="<?php echo $admin_dir; ?>images/wordpress-logo.png" /></h1>
|
||||
<?php echo $message; ?>
|
||||
|
||||
@@ -1468,10 +1472,11 @@ function smilies_init() {
|
||||
);
|
||||
}
|
||||
|
||||
$siteurl = get_option('siteurl');
|
||||
foreach ( (array) $wpsmiliestrans as $smiley => $img ) {
|
||||
$wp_smiliessearch[] = '/(\s|^)'.preg_quote($smiley, '/').'(\s|$)/';
|
||||
$smiley_masked = htmlspecialchars(trim($smiley), ENT_QUOTES);
|
||||
$wp_smiliesreplace[] = " <img src='" . get_option('siteurl') . "/wp-includes/images/smilies/$img' alt='$smiley_masked' class='wp-smiley' /> ";
|
||||
$wp_smiliesreplace[] = " <img src='$siteurl/wp-includes/images/smilies/$img' alt='$smiley_masked' class='wp-smiley' /> ";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1493,4 +1498,24 @@ function wp_parse_args( $args, $defaults = '' ) {
|
||||
endif;
|
||||
}
|
||||
|
||||
?>
|
||||
function wp_maybe_load_widgets() {
|
||||
if ( !function_exists( 'dynamic_sidebar' ) ) {
|
||||
require_once ABSPATH . WPINC . '/widgets.php';
|
||||
add_action( '_admin_menu', 'wp_widgets_add_menu' );
|
||||
}
|
||||
}
|
||||
|
||||
function wp_widgets_add_menu() {
|
||||
global $submenu;
|
||||
$submenu['themes.php'][7] = array( __( 'Widgets' ), 'edit_themes', 'widgets.php' );
|
||||
ksort($submenu['themes.php'], SORT_NUMERIC);
|
||||
}
|
||||
|
||||
// For PHP 5.2, make sure all output buffers are flushed
|
||||
// before our singletons our destroyed.
|
||||
function wp_ob_end_flush_all()
|
||||
{
|
||||
while ( @ob_end_flush() );
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -809,9 +809,16 @@ function rich_edit_exists() {
|
||||
|
||||
function user_can_richedit() {
|
||||
global $wp_rich_edit, $pagenow;
|
||||
|
||||
if ( !isset($wp_rich_edit) )
|
||||
$wp_rich_edit = ( 'true' == get_user_option('rich_editing') && !preg_match('!opera[ /][2-8]|konqueror|safari!i', $_SERVER['HTTP_USER_AGENT']) && 'comment.php' != $pagenow && rich_edit_exists() ) ? true : false;
|
||||
|
||||
if ( !isset( $wp_rich_edit) ) {
|
||||
if ( get_user_option( 'rich_editing' ) == 'true' &&
|
||||
( ( preg_match( '!AppleWebKit/(\d+)!', $_SERVER['HTTP_USER_AGENT'], $match ) && intval($match[1]) >= 420 ) ||
|
||||
!preg_match( '!opera[ /][2-8]|konqueror|safari!i', $_SERVER['HTTP_USER_AGENT'] ) ) ) {
|
||||
$wp_rich_edit = true;
|
||||
} else {
|
||||
$wp_rich_edit = false;
|
||||
}
|
||||
}
|
||||
|
||||
return apply_filters('user_can_richedit', $wp_rich_edit);
|
||||
}
|
||||
|
||||
BIN
wp-includes/images/rss.png
Normal file
BIN
wp-includes/images/rss.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.3 KiB |
@@ -84,7 +84,7 @@
|
||||
if (isset($_SERVER['HTTP_ACCEPT_ENCODING']))
|
||||
$encodings = explode(',', strtolower(preg_replace("/\s+/", "", $_SERVER['HTTP_ACCEPT_ENCODING'])));
|
||||
|
||||
if ((in_array('gzip', $encodings) || in_array('x-gzip', $encodings) || isset($_SERVER['---------------'])) && function_exists('ob_gzhandler') && !ini_get('zlib.output_compression')) {
|
||||
if ((in_array('gzip', $encodings) || in_array('x-gzip', $encodings) || isset($_SERVER['---------------'])) && function_exists('ob_gzhandler') && !ini_get('zlib.output_compression') && ini_get('output_handler') != 'ob_gzhandler') {
|
||||
$enc = in_array('x-gzip', $encodings) ? "x-gzip" : "gzip";
|
||||
$supportsGzip = true;
|
||||
}
|
||||
|
||||
@@ -59,7 +59,6 @@ function get_permalink($id = 0) {
|
||||
'%postname%',
|
||||
'%post_id%',
|
||||
'%category%',
|
||||
'%tag%',
|
||||
'%author%',
|
||||
'%pagename%'
|
||||
);
|
||||
|
||||
@@ -121,6 +121,8 @@ function get_userdatabylogin($user_login) {
|
||||
if ( $userdata )
|
||||
return $userdata;
|
||||
|
||||
$user_login = $wpdb->escape($user_login);
|
||||
|
||||
if ( !$user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE user_login = '$user_login'") )
|
||||
return false;
|
||||
|
||||
|
||||
@@ -136,6 +136,11 @@ function add_action($tag, $function_to_add, $priority = 10, $accepted_args = 1)
|
||||
function do_action($tag, $arg = '') {
|
||||
global $wp_filter, $wp_actions;
|
||||
|
||||
if ( is_array($wp_actions) )
|
||||
$wp_actions[] = $tag;
|
||||
else
|
||||
$wp_actions = array($tag);
|
||||
|
||||
$args = array();
|
||||
if ( is_array($arg) && 1 == count($arg) && is_object($arg[0]) ) // array(&$this)
|
||||
$args[] =& $arg[0];
|
||||
@@ -156,20 +161,19 @@ function do_action($tag, $arg = '') {
|
||||
|
||||
} while ( next($wp_filter[$tag]) );
|
||||
|
||||
if ( is_array($wp_actions) )
|
||||
$wp_actions[] = $tag;
|
||||
else
|
||||
$wp_actions = array($tag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the number of functions hooked to a specific action hook.
|
||||
* Return the number times an action is fired.
|
||||
* @param string $tag The name of the action hook.
|
||||
* @return int The number of functions hooked to action hook <tt>$tag</tt>
|
||||
* @return int The number of times action hook <tt>$tag</tt> is fired
|
||||
*/
|
||||
function did_action($tag) {
|
||||
global $wp_actions;
|
||||
|
||||
if ( empty($wp_actions) )
|
||||
return 0;
|
||||
|
||||
return count(array_keys($wp_actions, $tag));
|
||||
}
|
||||
|
||||
|
||||
@@ -225,14 +225,6 @@ function get_posts($args) {
|
||||
if (!empty($exclusions))
|
||||
$exclusions .= ')';
|
||||
|
||||
$query ="SELECT DISTINCT * FROM $wpdb->posts " ;
|
||||
$query .= ( empty( $category ) ? "" : ", $wpdb->post2cat " );
|
||||
$query .= ( empty( $meta_key ) ? "" : ", $wpdb->postmeta " );
|
||||
$query .= " WHERE (post_type = 'post' AND post_status = 'publish') $exclusions $inclusions ";
|
||||
$query .= ( empty( $category ) ? "" : "AND ($wpdb->posts.ID = $wpdb->post2cat.post_id AND $wpdb->post2cat.category_id = " . $category. ") " );
|
||||
$query .= ( empty( $meta_key ) | empty($meta_value) ? "" : " AND ($wpdb->posts.ID = $wpdb->postmeta.post_id AND $wpdb->postmeta.meta_key = '$meta_key' AND $wpdb->postmeta.meta_value = '$meta_value' )" );
|
||||
$query .= " GROUP BY $wpdb->posts.ID ORDER BY " . $orderby . " " . $order . " LIMIT " . $offset . ',' . $numberposts;
|
||||
|
||||
$query = "SELECT DISTINCT * FROM $wpdb->posts ";
|
||||
$query .= empty( $category ) ? '' : ", $wpdb->post2cat ";
|
||||
$query .= empty( $meta_key ) ? '' : ", $wpdb->postmeta ";
|
||||
@@ -458,17 +450,6 @@ function wp_get_post_categories($post_id = 0) {
|
||||
return array_unique($cat_ids);
|
||||
}
|
||||
|
||||
function wp_get_post_tags( $post_id = 0 ) {
|
||||
global $tag_cache, $blog_id;
|
||||
|
||||
$post_id = (int) $post_id;
|
||||
|
||||
if ( !isset( $tag_cache[$blog_id][$post_id] ) )
|
||||
update_post_category_cache( $post_id ); // loads $tag_cache
|
||||
|
||||
return $tag_cache[$blog_id][$post_id];
|
||||
}
|
||||
|
||||
function wp_get_recent_posts($num = 10) {
|
||||
global $wpdb;
|
||||
|
||||
@@ -530,7 +511,6 @@ function wp_insert_post($postarr = array()) {
|
||||
$post_name = apply_filters('name_save_pre', $post_name);
|
||||
$comment_status = apply_filters('comment_status_pre', $comment_status);
|
||||
$ping_status = apply_filters('ping_status_pre', $ping_status);
|
||||
$tags_input = apply_filters('tags_input_pre', $tags_input);
|
||||
}
|
||||
|
||||
if ( ('' == $post_content) && ('' == $post_title) && ('' == $post_excerpt) )
|
||||
@@ -665,8 +645,7 @@ function wp_insert_post($postarr = array()) {
|
||||
$wpdb->query( "UPDATE $wpdb->posts SET post_name = '$post_name' WHERE ID = '$post_ID'" );
|
||||
}
|
||||
|
||||
wp_set_post_categories( $post_ID, $post_category );
|
||||
wp_set_post_tags( $post_ID, $tags_input );
|
||||
wp_set_post_categories($post_ID, $post_category);
|
||||
|
||||
if ( 'page' == $post_type ) {
|
||||
clean_page_cache($post_ID);
|
||||
@@ -784,90 +763,6 @@ function wp_publish_post($post_id) {
|
||||
return wp_update_post(array('post_status' => 'publish', 'ID' => $post_id, 'no_filter' => true));
|
||||
}
|
||||
|
||||
function wp_add_post_tags($post_id = 0, $tags = '') {
|
||||
return wp_set_post_tags($post_id, $tags, true);
|
||||
}
|
||||
|
||||
function wp_set_post_tags( $post_id = 0, $tags = '', $append = false ) {
|
||||
/* $append - true = don't delete existing tags, just add on, false = replace the tags with the new tags */
|
||||
global $wpdb;
|
||||
|
||||
$post_id = (int) $post_id;
|
||||
|
||||
if ( !$post_id )
|
||||
return false;
|
||||
|
||||
// prevent warnings for unintialized variables
|
||||
$tag_ids = array();
|
||||
|
||||
if ( empty($tags) )
|
||||
$tags = array();
|
||||
$tags = (is_array($tags)) ? $tags : explode( ',', $tags );
|
||||
|
||||
foreach ( $tags as $tag ) {
|
||||
$tag = trim( $tag );
|
||||
if ( !$tag_slug = sanitize_title( $tag ) )
|
||||
continue; // discard
|
||||
if ( !$tag_id = tag_exists( $tag ) )
|
||||
$tag_id = wp_create_tag( $tag );
|
||||
$tag_ids[] = $tag_id;
|
||||
}
|
||||
|
||||
if ( empty($tag_ids) && ( !empty($tags) || $append ) )
|
||||
return false;
|
||||
|
||||
$tag_ids = array_unique( $tag_ids );
|
||||
|
||||
// First the old tags
|
||||
$old_tags = $wpdb->get_col("
|
||||
SELECT category_id
|
||||
FROM $wpdb->post2cat
|
||||
WHERE post_id = '$post_id' AND rel_type = 'tag'");
|
||||
|
||||
if ( !$old_tags ) {
|
||||
$old_tags = array();
|
||||
} else {
|
||||
$old_tags = array_unique( $old_tags );
|
||||
}
|
||||
|
||||
// Delete any?
|
||||
$delete_tags = array_diff( $old_tags, $tag_ids);
|
||||
if ( $delete_tags && !$append ) {
|
||||
foreach ( $delete_tags as $del ) {
|
||||
$wpdb->query("
|
||||
DELETE FROM $wpdb->post2cat
|
||||
WHERE category_id = '$del'
|
||||
AND post_id = '$post_id'
|
||||
AND rel_type = 'tag'
|
||||
");
|
||||
}
|
||||
}
|
||||
|
||||
// Add any?
|
||||
$add_tags = array_diff( $tag_ids, $old_tags );
|
||||
if ( $add_tags ) {
|
||||
foreach ( $add_tags as $new_tag ) {
|
||||
$new_tag = (int) $new_tag;
|
||||
if ( !empty($new_tag) )
|
||||
$wpdb->query("
|
||||
INSERT INTO $wpdb->post2cat (post_id, category_id, rel_type)
|
||||
VALUES ('$post_id', '$new_tag', 'tag')");
|
||||
}
|
||||
}
|
||||
|
||||
// Update category counts.
|
||||
$all_affected_tags = array_unique( array_merge( $tag_ids, $old_tags ) );
|
||||
foreach ( $all_affected_tags as $tag_id ) {
|
||||
$count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->post2cat, $wpdb->posts WHERE $wpdb->posts.ID=$wpdb->post2cat.post_id AND post_status = 'publish' AND post_type = 'post' AND category_id = '$tag_id' AND rel_type = 'tag'" );
|
||||
$wpdb->query( "UPDATE $wpdb->categories SET tag_count = '$count', type = type | " . TAXONOMY_TAG . " WHERE cat_ID = '$tag_id'" );
|
||||
if ( $count == 0 )
|
||||
$wpdb->query( "UPDATE $wpdb->categories SET type = type & ~". TAXONOMY_TAG . " WHERE cat_ID = '$tag_id'" );
|
||||
clean_category_cache( $tag_id );
|
||||
do_action( 'edit_category', $tag_id );
|
||||
do_action( 'edit_tag', $tag_id );
|
||||
}
|
||||
}
|
||||
|
||||
function wp_set_post_categories($post_ID = 0, $post_categories = array()) {
|
||||
global $wpdb;
|
||||
|
||||
@@ -882,7 +777,7 @@ function wp_set_post_categories($post_ID = 0, $post_categories = array()) {
|
||||
$old_categories = $wpdb->get_col("
|
||||
SELECT category_id
|
||||
FROM $wpdb->post2cat
|
||||
WHERE post_id = '$post_ID' AND rel_type = 'category'");
|
||||
WHERE post_id = '$post_ID'");
|
||||
|
||||
if (!$old_categories) {
|
||||
$old_categories = array();
|
||||
@@ -898,7 +793,7 @@ function wp_set_post_categories($post_ID = 0, $post_categories = array()) {
|
||||
$wpdb->query("
|
||||
DELETE FROM $wpdb->post2cat
|
||||
WHERE category_id = '$del'
|
||||
AND post_id = '$post_ID' AND rel_type = 'category'
|
||||
AND post_id = '$post_ID'
|
||||
");
|
||||
}
|
||||
}
|
||||
@@ -919,8 +814,8 @@ function wp_set_post_categories($post_ID = 0, $post_categories = array()) {
|
||||
// Update category counts.
|
||||
$all_affected_cats = array_unique(array_merge($post_categories, $old_categories));
|
||||
foreach ( $all_affected_cats as $cat_id ) {
|
||||
$count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->post2cat, $wpdb->posts WHERE $wpdb->posts.ID=$wpdb->post2cat.post_id AND post_status = 'publish' AND post_type = 'post' AND category_id = '$cat_id' AND rel_type = 'category'");
|
||||
$wpdb->query("UPDATE $wpdb->categories SET category_count = '$count', type = type | " . TAXONOMY_CATEGORY . " WHERE cat_ID = '$cat_id'");
|
||||
$count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->post2cat, $wpdb->posts WHERE $wpdb->posts.ID=$wpdb->post2cat.post_id AND post_status = 'publish' AND post_type = 'post' AND category_id = '$cat_id'");
|
||||
$wpdb->query("UPDATE $wpdb->categories SET category_count = '$count' WHERE cat_ID = '$cat_id'");
|
||||
clean_category_cache($cat_id);
|
||||
do_action('edit_category', $cat_id);
|
||||
}
|
||||
|
||||
@@ -86,20 +86,6 @@ function is_category ($category = '') {
|
||||
return false;
|
||||
}
|
||||
|
||||
function is_tag( $slug = '' ) {
|
||||
global $wp_query;
|
||||
if ( !$wp_query->is_tag )
|
||||
return false;
|
||||
|
||||
if ( empty( $slug ) )
|
||||
return true;
|
||||
|
||||
$cat_obj = $wp_query->get_queried_object();
|
||||
if ( $category == $cat_obj->category_nicename )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
function is_comments_popup () {
|
||||
global $wp_query;
|
||||
|
||||
@@ -319,7 +305,6 @@ class WP_Query {
|
||||
var $is_time = false;
|
||||
var $is_author = false;
|
||||
var $is_category = false;
|
||||
var $is_tag = false;
|
||||
var $is_search = false;
|
||||
var $is_feed = false;
|
||||
var $is_comment_feed = false;
|
||||
@@ -344,7 +329,6 @@ class WP_Query {
|
||||
$this->is_time = false;
|
||||
$this->is_author = false;
|
||||
$this->is_category = false;
|
||||
$this->is_tag = false;
|
||||
$this->is_search = false;
|
||||
$this->is_feed = false;
|
||||
$this->is_comment_feed = false;
|
||||
@@ -399,7 +383,6 @@ class WP_Query {
|
||||
, 'year'
|
||||
, 'w'
|
||||
, 'category_name'
|
||||
, 'tag'
|
||||
, 'author_name'
|
||||
, 'feed'
|
||||
, 'tb'
|
||||
@@ -548,9 +531,6 @@ class WP_Query {
|
||||
$this->is_category = true;
|
||||
}
|
||||
|
||||
if ( '' != $qv['tag'] )
|
||||
$this->is_tag = true;
|
||||
|
||||
if ( empty($qv['author']) || ($qv['author'] == '0') ) {
|
||||
$this->is_author = false;
|
||||
} else {
|
||||
@@ -561,7 +541,7 @@ class WP_Query {
|
||||
$this->is_author = true;
|
||||
}
|
||||
|
||||
if ( ($this->is_date || $this->is_author || $this->is_category || $this->is_tag ) )
|
||||
if ( ($this->is_date || $this->is_author || $this->is_category) )
|
||||
$this->is_archive = true;
|
||||
}
|
||||
|
||||
@@ -857,7 +837,7 @@ class WP_Query {
|
||||
$in_cats = substr($in_cats, 0, -2);
|
||||
$out_cats = substr($out_cats, 0, -2);
|
||||
if ( strlen($in_cats) > 0 )
|
||||
$in_cats = " AND $wpdb->post2cat.category_id IN ($in_cats) AND rel_type = 'category' ";
|
||||
$in_cats = " AND $wpdb->post2cat.category_id IN ($in_cats)";
|
||||
if ( strlen($out_cats) > 0 ) {
|
||||
$ids = $wpdb->get_col("SELECT post_id FROM $wpdb->post2cat WHERE $wpdb->post2cat.category_id IN ($out_cats)");
|
||||
if ( is_array($ids) && count($ids > 0) ) {
|
||||
@@ -874,21 +854,6 @@ class WP_Query {
|
||||
$groupby = "{$wpdb->posts}.ID";
|
||||
}
|
||||
|
||||
if ( '' != $q['tag'] ) {
|
||||
$reqcat= get_category_by_slug( $q['tag'] );
|
||||
if ( !empty($reqcat) )
|
||||
$reqcat = $reqcat->cat_ID;
|
||||
else
|
||||
$reqcat = 0;
|
||||
|
||||
$q['cat'] = $reqcat;
|
||||
|
||||
$tables = ", $wpdb->post2cat, $wpdb->categories";
|
||||
$join = " LEFT JOIN $wpdb->post2cat ON ($wpdb->posts.ID = $wpdb->post2cat.post_id) LEFT JOIN $wpdb->categories ON ($wpdb->post2cat.category_id = $wpdb->categories.cat_ID) ";
|
||||
$whichcat = " AND category_id IN ({$q['cat']}) AND rel_type = 'tag' ";
|
||||
$groupby = "{$wpdb->posts}.ID";
|
||||
}
|
||||
|
||||
// Category stuff for nice URLs
|
||||
if ( '' != $q['category_name'] ) {
|
||||
$reqcat = get_category_by_path($q['category_name']);
|
||||
@@ -919,7 +884,7 @@ class WP_Query {
|
||||
$whichcat = " AND category_id IN ({$q['cat']}, ";
|
||||
$whichcat .= get_category_children($q['cat'], '', ', ');
|
||||
$whichcat = substr($whichcat, 0, -2);
|
||||
$whichcat .= ") AND rel_type = 'category'";
|
||||
$whichcat .= ")";
|
||||
$groupby = "{$wpdb->posts}.ID";
|
||||
}
|
||||
|
||||
|
||||
@@ -46,12 +46,11 @@ define('EP_ROOT', 64 );
|
||||
define('EP_COMMENTS', 128 );
|
||||
define('EP_SEARCH', 256 );
|
||||
define('EP_CATEGORIES', 512 );
|
||||
define('EP_TAGS', 1024 );
|
||||
define('EP_AUTHORS', 2048);
|
||||
define('EP_PAGES', 4096);
|
||||
define('EP_AUTHORS', 1024);
|
||||
define('EP_PAGES', 2048);
|
||||
//pseudo-places
|
||||
define('EP_NONE', 0 );
|
||||
define('EP_ALL', 8191);
|
||||
define('EP_ALL', 4095);
|
||||
|
||||
//and an endpoint, like /trackback/
|
||||
function add_rewrite_endpoint($name, $places) {
|
||||
@@ -153,9 +152,7 @@ class WP_Rewrite {
|
||||
var $permalink_structure;
|
||||
var $use_trailing_slashes;
|
||||
var $category_base;
|
||||
var $tag_base;
|
||||
var $category_structure;
|
||||
var $tag_structure;
|
||||
var $author_base = 'author';
|
||||
var $author_structure;
|
||||
var $date_structure;
|
||||
@@ -186,7 +183,6 @@ class WP_Rewrite {
|
||||
'%postname%',
|
||||
'%post_id%',
|
||||
'%category%',
|
||||
'%tag%',
|
||||
'%author%',
|
||||
'%pagename%',
|
||||
'%search%'
|
||||
@@ -203,7 +199,6 @@ class WP_Rewrite {
|
||||
'([^/]+)',
|
||||
'([0-9]+)',
|
||||
'(.+?)',
|
||||
'(.+?)',
|
||||
'([^/]+)',
|
||||
'([^/]+)',
|
||||
'(.+)'
|
||||
@@ -220,7 +215,6 @@ class WP_Rewrite {
|
||||
'name=',
|
||||
'p=',
|
||||
'category_name=',
|
||||
'tag=',
|
||||
'author_name=',
|
||||
'pagename=',
|
||||
's='
|
||||
@@ -386,26 +380,6 @@ class WP_Rewrite {
|
||||
return $this->category_structure;
|
||||
}
|
||||
|
||||
function get_tag_permastruct() {
|
||||
if (isset($this->tag_structure)) {
|
||||
return $this->tag_structure;
|
||||
}
|
||||
|
||||
if (empty($this->permalink_structure)) {
|
||||
$this->tag_structure = '';
|
||||
return false;
|
||||
}
|
||||
|
||||
if (empty($this->tag_base))
|
||||
$this->tag_structure = $this->front . 'tag/';
|
||||
else
|
||||
$this->tag_structure = $this->tag_base . '/';
|
||||
|
||||
$this->tag_structure .= '%tag%';
|
||||
|
||||
return $this->tag_structure;
|
||||
}
|
||||
|
||||
function get_author_permastruct() {
|
||||
if (isset($this->author_structure)) {
|
||||
return $this->author_structure;
|
||||
@@ -762,10 +736,6 @@ class WP_Rewrite {
|
||||
$category_rewrite = $this->generate_rewrite_rules($this->get_category_permastruct(), EP_CATEGORIES);
|
||||
$category_rewrite = apply_filters('category_rewrite_rules', $category_rewrite);
|
||||
|
||||
// Tags
|
||||
$tag_rewrite = $this->generate_rewrite_rules($this->get_tag_permastruct(), EP_TAGS);
|
||||
$tag_rewrite = apply_filters('tag_rewrite_rules', $tag_rewrite);
|
||||
|
||||
// Authors
|
||||
$author_rewrite = $this->generate_rewrite_rules($this->get_author_permastruct(), EP_AUTHORS);
|
||||
$author_rewrite = apply_filters('author_rewrite_rules', $author_rewrite);
|
||||
@@ -775,7 +745,7 @@ class WP_Rewrite {
|
||||
$page_rewrite = apply_filters('page_rewrite_rules', $page_rewrite);
|
||||
|
||||
// Put them together.
|
||||
$this->rules = array_merge($robots_rewrite, $default_feeds, $page_rewrite, $root_rewrite, $comments_rewrite, $search_rewrite, $category_rewrite, $tag_rewrite, $author_rewrite, $date_rewrite, $post_rewrite, $this->extra_rules);
|
||||
$this->rules = array_merge($robots_rewrite, $default_feeds, $page_rewrite, $root_rewrite, $comments_rewrite, $search_rewrite, $category_rewrite, $author_rewrite, $date_rewrite, $post_rewrite, $this->extra_rules);
|
||||
|
||||
do_action_ref_array('generate_rewrite_rules', array(&$this));
|
||||
$this->rules = apply_filters('rewrite_rules_array', $this->rules);
|
||||
@@ -901,8 +871,7 @@ class WP_Rewrite {
|
||||
if ($this->using_index_permalinks()) {
|
||||
$this->root = $this->index . '/';
|
||||
}
|
||||
$this->category_base = get_option( 'category_base' );
|
||||
$this->tag_base = get_option( 'tag_base' );
|
||||
$this->category_base = get_option('category_base');
|
||||
unset($this->category_structure);
|
||||
unset($this->author_structure);
|
||||
unset($this->date_structure);
|
||||
@@ -927,13 +896,6 @@ class WP_Rewrite {
|
||||
}
|
||||
}
|
||||
|
||||
function set_tag_base( $tag_base ) {
|
||||
if ( $tag_base != $this->tag_base ) {
|
||||
update_option( 'tag_base', $tag_base );
|
||||
$this->init();
|
||||
}
|
||||
}
|
||||
|
||||
function WP_Rewrite() {
|
||||
$this->init();
|
||||
}
|
||||
|
||||
@@ -35,9 +35,6 @@ if ( defined('WP_USE_THEMES') && constant('WP_USE_THEMES') ) {
|
||||
} else if ( is_category() && $template = get_category_template()) {
|
||||
include($template);
|
||||
return;
|
||||
} else if ( is_tag() && $template = get_tag_template()) {
|
||||
include($template);
|
||||
return;
|
||||
} else if ( is_author() && $template = get_author_template() ) {
|
||||
include($template);
|
||||
return;
|
||||
|
||||
@@ -163,6 +163,7 @@ function get_themes() {
|
||||
$template = $theme_data['Template'];
|
||||
$stylesheet = dirname($theme_file);
|
||||
|
||||
$screenshot = false;
|
||||
foreach ( array('png', 'gif', 'jpg', 'jpeg') as $ext ) {
|
||||
if (file_exists("$theme_root/$stylesheet/screenshot.$ext")) {
|
||||
$screenshot = "screenshot.$ext";
|
||||
@@ -328,17 +329,6 @@ function get_category_template() {
|
||||
return apply_filters('category_template', $template);
|
||||
}
|
||||
|
||||
function get_tag_template() {
|
||||
$template = '';
|
||||
if ( file_exists(TEMPLATEPATH . "/tag-" . get_query_var('tag') . '.php') )
|
||||
$template = TEMPLATEPATH . "/tag-" . get_query_var('tag') . '.php';
|
||||
elseif ( file_exists(TEMPLATEPATH . "/tag.php") )
|
||||
$template = TEMPLATEPATH . "/tag.php";
|
||||
|
||||
return apply_filters('tag_template', $template);
|
||||
}
|
||||
|
||||
|
||||
function get_date_template() {
|
||||
return get_query_template('date');
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
// This holds the version number in a separate file so we can bump it without cluttering the SVN
|
||||
|
||||
$wp_version = '2.2-almost-beta';
|
||||
$wp_version = '2.2';
|
||||
$wp_db_version = 5183;
|
||||
|
||||
?>
|
||||
|
||||
962
wp-includes/widgets.php
Normal file
962
wp-includes/widgets.php
Normal file
@@ -0,0 +1,962 @@
|
||||
<?php
|
||||
|
||||
/* Global Variables */
|
||||
|
||||
global $wp_registered_sidebars, $wp_registered_widgets, $wp_registered_widget_controls, $wp_registered_widget_styles, $wp_registered_widget_defaults;
|
||||
|
||||
$wp_registered_sidebars = array();
|
||||
$wp_registered_widgets = array();
|
||||
$wp_registered_widget_controls = array();
|
||||
$wp_registered_widget_styles = array();
|
||||
$wp_register_widget_defaults = false;
|
||||
|
||||
/* Template tags & API functions */
|
||||
|
||||
function register_sidebars($number = 1, $args = array()) {
|
||||
$number = (int) $number;
|
||||
|
||||
if ( is_string($args) )
|
||||
parse_str($args, $args);
|
||||
|
||||
$i = 1;
|
||||
|
||||
while ( $i <= $number ) {
|
||||
$_args = $args;
|
||||
if ( $number > 1 ) {
|
||||
$_args['name'] = isset($args['name']) ? $args['name'] : sprintf(__('Sidebar %d'), $i);
|
||||
} else {
|
||||
$_args['name'] = isset($args['name']) ? $args['name'] : __('Sidebar');
|
||||
}
|
||||
$_args['id'] = isset($args['id']) ? $args['id'] : "sidebar-$i";
|
||||
register_sidebar($_args);
|
||||
++$i;
|
||||
}
|
||||
}
|
||||
|
||||
function register_sidebar($args = array()) {
|
||||
global $wp_registered_sidebars;
|
||||
|
||||
if ( is_string($args) )
|
||||
parse_str($args, $args);
|
||||
|
||||
$i = count($wp_registered_sidebars) + 1;
|
||||
|
||||
$defaults = array(
|
||||
'name' => sprintf(__('Sidebar %d'), $i ),
|
||||
'id' => "sidebar-$i",
|
||||
'before_widget' => '<li id="%1$s" class="widget %2$s">',
|
||||
'after_widget' => "</li>\n",
|
||||
'before_title' => '<h2 class="widgettitle">',
|
||||
'after_title' => "</h2>\n",
|
||||
);
|
||||
|
||||
$sidebar = array_merge($defaults, $args);
|
||||
|
||||
$wp_registered_sidebars[$sidebar['id']] = $sidebar;
|
||||
|
||||
return $sidebar['id'];
|
||||
}
|
||||
|
||||
function unregister_sidebar( $name ) {
|
||||
global $wp_registered_sidebars;
|
||||
|
||||
if ( isset( $wp_registered_sidebars[$name] ) )
|
||||
unset( $wp_registered_sidebars[$name] );
|
||||
}
|
||||
|
||||
function register_sidebar_widget($name, $output_callback, $classname = '') {
|
||||
// Compat
|
||||
if ( is_array($name) ) {
|
||||
if ( count($name) == 3 )
|
||||
$name = sprintf($name[0], $name[2]);
|
||||
else
|
||||
$name = $name[0];
|
||||
}
|
||||
|
||||
$id = sanitize_title($name);
|
||||
$options = array();
|
||||
if ( !empty($classname) )
|
||||
$options['classname'] = $classname;
|
||||
$params = array_slice(func_get_args(), 3);
|
||||
$args = array($id, $name, $output_callback, $options);
|
||||
if ( !empty($params) )
|
||||
$args = array_merge($args, $params);
|
||||
|
||||
call_user_func_array('wp_register_sidebar_widget', $args);
|
||||
}
|
||||
|
||||
function wp_register_sidebar_widget($id, $name, $output_callback, $options = array()) {
|
||||
|
||||
global $wp_registered_widgets, $wp_register_widget_defaults;
|
||||
|
||||
$id = sanitize_title($id);
|
||||
|
||||
if ( empty($output_callback) ) {
|
||||
unset($wp_registered_widgets[$id]);
|
||||
return;
|
||||
}
|
||||
|
||||
$defaults = array('classname' => $output_callback);
|
||||
$options = wp_parse_args($options, $defaults);
|
||||
$widget = array(
|
||||
'name' => $name,
|
||||
'id' => $id,
|
||||
'callback' => $output_callback,
|
||||
'params' => array_slice(func_get_args(), 4)
|
||||
);
|
||||
$widget = array_merge($widget, $options);
|
||||
|
||||
if ( is_callable($output_callback) && ( !isset($wp_registered_widgets[$id]) || !$wp_register_widget_defaults) )
|
||||
$wp_registered_widgets[$id] = $widget;
|
||||
}
|
||||
|
||||
function unregister_sidebar_widget($id) {
|
||||
return wp_unregister_sidebar_widget($id);
|
||||
}
|
||||
|
||||
function wp_unregister_sidebar_widget($id) {
|
||||
wp_register_sidebar_widget($id, '', '');
|
||||
wp_unregister_widget_control($id);
|
||||
}
|
||||
|
||||
function register_widget_control($name, $control_callback, $width = '', $height = '') {
|
||||
// Compat
|
||||
if ( is_array($name) ) {
|
||||
if ( count($name) == 3 )
|
||||
$name = sprintf($name[0], $name[2]);
|
||||
else
|
||||
$name = $name[0];
|
||||
}
|
||||
|
||||
$id = sanitize_title($name);
|
||||
$options = array();
|
||||
if ( !empty($width) )
|
||||
$options['width'] = $width;
|
||||
if ( !empty($height) )
|
||||
$options['height'] = $height;
|
||||
$params = array_slice(func_get_args(), 4);
|
||||
$args = array($id, $name, $control_callback, $options);
|
||||
if ( !empty($params) )
|
||||
$args = array_merge($args, $params);
|
||||
|
||||
call_user_func_array('wp_register_widget_control', $args);
|
||||
}
|
||||
|
||||
function wp_register_widget_control($id, $name, $control_callback, $options = array()) {
|
||||
global $wp_registered_widget_controls, $wp_register_widget_defaults;
|
||||
|
||||
$id = sanitize_title($id);
|
||||
|
||||
if ( empty($control_callback) ) {
|
||||
unset($wp_registered_widget_controls[$id]);
|
||||
return;
|
||||
}
|
||||
|
||||
if ( isset($wp_registered_widget_controls[$id]) && $wp_register_widget_defaults )
|
||||
return;
|
||||
|
||||
$defaults = array('width' => 300, 'height' => 200);
|
||||
$options = wp_parse_args($options, $defaults);
|
||||
$options['width'] = (int) $options['width'];
|
||||
$options['height'] = (int) $options['height'];
|
||||
$options['width'] = $options['width'] > 90 ? $options['width'] + 60 : 360;
|
||||
$options['height'] = $options['height'] > 60 ? $options['height'] + 40 : 240;
|
||||
|
||||
$widget = array(
|
||||
'name' => $name,
|
||||
'id' => $id,
|
||||
'callback' => $control_callback,
|
||||
'params' => array_slice(func_get_args(), 4)
|
||||
);
|
||||
$widget = array_merge($widget, $options);
|
||||
|
||||
$wp_registered_widget_controls[$id] = $widget;
|
||||
}
|
||||
|
||||
function unregister_widget_control($id) {
|
||||
return wp_unregister_widget_control($id);
|
||||
}
|
||||
|
||||
function wp_unregister_widget_control($id) {
|
||||
return wp_register_widget_control($id, '', '');
|
||||
}
|
||||
|
||||
function dynamic_sidebar($index = 1) {
|
||||
global $wp_registered_sidebars, $wp_registered_widgets;
|
||||
|
||||
if ( is_int($index) ) {
|
||||
$index = "sidebar-$index";
|
||||
} else {
|
||||
$index = sanitize_title($index);
|
||||
foreach ( $wp_registered_sidebars as $key => $value ) {
|
||||
if ( sanitize_title($value['name']) == $index ) {
|
||||
$index = $key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$sidebars_widgets = wp_get_sidebars_widgets();
|
||||
|
||||
if ( empty($wp_registered_sidebars[$index]) || !is_array($sidebars_widgets[$index]) || empty($sidebars_widgets[$index]) )
|
||||
return false;
|
||||
|
||||
$sidebar = $wp_registered_sidebars[$index];
|
||||
|
||||
$did_one = false;
|
||||
foreach ( $sidebars_widgets[$index] as $id ) {
|
||||
$callback = $wp_registered_widgets[$id]['callback'];
|
||||
|
||||
$params = array_merge(array($sidebar), (array) $wp_registered_widgets[$id]['params']);
|
||||
|
||||
// Substitute HTML id and class attributes into before_widget
|
||||
$params[0]['before_widget'] = sprintf($params[0]['before_widget'], $id, $wp_registered_widgets[$id]['classname']);
|
||||
|
||||
if ( is_callable($callback) ) {
|
||||
call_user_func_array($callback, $params);
|
||||
$did_one = true;
|
||||
}
|
||||
}
|
||||
|
||||
return $did_one;
|
||||
}
|
||||
|
||||
function is_active_widget($callback) {
|
||||
global $wp_registered_widgets;
|
||||
|
||||
$sidebars_widgets = wp_get_sidebars_widgets(false);
|
||||
|
||||
if ( is_array($sidebars_widgets) ) foreach ( $sidebars_widgets as $sidebar => $widgets )
|
||||
if ( is_array($widgets) ) foreach ( $widgets as $widget )
|
||||
if ( $wp_registered_widgets[$widget]['callback'] == $callback )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function is_dynamic_sidebar() {
|
||||
global $wp_registered_widgets, $wp_registered_sidebars;
|
||||
$sidebars_widgets = get_option('sidebars_widgets');
|
||||
foreach ( $wp_registered_sidebars as $index => $sidebar ) {
|
||||
if ( count($sidebars_widgets[$index]) ) {
|
||||
foreach ( $sidebars_widgets[$index] as $widget )
|
||||
if ( array_key_exists($widget, $wp_registered_widgets) )
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Internal Functions */
|
||||
|
||||
function wp_get_sidebars_widgets($update = true) {
|
||||
global $wp_registered_widgets, $wp_registered_sidebars;
|
||||
|
||||
$sidebars_widgets = get_option('sidebars_widgets');
|
||||
$_sidebars_widgets = array();
|
||||
|
||||
if ( !isset($sidebars_widgets['array_version']) )
|
||||
$sidebars_widgets['array_version'] = 1;
|
||||
|
||||
switch ( $sidebars_widgets['array_version'] ) {
|
||||
case 1 :
|
||||
foreach ( $sidebars_widgets as $index => $sidebar )
|
||||
if ( is_array($sidebar) )
|
||||
foreach ( $sidebar as $i => $name ) {
|
||||
$id = strtolower($name);
|
||||
if ( isset($wp_registered_widgets[$id]) ) {
|
||||
$_sidebars_widgets[$index][$i] = $id;
|
||||
continue;
|
||||
}
|
||||
$id = sanitize_title($name);
|
||||
if ( isset($wp_registered_widgets[$id]) ) {
|
||||
$_sidebars_widgets[$index][$i] = $id;
|
||||
continue;
|
||||
}
|
||||
unset($_sidebars_widgets[$index][$i]);
|
||||
}
|
||||
$_sidebars_widgets['array_version'] = 2;
|
||||
$sidebars_widgets = $_sidebars_widgets;
|
||||
unset($_sidebars_widgets);
|
||||
|
||||
case 2 :
|
||||
$sidebars = array_keys( $wp_registered_sidebars );
|
||||
if ( !empty( $sidebars ) ) {
|
||||
// Move the known-good ones first
|
||||
foreach ( $sidebars as $id ) {
|
||||
if ( array_key_exists( $id, $sidebars_widgets ) ) {
|
||||
$_sidebars_widgets[$id] = $sidebars_widgets[$id];
|
||||
unset($sidebars_widgets[$id], $sidebars[$id]);
|
||||
}
|
||||
}
|
||||
|
||||
// Assign to each unmatched registered sidebar the first available orphan
|
||||
unset( $sidebars_widgets[ 'array_version' ] );
|
||||
while ( ( $sidebar = array_shift( $sidebars ) ) && $widgets = array_shift( $sidebars_widgets ) )
|
||||
$_sidebars_widgets[ $sidebar ] = $widgets;
|
||||
|
||||
$_sidebars_widgets['array_version'] = 3;
|
||||
$sidebars_widgets = $_sidebars_widgets;
|
||||
unset($_sidebars_widgets);
|
||||
}
|
||||
|
||||
if ( $update )
|
||||
update_option('sidebars_widgets', $sidebars_widgets);
|
||||
}
|
||||
|
||||
unset($sidebars_widgets['array_version']);
|
||||
|
||||
return $sidebars_widgets;
|
||||
}
|
||||
|
||||
function wp_set_sidebars_widgets( $sidebars_widgets ) {
|
||||
update_option( 'sidebars_widgets', $sidebars_widgets );
|
||||
}
|
||||
|
||||
function wp_get_widget_defaults() {
|
||||
global $wp_registered_sidebars;
|
||||
|
||||
$defaults = array();
|
||||
|
||||
foreach ( $wp_registered_sidebars as $index => $sidebar )
|
||||
$defaults[$index] = array();
|
||||
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
/* Default Widgets */
|
||||
|
||||
function wp_widget_pages($args) {
|
||||
extract($args);
|
||||
$options = get_option('widget_pages');
|
||||
$title = empty($options['title']) ? __('Pages') : $options['title'];
|
||||
echo $before_widget . $before_title . $title . $after_title . "<ul>\n";
|
||||
wp_list_pages("title_li=");
|
||||
echo "</ul>\n" . $after_widget;
|
||||
}
|
||||
|
||||
function wp_widget_pages_control() {
|
||||
$options = $newoptions = get_option('widget_pages');
|
||||
if ( $_POST["pages-submit"] ) {
|
||||
$newoptions['title'] = strip_tags(stripslashes($_POST["pages-title"]));
|
||||
}
|
||||
if ( $options != $newoptions ) {
|
||||
$options = $newoptions;
|
||||
update_option('widget_pages', $options);
|
||||
}
|
||||
$title = attribute_escape($options['title']);
|
||||
?>
|
||||
<p><label for="pages-title"><?php _e('Title:'); ?> <input style="width: 250px;" id="pages-title" name="pages-title" type="text" value="<?php echo $title; ?>" /></label></p>
|
||||
<input type="hidden" id="pages-submit" name="pages-submit" value="1" />
|
||||
<?php
|
||||
}
|
||||
|
||||
function wp_widget_links($args) {
|
||||
global $wp_db_version;
|
||||
extract($args);
|
||||
if ( $wp_db_version < 3582 ) {
|
||||
// This ONLY works with li/h2 sidebars.
|
||||
get_links_list();
|
||||
} else {
|
||||
wp_list_bookmarks(array(
|
||||
'title_before' => $before_title, 'title_after' => $after_title,
|
||||
'category_before' => $before_widget, 'category_after' => $after_widget,
|
||||
'show_images' => true, 'class' => 'linkcat widget'
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
function wp_widget_search($args) {
|
||||
extract($args);
|
||||
?>
|
||||
<?php echo $before_widget; ?>
|
||||
<form id="searchform" method="get" action="<?php bloginfo('home'); ?>">
|
||||
<div>
|
||||
<input type="text" name="s" id="s" size="15" /><br />
|
||||
<input type="submit" value="<?php echo attribute_escape(__('Search')); ?>" />
|
||||
</div>
|
||||
</form>
|
||||
<?php echo $after_widget; ?>
|
||||
<?php
|
||||
}
|
||||
|
||||
function wp_widget_archives($args) {
|
||||
extract($args);
|
||||
$options = get_option('widget_archives');
|
||||
$c = $options['count'] ? '1' : '0';
|
||||
$d = $options['dropdown'] ? '1' : '0';
|
||||
$title = empty($options['title']) ? __('Archives') : $options['title'];
|
||||
|
||||
echo $before_widget;
|
||||
echo $before_title . $title . $after_title;
|
||||
|
||||
if($d) {
|
||||
?>
|
||||
<select name="archive-dropdown" onChange='document.location.href=this.options[this.selectedIndex].value;'> <option value=""><?php echo attribute_escape(__('Select Month')); ?></option> <?php wp_get_archives("type=monthly&format=option&show_post_count=$c"); ?> </select>
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<ul>
|
||||
<?php wp_get_archives("type=monthly&show_post_count=$c"); ?>
|
||||
</ul>
|
||||
<?php
|
||||
}
|
||||
|
||||
echo $after_widget;
|
||||
}
|
||||
|
||||
function wp_widget_archives_control() {
|
||||
$options = $newoptions = get_option('widget_archives');
|
||||
if ( $_POST["archives-submit"] ) {
|
||||
$newoptions['count'] = isset($_POST['archives-count']);
|
||||
$newoptions['dropdown'] = isset($_POST['archives-dropdown']);
|
||||
$newoptions['title'] = strip_tags(stripslashes($_POST["archives-title"]));
|
||||
}
|
||||
if ( $options != $newoptions ) {
|
||||
$options = $newoptions;
|
||||
update_option('widget_archives', $options);
|
||||
}
|
||||
$count = $options['count'] ? 'checked="checked"' : '';
|
||||
$dropdown = $options['dropdown'] ? 'checked="checked"' : '';
|
||||
$title = attribute_escape($options['title']);
|
||||
?>
|
||||
<p><label for="archives-title"><?php _e('Title:'); ?> <input style="width: 250px;" id="archives-title" name="archives-title" type="text" value="<?php echo $title; ?>" /></label></p>
|
||||
<p style="text-align:right;margin-right:40px;"><label for="archives-count"><?php _e('Show post counts'); ?> <input class="checkbox" type="checkbox" <?php echo $count; ?> id="archives-count" name="archives-count" /></label></p>
|
||||
<p style="text-align:right;margin-right:40px;"><label for="archives-dropdown"><?php _e('Display as a drop down'); ?> <input class="checkbox" type="checkbox" <?php echo $dropdown; ?> id="archives-dropdown" name="archives-dropdown" /></label></p>
|
||||
<input type="hidden" id="archives-submit" name="archives-submit" value="1" />
|
||||
<?php
|
||||
}
|
||||
|
||||
function wp_widget_meta($args) {
|
||||
extract($args);
|
||||
$options = get_option('widget_meta');
|
||||
$title = empty($options['title']) ? __('Meta') : $options['title'];
|
||||
?>
|
||||
<?php echo $before_widget; ?>
|
||||
<?php echo $before_title . $title . $after_title; ?>
|
||||
<ul>
|
||||
<?php wp_register(); ?>
|
||||
<li><?php wp_loginout(); ?></li>
|
||||
<li><a href="<?php bloginfo('rss2_url'); ?>" title="<?php echo attribute_escape(__('Syndicate this site using RSS 2.0')); ?>"><?php _e('Entries <abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li>
|
||||
<li><a href="<?php bloginfo('comments_rss2_url'); ?>" title="<?php echo attribute_escape(__('The latest comments to all posts in RSS')); ?>"><?php _e('Comments <abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li>
|
||||
<li><a href="http://wordpress.org/" title="<?php echo attribute_escape(__('Powered by WordPress, state-of-the-art semantic personal publishing platform.')); ?>">WordPress.org</a></li>
|
||||
<?php wp_meta(); ?>
|
||||
</ul>
|
||||
<?php echo $after_widget; ?>
|
||||
<?php
|
||||
}
|
||||
function wp_widget_meta_control() {
|
||||
$options = $newoptions = get_option('widget_meta');
|
||||
if ( $_POST["meta-submit"] ) {
|
||||
$newoptions['title'] = strip_tags(stripslashes($_POST["meta-title"]));
|
||||
}
|
||||
if ( $options != $newoptions ) {
|
||||
$options = $newoptions;
|
||||
update_option('widget_meta', $options);
|
||||
}
|
||||
$title = attribute_escape($options['title']);
|
||||
?>
|
||||
<p><label for="meta-title"><?php _e('Title:'); ?> <input style="width: 250px;" id="meta-title" name="meta-title" type="text" value="<?php echo $title; ?>" /></label></p>
|
||||
<input type="hidden" id="meta-submit" name="meta-submit" value="1" />
|
||||
<?php
|
||||
}
|
||||
|
||||
function wp_widget_calendar($args) {
|
||||
extract($args);
|
||||
$options = get_option('widget_calendar');
|
||||
$title = $options['title'];
|
||||
if ( empty($title) )
|
||||
$title = ' ';
|
||||
echo $before_widget . $before_title . $title . $after_title;
|
||||
echo '<div id="calendar_wrap">';
|
||||
get_calendar();
|
||||
echo '</div>';
|
||||
echo $after_widget;
|
||||
}
|
||||
function wp_widget_calendar_control() {
|
||||
$options = $newoptions = get_option('widget_calendar');
|
||||
if ( $_POST["calendar-submit"] ) {
|
||||
$newoptions['title'] = strip_tags(stripslashes($_POST["calendar-title"]));
|
||||
}
|
||||
if ( $options != $newoptions ) {
|
||||
$options = $newoptions;
|
||||
update_option('widget_calendar', $options);
|
||||
}
|
||||
$title = attribute_escape($options['title']);
|
||||
?>
|
||||
<p><label for="calendar-title"><?php _e('Title:'); ?> <input style="width: 250px;" id="calendar-title" name="calendar-title" type="text" value="<?php echo $title; ?>" /></label></p>
|
||||
<input type="hidden" id="calendar-submit" name="calendar-submit" value="1" />
|
||||
<?php
|
||||
}
|
||||
|
||||
function wp_widget_text($args, $number = 1) {
|
||||
extract($args);
|
||||
$options = get_option('widget_text');
|
||||
$title = $options[$number]['title'];
|
||||
if ( empty($title) )
|
||||
$title = ' ';
|
||||
$text = $options[$number]['text'];
|
||||
?>
|
||||
<?php echo $before_widget; ?>
|
||||
<?php $title ? print($before_title . $title . $after_title) : null; ?>
|
||||
<div class="textwidget"><?php echo $text; ?></div>
|
||||
<?php echo $after_widget; ?>
|
||||
<?php
|
||||
}
|
||||
|
||||
function wp_widget_text_control($number) {
|
||||
$options = $newoptions = get_option('widget_text');
|
||||
if ( !is_array($options) )
|
||||
$options = $newoptions = array();
|
||||
if ( $_POST["text-submit-$number"] ) {
|
||||
$newoptions[$number]['title'] = strip_tags(stripslashes($_POST["text-title-$number"]));
|
||||
$newoptions[$number]['text'] = stripslashes($_POST["text-text-$number"]);
|
||||
if ( !current_user_can('unfiltered_html') )
|
||||
$newoptions[$number]['text'] = stripslashes(wp_filter_post_kses($newoptions[$number]['text']));
|
||||
}
|
||||
if ( $options != $newoptions ) {
|
||||
$options = $newoptions;
|
||||
update_option('widget_text', $options);
|
||||
}
|
||||
$title = attribute_escape($options[$number]['title']);
|
||||
$text = attribute_escape($options[$number]['text']);
|
||||
?>
|
||||
<input style="width: 450px;" id="text-title-<?php echo "$number"; ?>" name="text-title-<?php echo "$number"; ?>" type="text" value="<?php echo $title; ?>" />
|
||||
<textarea style="width: 450px; height: 280px;" id="text-text-<?php echo "$number"; ?>" name="text-text-<?php echo "$number"; ?>"><?php echo $text; ?></textarea>
|
||||
<input type="hidden" id="text-submit-<?php echo "$number"; ?>" name="text-submit-<?php echo "$number"; ?>" value="1" />
|
||||
<?php
|
||||
}
|
||||
|
||||
function wp_widget_text_setup() {
|
||||
$options = $newoptions = get_option('widget_text');
|
||||
if ( isset($_POST['text-number-submit']) ) {
|
||||
$number = (int) $_POST['text-number'];
|
||||
if ( $number > 9 ) $number = 9;
|
||||
if ( $number < 1 ) $number = 1;
|
||||
$newoptions['number'] = $number;
|
||||
}
|
||||
if ( $options != $newoptions ) {
|
||||
$options = $newoptions;
|
||||
update_option('widget_text', $options);
|
||||
wp_widget_text_register($options['number']);
|
||||
}
|
||||
}
|
||||
|
||||
function wp_widget_text_page() {
|
||||
$options = $newoptions = get_option('widget_text');
|
||||
?>
|
||||
<div class="wrap">
|
||||
<form method="POST">
|
||||
<h2><?php _e('Text Widgets'); ?></h2>
|
||||
<p style="line-height: 30px;"><?php _e('How many text widgets would you like?'); ?>
|
||||
<select id="text-number" name="text-number" value="<?php echo $options['number']; ?>">
|
||||
<?php for ( $i = 1; $i < 10; ++$i ) echo "<option value='$i' ".($options['number']==$i ? "selected='selected'" : '').">$i</option>"; ?>
|
||||
</select>
|
||||
<span class="submit"><input type="submit" name="text-number-submit" id="text-number-submit" value="<?php echo attribute_escape(__('Save')); ?>" /></span></p>
|
||||
</form>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
function wp_widget_text_register() {
|
||||
$options = get_option('widget_text');
|
||||
$number = $options['number'];
|
||||
if ( $number < 1 ) $number = 1;
|
||||
if ( $number > 9 ) $number = 9;
|
||||
$dims = array('width' => 460, 'height' => 350);
|
||||
$class = array('classname' => 'widget_text');
|
||||
for ($i = 1; $i <= 9; $i++) {
|
||||
$name = sprintf(__('Text %d'), $i);
|
||||
$id = "text-$i"; // Never never never translate an id
|
||||
wp_register_sidebar_widget($id, $name, $i <= $number ? 'wp_widget_text' : /* unregister */ '', $class, $i);
|
||||
wp_register_widget_control($id, $name, $i <= $number ? 'wp_widget_text_control' : /* unregister */ '', $dims, $i);
|
||||
}
|
||||
add_action('sidebar_admin_setup', 'wp_widget_text_setup');
|
||||
add_action('sidebar_admin_page', 'wp_widget_text_page');
|
||||
}
|
||||
|
||||
function wp_widget_categories($args) {
|
||||
extract($args);
|
||||
$options = get_option('widget_categories');
|
||||
$c = $options['count'] ? '1' : '0';
|
||||
$h = $options['hierarchical'] ? '1' : '0';
|
||||
$d = $options['dropdown'] ? '1' : '0';
|
||||
$title = empty($options['title']) ? __('Categories') : $options['title'];
|
||||
|
||||
echo $before_widget;
|
||||
echo $before_title . $title . $after_title;
|
||||
|
||||
$cat_args = "orderby=name&show_count={$c}&hierarchical={$h}";
|
||||
|
||||
if($d) {
|
||||
wp_dropdown_categories($cat_args . '&show_option_none= ' . __('Select Category'));
|
||||
?>
|
||||
|
||||
<script lang='javascript'><!--
|
||||
var dropdown = document.getElementById("cat");
|
||||
function onCatChange() {
|
||||
if ( dropdown.options[dropdown.selectedIndex].value > 0 ) {
|
||||
location.href = "<?php echo get_option('siteurl'); ?>/?cat="+dropdown.options[dropdown.selectedIndex].value;
|
||||
}
|
||||
}
|
||||
dropdown.onchange = onCatChange;
|
||||
--></script>
|
||||
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<ul>
|
||||
<?php wp_list_categories($cat_args . '&title_li='); ?>
|
||||
</ul>
|
||||
<?php
|
||||
}
|
||||
|
||||
echo $after_widget;
|
||||
}
|
||||
|
||||
function wp_widget_categories_control() {
|
||||
$options = $newoptions = get_option('widget_categories');
|
||||
if ( $_POST['categories-submit'] ) {
|
||||
$newoptions['count'] = isset($_POST['categories-count']);
|
||||
$newoptions['hierarchical'] = isset($_POST['categories-hierarchical']);
|
||||
$newoptions['dropdown'] = isset($_POST['categories-dropdown']);
|
||||
$newoptions['title'] = strip_tags(stripslashes($_POST['categories-title']));
|
||||
}
|
||||
if ( $options != $newoptions ) {
|
||||
$options = $newoptions;
|
||||
update_option('widget_categories', $options);
|
||||
}
|
||||
$count = $options['count'] ? 'checked="checked"' : '';
|
||||
$hierarchical = $options['hierarchical'] ? 'checked="checked"' : '';
|
||||
$dropdown = $options['dropdown'] ? 'checked="checked"' : '';
|
||||
$title = attribute_escape($options['title']);
|
||||
?>
|
||||
<p><label for="categories-title"><?php _e('Title:'); ?> <input style="width: 250px;" id="categories-title" name="categories-title" type="text" value="<?php echo $title; ?>" /></label></p>
|
||||
<p style="text-align:right;margin-right:40px;"><label for="categories-count"><?php _e('Show post counts'); ?> <input class="checkbox" type="checkbox" <?php echo $count; ?> id="categories-count" name="categories-count" /></label></p>
|
||||
<p style="text-align:right;margin-right:40px;"><label for="categories-hierarchical" style="text-align:right;"><?php _e('Show hierarchy'); ?> <input class="checkbox" type="checkbox" <?php echo $hierarchical; ?> id="categories-hierarchical" name="categories-hierarchical" /></label></p>
|
||||
<p style="text-align:right;margin-right:40px;"><label for="categories-dropdown" style="text-align:right;"><?php _e('Display as a drop down'); ?> <input class="checkbox" type="checkbox" <?php echo $dropdown; ?> id="categories-dropdown" name="categories-dropdown" /></label></p>
|
||||
<input type="hidden" id="categories-submit" name="categories-submit" value="1" />
|
||||
<?php
|
||||
}
|
||||
|
||||
function wp_widget_recent_entries($args) {
|
||||
if ( $output = wp_cache_get('widget_recent_entries') )
|
||||
return print($output);
|
||||
|
||||
ob_start();
|
||||
extract($args);
|
||||
$options = get_option('widget_recent_entries');
|
||||
$title = empty($options['title']) ? __('Recent Posts') : $options['title'];
|
||||
if ( !$number = (int) $options['number'] )
|
||||
$number = 10;
|
||||
else if ( $number < 1 )
|
||||
$number = 1;
|
||||
else if ( $number > 15 )
|
||||
$number = 15;
|
||||
|
||||
$r = new WP_Query("showposts=$number&what_to_show=posts&nopaging=0");
|
||||
if ($r->have_posts()) :
|
||||
?>
|
||||
<?php echo $before_widget; ?>
|
||||
<?php echo $before_title . $title . $after_title; ?>
|
||||
<ul>
|
||||
<?php while ($r->have_posts()) : $r->the_post(); ?>
|
||||
<li><a href="<?php the_permalink() ?>"><?php if ( get_the_title() ) the_title(); else the_ID(); ?> </a></li>
|
||||
<?php endwhile; ?>
|
||||
</ul>
|
||||
<?php echo $after_widget; ?>
|
||||
<?php
|
||||
endif;
|
||||
wp_cache_add('widget_recent_entries', ob_get_flush());
|
||||
}
|
||||
|
||||
function wp_flush_widget_recent_entries() {
|
||||
wp_cache_delete('widget_recent_entries');
|
||||
}
|
||||
|
||||
add_action('save_post', 'wp_flush_widget_recent_entries');
|
||||
add_action('post_deleted', 'wp_flush_widget_recent_entries');
|
||||
|
||||
function wp_widget_recent_entries_control() {
|
||||
$options = $newoptions = get_option('widget_recent_entries');
|
||||
if ( $_POST["recent-entries-submit"] ) {
|
||||
$newoptions['title'] = strip_tags(stripslashes($_POST["recent-entries-title"]));
|
||||
$newoptions['number'] = (int) $_POST["recent-entries-number"];
|
||||
}
|
||||
if ( $options != $newoptions ) {
|
||||
$options = $newoptions;
|
||||
update_option('widget_recent_entries', $options);
|
||||
wp_flush_widget_recent_entries();
|
||||
}
|
||||
$title = attribute_escape($options['title']);
|
||||
if ( !$number = (int) $options['number'] )
|
||||
$number = 5;
|
||||
?>
|
||||
<p><label for="recent-entries-title"><?php _e('Title:'); ?> <input style="width: 250px;" id="recent-entries-title" name="recent-entries-title" type="text" value="<?php echo $title; ?>" /></label></p>
|
||||
<p><label for="recent-entries-number"><?php _e('Number of posts to show:'); ?> <input style="width: 25px; text-align: center;" id="recent-entries-number" name="recent-entries-number" type="text" value="<?php echo $number; ?>" /></label> <?php _e('(at most 15)'); ?></p>
|
||||
<input type="hidden" id="recent-entries-submit" name="recent-entries-submit" value="1" />
|
||||
<?php
|
||||
}
|
||||
|
||||
function wp_widget_recent_comments($args) {
|
||||
global $wpdb, $comments, $comment;
|
||||
extract($args, EXTR_SKIP);
|
||||
$options = get_option('widget_recent_comments');
|
||||
$title = empty($options['title']) ? __('Recent Comments') : $options['title'];
|
||||
if ( !$number = (int) $options['number'] )
|
||||
$number = 5;
|
||||
else if ( $number < 1 )
|
||||
$number = 1;
|
||||
else if ( $number > 15 )
|
||||
$number = 15;
|
||||
|
||||
if ( !$comments = wp_cache_get( 'recent_comments', 'widget' ) ) {
|
||||
$comments = $wpdb->get_results("SELECT comment_author, comment_author_url, comment_ID, comment_post_ID FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT $number");
|
||||
wp_cache_add( 'recent_comments', $comments, 'widget' );
|
||||
}
|
||||
?>
|
||||
|
||||
<?php echo $before_widget; ?>
|
||||
<?php echo $before_title . $title . $after_title; ?>
|
||||
<ul id="recentcomments"><?php
|
||||
if ( $comments ) : foreach ($comments as $comment) :
|
||||
echo '<li class="recentcomments">' . sprintf(__('%1$s on %2$s'), get_comment_author_link(), '<a href="'. get_permalink($comment->comment_post_ID) . '#comment-' . $comment->comment_ID . '">' . get_the_title($comment->comment_post_ID) . '</a>') . '</li>';
|
||||
endforeach; endif;?></ul>
|
||||
<?php echo $after_widget; ?>
|
||||
<?php
|
||||
}
|
||||
|
||||
function wp_delete_recent_comments_cache() {
|
||||
wp_cache_delete( 'recent_comments', 'widget' );
|
||||
}
|
||||
add_action( 'comment_post', 'wp_delete_recent_comments_cache' );
|
||||
add_action( 'wp_set_comment_status', 'wp_delete_recent_comments_cache' );
|
||||
|
||||
function wp_widget_recent_comments_control() {
|
||||
$options = $newoptions = get_option('widget_recent_comments');
|
||||
if ( $_POST["recent-comments-submit"] ) {
|
||||
$newoptions['title'] = strip_tags(stripslashes($_POST["recent-comments-title"]));
|
||||
$newoptions['number'] = (int) $_POST["recent-comments-number"];
|
||||
}
|
||||
if ( $options != $newoptions ) {
|
||||
$options = $newoptions;
|
||||
update_option('widget_recent_comments', $options);
|
||||
wp_delete_recent_comments_cache();
|
||||
}
|
||||
$title = attribute_escape($options['title']);
|
||||
if ( !$number = (int) $options['number'] )
|
||||
$number = 5;
|
||||
?>
|
||||
<p><label for="recent-comments-title"><?php _e('Title:'); ?> <input style="width: 250px;" id="recent-comments-title" name="recent-comments-title" type="text" value="<?php echo $title; ?>" /></label></p>
|
||||
<p><label for="recent-comments-number"><?php _e('Number of comments to show:'); ?> <input style="width: 25px; text-align: center;" id="recent-comments-number" name="recent-comments-number" type="text" value="<?php echo $number; ?>" /></label> <?php _e('(at most 15)'); ?></p>
|
||||
<input type="hidden" id="recent-comments-submit" name="recent-comments-submit" value="1" />
|
||||
<?php
|
||||
}
|
||||
|
||||
function wp_widget_recent_comments_style() {
|
||||
?>
|
||||
<style type="text/css">.recentcomments a{display:inline !important;padding: 0 !important;margin: 0 !important;}</style>
|
||||
<?php
|
||||
}
|
||||
|
||||
function wp_widget_recent_comments_register() {
|
||||
$dims = array('width' => 320, 'height' => 90);
|
||||
$class = array('classname' => 'widget_recent_comments');
|
||||
wp_register_sidebar_widget('recent-comments', __('Recent Comments'), 'wp_widget_recent_comments', $class);
|
||||
wp_register_widget_control('recent-comments', __('Recent Comments'), 'wp_widget_recent_comments_control', $dims);
|
||||
|
||||
if ( is_active_widget('wp_widget_recent_comments') )
|
||||
add_action('wp_head', 'wp_widget_recent_comments_style');
|
||||
}
|
||||
|
||||
function wp_widget_rss($args, $number = 1) {
|
||||
require_once(ABSPATH . WPINC . '/rss.php');
|
||||
extract($args);
|
||||
$options = get_option('widget_rss');
|
||||
if ( isset($options['error']) && $options['error'] )
|
||||
return;
|
||||
$num_items = (int) $options[$number]['items'];
|
||||
$show_summary = $options[$number]['show_summary'];
|
||||
if ( empty($num_items) || $num_items < 1 || $num_items > 10 ) $num_items = 10;
|
||||
$url = $options[$number]['url'];
|
||||
while ( strstr($url, 'http') != $url )
|
||||
$url = substr($url, 1);
|
||||
if ( empty($url) )
|
||||
return;
|
||||
$rss = fetch_rss($url);
|
||||
$link = clean_url(strip_tags($rss->channel['link']));
|
||||
while ( strstr($link, 'http') != $link )
|
||||
$link = substr($link, 1);
|
||||
$desc = attribute_escape(strip_tags(html_entity_decode($rss->channel['description'], ENT_QUOTES)));
|
||||
$title = $options[$number]['title'];
|
||||
if ( empty($title) )
|
||||
$title = htmlentities(strip_tags($rss->channel['title']));
|
||||
if ( empty($title) )
|
||||
$title = $desc;
|
||||
if ( empty($title) )
|
||||
$title = __('Unknown Feed');
|
||||
$url = clean_url(strip_tags($url));
|
||||
if ( file_exists(dirname(__FILE__) . '/rss.png') )
|
||||
$icon = str_replace(ABSPATH, get_option('siteurl').'/', dirname(__FILE__)) . '/rss.png';
|
||||
else
|
||||
$icon = get_option('siteurl').'/wp-includes/images/rss.png';
|
||||
$title = "<a class='rsswidget' href='$url' title='" . attribute_escape(__('Syndicate this content')) ."'><img style='background:orange;color:white;border:none;' width='14' height='14' src='$icon' alt='RSS' /></a> <a class='rsswidget' href='$link' title='$desc'>$title</a>";
|
||||
?>
|
||||
<?php echo $before_widget; ?>
|
||||
<?php $title ? print($before_title . $title . $after_title) : null; ?>
|
||||
<ul>
|
||||
<?php
|
||||
if ( is_array( $rss->items ) ) {
|
||||
$rss->items = array_slice($rss->items, 0, $num_items);
|
||||
foreach ($rss->items as $item ) {
|
||||
while ( strstr($item['link'], 'http') != $item['link'] )
|
||||
$item['link'] = substr($item['link'], 1);
|
||||
$link = clean_url(strip_tags($item['link']));
|
||||
$title = attribute_escape(strip_tags($item['title']));
|
||||
if ( empty($title) )
|
||||
$title = __('Untitled');
|
||||
$desc = '';
|
||||
if ( $show_summary ) {
|
||||
$summary = '<div class="rssSummary">' . $item['description'] . '</div>';
|
||||
} else {
|
||||
if ( isset( $item['description'] ) && is_string( $item['description'] ) )
|
||||
$desc = str_replace(array("\n", "\r"), ' ', attribute_escape(strip_tags(html_entity_decode($item['description'], ENT_QUOTES))));
|
||||
$summary = '';
|
||||
}
|
||||
echo "<li><a class='rsswidget' href='$link' title='$desc'>$title</a>$summary</li>";
|
||||
}
|
||||
} else {
|
||||
echo __('<li>An error has occured; the feed is probably down. Try again later.</li>');
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
<?php echo $after_widget; ?>
|
||||
<?php
|
||||
}
|
||||
|
||||
function wp_widget_rss_control($number) {
|
||||
$options = $newoptions = get_option('widget_rss');
|
||||
if ( $_POST["rss-submit-$number"] ) {
|
||||
$newoptions[$number]['items'] = (int) $_POST["rss-items-$number"];
|
||||
$url = clean_url(strip_tags(stripslashes($_POST["rss-url-$number"])));
|
||||
$newoptions[$number]['title'] = trim(strip_tags(stripslashes($_POST["rss-title-$number"])));
|
||||
if ( $url !== $options[$number]['url'] ) {
|
||||
require_once(ABSPATH . WPINC . '/rss.php');
|
||||
$rss = fetch_rss($url);
|
||||
if ( is_object($rss) ) {
|
||||
$newoptions[$number]['url'] = $url;
|
||||
$newoptions[$number]['error'] = false;
|
||||
} else {
|
||||
$newoptions[$number]['error'] = true;
|
||||
$newoptions[$number]['url'] = wp_specialchars(__('Error: could not find an RSS or ATOM feed at that URL.'), 1);
|
||||
$error = sprintf(__('Error in RSS %1$d: %2$s'), $number, $newoptions[$number]['error']);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( $options != $newoptions ) {
|
||||
$options = $newoptions;
|
||||
update_option('widget_rss', $options);
|
||||
}
|
||||
$url = attribute_escape($options[$number]['url']);
|
||||
$items = (int) $options[$number]['items'];
|
||||
$title = attribute_escape($options[$number]['title']);
|
||||
if ( empty($items) || $items < 1 ) $items = 10;
|
||||
?>
|
||||
<p style="text-align:center;"><?php _e('Enter the RSS feed URL here:'); ?></p>
|
||||
<input style="width: 400px;" id="rss-url-<?php echo "$number"; ?>" name="rss-url-<?php echo "$number"; ?>" type="text" value="<?php echo $url; ?>" />
|
||||
<p style="text-align:center;"><?php _e('Give the feed a title (optional):'); ?></p>
|
||||
<input style="width: 400px;" id="rss-title-<?php echo "$number"; ?>" name="rss-title-<?php echo "$number"; ?>" type="text" value="<?php echo $title; ?>" />
|
||||
<p style="text-align:center; line-height: 30px;"><?php _e('How many items would you like to display?'); ?> <select id="rss-items-<?php echo $number; ?>" name="rss-items-<?php echo $number; ?>"><?php for ( $i = 1; $i <= 10; ++$i ) echo "<option value='$i' ".($items==$i ? "selected='selected'" : '').">$i</option>"; ?></select></p>
|
||||
<input type="hidden" id="rss-submit-<?php echo "$number"; ?>" name="rss-submit-<?php echo "$number"; ?>" value="1" />
|
||||
<?php
|
||||
}
|
||||
|
||||
function wp_widget_rss_setup() {
|
||||
$options = $newoptions = get_option('widget_rss');
|
||||
if ( isset($_POST['rss-number-submit']) ) {
|
||||
$number = (int) $_POST['rss-number'];
|
||||
if ( $number > 9 ) $number = 9;
|
||||
if ( $number < 1 ) $number = 1;
|
||||
$newoptions['number'] = $number;
|
||||
}
|
||||
if ( $options != $newoptions ) {
|
||||
$options = $newoptions;
|
||||
update_option('widget_rss', $options);
|
||||
wp_widget_rss_register($options['number']);
|
||||
}
|
||||
}
|
||||
|
||||
function wp_widget_rss_page() {
|
||||
$options = $newoptions = get_option('widget_rss');
|
||||
?>
|
||||
<div class="wrap">
|
||||
<form method="POST">
|
||||
<h2><?php _e('RSS Feed Widgets'); ?></h2>
|
||||
<p style="line-height: 30px;"><?php _e('How many RSS widgets would you like?'); ?>
|
||||
<select id="rss-number" name="rss-number" value="<?php echo $options['number']; ?>">
|
||||
<?php for ( $i = 1; $i < 10; ++$i ) echo "<option value='$i' ".($options['number']==$i ? "selected='selected'" : '').">$i</option>"; ?>
|
||||
</select>
|
||||
<span class="submit"><input type="submit" name="rss-number-submit" id="rss-number-submit" value="<?php echo attribute_escape(__('Save')); ?>" /></span></p>
|
||||
</form>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
function wp_widget_rss_register() {
|
||||
$options = get_option('widget_rss');
|
||||
$number = $options['number'];
|
||||
if ( $number < 1 ) $number = 1;
|
||||
if ( $number > 9 ) $number = 9;
|
||||
$dims = array('width' => 410, 'height' => 200);
|
||||
$class = array('classname' => 'widget_rss');
|
||||
for ($i = 1; $i <= 9; $i++) {
|
||||
$name = sprintf(__('RSS %d'), $i);
|
||||
$id = "rss-$i"; // Never never never translate an id
|
||||
wp_register_sidebar_widget($id, $name, $i <= $number ? 'wp_widget_rss' : /* unregister */ '', $class, $i);
|
||||
wp_register_widget_control($id, $name, $i <= $number ? 'wp_widget_rss_control' : /* unregister */ '', $dims, $i);
|
||||
}
|
||||
add_action('sidebar_admin_setup', 'wp_widget_rss_setup');
|
||||
add_action('sidebar_admin_page', 'wp_widget_rss_page');
|
||||
}
|
||||
|
||||
function wp_widgets_init() {
|
||||
global $wp_register_widget_defaults;
|
||||
|
||||
$wp_register_widget_defaults = true;
|
||||
$dims90 = array('height' => 90, 'width' => 300);
|
||||
$dims100 = array('height' => 100, 'width' => 300);
|
||||
$dims150 = array('height' => 150, 'width' => 300);
|
||||
$class = array('classname' => 'widget_pages');
|
||||
wp_register_sidebar_widget('pages', __('Pages'), 'wp_widget_pages', $class);
|
||||
wp_register_widget_control('pages', __('Pages'), 'wp_widget_pages_control', $dims90);
|
||||
$class['classname'] = 'widget_calendar';
|
||||
wp_register_sidebar_widget('calendar', __('Calendar'), 'wp_widget_calendar', $class);
|
||||
wp_register_widget_control('calendar', __('Calendar'), 'wp_widget_calendar_control', $dims90);
|
||||
$class['classname'] = 'widget_archives';
|
||||
wp_register_sidebar_widget('archives', __('Archives'), 'wp_widget_archives', $class);
|
||||
wp_register_widget_control('archives', __('Archives'), 'wp_widget_archives_control', $dims100);
|
||||
$class['classname'] = 'widget_links';
|
||||
wp_register_sidebar_widget('links', __('Links'), 'wp_widget_links', $class);
|
||||
$class['classname'] = 'widget_meta';
|
||||
wp_register_sidebar_widget('meta', __('Meta'), 'wp_widget_meta', $class);
|
||||
wp_register_widget_control('meta', __('Meta'), 'wp_widget_meta_control', $dims90);
|
||||
$class['classname'] = 'widget_search';
|
||||
wp_register_sidebar_widget('search', __('Search'), 'wp_widget_search', $class);
|
||||
$class['classname'] = 'widget_categories';
|
||||
wp_register_sidebar_widget('categories', __('Categories'), 'wp_widget_categories', $class);
|
||||
wp_register_widget_control('categories', __('Categories'), 'wp_widget_categories_control', $dims150);
|
||||
$class['classname'] = 'widget_recent_entries';
|
||||
wp_register_sidebar_widget('recent-posts', __('Recent Posts'), 'wp_widget_recent_entries', $class);
|
||||
wp_register_widget_control('recent-posts', __('Recent Posts'), 'wp_widget_recent_entries_control', $dims90);
|
||||
wp_widget_text_register();
|
||||
wp_widget_rss_register();
|
||||
wp_widget_recent_comments_register();
|
||||
|
||||
$wp_register_widget_defaults = false;
|
||||
|
||||
do_action('widgets_init');
|
||||
}
|
||||
|
||||
add_action('init', 'wp_widgets_init', 1);
|
||||
|
||||
?>
|
||||
@@ -62,7 +62,7 @@ for ($i=1; $i <= $count; $i++) :
|
||||
|
||||
// Set the author using the email address (To or Reply-To, the last used)
|
||||
// otherwise use the site admin
|
||||
if (preg_match('/From: /', $line) | preg_match('Reply-To: /', $line)) {
|
||||
if (preg_match('/From: /', $line) | preg_match('/Reply-To: /', $line)) {
|
||||
$author=trim($line);
|
||||
if ( ereg("([a-zA-Z0-9\_\-\.]+@[\a-zA-z0-9\_\-\.]+)", $author , $regs) ) {
|
||||
$author = $regs[1];
|
||||
|
||||
@@ -263,4 +263,4 @@ register_shutdown_function('shutdown_action_hook');
|
||||
// Everything is loaded and initialized.
|
||||
do_action('init');
|
||||
|
||||
?>
|
||||
?>
|
||||
26
xmlrpc.php
26
xmlrpc.php
@@ -5,6 +5,12 @@ define('XMLRPC_REQUEST', true);
|
||||
// Some browser-embedded clients send cookies. We don't want them.
|
||||
$_COOKIE = array();
|
||||
|
||||
// A bug in PHP < 5.2.2 makes $HTTP_RAW_POST_DATA not set by default,
|
||||
// but we can do it ourself.
|
||||
if ( !isset( $HTTP_RAW_POST_DATA ) ) {
|
||||
$HTTP_RAW_POST_DATA = file_get_contents( 'php://input' );
|
||||
}
|
||||
|
||||
# fix for mozBlog and other cases where '<?xml' isn't on the very first line
|
||||
if ( isset($HTTP_RAW_POST_DATA) )
|
||||
$HTTP_RAW_POST_DATA = trim($HTTP_RAW_POST_DATA);
|
||||
@@ -202,7 +208,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
$allow_pings = ("open" == $page->ping_status) ? 1 : 0;
|
||||
|
||||
// Format page date.
|
||||
$page_date = mysql2date("Ymd\TH:i:s", $page->post_date);
|
||||
$page_date = mysql2date("Ymd\TH:i:s", $page->post_date_gmt);
|
||||
|
||||
// Pull the categories info together.
|
||||
$categories = array();
|
||||
@@ -423,7 +429,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
SELECT ID page_id,
|
||||
post_title page_title,
|
||||
post_parent page_parent_id,
|
||||
post_date
|
||||
post_date_gmt
|
||||
FROM {$wpdb->posts}
|
||||
WHERE post_type = 'page'
|
||||
ORDER BY ID
|
||||
@@ -432,10 +438,10 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
// The date needs to be formated properly.
|
||||
$num_pages = count($page_list);
|
||||
for($i = 0; $i < $num_pages; $i++) {
|
||||
$post_date = mysql2date("Ymd\TH:i:s", $page_list[$i]->post_date);
|
||||
$post_date = mysql2date("Ymd\TH:i:s", $page_list[$i]->post_date_gmt);
|
||||
$page_list[$i]->dateCreated = new IXR_Date($post_date);
|
||||
|
||||
unset($page_list[$i]->post_date);
|
||||
unset($page_list[$i]->post_date_gmt);
|
||||
}
|
||||
|
||||
return($page_list);
|
||||
@@ -1033,7 +1039,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
if (!empty($dateCreatedd)) {
|
||||
$dateCreated = $dateCreatedd->getIso();
|
||||
$post_date = get_date_from_gmt(iso8601_to_datetime($dateCreated));
|
||||
$post_date_gmt = iso8601_to_datetime($dateCreated, GMT);
|
||||
$post_date_gmt = iso8601_to_datetime($dateCreated. "Z", GMT);
|
||||
} else {
|
||||
$post_date = current_time('mysql');
|
||||
$post_date_gmt = current_time('mysql', 1);
|
||||
@@ -1223,7 +1229,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
if (!empty($dateCreatedd)) {
|
||||
$dateCreated = $dateCreatedd->getIso();
|
||||
$post_date = get_date_from_gmt(iso8601_to_datetime($dateCreated));
|
||||
$post_date_gmt = iso8601_to_datetime($dateCreated, GMT);
|
||||
$post_date_gmt = iso8601_to_datetime($dateCreated . "Z", GMT);
|
||||
} else {
|
||||
$post_date = $postdata['post_date'];
|
||||
$post_date_gmt = $postdata['post_date_gmt'];
|
||||
@@ -1263,7 +1269,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
|
||||
if ($postdata['post_date'] != '') {
|
||||
|
||||
$post_date = mysql2date('Ymd\TH:i:s', $postdata['post_date']);
|
||||
$post_date = mysql2date('Ymd\TH:i:s', $postdata['post_date_gmt']);
|
||||
|
||||
$categories = array();
|
||||
$catids = wp_get_post_categories($post_ID);
|
||||
@@ -1331,7 +1337,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
|
||||
foreach ($posts_list as $entry) {
|
||||
|
||||
$post_date = mysql2date('Ymd\TH:i:s', $entry['post_date']);
|
||||
$post_date = mysql2date('Ymd\TH:i:s', $entry['post_date_gmt']);
|
||||
$categories = array();
|
||||
$catids = wp_get_post_categories($entry['ID']);
|
||||
foreach($catids as $catid) {
|
||||
@@ -1516,7 +1522,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
|
||||
foreach ($posts_list as $entry) {
|
||||
|
||||
$post_date = mysql2date('Ymd\TH:i:s', $entry['post_date']);
|
||||
$post_date = mysql2date('Ymd\TH:i:s', $entry['post_date_gmt']);
|
||||
|
||||
$struct[] = array(
|
||||
'dateCreated' => new IXR_Date($post_date),
|
||||
@@ -1554,7 +1560,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
$categories_struct = array();
|
||||
|
||||
// FIXME: can we avoid using direct SQL there?
|
||||
if ($cats = $wpdb->get_results("SELECT cat_ID, cat_name FROM $wpdb->categories WHERE (type & " . TAXONOMY_CATEGORY . " != 0)", ARRAY_A)) {
|
||||
if ($cats = $wpdb->get_results("SELECT cat_ID, cat_name FROM $wpdb->categories", ARRAY_A)) {
|
||||
foreach ($cats as $cat) {
|
||||
$struct['categoryId'] = $cat['cat_ID'];
|
||||
$struct['categoryName'] = $cat['cat_name'];
|
||||
|
||||
Reference in New Issue
Block a user