mirror of
https://github.com/WordPress/WordPress.git
synced 2025-01-09 09:57:38 +01:00
Third pass on internal linking preloading. Or, what I left out of the second pass commit. see #11420.
git-svn-id: http://svn.automattic.com/wordpress/trunk@16459 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
9820a48b54
commit
485daddde1
@ -1074,9 +1074,21 @@ case 'menu-quick-search':
|
||||
exit;
|
||||
break;
|
||||
case 'wp-link-ajax':
|
||||
require_once ABSPATH . WPINC . '/js/tinymce/wp-mce-link.php';
|
||||
require_once ABSPATH . 'wp-admin/includes/internal-linking.php';
|
||||
|
||||
wp_link_ajax( $_POST );
|
||||
$args = array();
|
||||
|
||||
if ( isset( $_POST['title'] ) )
|
||||
$args['s'] = stripslashes( $_POST['title'] );
|
||||
$args['pagenum'] = ! empty( $_POST['page'] ) ? absint( $_POST['page'] ) : 1;
|
||||
|
||||
$results = wp_link_query( $args );
|
||||
|
||||
if ( ! isset( $results ) )
|
||||
die( '0' );
|
||||
|
||||
echo json_encode( $results );
|
||||
echo "\n";
|
||||
|
||||
exit;
|
||||
break;
|
||||
|
File diff suppressed because one or more lines are too long
@ -1,4 +1,5 @@
|
||||
html {
|
||||
html,
|
||||
.wp-dialog {
|
||||
background-color: #fcfcfb;
|
||||
}
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
@ -1,4 +1,5 @@
|
||||
html {
|
||||
html,
|
||||
.wp-dialog {
|
||||
background-color: #f9f9f9;
|
||||
}
|
||||
|
||||
|
137
wp-admin/includes/internal-linking.php
Normal file
137
wp-admin/includes/internal-linking.php
Normal file
@ -0,0 +1,137 @@
|
||||
<?php
|
||||
/**
|
||||
* Internal linking functions.
|
||||
*
|
||||
* @package WordPres
|
||||
* @subpackage Administration
|
||||
* @since 3.1.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* Performs post queries for internal linking.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*
|
||||
* @param array $args Optional. Accepts 'pagenum' and 's' (search) arguments.
|
||||
* @return array Results.
|
||||
*/
|
||||
function wp_link_query( $args = array() ) {
|
||||
$pts = get_post_types( array( 'publicly_queryable' => true ), 'objects' );
|
||||
$pt_names = array_keys( $pts );
|
||||
|
||||
$query = array(
|
||||
'post_type' => $pt_names,
|
||||
'suppress_filters' => true,
|
||||
'update_post_term_cache' => false,
|
||||
'update_post_meta_cache' => false,
|
||||
'post_status' => 'publish',
|
||||
'order' => 'DESC',
|
||||
'orderby' => 'post_date',
|
||||
'posts_per_page' => 20,
|
||||
);
|
||||
|
||||
$args['pagenum'] = isset( $args['pagenum'] ) ? absint( $args['pagenum'] ) : 1;
|
||||
|
||||
if ( isset( $args['s'] ) )
|
||||
$query['s'] = $args['s'];
|
||||
|
||||
$query['offset'] = $args['pagenum'] > 1 ? $query['posts_per_page'] * ( $args['pagenum'] - 1 ) : 0;
|
||||
|
||||
// Do main query.
|
||||
$get_posts = new WP_Query;
|
||||
$posts = $get_posts->query( $query );
|
||||
// Check if any posts were found.
|
||||
if ( ! $get_posts->post_count )
|
||||
return false;
|
||||
|
||||
// Build results.
|
||||
$results = array();
|
||||
foreach ( $posts as $post ) {
|
||||
if ( 'post' == $post->post_type )
|
||||
$info = mysql2date( __( 'Y/m/d' ), $post->post_date );
|
||||
else
|
||||
$info = $pts[ $post->post_type ]->labels->singular_name;
|
||||
|
||||
$results[] = array(
|
||||
'ID' => $post->ID,
|
||||
'title' => esc_html( strip_tags($post->post_title) ),
|
||||
'permalink' => get_permalink( $post->ID ),
|
||||
'info' => $info,
|
||||
);
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dialog for internal linking.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*/
|
||||
function wp_link_dialog() {
|
||||
?>
|
||||
<div id="wp-link">
|
||||
<div id="link-selector">
|
||||
<div id="link-options">
|
||||
<p class="howto"><?php _e( 'Enter the destination URL:' ); ?></p>
|
||||
<div>
|
||||
<label><span><?php _e( 'URL' ); ?></span><input id="url-field" type="text" /></label>
|
||||
</div>
|
||||
<div>
|
||||
<label><span><?php _e( 'Title' ); ?></span><input id="link-title-field" type="text" /></label>
|
||||
</div>
|
||||
<div class="link-target">
|
||||
<label><input type="checkbox" id="link-target-checkbox" /> <?php _e( 'Open link in a new window/tab' ); ?></label>
|
||||
</div>
|
||||
</div>
|
||||
<div id="search-panel">
|
||||
<div class="link-search-wrapper">
|
||||
<p class="howto"><?php _e( 'Or, link to existing site content:' ); ?></p>
|
||||
<label for="search-field">
|
||||
<span><?php _e( 'Search' ); ?></span>
|
||||
<input type="text" id="search-field" class="link-search-field" />
|
||||
<img class="waiting" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" />
|
||||
</label>
|
||||
</div>
|
||||
<div id="search-results" class="query-results">
|
||||
<ul>
|
||||
<li class="loading-results unselectable"><em><?php _e( 'Loading...' ); ?></em></li>
|
||||
</ul>
|
||||
<div class="river-waiting">
|
||||
<img class="waiting" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" />
|
||||
</div>
|
||||
</div>
|
||||
<?php $most_recent = wp_link_query(); ?>
|
||||
<div id="most-recent-results" class="query-results">
|
||||
<ul>
|
||||
<li class="unselectable"><em><?php _e( 'No search term specified. Showing recent items.' ); ?></em></li>
|
||||
<?php
|
||||
$alt = true;
|
||||
foreach ( $most_recent as $item ) : ?>
|
||||
<li<?php if ( $alt ) echo ' class="alternate"'; ?>>
|
||||
<input type="hidden" class="item-permalink" value="<?php echo esc_url( $item['permalink'] ); ?>" />
|
||||
<span class="item-title"><?php echo $item['title']; ?></span>
|
||||
<span class="item-info"><?php echo esc_html( $item['info'] ); ?></span>
|
||||
</li>
|
||||
<?php
|
||||
$alt = ! $alt;
|
||||
endforeach; ?>
|
||||
</ul>
|
||||
<div class="river-waiting">
|
||||
<img class="waiting" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="submitbox">
|
||||
<div id="wp-link-cancel">
|
||||
<a class="submitdelete deletion" href="#"><?php _e( 'Cancel' ); ?></a>
|
||||
</div>
|
||||
<div id="wp-link-update">
|
||||
<a class="button-primary" href="#"><?php _e( 'Update' ); ?></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
@ -1483,7 +1483,7 @@ function wp_tiny_mce( $teeny = false, $settings = false ) {
|
||||
'paste_strip_class_attributes' => 'all',
|
||||
'paste_text_use_dialog' => true,
|
||||
'wpeditimage_disable_captions' => $no_captions,
|
||||
'plugins' => implode($plugins, ',')
|
||||
'plugins' => implode( ',', $plugins ),
|
||||
);
|
||||
|
||||
if ( ! empty( $editor_styles ) && is_array( $editor_styles ) ) {
|
||||
@ -1609,11 +1609,11 @@ tinyMCE.init(tinyMCEPreInit.mceInit);
|
||||
|
||||
// Load additional inline scripts based on active plugins.
|
||||
if ( in_array( 'wpdialogs', $plugins ) ) {
|
||||
wp_print_scripts( array('jquery-ui-dialog', 'wpdialogsPopup') );
|
||||
wp_print_scripts( array( 'wpdialogs-popup' ) );
|
||||
wp_print_styles('wp-jquery-ui-dialog');
|
||||
}
|
||||
if ( in_array( 'wplink', $plugins ) ) {
|
||||
require_once ABSPATH . WPINC . "/js/tinymce/wp-mce-link.php";
|
||||
require_once ABSPATH . 'wp-admin/includes/internal-linking.php';
|
||||
add_action('tiny_mce_preload_dialogs', 'wp_link_dialog');
|
||||
wp_print_scripts('wplink');
|
||||
wp_print_styles('wplink');
|
||||
|
@ -268,14 +268,14 @@ function wp_default_scripts( &$scripts ) {
|
||||
'url' => __( 'URL:' ),
|
||||
'noShortlink' => __( 'No shortlink available for this page.' ),
|
||||
) );
|
||||
|
||||
|
||||
$scripts->add( 'wplink', "/wp-includes/js/tinymce/plugins/wplink/js/wplink$suffix.js", array('jquery'), '20101117' );
|
||||
$scripts->localize( 'wplink', 'wpLinkL10n', array(
|
||||
'untitled' => __('Untitled'),
|
||||
'noMatchesFound' => __('No matches found.'),
|
||||
) );
|
||||
|
||||
$scripts->add( 'wpdialogsPopup', "/wp-includes/js/tinymce/plugins/wpdialogs/js/popup$suffix.js", false, '20101117' );
|
||||
|
||||
$scripts->add( 'wpdialogs-popup', "/wp-includes/js/tinymce/plugins/wpdialogs/js/popup$suffix.js", array( 'jquery-ui-dialog' ), '20101117' );
|
||||
|
||||
if ( is_admin() ) {
|
||||
$scripts->add( 'ajaxcat', "/wp-admin/js/cat$suffix.js", array( 'wp-lists' ), '20090102' );
|
||||
@ -484,7 +484,7 @@ function wp_default_styles( &$styles ) {
|
||||
$styles->add_data( 'ie', 'conditional', 'lte IE 7' );
|
||||
|
||||
// all colors stylesheets need to have the same query strings (cache manifest compat)
|
||||
$colors_version = '20101117';
|
||||
$colors_version = '20101117b';
|
||||
|
||||
// Register "meta" stylesheet for admin colors. All colors-* style sheets should have the same version string.
|
||||
$styles->add( 'colors', true, array(), $colors_version );
|
||||
@ -509,13 +509,8 @@ function wp_default_styles( &$styles ) {
|
||||
$styles->add( 'jcrop', '/wp-includes/js/jcrop/jquery.Jcrop.css', array(), '0.9.8' );
|
||||
$styles->add( 'imgareaselect', '/wp-includes/js/imgareaselect/imgareaselect.css', array(), '0.9.1' );
|
||||
$styles->add( 'nav-menu', "/wp-admin/css/nav-menu$suffix.css", array(), '20100907' );
|
||||
|
||||
// Admin bar
|
||||
$styles->add( 'admin-bar', "/wp-includes/css/admin-bar$suffix.css", array(), '20101117' );
|
||||
|
||||
// WP jQuery UI Dialog
|
||||
$styles->add( 'wp-jquery-ui-dialog', "/wp-includes/css/jquery-ui-dialog$suffix.css", array(), '20101117' );
|
||||
// WPLink TinyMCE plugin
|
||||
$styles->add( 'wplink', "/wp-includes/js/tinymce/plugins/wplink/css/wplink$suffix.css", array(), '20101117' );
|
||||
|
||||
foreach ( $rtl_styles as $rtl_style ) {
|
||||
|
Loading…
Reference in New Issue
Block a user