__( 'For individuals', 'wporg-5ftf' ), 'url' => '/for-individuals/', ); $menu[] = array( 'label' => __( 'For organizations', 'wporg-5ftf' ), 'url' => '/for-organizations/', ); $menu[] = array( 'label' => __( 'Handbook', 'wporg-5ftf' ), 'url' => '/handbook/', 'className' => $is_handbook ? 'current-menu-item' : '', ); $menu[] = array( 'label' => __( 'Pledges', 'wporg-5ftf' ), 'url' => '/pledges/', ); $menu[] = array( 'label' => __( 'Contact', 'wporg-5ftf' ), 'url' => '/contact/', ); $menu[] = array( 'label' => __( 'My pledges', 'wporg-5ftf' ), 'url' => '/my-pledges/', 'className' => 'has-separator', ); if ( ! is_user_logged_in() ) { global $wp; $redirect_url = home_url( $wp->request ); $menu[] = array( 'label' => __( 'Log in', 'wporg-5ftf' ), 'url' => wp_login_url( $redirect_url ), ); } return array( 'main' => $menu, ); } /** * Update the query total label to reflect "pledges" found. * * @param string $label The maybe-pluralized label to use, a result of `_n()`. * @param int $found_posts The number of posts to use for determining pluralization. * * @return string Updated string with total placeholder. */ function update_query_total_label( $label, $found_posts ) { /* translators: %s: the result count. */ return _n( '%s pledge', '%s pledges', $found_posts, 'wporg-5ftf' ); } /** * Provide a list of sort options. * * @param array $options The options for this filter. * @return array New list of category options. */ function get_sort_options( $options ) { global $wp_query; $sort = isset( $_GET['order'] ) ? $_GET['order'] : ''; $label = __( 'Sort: Random', 'wporg-5ftf' ); switch ( $sort ) { case 'alphabetical': $label = __( 'Sort: Alphabetical', 'wporg-5ftf' ); break; case 'contributors': $label = __( 'Sort: Total Contributors', 'wporg-5ftf' ); break; case 'hours': $label = __( 'Sort: Total Hours', 'wporg-5ftf' ); break; } return array( 'label' => $label, 'title' => __( 'Sort', 'wporg-5ftf' ), 'key' => 'order', 'action' => home_url( '/pledges/' ), 'options' => array( '' => __( 'Random', 'wporg-5ftf' ), 'alphabetical' => __( 'Alphabetical', 'wporg-5ftf' ), 'contributors' => __( 'Total Contributors', 'wporg-5ftf' ), 'hours' => __( 'Total Hours', 'wporg-5ftf' ), ), 'selected' => [ $sort ], ); } /** * Add in the search term as a hidden input in the filter form. * * This enables the sort filter to apply to search results, as opposed to * clearing the search when selected. * * @param string $key The key for the current filter. */ function inject_other_filters( $key ) { global $wp_query; // Pass through search query. if ( isset( $wp_query->query['s'] ) ) { printf( '', esc_attr( $wp_query->query['s'] ) ); } } /** * Update the excerpt block content, replacing the placeholder string with * dynamic text including the pledge title for unique link text. * * @param string $block_content The block content. * @param array $block The full block, including name and attributes. * @param WP_Block $instance The block instance. * * @return string Updated block content. */ function inject_excerpt_more_link( $block_content, $block, $instance ) { $more_text = sprintf( __( 'Continue reading %s', 'wporg-5ftf' ), get_the_title( $instance->context['postId'] ) ); return str_replace( '[MORE]', $more_text, $block_content ); }