$slug ), $args ), admin_url( 'admin.php' ) ); } /** * The Tapmap menu. */ public static function menu() { /** * Filter the number shown next to the menu, like new comments. * * @param int $count Count. */ $count = (int) apply_filters( 'tapmap_menu_count', 0 ); $bubble = $count ? ' ' . $count . '' : ''; $icon = 'data:image/svg+xml;base64,' . base64_encode( '' ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode -- Menu icon. add_menu_page( __( 'Tapmap', 'tapmap' ), __( 'Tapmap', 'tapmap' ) . $bubble, self::cap(), self::SLUG, array( __CLASS__, 'page_maps' ), $icon, 26 ); add_submenu_page( self::SLUG, __( 'Maps', 'tapmap' ), __( 'Maps', 'tapmap' ), self::cap(), self::SLUG, array( __CLASS__, 'page_maps' ) ); } /** * "Maps" on the Plugins screen. * * @param array $links Links. * * @return array */ public static function action_links( $links ) { array_unshift( $links, '' . esc_html__( 'Maps', 'tapmap' ) . '' ); return $links; } /** * Styles for Tapmap's pages only. * * @param string $hook Page hook. */ public static function assets( $hook ) { if ( false === strpos( $hook, self::SLUG ) ) { return; } wp_enqueue_style( 'tapmap-admin', TAPMAP_URL . 'assets/css/admin.css', array(), TAPMAP_VERSION ); } /* ------------------------------------------------------------------ */ /* Data */ /* ------------------------------------------------------------------ */ /** * Every Tapmap block on the site (not in the bin), newest posts first. * * @return array[] Each: post (WP_Post), attrs (array), key ("postid:mapid"). */ public static function all_maps() { global $wpdb; // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Finding blocks in content has no API. $ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM %i WHERE post_content LIKE %s AND post_status NOT IN ('trash','auto-draft','inherit') AND post_type <> 'revision' ORDER BY post_modified DESC LIMIT 500", $wpdb->posts, '%' . $wpdb->esc_like( '