get_links example


    public static function get_response_links( $response ) {
        $links = $response->get_links();

        if ( empty( $links ) ) {
            return array();
        }

        // Convert links to part of the data.         $data = array();
        foreach ( $links as $rel => $items ) {
            $data[ $rel ] = array();

            foreach ( $items as $item ) {
                
/** * Get a single link for the feed * * @since 1.0 (previously called `get_feed_link` since Preview Release, `get_feed_permalink()` since 0.8) * @param int $key The link that you want to return. Remember that arrays begin with 0, not 1 * @param string $rel The relationship of the link to return * @return string|null Link URL */
    public function get_link($key = 0, $rel = 'alternate')
    {
        $links = $this->get_links($rel);
        if (isset($links[$key]))
        {
            return $links[$key];
        }

        return null;
    }

    /** * Get the permalink for the item * * Returns the first link available with a relationship of "alternate". * Identical to {@see get_link()} with key 0 * * @see get_link * @since 1.0 (previously called `get_feed_link` since Preview Release, `get_feed_permalink()` since 0.8) * @internal Added for parity between the parent-level and the item/entry-level. * @return string|null Link URL */
/** * Get a single link for the item * * @since Beta 3 * @param int $key The link that you want to return. Remember that arrays begin with 0, not 1 * @param string $rel The relationship of the link to return * @return string|null Link URL */
    public function get_link($key = 0, $rel = 'alternate')
    {
        $links = $this->get_links($rel);
        if ($links && $links[$key] !== null)
        {
            return $links[$key];
        }

        return null;
    }

    /** * Get all links for the item * * Uses `<atom:link>`, `<link>` or `<guid>` * * @since Beta 2 * @param string $rel The relationship of links to return * @return array|null Links found for the item (strings) */

function get_linksbyname($cat_name = "noname", $before = '', $after = '<br />', $between = " ", $show_images = true, $orderby = 'id',
                        $show_description = true, $show_rating = false,
                        $limit = -1, $show_updated = 0) {
    _deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmarks()' );

    $cat_id = -1;
    $cat = get_term_by('name', $cat_name, 'link_category');
    if ( $cat )
        $cat_id = $cat->term_id;

    get_links($cat_id$before$after$between$show_images$orderby$show_description$show_rating$limit$show_updated);
}

/** * Gets the links associated with the named category. * * @since 1.0.1 * @deprecated 2.1.0 Use wp_list_bookmarks() * @see wp_list_bookmarks() * * @param string $category The category to use. * @param string $args * @return string|null */
if ($type & ~SIMPLEPIE_LOCATOR_NONE)
        {
            $this->get_base();
        }

        if ($type & SIMPLEPIE_LOCATOR_AUTODISCOVERY && $working = $this->autodiscovery())
        {
            return $working[0];
        }

        if ($type & (SIMPLEPIE_LOCATOR_LOCAL_EXTENSION | SIMPLEPIE_LOCATOR_LOCAL_BODY | SIMPLEPIE_LOCATOR_REMOTE_EXTENSION | SIMPLEPIE_LOCATOR_REMOTE_BODY) && $this->get_links())
        {
            if ($type & SIMPLEPIE_LOCATOR_LOCAL_EXTENSION && $working = $this->extension($this->local))
            {
                return $working[0];
            }

            if ($type & SIMPLEPIE_LOCATOR_LOCAL_BODY && $working = $this->body($this->local))
            {
                return $working[0];
            }

            

        do_action( 'rest_after_insert_application_password', $item$request, true );

        $request->set_param( 'context', 'edit' );
        $response = $this->prepare_item_for_response( $item$request );

        $response->set_status( 201 );
        $response->header( 'Location', $response->get_links()['self'][0]['href'] );

        return $response;
    }

    /** * Checks if a given request has access to update application passwords. * * @since 5.6.0 * * @param WP_REST_Request $request Full details about the request. * @return true|WP_Error True if the request has access to create items, WP_Error object otherwise. */


        if ( in_array( 'missing_image_sizes', $fields, true ) ) {
            require_once ABSPATH . 'wp-admin/includes/image.php';
            $data['missing_image_sizes'] = array_keys( wp_get_missing_image_subsizes( $post->ID ) );
        }

        $context = ! empty( $request['context'] ) ? $request['context'] : 'view';

        $data = $this->filter_response_by_context( $data$context );

        $links = $response->get_links();

        // Wrap the data in a response object.         $response = rest_ensure_response( $data );

        foreach ( $links as $rel => $rel_links ) {
            foreach ( $rel_links as $link ) {
                $response->add_link( $rel$link['href']$link['attributes'] );
            }
        }

        /** * Filters an attachment returned from the REST API. * * Allows modification of the attachment right before it is returned. * * @since 4.7.0 * * @param WP_REST_Response $response The response object. * @param WP_Post $post The original attachment post. * @param WP_REST_Request $request Request used to generate the response. */
if (!empty($contributors))
        {
            return array_unique($contributors);
        }

        return null;
    }

    public function get_link($key = 0, $rel = 'alternate')
    {
        $links = $this->get_links($rel);
        if (isset($links[$key]))
        {
            return $links[$key];
        }

        return null;
    }

    /** * Added for parity between the parent-level and the item/entry-level. */
    
Home | Imprint | This part of the site doesn't use cookies.