'publish', 'post_type' => $post_type, 'posts_per_page' => 1, 'fields' => 'ids', ) ); if ( empty( $post_ids ) ) { return false; } $post_id = $post_ids[0]; return amp_get_permalink( $post_id ); } /** * Registers a submenu page to access the AMP template editor panel in the Customizer. */ function amp_add_customizer_link() { // Teensy little hack on menu_slug, but it works. No redirect! $menu_slug = add_query_arg( array( 'autofocus[panel]' => AMP_Template_Customizer::PANEL_ID, 'return' => rawurlencode( admin_url() ), AMP_CUSTOMIZER_QUERY_VAR => true, ), 'customize.php' ); // Add the theme page. add_theme_page( __( 'AMP', 'amp' ), __( 'AMP', 'amp' ), 'edit_theme_options', $menu_slug ); } /** * Registers a top-level menu for AMP configuration options */ function amp_add_options_menu() { if ( ! is_admin() ) { return; } $show_options_menu = apply_filters( 'amp_options_menu_is_enabled', true ); if ( true !== $show_options_menu ) { return; } $amp_options = new AMP_Options_Menu(); $amp_options->init(); } add_action( 'wp_loaded', 'amp_add_options_menu' ); function amp_add_custom_analytics( $analytics ) { $analytics_entries = AMP_Options_Manager::get_option( 'analytics', array() ); if ( ! $analytics_entries ) { return $analytics; } foreach ( $analytics_entries as $entry_id => $entry ) { $analytics[ $entry_id ] = array( 'type' => $entry['type'], 'attributes' => array(), 'config_data' => json_decode( $entry['config'] ), ); } return $analytics; } add_filter( 'amp_post_template_analytics', 'amp_add_custom_analytics' );