{"id":22606600,"url":"https://github.com/benjaminmedia/wp-trapp","last_synced_at":"2025-03-28T22:15:10.046Z","repository":{"id":62493226,"uuid":"46280112","full_name":"BenjaminMedia/wp-trapp","owner":"BenjaminMedia","description":"The repo for Trapps wordpress plugin","archived":false,"fork":false,"pushed_at":"2016-10-26T07:05:09.000Z","size":175,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-03-26T14:54:36.519Z","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/BenjaminMedia.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":"2015-11-16T14:35:10.000Z","updated_at":"2017-06-14T07:58:43.000Z","dependencies_parsed_at":"2022-11-02T11:17:10.752Z","dependency_job_id":null,"html_url":"https://github.com/BenjaminMedia/wp-trapp","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/BenjaminMedia%2Fwp-trapp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BenjaminMedia%2Fwp-trapp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BenjaminMedia%2Fwp-trapp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BenjaminMedia%2Fwp-trapp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BenjaminMedia","download_url":"https://codeload.github.com/BenjaminMedia/wp-trapp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246106689,"owners_count":20724401,"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-12-08T14:14:15.986Z","updated_at":"2025-03-28T22:15:10.023Z","avatar_url":"https://github.com/BenjaminMedia.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WP TRAPP Plugin\nSend content to the TRAPP translation service.\n\n## Installation\n\nAs composer is very optional in WordPress community there are two ways to install this plugin.\n\n### Composer\n\n**If the project is loading the main composer autoload file.**\n\nInstall plugin:\n\n`composer create-project benjaminmedia/wp-trapp 1.*`\n\nInstall plugin as working dev/master version:\n\n`composer create-project benjaminmedia/wp-trapp --stability dev --prefer-dist`\n\nInstall plugin as a working dev/master version with all vcs files:\n\n`composer create-project benjaminmedia/wp-trapp --stability dev --prefer-source --keep-vcs`\n\n### WP Plugin\n\n**If the plugin should not rely on anything other than its own composer functionality.**\n\nInstall plugin:\n\n`composer require benjaminmedia/wp-trapp 1.*`\n\nInstall plugin as working dev/master version:\n\n`composer require benjaminmedia/wp-trapp dev-master --prefer-dist`\n\nInstall plugin as a working dev/master version with all vcs files:\n\n`composer require benjaminmedia/wp-trapp dev-master --prefer-source`\n\n### Setup\n\nTRAPP requires some information like username and password. This is how they can be defined.\n\n`Username`\n\nDefine either `WA_TRAPP_USERNAME` or from the `bp_trapp_service_username` filter.\n\n```\nadd_filter('bp_trapp_service_username', function() {\n{\n    return 'myuser';\n});\n```\n\n`Secret`\n\nDefine either `WA_TRAPP_SECRET` or from the `bp_trapp_service_secret` filter.\n\n```\nadd_filter('bp_trapp_service_secret', function() {\n{\n    return 'mysecret';\n});\n```\n\n`Development`\n\nDefault is false.\nIf `APP_ENV` is found it will return true if `APP_ENV` is production.\nChange how development is defined in the `bp_trapp_service_development` filter.\n\n```\nadd_filter('bp_trapp_service_development', function($isDevelopment) {\n{\n    if (defined('WP_DEBUG') \u0026\u0026 WP_DEBUG) {\n        return true;\n    }\n\n    return $isDevelopment;\n});\n```\n\n`APP Code`\n\nDefine either `WA_APP_CODE` or from the `bp_trapp_save_app_code` filter.\n\n```\nadd_filter('bp_trapp_save_app_code', function() {\n{\n    return 'my_app_code';\n});\n```\n\n`Brand Code`\n\nDefine either `WA_BRAND_CODE` or from the `bp_trapp_save_brand_code` filter.\n\n```\nadd_filter('bp_trapp_save_brand_code', function() {\n{\n    return 'my_brand_code';\n});\n```\n\n### Extend (Hooks)\n\n`bp_trapp_post_types`\n\nCustom post types are whitelisted in this filter. If the 'mycpt' custom post type is suppose to send translations to TRAPP this is the filter for it.\n\n- `$post_types` Array values of post types\n\n```\n/**\n * Adds 'mycpt' to the accepted TRAPP post types.\n */\nadd_filter('bp_trapp_post_types', function($post_types) {\n    $post_types[] = 'mycpt';\n\n    return $post_types;\n});\n```\n\n`bp_trapp_save_{$post_type}_taxonomies`\n\nEnables which taxonomies that should be copied to the new translation from the master. This will copy the translated versions of the terms from the master.\n\nThe `{$post_type}` is a dynamic filter and is specific to the `{$post_type}`\n\n- `$taxonomies` Array values of taxonomies\n\n```\n/**\n * Clone taxonomy 'myct' when a 'mycpt' post type is translated.\n */\nadd_filter('bp_trapp_save_mycpt_taxonomies', function($taxonomies) {\n    $taxonomies[] = 'myct';\n\n    return $taxonomies;\n});\n```\n\n`bp_trapp_locked_field`\n\n- `$return` The return value.\n- `$field` Array data of the current field\n\nPasses input names to js to disable these fields in the edit post view. Use this filter if the name of the metadata does not match the input name output in HTML.\n\n```\n/**\n * The field '_mycustomfield' is saved from the input[name=\"mycustomfield_textinput\"].\n */\nadd_filter('bp_trapp_locked_field', function($return, $field) {\n    if ($field['type'] == 'post_meta' \u0026\u0026 $field['args']['key'] == '_mycustomfield') {\n        return 'mycustomfield_textinput';\n    }\n\n    return $return;\n}, 12, 2);\n```\n\n`bp_trapp_get_{$post_type}_fields`\n\nUse this filter to modify the fields sent and updated from TRAPP. This can be used to unset fields, modify labels or add new fields.\n\nThe `{$post_type}` is a dynamic filter and is specific to the `{$post_type}`\n\n- `$fields` Array of field groups containing fields\n\n```\n/**\n * Change the \"Post Thumbnail\" to \"Main Image\"\n */\nadd_filter('bp_trapp_get_mycpt_fields', function($fields) {\n    if (array_key_exists('post_thumbnail', $fields)) {\n        $fields['post_thumbnail']['title'] = 'Main Image';\n\n        foreach ($fields['post_thumbnail']['fields'] as $key =\u003e $field) {\n            $fields['post_thumbnail']['fields'][$key]['label'] = str_replace('Post Thumbnail', 'Main Image', $field['label']);\n        }\n    }\n});\n\n/**\n * Extend TRAPP with my field group.\n */\nadd_filter('bp_trapp_get_mycpt_fields', function($fields) {\n    $fields['my_field_group'] = [\n        'title' =\u003e 'My field group',\n        'fields' =\u003e [\n            'title' =\u003e [\n                'label' =\u003e 'My field group title',\n                'args' =\u003e [\n                    'key' =\u003e 'mfg_title'\n                ],\n                'type' =\u003e 'post_meta',\n            ],\n            'text' =\u003e [\n                'label' =\u003e 'My field group text',\n                'args' =\u003e [\n                    'key' =\u003e 'mfg_teaser_text'\n                ],\n                'type' =\u003e 'post_meta',\n            ],\n        ],\n    ];\n});\n\n/**\n * Extend TRAPP with my image field group.\n */\nadd_filter('bp_trapp_get_mycpt_image_fields', function($fields) {\n    $fields['my_image_field_group'] = [\n        'title' =\u003e 'My Image',\n        'fields' =\u003e [\n            'display_image' =\u003e [\n                'label' =\u003e 'My image Url',\n                'args' =\u003e [\n                    'image_key' =\u003e 'mifg_image',\n                ],\n                'type' =\u003e 'image_display',\n                'display_format' =\u003e 'image',\n            ],\n            'title' =\u003e [\n                'label' =\u003e 'My image Title',\n                'args' =\u003e [\n                    'image_key' =\u003e 'mifg_image',\n                    'key' =\u003e 'post_title'\n                ],\n                'type' =\u003e 'image_wp_post',\n            ],\n            'alt' =\u003e [\n                'label' =\u003e 'My image Alt',\n                'args' =\u003e [\n                    'image_key' =\u003e 'mifg_image',\n                    'key' =\u003e '_wp_attachment_image_alt'\n                ],\n                'type' =\u003e 'image_post_meta',\n            ],\n        ],\n    ];\n});\n```\n\n`bp_trapp_save_images`\n\nAdd images that should get saved whenever a post is getting translated.\n\n- `$images` Array of images containing image data\n- `$postId` Post ID of the post\n\n```\nadd_filter('bp_trapp_save_images', function($images, $postId) {\n    $secondaryImage = get_post_meta($postId, 'secondary_image', true);\n\n    if ($secondaryImage) {\n        $images['secondary_image'] = [\n            'id' =\u003e $secondaryImage,\n            'post' =\u003e get_post($secondaryImage),\n            'type' =\u003e 'meta',\n            'key' =\u003e 'secondary_image',\n        ];\n    }\n\n    return $images;\n}, 10, 2);\n```\n\n`bp_trapp_after_save_post_image`\n\nDo something after a translated image has been saved.\n\n- `$translationImageId` ID of the translated ID\n- `$image` Array of translated from image data\n\nExample:\n```\n/**\n * Add metadata to new translated image from the master image.\n */\nadd_action('bp_trapp_after_save_post_image', function($translationImageId, $image) {\n    add_post_meta($translationImageId, 'custom_seo_field', get_post_meta($image['id'], 'custom_seo_field', true));\n}, 10, 2);\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenjaminmedia%2Fwp-trapp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbenjaminmedia%2Fwp-trapp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenjaminmedia%2Fwp-trapp/lists"}