Changeset 3406449
- Timestamp:
- 12/01/2025 05:32:19 AM (6 weeks ago)
- File:
-
- 1 edited
-
inline-context/assets/blueprints/blueprint.json (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
inline-context/assets/blueprints/blueprint.json
r3405497 r3406449 25 25 { 26 26 "step": "runPHP", 27 "code": "<?php\nrequire_once 'wordpress/wp-load.php';\n\n// Create a demo post with inline context examples\n$post_content = '<!-- wp:paragraph -->\n<p>The <a class=\"wp-inline-context\" data-inline-context=\"<p>A <strong>blockchain</strong> is a distributed ledger technology that maintains a secure and decentralized record of transactions.</p>\" data-anchor-id=\"context-note-1732800000000-abc\" href=\"#context-note-1732800000000-abc\" role=\"button\" aria-expanded=\"false\">blockchain</a> is revolutionizing digital transactions.</p>\n<!-- /wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>Scientists have discovered that <a class=\"wp-inline-context\" data-inline-context=\"<p>Photosynthesis is the process by which plants convert light energy into chemical energy, producing oxygen as a byproduct.</p>\" data-anchor-id=\"context-note-1732800000001-def\" href=\"#context-note-1732800000001-def\" role=\"button\" aria-expanded=\"false\">photosynthesis</a> plays a crucial role in maintaining Earth’s atmosphere.</p>\n<!-- /wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>The concept of <a class=\"wp-inline-context\" data-inline-context=\"<p><strong>Machine learning</strong> is a subset of artificial intelligence that enables computers to learn from data without being explicitly programmed. It uses algorithms to identify patterns and make predictions.</p>\" data-anchor-id=\"context-note-1732800000002-ghi\" href=\"#context-note-1732800000002-ghi\" role=\"button\" aria-expanded=\"false\">machine learning</a> has transformed modern technology.</p>\n<!-- /wp:paragraph -->\n\n<!-- wp:heading -->\n<h2 class=\"wp-block-heading\">Getting Started</h2>\n<!-- /wp:heading -->\n\n<!-- wp:paragraph -->\n<p>Click any underlined term above to reveal its context note. Click again to hide it. You can also use the block editor to add your own inline context notes!</p>\n<!-- /wp:paragraph -->\n';\n\n$demo_post = array(\n 'post_title' => 'Welcome to Inline Context Demo',\n 'post_content' => $post_content,\n 'post_status' => 'publish',\n 'post_author' => 1,\n 'post_type' => 'post',\n);\n\n$post_id = wp_insert_post( $demo_post );\n\nif ( $post_id ) {\n echo 'Demo post created successfully with ID: ' . $post_id;\n} else {\n echo 'Failed to create demo post';\n}\n?>"28 },29 {30 "step": "runPHP",31 27 "code": "<?php\nrequire_once 'wordpress/wp-load.php';\n\n// Create default categories for inline context\n$categories = array(\n array(\n 'name' => 'Internal Article',\n 'slug' => 'internal-article',\n 'meta' => array(\n 'icon_closed' => 'dashicons-admin-links',\n 'icon_open' => 'dashicons-admin-links',\n 'color' => '#0073aa'\n )\n ),\n array(\n 'name' => 'External Article',\n 'slug' => 'external-article',\n 'meta' => array(\n 'icon_closed' => 'dashicons-external',\n 'icon_open' => 'dashicons-external',\n 'color' => '#00a32a'\n )\n ),\n array(\n 'name' => 'Definition',\n 'slug' => 'definition',\n 'meta' => array(\n 'icon_closed' => 'dashicons-book',\n 'icon_open' => 'dashicons-book-alt',\n 'color' => '#826eb4'\n )\n ),\n array(\n 'name' => 'Tip',\n 'slug' => 'tip',\n 'meta' => array(\n 'icon_closed' => 'dashicons-lightbulb',\n 'icon_open' => 'dashicons-lightbulb',\n 'color' => '#f0b849'\n )\n )\n);\n\n$created_terms = array();\nforeach ( $categories as $cat ) {\n $term = wp_insert_term( $cat['name'], 'inline_context_category', array( 'slug' => $cat['slug'] ) );\n if ( ! is_wp_error( $term ) ) {\n foreach ( $cat['meta'] as $key => $value ) {\n update_term_meta( $term['term_id'], $key, $value );\n }\n $created_terms[$cat['slug']] = $term['term_id'];\n }\n}\n\necho 'Demo categories created successfully: ' . count($created_terms);\n?>" 32 28 }, 33 29 { 34 30 "step": "runPHP", 35 "code": "<?php\nrequire_once 'wordpress/wp-load.php';\n\n// Get category IDs\n$internal_term = get_term_by('slug', 'internal-article', 'inline_context_category');\n$external_term = get_term_by('slug', 'external-article', 'inline_context_category');\n$definition_term = get_term_by('slug', 'definition', 'inline_context_category');\n$tip_term = get_term_by('slug', 'tip', 'inline_context_category');\n\n// Create reusable inline context notes with links\n$notes = array(\n array(\n 'title' => 'What is Blockchain?',\n 'content' => '<p>A <strong>blockchain</strong> is a distributed ledger technology that maintains a secure and decentralized record of transactions. <a href=\"https://en.wikipedia.org/wiki/Blockchain\" target=\"_blank\" rel=\"noopener noreferrer\">Learn more about blockchain on Wikipedia</a>.</p>',\n 'category' => $external_term ? $external_term->term_id : 0,\n 'reusable' => true,\n ),\n array(\n 'title' => 'Photosynthesis Explained',\n 'content' => '<p>Photosynthesis is the process by which plants convert light energy into chemical energy, producing oxygen as a byproduct. For a detailed explanation, see <a href=\"#getting-started\">our Getting Started section below</a>.</p>',\n 'category' => $internal_term ? $internal_term->term_id : 0,\n 'reusable' => true,\n ),\n array(\n 'title' => 'Machine Learning Definition',\n 'content' => '<p><strong>Machine learning</strong> is a subset of artificial intelligence that enables computers to learn from data without being explicitly programmed. It uses algorithms to identify patterns and make predictions.</p>',\n 'category' => $definition_term ? $definition_term->term_id : 0,\n 'reusable' => true,\n ),\n array(\n 'title' => 'Quick Start Tip',\n 'content' => '<p><strong>Pro tip:</strong> You can create reusable notes and use them across multiple posts! Check out the <a href=\"/wp-admin/edit.php?post_type=inline_context_note\">Notes Library</a> in your admin panel to manage all your inline context notes.</p>',\n 'category' => $tip_term ? $tip_term->term_id : 0,\n 'reusable' => true,\n ),\n);\n\n$note_ids = array();\nforeach ( $notes as $note ) {\n $post_id = wp_insert_post( array(\n 'post_title' => $note['title'],\n 'post_content' => $note['content'],\n 'post_status' => 'publish',\n 'post_type' => 'inline_context_note',\n ) );\n \n if ( $post_id && ! is_wp_error( $post_id ) ) {\n update_post_meta( $post_id, 'is_reusable', $note['reusable'] );\n if ( $note['category'] > 0 ) {\n wp_set_object_terms( $post_id, $note['category'], 'inline_context_category' );\n }\n $note_ids[$note['title']] = $post_id;\n }\n}\n\necho 'Created ' . count($note_ids) . ' reusable inline context notes with internal and externallinks';\n?>"31 "code": "<?php\nrequire_once 'wordpress/wp-load.php';\n\n// Get category IDs\n$internal_term = get_term_by('slug', 'internal-article', 'inline_context_category');\n$external_term = get_term_by('slug', 'external-article', 'inline_context_category');\n$definition_term = get_term_by('slug', 'definition', 'inline_context_category');\n$tip_term = get_term_by('slug', 'tip', 'inline_context_category');\n\n// Create reusable inline context notes with links\n$notes = array(\n array(\n 'title' => 'What is Blockchain?',\n 'content' => '<p>A <strong>blockchain</strong> is a distributed ledger technology that maintains a secure and decentralized record of transactions. <a href=\"https://en.wikipedia.org/wiki/Blockchain\" target=\"_blank\" rel=\"noopener noreferrer\">Learn more about blockchain on Wikipedia</a>.</p>',\n 'category' => $external_term ? array( $external_term->term_id ) : array(),\n 'reusable' => true,\n ),\n array(\n 'title' => 'Photosynthesis Explained',\n 'content' => '<p>Photosynthesis is the process by which plants convert light energy into chemical energy, producing oxygen as a byproduct. For a detailed explanation, see <a href=\"#getting-started\">our Getting Started section below</a>.</p>',\n 'category' => $internal_term ? array( $internal_term->term_id ) : array(),\n 'reusable' => true,\n ),\n array(\n 'title' => 'Machine Learning Definition',\n 'content' => '<p><strong>Machine learning</strong> is a subset of artificial intelligence that enables computers to learn from data without being explicitly programmed. It uses algorithms to identify patterns and make predictions.</p>',\n 'category' => $definition_term ? array( $definition_term->term_id ) : array(),\n 'reusable' => true,\n ),\n array(\n 'title' => 'Quick Start Tip',\n 'content' => '<p><strong>Pro tip:</strong> You can create reusable notes and use them across multiple posts! Check out the <a href=\"/wp-admin/edit.php?post_type=inline_context_note\">Notes Library</a> in your admin panel to manage all your inline context notes.</p>',\n 'category' => $tip_term ? array( $tip_term->term_id ) : array(),\n 'reusable' => true,\n ),\n);\n\n$note_ids = array();\nforeach ( $notes as $note ) {\n $post_id = wp_insert_post( array(\n 'post_title' => $note['title'],\n 'post_content' => $note['content'],\n 'post_status' => 'publish',\n 'post_type' => 'inline_context_note',\n ) );\n \n if ( $post_id && ! is_wp_error( $post_id ) ) {\n update_post_meta( $post_id, 'is_reusable', $note['reusable'] );\n update_post_meta( $post_id, 'used_in_posts', array() );\n update_post_meta( $post_id, 'usage_count', 0 );\n if ( ! empty( $note['category'] ) ) {\n wp_set_object_terms( $post_id, $note['category'], 'inline_context_category', false );\n }\n $note_ids[$note['title']] = $post_id;\n }\n}\n\necho 'Created ' . count($note_ids) . ' reusable inline context notes with categories and links';\n?>" 36 32 }, 37 33 { 38 34 "step": "runPHP", 39 "code": "<?php\nrequire_once 'wordpress/wp-load.php';\n\n// Get the note IDs we just created\n$blockchain_note = get_page_by_title( 'What is Blockchain?', OBJECT, 'inline_context_note' );\n$photosynthesis_note = get_page_by_title( 'Photosynthesis Explained', OBJECT, 'inline_context_note' );\n$ml_note = get_page_by_title( 'Machine Learning Definition', OBJECT, 'inline_context_note' );\n$tip_note = get_page_by_title( 'Quick Start Tip', OBJECT, 'inline_context_note' );\n\n// Get category IDs for each note\n$blockchain_cats = wp_get_object_terms( $blockchain_note->ID, 'inline_context_category', array('fields' => 'ids') );\n$photosynthesis_cats = wp_get_object_terms( $photosynthesis_note->ID, 'inline_context_category', array('fields' => 'ids') );\n$ml_cats = wp_get_object_terms( $ml_note->ID, 'inline_context_category', array('fields' => 'ids') );\n$tip_cats = wp_get_object_terms( $tip_note->ID, 'inline_context_category', array('fields' => 'ids') );\n\n$blockchain_cat_id = ! empty( $blockchain_cats ) ? $blockchain_cats[0] : '';\n$photosynthesis_cat_id = ! empty( $photosynthesis_cats ) ? $photosynthesis_cats[0] : '';\n$ml_cat_id = ! empty( $ml_cats ) ? $ml_cats[0] : '';\n$tip_cat_id = ! empty( $tip_cats ) ? $tip_cats[0] : '';\n\n// Create demo post using the actual notes\n$post_content = '<!-- wp:paragraph -->\n<p>Modern technology is rapidly evolving. The <a class=\"wp-inline-context\" data-note-id=\"' . ($blockchain_note ? $blockchain_note->ID : '') . '\" data-category-id=\"' . $blockchain_cat_id . '\" data-inline-context=\"' . esc_attr( $blockchain_note ? $blockchain_note->post_content : '' ) . '\" data-anchor-id=\"context-note-blockchain\" href=\"#context-note-blockchain\" role=\"button\" aria-expanded=\"false\">blockchain</a> is revolutionizing digital transactions and creating new possibilities for secure, decentralized systems.</p>\n<!-- /wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>In the natural world, <a class=\"wp-inline-context\" data-note-id=\"' . ($photosynthesis_note ? $photosynthesis_note->ID : '') . '\" data-category-id=\"' . $photosynthesis_cat_id . '\" data-inline-context=\"' . esc_attr( $photosynthesis_note ? $photosynthesis_note->post_content : '' ) . '\" data-anchor-id=\"context-note-photosynthesis\" href=\"#context-note-photosynthesis\" role=\"button\" aria-expanded=\"false\">photosynthesis</a> plays a crucial role in maintaining Earth’s atmosphere and supporting the entire ecosystem.</p>\n<!-- /wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>The concept of <a class=\"wp-inline-context\" data-note-id=\"' . ($ml_note ? $ml_note->ID : '') . '\" data-category-id=\"' . $ml_cat_id . '\" data-inline-context=\"' . esc_attr( $ml_note ? $ml_note->post_content : '' ) . '\" data-anchor-id=\"context-note-machine-learning\" href=\"#context-note-machine-learning\" role=\"button\" aria-expanded=\"false\">machine learning</a> has transformed modern technology and is powering innovations across every industry.</p>\n<!-- /wp:paragraph -->\n\n<!-- wp:heading {\"level\":2} -->\n<h2 class=\"wp-block-heading\" id=\"getting-started\">Getting Started</h2>\n<!-- /wp:heading -->\n\n<!-- wp:paragraph -->\n<p>Click any underlined term above to reveal its context note. Notice how some notes contain external links (opening in new tabs) while others have internal links (staying on the same page). <a class=\"wp-inline-context\" data-note-id=\"' . ($tip_note ? $tip_note->ID : '') . '\" data-category-id=\"' . $tip_cat_id . '\" data-inline-context=\"' . esc_attr( $tip_note ? $tip_note->post_content : '' ) . '\" data-anchor-id=\"context-note-tip\" href=\"#context-note-tip\" role=\"button\" aria-expanded=\"false\">Click here for a quick tip</a> about managing your notes.</p>\n<!-- /wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>These notes are created as reusable Custom Post Type entries that can be used across multiple posts. Try editing this post in the block editor to see how easy it is to search for and insert existing notes!</p>\n<!-- /wp:paragraph -->\n';\n\n$demo_post = array(\n 'post_title' => 'Welcome to Inline Context Demo',\n 'post_content' => $post_content,\n 'post_status' => 'publish',\n 'post_author' => 1,\n 'post_type' => 'post',\n);\n\n$post_id = wp_insert_post( $demo_post );\n\n // Update usage tracking for the notes\n$notes_to_track = array( $blockchain_note, $photosynthesis_note, $ml_note, $tip_note );\nforeach ( $notes_to_track as $note ) {\n if ( $post_id && $note ) {\n $used_in = get_post_meta( $note->ID, 'used_in_posts', true ) ?: array();\n if ( ! in_array( $post_id, $used_in ) ) {\n $used_in[] = $post_id;\n update_post_meta( $note->ID, 'used_in_posts', $used_in );\n update_post_meta( $note->ID, 'usage_count', count($used_in) );\n }\n }\n}\n\nif ( $post_id ) {\n echo 'Demo post created with ID: ' . $post_id . ' using 4 reusable notes with categories and links';\n} else {\n echo 'Failed to create demo post';\n}\n?>"35 "code": "<?php\nrequire_once 'wordpress/wp-load.php';\n\n// Get the note IDs we just created\n$blockchain_note = get_page_by_title( 'What is Blockchain?', OBJECT, 'inline_context_note' );\n$photosynthesis_note = get_page_by_title( 'Photosynthesis Explained', OBJECT, 'inline_context_note' );\n$ml_note = get_page_by_title( 'Machine Learning Definition', OBJECT, 'inline_context_note' );\n$tip_note = get_page_by_title( 'Quick Start Tip', OBJECT, 'inline_context_note' );\n\n// Get category IDs for each note\n$blockchain_cats = wp_get_object_terms( $blockchain_note->ID, 'inline_context_category', array('fields' => 'ids') );\n$photosynthesis_cats = wp_get_object_terms( $photosynthesis_note->ID, 'inline_context_category', array('fields' => 'ids') );\n$ml_cats = wp_get_object_terms( $ml_note->ID, 'inline_context_category', array('fields' => 'ids') );\n$tip_cats = wp_get_object_terms( $tip_note->ID, 'inline_context_category', array('fields' => 'ids') );\n\n$blockchain_cat_id = ! empty( $blockchain_cats ) ? $blockchain_cats[0] : '';\n$photosynthesis_cat_id = ! empty( $photosynthesis_cats ) ? $photosynthesis_cats[0] : '';\n$ml_cat_id = ! empty( $ml_cats ) ? $ml_cats[0] : '';\n$tip_cat_id = ! empty( $tip_cats ) ? $tip_cats[0] : '';\n\n// Create demo post using the actual notes\n$post_content = '<!-- wp:paragraph -->\n<p>Modern technology is rapidly evolving. The <a class=\"wp-inline-context\" data-note-id=\"' . ($blockchain_note ? $blockchain_note->ID : '') . '\" data-category-id=\"' . $blockchain_cat_id . '\" data-inline-context=\"' . esc_attr( $blockchain_note ? $blockchain_note->post_content : '' ) . '\" data-anchor-id=\"context-note-blockchain\" href=\"#context-note-blockchain\" role=\"button\" aria-expanded=\"false\">blockchain</a> is revolutionizing digital transactions and creating new possibilities for secure, decentralized systems.</p>\n<!-- /wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>In the natural world, <a class=\"wp-inline-context\" data-note-id=\"' . ($photosynthesis_note ? $photosynthesis_note->ID : '') . '\" data-category-id=\"' . $photosynthesis_cat_id . '\" data-inline-context=\"' . esc_attr( $photosynthesis_note ? $photosynthesis_note->post_content : '' ) . '\" data-anchor-id=\"context-note-photosynthesis\" href=\"#context-note-photosynthesis\" role=\"button\" aria-expanded=\"false\">photosynthesis</a> plays a crucial role in maintaining Earth’s atmosphere and supporting the entire ecosystem.</p>\n<!-- /wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>The concept of <a class=\"wp-inline-context\" data-note-id=\"' . ($ml_note ? $ml_note->ID : '') . '\" data-category-id=\"' . $ml_cat_id . '\" data-inline-context=\"' . esc_attr( $ml_note ? $ml_note->post_content : '' ) . '\" data-anchor-id=\"context-note-machine-learning\" href=\"#context-note-machine-learning\" role=\"button\" aria-expanded=\"false\">machine learning</a> has transformed modern technology and is powering innovations across every industry.</p>\n<!-- /wp:paragraph -->\n\n<!-- wp:heading {\"level\":2} -->\n<h2 class=\"wp-block-heading\" id=\"getting-started\">Getting Started</h2>\n<!-- /wp:heading -->\n\n<!-- wp:paragraph -->\n<p>Click any underlined term above to reveal its context note. Notice how some notes contain external links (opening in new tabs) while others have internal links (staying on the same page). <a class=\"wp-inline-context\" data-note-id=\"' . ($tip_note ? $tip_note->ID : '') . '\" data-category-id=\"' . $tip_cat_id . '\" data-inline-context=\"' . esc_attr( $tip_note ? $tip_note->post_content : '' ) . '\" data-anchor-id=\"context-note-tip\" href=\"#context-note-tip\" role=\"button\" aria-expanded=\"false\">Click here for a quick tip</a> about managing your notes.</p>\n<!-- /wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>These notes are created as reusable Custom Post Type entries that can be used across multiple posts. Try editing this post in the block editor to see how easy it is to search for and insert existing notes!</p>\n<!-- /wp:paragraph -->\n';\n\n$demo_post = array(\n 'post_title' => 'Welcome to Inline Context Demo',\n 'post_content' => $post_content,\n 'post_status' => 'publish',\n 'post_author' => 1,\n 'post_type' => 'post',\n);\n\n$post_id = wp_insert_post( $demo_post );\n\nif ( ! $post_id || is_wp_error( $post_id ) ) {\n echo 'Failed to create demo post';\n return;\n}\n\n// Update usage tracking for the notes\n$notes_to_track = array(\n array( 'note' => $blockchain_note, 'count' => 1 ),\n array( 'note' => $photosynthesis_note, 'count' => 1 ),\n array( 'note' => $ml_note, 'count' => 1 ),\n array( 'note' => $tip_note, 'count' => 1 ),\n);\n\nforeach ( $notes_to_track as $item ) {\n $note = $item['note'];\n if ( $note && ! is_wp_error( $note ) ) {\n // Get existing usage data\n $used_in = get_post_meta( $note->ID, 'used_in_posts', true );\n if ( ! is_array( $used_in ) ) {\n $used_in = array();\n }\n \n // Add this post ID if not already tracked\n if ( ! in_array( $post_id, $used_in, true ) ) {\n $used_in[] = $post_id;\n }\n \n // Update meta fields\n update_post_meta( $note->ID, 'used_in_posts', $used_in );\n update_post_meta( $note->ID, 'usage_count', count( $used_in ) );\n }\n}\n\necho 'Demo post created with ID: ' . $post_id . ' using 4 reusable notes with categories and usage tracking';\n?>" 40 36 }, 41 37 {
Note: See TracChangeset
for help on using the changeset viewer.