当前位置: 首页>>代码示例>>PHP>>正文


PHP _WP_Editors::wp_link_query方法代码示例

本文整理汇总了PHP中_WP_Editors::wp_link_query方法的典型用法代码示例。如果您正苦于以下问题:PHP _WP_Editors::wp_link_query方法的具体用法?PHP _WP_Editors::wp_link_query怎么用?PHP _WP_Editors::wp_link_query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在_WP_Editors的用法示例。


在下文中一共展示了_WP_Editors::wp_link_query方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: wp_ajax_wp_link_ajax

/**
 * Ajax handler for internal linking.
 *
 * @since 3.1.0
 */
function wp_ajax_wp_link_ajax()
{
    check_ajax_referer('internal-linking', '_ajax_linking_nonce');
    $args = array();
    if (isset($_POST['search'])) {
        $args['s'] = wp_unslash($_POST['search']);
    }
    $args['pagenum'] = !empty($_POST['page']) ? absint($_POST['page']) : 1;
    require ABSPATH . WPINC . '/class-wp-editor.php';
    $results = _WP_Editors::wp_link_query($args);
    if (!isset($results)) {
        wp_die(0);
    }
    echo wp_json_encode($results);
    echo "\n";
    wp_die();
}
开发者ID:hughnet,项目名称:WordPress,代码行数:22,代码来源:ajax-actions.php

示例2: ckeditor_linkbrowser_search

 public function ckeditor_linkbrowser_search()
 {
     check_ajax_referer('internal-linking', '_ajax_linking_nonce');
     $args = array();
     if (isset($_POST['search'])) {
         $args['s'] = stripslashes($_POST['search']);
     }
     $args['pagenum'] = !empty($_POST['page']) ? absint($_POST['page']) : 1;
     $results = _WP_Editors::wp_link_query($args);
     if (!isset($results)) {
         wp_die(0);
     }
     echo json_encode($results);
     echo "\n";
     wp_die();
 }
开发者ID:vanlong200880,项目名称:tmdt,代码行数:16,代码来源:ckeditor_class.php

示例3: die

     if (!current_user_can('edit_theme_options')) {
         die('-1');
     }
     require_once ABSPATH . 'wp-admin/includes/nav-menu.php';
     _wp_ajax_menu_quick_search($_REQUEST);
     exit;
     break;
 case 'wp-link-ajax':
     check_ajax_referer('internal-linking', '_ajax_linking_nonce');
     $args = array();
     if (isset($_POST['search'])) {
         $args['s'] = stripslashes($_POST['search']);
     }
     $args['pagenum'] = !empty($_POST['page']) ? absint($_POST['page']) : 1;
     require ABSPATH . WPINC . '/class-wp-editor.php';
     $results = _WP_Editors::wp_link_query($args);
     if (!isset($results)) {
         die('0');
     }
     echo json_encode($results);
     echo "\n";
     exit;
     break;
 case 'menu-locations-save':
     if (!current_user_can('edit_theme_options')) {
         die('-1');
     }
     check_ajax_referer('add-menu_item', 'menu-settings-column-nonce');
     if (!isset($_POST['menu-locations'])) {
         die('0');
     }
开发者ID:vivekkodira1,项目名称:wordpress,代码行数:31,代码来源:admin-ajax.php

示例4: ajax_get_link_search_results

 /**
  * Returns search results.
  *
  * Results returned in a format expected by the internal link manager.
  * Doesn't have support for paging.
  *
  * Multiple filters provided for either adding results or short-circuiting
  * the flow at various points.
  *
  * @since 1.1.0
  */
 public static function ajax_get_link_search_results()
 {
     global $wpdb;
     check_ajax_referer('internal-linking', '_ajax_linking_nonce');
     if (isset($_POST['search'])) {
         $results = array();
         $s = stripslashes($_POST['search']);
         $args['s'] = $s;
         $args['page'] = !empty($_POST['page']) ? absint($_POST['page']) : 1;
         $args['per_page'] = 20;
         // Default for usage in filters, otherwise, it shouldn't do anything.
         // Check to see if the request is prepended with a modifier (ex: -wikipedia interrobang, -spotify:artist willie nelson).
         if (0 === mb_strpos($s, '-')) {
             preg_match('/-([^\\s]+)\\s?(.*)?/', $s, $matches);
             $s = trim($matches[2]);
             $args['s'] = $s;
             $args['modifier'] = explode(':', trim($matches[1]));
             $results = (array) apply_filters('better_internal_link_search_modifier-' . $args['modifier'][0], array(), $args);
             if (!empty($results)) {
                 echo json_encode($results);
                 wp_die();
             }
         }
         // Allow plugins to intercept the request and add their own results or short-circuit execution.
         $pre_results = (array) apply_filters('pre_better_internal_link_search_results', array(), $args);
         if (!empty($pre_results)) {
             $results = array_merge($results, $pre_results);
         }
         // Short-circuit if this is a paged request. The first request should have returned all results.
         if (isset($_POST['page']) && $_POST['page'] > 1) {
             wp_die(0);
         }
         // Don't continue if the query length is less than three.
         if (strlen($args['s']) < 3) {
             wp_die(0);
         }
         // @see wp_link_ajax();
         require_once ABSPATH . WPINC . '/class-wp-editor.php';
         $posts = _WP_Editors::wp_link_query($args);
         if ($posts) {
             $future_status_object = get_post_status_object('future');
             $private_status_object = get_post_status_object('private');
             foreach ($posts as $key => $post) {
                 if ('future' == get_post_status($post['ID'])) {
                     $posts[$key]['info'] = $future_status_object->label;
                 } elseif ('private' == get_post_status($post['ID'])) {
                     $posts[$key]['info'] .= ' (' . $private_status_object->label . ')';
                 }
             }
             $results = array_merge($results, $posts);
         }
         if ('yes' === Better_Internal_Link_Search_Settings::get_settings('include_term_results')) {
             // Search for matching term archives.
             $search = '%' . self::esc_like($s) . '%';
             $terms = $wpdb->get_results($wpdb->prepare("SELECT t.term_id, t.name, tt.taxonomy\n\t\t\t\t\tFROM {$wpdb->terms} t\n\t\t\t\t\tINNER JOIN {$wpdb->term_taxonomy} tt ON t.term_id=tt.term_id\n\t\t\t\t\tWHERE t.name LIKE %s\n\t\t\t\t\tORDER BY name ASC", $search));
             if ($terms) {
                 foreach ($terms as $term) {
                     $taxonomy = get_taxonomy($term->taxonomy);
                     if (isset($taxonomy->query_var)) {
                         $results[] = array('title' => trim(esc_html(strip_tags($term->name))), 'permalink' => get_term_link((int) $term->term_id, $term->taxonomy), 'info' => $taxonomy->labels->singular_name);
                     }
                 }
             }
         }
         // Allow results to be filtered one last time and attempt to sort them.
         if (!empty($results)) {
             self::$s = $s;
             $results = apply_filters('better_internal_link_search_results', $results, $args);
             if (apply_filters('better_internal_link_search_sort_results', true, $results, $args)) {
                 usort($results, array(__CLASS__, 'sort_results'));
             }
         }
         // Add shortcut results.
         $shortcuts = (array) self::get_shortcuts();
         if (!empty($shortcuts)) {
             if (array_key_exists($s, $shortcuts)) {
                 array_unshift($results, $shortcuts[$s]);
             } elseif ('shortcuts' == $s) {
                 $results = array_merge($shortcuts, $results);
             }
         }
     }
     if (!isset($results) || empty($results)) {
         wp_die(0);
     }
     echo json_encode($results);
     echo "\n";
     wp_die();
 }
开发者ID:lmartins,项目名称:better-internal-link-search,代码行数:100,代码来源:better-internal-link-search.php


注:本文中的_WP_Editors::wp_link_query方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。