{"id":16506791,"url":"https://github.com/screamingdev/wp-fast-simple-import","last_synced_at":"2026-05-12T18:19:24.002Z","repository":{"id":57056120,"uuid":"65192139","full_name":"ScreamingDev/wp-fast-simple-import","owner":"ScreamingDev","description":"Import things in WordPress made easy for developers.","archived":false,"fork":false,"pushed_at":"2016-12-09T08:48:40.000Z","size":24,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-12T14:16:04.892Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ScreamingDev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-08-08T09:39:05.000Z","updated_at":"2016-08-08T09:39:43.000Z","dependencies_parsed_at":"2022-08-24T14:00:36.599Z","dependency_job_id":null,"html_url":"https://github.com/ScreamingDev/wp-fast-simple-import","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScreamingDev%2Fwp-fast-simple-import","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScreamingDev%2Fwp-fast-simple-import/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScreamingDev%2Fwp-fast-simple-import/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScreamingDev%2Fwp-fast-simple-import/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ScreamingDev","download_url":"https://codeload.github.com/ScreamingDev/wp-fast-simple-import/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241445040,"owners_count":19963915,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T15:22:13.331Z","updated_at":"2026-05-12T18:19:23.957Z","avatar_url":"https://github.com/ScreamingDev.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Easy import for WordPress\n\nWriting an import couldn't be easier.\nJust fetch data and forward it to WP-FSI:\n\n    $query = 'SELECT\n                uid   AS _import_uid,\n                title AS name\n              FROM `typo3-db`.categories\n              WHERE deleted = 0';\n    \n    foreach ( fsi_query( $query ) as $item ) {\n        fsi_term_import( $item['name'], 'my_taxonomy' );\n    }\n\nSimple as that for **posts, terms and attachments**.\nBlazing fast thanks to yields which WordPress is not capable of.\n\n\n## Features\n\n- Posts\n  - Import Posts with `fsi_import_post`.\n  - `fsi_post_add_term` creates terms or just adds them if they exist already.\n- Media\n  - `fsi_import_thumbnail` imports an image from filesystem or URL.\n- Term\n  - `fsi_term_import` creates a term or just updates if it already exists.\n  - `fsi_term_meta_update` eats an array and applies it as new term meta.\n  - `fsi_term_meta_replace` like above but with deletion of all old data.\n\nAnd some neat helpers:\n\n- Use `fsi_query` if you want faster imports.\n- Do `fsi_enable_all_caps()` to supercharge your import\n  and give it all kind of capabilities.\n- Or `fsi_enable_caps` for a subset of caps.\n\n### Mapping\n\nThere is a helper for mapping included. Basically it is an array with some magic:\n\n- The **key** is where the data should go.\n- The **value** is where the data comes from.\n- So to speak data flows from the right side of `[ 'target_field' =\u003e 'source_field' ]` to the left\n\nSo it is like:\n\n```php\n$mapping = new WP_FSI\\Mapping();\n\n$mapping['target_column_name'] = 'source_column_name';\n$mapping['_import_uid']        = 'uid';\n$mapping['post_title']         = 'subject';\n$mapping['post_excerpt']       = 'This is no field of the source, so the string / value will be stored.';\n$mapping['i_am_meta']          = 42; // Also no field of the source? Then all those meta_fields \" will have the value 42.\n\n// And for now it is very easy piping all through.\n$some_data_source = fetched_from_somewhere();\n$post_data = $mapping( $some_data_source );\nfsi_import_post( $post_data );\n```\n\n**Callables can transform data** on the value side.\nIt receives the actual mapping (first arg),\nthe source data (second arg)\nand the so far resulting target data (third arg).\nWhat you return is what will be stored in the target:\n\n```php\n$mapping = new WP_FSI\\Mapping();\n\n$mapping['post_excerpt'] = function( $mapping_object, $source_data, $target_data ) {\n   \n    // The FIRST ARGUMENT is the mapping itself so that you can delegate.\n    if ( is_callable( $mapping_object['some_callable'] ) ) {\n        return call_user_func_array( $mapping_object['some_callable'], func_get_args() );\n    }\n    \n    // The SECOND ARGUMENT is where everything came from.\n    if ( 'dog' == $source_data['animal'] ) {\n        return 'Such fast. Very simple. Much wow!';\n    }\n    \n    // The THIRD ARGUMENT is the target data that you still can manipulate.\n    // It is an array object so the reference is given by default - nice, huh? ;)\n    if ( 'cat' == $source_data['animal'] ) {\n        shuffle( $target_data );\n        $target_data['post_title'] = 'meow meow!';\n    }\n    \n    // or imagine sub queries here, data manipulation and more\n    return 'Last seen on ' . date( 'Y-m-d', $source_data['timestamp'] );\n}\n\n// Still the same and easy.\n$some_data_source = fetched_from_somewhere();\n$post_data = $mapping( $some_data_source );\nfsi_import_post( $post_data );\n```\n\n## Real life examples\n\n### Import tt_news from Typo\n\nHere I had some typo instance and had to import all news as new posts.\nA simple query and forwarding to a function.\nThat's all:\n\n    $query = '\n    SELECT\n      uid\t\t\t\t\t\t\t\t\tAS _import_uid,\n      title                                 AS post_title,\n      \"post\"                                AS post_type,\n      short\t\t\t\t\t\t\t\t\tAS post_excerpt,\n      bodytext\t\t\t\t\t\t\t    AS post_content,\n      CONCAT('http://example.org/', logo)   AS _thumbnail_id,\n    FROM `typo3-databse`.tt_news\n    ';\n    \n    foreach( fsi_query ( $query ) as $item ) {\n        fsi_import_post( $item );\n    }\n\nThis does a lot:\n\n- **No duplicates** - Run this several times without hurt.\n- **Faster import** - Using `fsi_query` will yield data through.\n- **Downloads thumbnail only once** - No duplicates there too.\n\nYou can also use the mapper for that:\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscreamingdev%2Fwp-fast-simple-import","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscreamingdev%2Fwp-fast-simple-import","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscreamingdev%2Fwp-fast-simple-import/lists"}