array( 'xmlns' => true, 'viewbox' => true, 'width' => true, 'height' => true, 'fill' => true, 'focusable' => true, 'aria-hidden' => true, ), 'path' => array( 'd' => true, 'fill' => true, 'stroke' => true, 'stroke-width' => true, 'stroke-linecap' => true, 'stroke-linejoin' => true, ), ); $icon = ''; ?>

array( 'xmlns' => true, 'viewbox' => true, 'width' => true, 'height' => true, 'fill' => true, 'focusable' => true, 'aria-hidden' => true, ), 'path' => array( 'd' => true, 'fill' => true, 'stroke' => true, 'stroke-width' => true, 'stroke-linecap' => true, 'stroke-linejoin' => true, ), ); $icon = ''; ?>

comment_ID ); $is_open = ! Task_Status::is_resolved( (int) $comment->comment_ID ); $edit = get_edit_post_link( (int) $comment->comment_post_ID, 'raw' ); ?>
comment_content ), 14, '…' ) ); ?>
comment_content ) ); ?>

' . esc_html__( '4WP TODO admin UI is not built.', '4wp-todo' ) . ' '; echo esc_html__( 'Run npm install && npm run build in the plugin directory, then refresh this page.', '4wp-todo' ); echo '

'; } ); return; } $asset = include $asset_file; wp_enqueue_style( 'wp-components' ); wp_enqueue_script( 'forwp-todo-admin', forwp_todo_asset_url( 'build/admin/index.js' ), $asset['dependencies'], $asset['version'], true ); wp_set_script_translations( 'forwp-todo-admin', '4wp-todo', FORWP_TODO_PATH . 'languages' ); wp_localize_script( 'forwp-todo-admin', 'forwpTodoAdmin', array( 'restRoot' => self::rest_root_for_browser(), 'nonce' => wp_create_nonce( 'wp_rest' ), 'screen' => self::screen_from_page_request(), 'pages' => array( 'dashboard' => self::PAGE_SLUG, 'lists' => self::LISTS_PAGE_SLUG, 'taxonomy' => self::TAXONOMY_PAGE_SLUG, 'settings' => self::SETTINGS_PAGE_SLUG, ), ) ); } /** * Keep 4WP TODO menu highlighted on native taxonomy screens. * * @param string $parent_file Parent menu file. * @return string */ public static function highlight_taxonomy_parent_menu( string $parent_file ): string { global $pagenow, $taxonomy; if ( 'edit-tags.php' !== $pagenow || ! is_string( $taxonomy ) ) { return $parent_file; } $todo_taxonomies = array( \ForWP\Todo\Task_Taxonomies::CATEGORY, \ForWP\Todo\Task_Taxonomies::STATUS, \ForWP\Todo\Task_Taxonomies::WORKFLOW, ); return in_array( $taxonomy, $todo_taxonomies, true ) ? self::PAGE_SLUG : $parent_file; } /** * @return bool */ private static function is_plugin_page_request(): bool { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- admin screen routing only. $page = isset( $_GET['page'] ) ? sanitize_key( wp_unslash( $_GET['page'] ) ) : ''; return in_array( $page, array( self::PAGE_SLUG, self::LISTS_PAGE_SLUG, self::SETTINGS_PAGE_SLUG, ), true ); } /** * @return string */ private static function screen_from_page_request(): string { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- admin screen routing only. $page = isset( $_GET['page'] ) ? sanitize_key( wp_unslash( $_GET['page'] ) ) : ''; if ( self::LISTS_PAGE_SLUG === $page ) { return 'lists'; } if ( self::SETTINGS_PAGE_SLUG === $page ) { return 'settings'; } return 'dashboard'; } /** * REST root on the current host (Local often uses :10144 while siteurl has no port). * * @return string Path like /wp-json/ so apiFetch uses the active browser origin. */ private static function rest_root_for_browser(): string { $path = wp_parse_url( rest_url(), PHP_URL_PATH ); return trailingslashit( is_string( $path ) && '' !== $path ? $path : '/wp-json/' ); } }