ap_menu_obejct()
Description #
Create array of object containing AnsPress pages. To be used in admin menu metabox.
Source #
File: includes/theme.php
function ap_menu_obejct() {
$menu_items = array();
foreach ( (array) anspress()->pages as $k => $args ) {
if ( $args['show_in_menu'] ) {
$object_id = 1;
$object = $k;
$title = $args['title'];
$url = home_url( '/' );
$type = 'anspress-links';
$main_pages = array_keys( ap_main_pages() );
if ( in_array( $k . '_page', $main_pages, true ) ) {
$post = get_post( ap_opt( $k . '_page' ) );
// Proceed only if post is available.
if ( $post ) {
$object_id = ap_opt( $k . '_page' );
$object = 'page';
$url = get_permalink( $post );
$title = $post->post_title;
$type = 'post_type';
}
}
$menu_items[] = (object) array(
'ID' => 1,
'db_id' => 0,
'menu_item_parent' => 0,
'object_id' => $object_id,
'post_parent' => 0,
'type' => $type,
'object' => $object,
'type_label' => __( 'AnsPress links', 'anspress-question-answer' ),
'title' => $title,
'url' => $url,
'target' => '',
'attr_title' => '',
'description' => '',
'classes' => array( 'anspress-menu-' . $k ),
'xfn' => '',
);
}
}
/**
* Hook for filtering default AnsPress menu objects.
*
* @param array $menu_items Array of menu objects.
* @since 4.1.2
*/
return apply_filters( 'ap_menu_object', $menu_items );
}
Expand full source code Collapse full source code View on GitHub: includes/theme.php:974
Add your comment