ap_current_page( false|string $looking_for = false )
Description #
Return current AnsPress page
Parameters #
- $looking_forfalse | string (Optional) Looking for page. Default value: false
Changelog #
Source #
File: includes/theme.php
function ap_current_page( $looking_for = false ) { $query_var = get_query_var( 'ap_page', '' ); $main_pages = array_keys( ap_main_pages() ); $page_ids = array(); foreach ( $main_pages as $page_slug ) { $page_ids[ ap_opt( $page_slug ) ] = $page_slug; } if ( is_question() || is_singular( 'question' ) ) { $query_var = 'question'; } elseif ( 'edit' === $query_var ) { $query_var = 'edit'; } elseif ( in_array( $query_var . '_page', $main_pages, true ) ) { $query_var = $query_var; } elseif ( in_array( get_the_ID(), array_keys( $page_ids ) ) ) { // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict if ( ! empty( $page_ids[ get_the_ID() ] ) ) { $query_var = str_replace( '_page', '', $page_ids[ get_the_ID() ] ); } } elseif ( 'base' === $query_var ) { $query_var = 'base'; } elseif ( is_404() ) { $query_var = ''; } /** * Filter AnsPress current page. * * @param string $query_var Current page slug. */ $ret = apply_filters( 'ap_current_page', esc_attr( $query_var ) ); if ( false !== $looking_for ) { return $looking_for === $ret; } return $ret; }
Expand full source code Collapse full source code View on GitHub: includes/theme.php:606
Add your comment