web/wp-admin/press-this.php
changeset 204 09a1c134465b
parent 194 32102edaa81b
equal deleted inserted replaced
203:f507feede89a 204:09a1c134465b
    11 /** WordPress Administration Bootstrap */
    11 /** WordPress Administration Bootstrap */
    12 require_once('./admin.php');
    12 require_once('./admin.php');
    13 
    13 
    14 header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
    14 header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
    15 
    15 
    16 if ( ! current_user_can('edit_posts') )
    16 if ( ! current_user_can( 'edit_posts' ) || ! current_user_can( get_post_type_object( 'post' )->cap->create_posts ) )
    17 	wp_die( __( 'Cheatin’ uh?' ) );
    17 	wp_die( __( 'Cheatin’ uh?' ) );
    18 
    18 
    19 /**
    19 /**
    20  * Press It form handler.
    20  * Press It form handler.
    21  *
    21  *
   108 $image = isset($_GET['i']) ? $_GET['i'] : '';
   108 $image = isset($_GET['i']) ? $_GET['i'] : '';
   109 
   109 
   110 if ( !empty($_REQUEST['ajax']) ) {
   110 if ( !empty($_REQUEST['ajax']) ) {
   111 	switch ($_REQUEST['ajax']) {
   111 	switch ($_REQUEST['ajax']) {
   112 		case 'video': ?>
   112 		case 'video': ?>
   113 			<script type="text/javascript" charset="utf-8">
   113 			<script type="text/javascript">
   114 			/* <![CDATA[ */
   114 			/* <![CDATA[ */
   115 				jQuery('.select').click(function() {
   115 				jQuery('.select').click(function() {
   116 					append_editor(jQuery('#embed-code').val());
   116 					append_editor(jQuery('#embed-code').val());
   117 					jQuery('#extra-fields').hide();
   117 					jQuery('#extra-fields').hide();
   118 					jQuery('#extra-fields').html('');
   118 					jQuery('#extra-fields').html('');
   131 				</div>
   131 				</div>
   132 			</div>
   132 			</div>
   133 			<?php break;
   133 			<?php break;
   134 
   134 
   135 		case 'photo_thickbox': ?>
   135 		case 'photo_thickbox': ?>
   136 			<script type="text/javascript" charset="utf-8">
   136 			<script type="text/javascript">
   137 				/* <![CDATA[ */
   137 				/* <![CDATA[ */
   138 				jQuery('.cancel').click(function() {
   138 				jQuery('.cancel').click(function() {
   139 					tb_remove();
   139 					tb_remove();
   140 				});
   140 				});
   141 				jQuery('.select').click(function() {
   141 				jQuery('.select').click(function() {
   170 		 * @param string $uri
   170 		 * @param string $uri
   171 		 * @return string
   171 		 * @return string
   172 		 */
   172 		 */
   173 		function get_images_from_uri($uri) {
   173 		function get_images_from_uri($uri) {
   174 			$uri = preg_replace('/\/#.+?$/','', $uri);
   174 			$uri = preg_replace('/\/#.+?$/','', $uri);
   175 			if ( preg_match('/\.(jpg|jpe|jpeg|png|gif)$/', $uri) && !strpos($uri,'blogger.com') )
   175 			if ( preg_match( '/\.(jpe?g|jpe|gif|png)\b/i', $uri ) && !strpos( $uri, 'blogger.com' ) )
   176 				return "'" . esc_attr( html_entity_decode($uri) ) . "'";
   176 				return "'" . esc_attr( html_entity_decode($uri) ) . "'";
   177 			$content = wp_remote_fopen($uri);
   177 			$content = wp_remote_fopen($uri);
   178 			if ( false === $content )
   178 			if ( false === $content )
   179 				return '';
   179 				return '';
   180 			$host = parse_url($uri);
   180 			$host = parse_url($uri);
   286 			jQuery('#extra-fields').hide();
   286 			jQuery('#extra-fields').hide();
   287 			jQuery('#extra-fields').html('');
   287 			jQuery('#extra-fields').html('');
   288 			return false;
   288 			return false;
   289 		}
   289 		}
   290 
   290 
   291 		jQuery('#extra-fields').html('<div class="postbox"><h2><?php _e( 'Add Photos' ); ?> <small id="photo_directions">(<?php _e("click images to select") ?>)</small></h2><ul class="actions"><li><a href="#" id="photo-add-url" class="button"><?php _e("Add from URL") ?> +</a></li></ul><div class="inside"><div class="titlewrap"><div id="img_container"></div></div><p id="options"><a href="#" class="close button"><?php _e('Cancel'); ?></a><a href="#" class="refresh button"><?php _e('Refresh'); ?></a></p></div>');
   291 		jQuery('#extra-fields').html('<div class="postbox"><h2><?php _e( 'Add Photos' ); ?> <small id="photo_directions">(<?php _e("click images to select") ?>)</small></h2><ul class="actions"><li><a href="#" id="photo-add-url" class="button button-small"><?php _e("Add from URL") ?> +</a></li></ul><div class="inside"><div class="titlewrap"><div id="img_container"></div></div><p id="options"><a href="#" class="close button"><?php _e('Cancel'); ?></a><a href="#" class="refresh button"><?php _e('Refresh'); ?></a></p></div>');
   292 		jQuery('#img_container').html(strtoappend);
   292 		jQuery('#img_container').html(strtoappend);
   293 		<?php break;
   293 		<?php break;
   294 }
   294 }
   295 die;
   295 die;
   296 }
   296 }
   412 				break;
   412 				break;
   413 		}
   413 		}
   414 	}
   414 	}
   415 	jQuery(document).ready(function($) {
   415 	jQuery(document).ready(function($) {
   416 		//resize screen
   416 		//resize screen
   417 		window.resizeTo(720,580);
   417 		window.resizeTo(740,580);
   418 		// set button actions
   418 		// set button actions
   419 		jQuery('#photo_button').click(function() { show('photo'); return false; });
   419 		jQuery('#photo_button').click(function() { show('photo'); return false; });
   420 		jQuery('#video_button').click(function() { show('video'); return false; });
   420 		jQuery('#video_button').click(function() { show('video'); return false; });
   421 		// auto select
   421 		// auto select
   422 		<?php if ( preg_match("/youtube\.com\/watch/i", $url) ) { ?>
   422 		<?php if ( preg_match("/youtube\.com\/watch/i", $url) ) { ?>
   425 			show('video');
   425 			show('video');
   426 		<?php } elseif ( preg_match("/flickr\.com/i", $url) ) { ?>
   426 		<?php } elseif ( preg_match("/flickr\.com/i", $url) ) { ?>
   427 			show('photo');
   427 			show('photo');
   428 		<?php } ?>
   428 		<?php } ?>
   429 		jQuery('#title').unbind();
   429 		jQuery('#title').unbind();
   430 		jQuery('#publish, #save').click(function() { jQuery('#saving').css('display', 'inline'); });
   430 		jQuery('#publish, #save').click(function() { jQuery('.press-this #publishing-actions .spinner').css('display', 'inline-block'); });
   431 
   431 
   432 		$('#tagsdiv-post_tag, #categorydiv').children('h3, .handlediv').click(function(){
   432 		$('#tagsdiv-post_tag, #categorydiv').children('h3, .handlediv').click(function(){
   433 			$(this).siblings('.inside').toggle();
   433 			$(this).siblings('.inside').toggle();
   434 		});
   434 		});
   435 	});
   435 	});
   437 </head>
   437 </head>
   438 <?php
   438 <?php
   439 $admin_body_class = ( is_rtl() ) ? 'rtl' : '';
   439 $admin_body_class = ( is_rtl() ) ? 'rtl' : '';
   440 $admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) );
   440 $admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) );
   441 ?>
   441 ?>
   442 <body class="press-this wp-admin <?php echo $admin_body_class; ?>">
   442 <body class="press-this wp-admin wp-core-ui <?php echo $admin_body_class; ?>">
   443 <form action="press-this.php?action=post" method="post">
   443 <form action="press-this.php?action=post" method="post">
   444 <div id="poststuff" class="metabox-holder">
   444 <div id="poststuff" class="metabox-holder">
   445 	<div id="side-sortables" class="press-this-sidebar">
   445 	<div id="side-sortables" class="press-this-sidebar">
   446 		<div class="sleeve">
   446 		<div class="sleeve">
   447 			<?php wp_nonce_field('press-this') ?>
   447 			<?php wp_nonce_field('press-this') ?>
   465 							submit_button( __( 'Publish' ), 'primary', 'publish', false );
   465 							submit_button( __( 'Publish' ), 'primary', 'publish', false );
   466 						} else {
   466 						} else {
   467 							echo '<br /><br />';
   467 							echo '<br /><br />';
   468 							submit_button( __( 'Submit for Review' ), 'primary', 'review', false );
   468 							submit_button( __( 'Submit for Review' ), 'primary', 'review', false );
   469 						} ?>
   469 						} ?>
   470 						<img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" id="saving" style="display:none;" />
   470 						<span class="spinner" style="display: none;"></span>
   471 					</p>
   471 					</p>
   472 					<?php if ( current_theme_supports( 'post-formats' ) && post_type_supports( 'post', 'post-formats' ) ) :
   472 					<?php if ( current_theme_supports( 'post-formats' ) && post_type_supports( 'post', 'post-formats' ) ) :
   473 							$post_formats = get_theme_support( 'post-formats' );
   473 							$post_formats = get_theme_support( 'post-formats' );
   474 							if ( is_array( $post_formats[0] ) ) :
   474 							if ( is_array( $post_formats[0] ) ) :
   475 								$default_format = get_option( 'default_post_format', '0' );
   475 								$default_format = get_option( 'default_post_format', '0' );
   493 				<h3 class="hndle"><?php _e('Categories') ?></h3>
   493 				<h3 class="hndle"><?php _e('Categories') ?></h3>
   494 				<div class="inside">
   494 				<div class="inside">
   495 				<div id="taxonomy-category" class="categorydiv">
   495 				<div id="taxonomy-category" class="categorydiv">
   496 
   496 
   497 					<ul id="category-tabs" class="category-tabs">
   497 					<ul id="category-tabs" class="category-tabs">
   498 						<li class="tabs"><a href="#category-all" tabindex="3"><?php echo $tax->labels->all_items; ?></a></li>
   498 						<li class="tabs"><a href="#category-all"><?php echo $tax->labels->all_items; ?></a></li>
   499 						<li class="hide-if-no-js"><a href="#category-pop" tabindex="3"><?php _e( 'Most Used' ); ?></a></li>
   499 						<li class="hide-if-no-js"><a href="#category-pop"><?php _e( 'Most Used' ); ?></a></li>
   500 					</ul>
   500 					</ul>
   501 
   501 
   502 					<div id="category-pop" class="tabs-panel" style="display: none;">
   502 					<div id="category-pop" class="tabs-panel" style="display: none;">
   503 						<ul id="categorychecklist-pop" class="categorychecklist form-no-clear" >
   503 						<ul id="categorychecklist-pop" class="categorychecklist form-no-clear" >
   504 							<?php $popular_ids = wp_popular_terms_checklist( 'category' ); ?>
   504 							<?php $popular_ids = wp_popular_terms_checklist( 'category' ); ?>
   505 						</ul>
   505 						</ul>
   506 					</div>
   506 					</div>
   507 
   507 
   508 					<div id="category-all" class="tabs-panel">
   508 					<div id="category-all" class="tabs-panel">
   509 						<ul id="categorychecklist" class="list:category categorychecklist form-no-clear">
   509 						<ul id="categorychecklist" data-wp-lists="list:category" class="categorychecklist form-no-clear">
   510 							<?php wp_terms_checklist($post_ID, array( 'taxonomy' => 'category', 'popular_cats' => $popular_ids ) ) ?>
   510 							<?php wp_terms_checklist($post_ID, array( 'taxonomy' => 'category', 'popular_cats' => $popular_ids ) ) ?>
   511 						</ul>
   511 						</ul>
   512 					</div>
   512 					</div>
   513 
   513 
   514 					<?php if ( !current_user_can($tax->cap->assign_terms) ) : ?>
   514 					<?php if ( !current_user_can($tax->cap->assign_terms) ) : ?>
   515 					<p><em><?php _e('You cannot modify this Taxonomy.'); ?></em></p>
   515 					<p><em><?php _e('You cannot modify this Taxonomy.'); ?></em></p>
   516 					<?php endif; ?>
   516 					<?php endif; ?>
   517 					<?php if ( current_user_can($tax->cap->edit_terms) ) : ?>
   517 					<?php if ( current_user_can($tax->cap->edit_terms) ) : ?>
   518 						<div id="category-adder" class="wp-hidden-children">
   518 						<div id="category-adder" class="wp-hidden-children">
   519 							<h4>
   519 							<h4>
   520 								<a id="category-add-toggle" href="#category-add" class="hide-if-no-js" tabindex="3">
   520 								<a id="category-add-toggle" href="#category-add" class="hide-if-no-js">
   521 									<?php printf( __( '+ %s' ), $tax->labels->add_new_item ); ?>
   521 									<?php printf( __( '+ %s' ), $tax->labels->add_new_item ); ?>
   522 								</a>
   522 								</a>
   523 							</h4>
   523 							</h4>
   524 							<p id="category-add" class="category-add wp-hidden-child">
   524 							<p id="category-add" class="category-add wp-hidden-child">
   525 								<label class="screen-reader-text" for="newcategory"><?php echo $tax->labels->add_new_item; ?></label>
   525 								<label class="screen-reader-text" for="newcategory"><?php echo $tax->labels->add_new_item; ?></label>
   526 								<input type="text" name="newcategory" id="newcategory" class="form-required form-input-tip" value="<?php echo esc_attr( $tax->labels->new_item_name ); ?>" tabindex="3" aria-required="true"/>
   526 								<input type="text" name="newcategory" id="newcategory" class="form-required form-input-tip" value="<?php echo esc_attr( $tax->labels->new_item_name ); ?>" aria-required="true"/>
   527 								<label class="screen-reader-text" for="newcategory_parent">
   527 								<label class="screen-reader-text" for="newcategory_parent">
   528 									<?php echo $tax->labels->parent_item_colon; ?>
   528 									<?php echo $tax->labels->parent_item_colon; ?>
   529 								</label>
   529 								</label>
   530 								<?php wp_dropdown_categories( array( 'taxonomy' => 'category', 'hide_empty' => 0, 'name' => 'newcategory_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => '&mdash; ' . $tax->labels->parent_item . ' &mdash;', 'tab_index' => 3 ) ); ?>
   530 								<?php wp_dropdown_categories( array( 'taxonomy' => 'category', 'hide_empty' => 0, 'name' => 'newcategory_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => '&mdash; ' . $tax->labels->parent_item . ' &mdash;' ) ); ?>
   531 								<input type="button" id="category-add-submit" class="add:categorychecklist:category-add button category-add-submit" value="<?php echo esc_attr( $tax->labels->add_new_item ); ?>" tabindex="3" />
   531 								<input type="button" id="category-add-submit" data-wp-lists="add:categorychecklist:category-add" class="button category-add-submit" value="<?php echo esc_attr( $tax->labels->add_new_item ); ?>" />
   532 								<?php wp_nonce_field( 'add-category', '_ajax_nonce-add-category', false ); ?>
   532 								<?php wp_nonce_field( 'add-category', '_ajax_nonce-add-category', false ); ?>
   533 								<span id="category-ajax-response"></span>
   533 								<span id="category-ajax-response"></span>
   534 							</p>
   534 							</p>
   535 						</div>
   535 						</div>
   536 					<?php endif; ?>
   536 					<?php endif; ?>
   546 						<div class="jaxtag">
   546 						<div class="jaxtag">
   547 							<label class="screen-reader-text" for="newtag"><?php _e('Tags'); ?></label>
   547 							<label class="screen-reader-text" for="newtag"><?php _e('Tags'); ?></label>
   548 							<input type="hidden" name="tax_input[post_tag]" class="the-tags" id="tax-input[post_tag]" value="" />
   548 							<input type="hidden" name="tax_input[post_tag]" class="the-tags" id="tax-input[post_tag]" value="" />
   549 							<div class="ajaxtag">
   549 							<div class="ajaxtag">
   550 								<input type="text" name="newtag[post_tag]" class="newtag form-input-tip" size="16" autocomplete="off" value="" />
   550 								<input type="text" name="newtag[post_tag]" class="newtag form-input-tip" size="16" autocomplete="off" value="" />
   551 								<input type="button" class="button tagadd" value="<?php esc_attr_e('Add'); ?>" tabindex="3" />
   551 								<input type="button" class="button tagadd" value="<?php esc_attr_e('Add'); ?>" />
   552 							</div>
   552 							</div>
   553 						</div>
   553 						</div>
   554 						<div class="tagchecklist"></div>
   554 						<div class="tagchecklist"></div>
   555 					</div>
   555 					</div>
   556 					<p class="tagcloud-link"><a href="#titlediv" class="tagcloud-link" id="link-post_tag"><?php _e('Choose from the most used tags'); ?></a></p>
   556 					<p class="tagcloud-link"><a href="#titlediv" class="tagcloud-link" id="link-post_tag"><?php _e('Choose from the most used tags'); ?></a></p>
   584 			<div class="titlewrap">
   584 			<div class="titlewrap">
   585 				<input name="title" id="title" class="text" value="<?php echo esc_attr($title);?>"/>
   585 				<input name="title" id="title" class="text" value="<?php echo esc_attr($title);?>"/>
   586 			</div>
   586 			</div>
   587 		</div>
   587 		</div>
   588 
   588 
   589 		<div id="waiting" style="display: none"><img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" /> <?php esc_html_e( 'Loading...' ); ?></div>
   589 		<div id="waiting" style="display: none"><span class="spinner"></span> <span><?php esc_html_e( 'Loading...' ); ?></span></div>
   590 
   590 
   591 		<div id="extra-fields" style="display: none"></div>
   591 		<div id="extra-fields" style="display: none"></div>
   592 
   592 
   593 		<div class="postdivrich">
   593 		<div class="postdivrich">
   594 		<?php
   594 		<?php