├── .gitignore ├── assets ├── css │ └── admin.css └── images │ ├── cover.png │ ├── deploy-buddy-logo.svg │ └── logo.svg ├── buddy-deploy.php ├── composer.json ├── composer.lock ├── index.php ├── languages ├── deploy-buddy-en_US.mo └── deploy-buddy-en_US.po ├── package-lock.json ├── package.json ├── readme.md ├── readme.txt ├── src ├── AutomaticDeploy.php ├── BuddyIntegration.php ├── Config.php ├── ContextHelp.php ├── ManualDeploy.php ├── Notice.js ├── SaveButton.js ├── Settings.php ├── admin.js ├── admin.scss ├── functions.php └── index.js ├── templates ├── automatic_deploy.php ├── configuration.php ├── footer.php ├── header.php ├── installation.php └── manual_deploy.php └── webpack.config.js /.gitignore: -------------------------------------------------------------------------------- 1 | vendor 2 | node_modules 3 | build 4 | -------------------------------------------------------------------------------- /assets/css/admin.css: -------------------------------------------------------------------------------- 1 | :root { 2 | --color-white: #ffffff; 3 | --color-blue-1: #004DFF; 4 | --color-blue-2: #1A86FD; 5 | --color-blue-3: #0DA7FE; 6 | --color-blue-4: #05BBFF; 7 | --color-blue-5: #00C9FF; 8 | --color-orange: #FFA500; 9 | --color-light: #E6EDFF; 10 | --color-black: #000000; 11 | } 12 | 13 | .buddy-header { 14 | background-color: var(--color-white); 15 | padding: 20px 30px; 16 | width: calc(100% - 80px); 17 | box-shadow: 0 1px 1px rgb(0 0 0 / 4%); 18 | margin-top: 20px; 19 | align-self: center; 20 | align-items: center; 21 | } 22 | 23 | @media screen and (max-width: 660px) { 24 | .buddy-header { 25 | justify-items: center; 26 | } 27 | } 28 | 29 | .buddy-header nav { 30 | justify-self: end; 31 | text-align: right; 32 | font-size: 16px; 33 | font-weight: 700; 34 | } 35 | 36 | @media screen and (max-width: 660px) { 37 | .buddy-header nav { 38 | justify-self: center; 39 | text-align: center; 40 | margin-top: 1em; 41 | border-top: 1px solid var(--color-light); 42 | width: 100%; 43 | } 44 | } 45 | 46 | .buddy-header nav ul { 47 | display: flex; 48 | flex-direction: row; 49 | flex-wrap: nowrap; 50 | } 51 | 52 | @media screen and (max-width: 660px) { 53 | .buddy-header nav ul { 54 | justify-content: center; 55 | } 56 | } 57 | 58 | .buddy-header nav ul li { 59 | margin-left: 30px; 60 | margin-bottom: 0; 61 | } 62 | 63 | @media screen and (max-width: 660px) { 64 | .buddy-header nav ul li { 65 | margin-left: 15px; 66 | margin-right: 15px; 67 | } 68 | } 69 | 70 | .buddy-header nav ul li a { 71 | text-decoration: none; 72 | color: var(--color-black); 73 | transition: all 0.2s linear; 74 | } 75 | 76 | .buddy-logo { 77 | display: block; 78 | line-height: 0; 79 | } 80 | 81 | .buddy-logo img { 82 | height: 45px; 83 | } 84 | 85 | .buddy-header nav ul li a:hover, 86 | .buddy-header nav ul li a:focus { 87 | color: var(--color-blue-2); 88 | } 89 | 90 | @media screen and (max-width: 660px) { 91 | .buddy-header nav { 92 | text-align: left; 93 | } 94 | } 95 | 96 | .buddy-grid { 97 | display: grid; 98 | } 99 | 100 | .grid-columns-1 { 101 | grid-template-columns: repeat(1, 1fr); 102 | } 103 | 104 | .grid-columns-2 { 105 | grid-template-columns: repeat(2, 1fr); 106 | } 107 | 108 | @media screen and (max-width: 1024px) { 109 | .grid-columns-2 { 110 | grid-template-columns: repeat(2, 1fr); 111 | } 112 | } 113 | 114 | @media screen and (max-width: 660px) { 115 | .grid-columns-2 { 116 | grid-template-columns: repeat(1, 1fr); 117 | } 118 | } 119 | 120 | .grid-columns-3 { 121 | grid-template-columns: repeat(3, 1fr); 122 | } 123 | 124 | @media screen and (max-width: 1024px) { 125 | .grid-columns-3 { 126 | grid-template-columns: repeat(1, 1fr); 127 | } 128 | } 129 | 130 | @media screen and (max-width: 660px) { 131 | .grid-columns-3 { 132 | grid-template-columns: repeat(1, 1fr); 133 | } 134 | } 135 | 136 | .grid-columns-4 { 137 | grid-template-columns: repeat(4, 1fr); 138 | } 139 | 140 | @media screen and (max-width: 1024px) { 141 | .grid-columns-4 { 142 | grid-template-columns: repeat(2, 1fr); 143 | } 144 | } 145 | 146 | @media screen and (max-width: 660px) { 147 | .grid-columns-4 { 148 | grid-template-columns: repeat(1, 1fr); 149 | } 150 | } 151 | 152 | .buddy-wrapper { 153 | padding: 40px; 154 | background-color: var(--color-white); 155 | box-shadow: 0 1px 1px rgb(0 0 0 / 4%); 156 | margin: 30px .5em; 157 | } 158 | 159 | .buddy-wrapper h3.cmb2-metabox-title { 160 | font-size: 1.3em; 161 | margin-top: 30px; 162 | } 163 | 164 | .buddy-wrapper .cmb-type-title { 165 | border-bottom:#ccc 1px solid; 166 | } 167 | -------------------------------------------------------------------------------- /assets/images/cover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/palmiak/deploy-buddy/0fb7e653de3d35c86afa42318ca8fed516450317/assets/images/cover.png -------------------------------------------------------------------------------- /assets/images/deploy-buddy-logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /assets/images/logo.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /buddy-deploy.php: -------------------------------------------------------------------------------- 1 | '1.3.4', 24 | 'file_path' => __FILE__, 25 | 'dir' => __DIR__, 26 | 'base_name' => plugin_basename( __FILE__ ), 27 | 'plugin_url' => plugin_dir_url( __FILE__ ), 28 | 'slug' => 'deploy-buddy', 29 | 'language_slug' => 'deploy-buddy', 30 | 'name' => 'Deploy Buddy', 31 | 'shortname' => 'Deploy Buddy', 32 | 'utm' => 'https://buddy.works/?utm_medium=referral&utm_campaign=deploy_buddy_plugin', 33 | 'settings_version' => get_option( 'buddy_options_version' ), 34 | 'webhook' => options_helper( 'buddy_webhook', false ), 35 | 'add_to_topbar' => options_helper( 'buddy_topbar', true, ), 36 | 'manual_deploy_capabilities' => options_helper( 'buddy_manual_deploy_capabilities', 'manage_options' ), 37 | 'manual_deploy' => options_helper( 'buddy_manual_deploy', true ), 38 | 'automatic_deploy' => options_helper( 'buddy_automatic_deploy', false ), 39 | 'automatic_deploy_post_types' => options_helper( 'buddy_automatic_deploy_post_types', array( 'post', 'page' ) ), 40 | 'automatic_deploy_capabilities' => options_helper( 'buddy_automatic_deploy_capabilities', 'manage_options' ), 41 | 'capabilities_options' => options_helper( 'buddy_capabilities_options', 'manage_options' ), 42 | ) 43 | ); 44 | 45 | add_action( 'init', __NAMESPACE__ . '\\load_text_domain', 10, 0 ); 46 | 47 | if ( ! requirements_met() ) { 48 | add_action( 'admin_notices', __NAMESPACE__ . '\\print_requirements_notice', 0, 0 ); 49 | } 50 | register_activation_hook( __FILE__, __NAMESPACE__ . '\\activate' ); 51 | register_deactivation_hook( __FILE__, __NAMESPACE__ . '\\deactivate' ); 52 | register_uninstall_hook( __FILE__, __NAMESPACE__ . '\\uninstall' ); 53 | add_action( 'plugins_loaded', __NAMESPACE__ . '\\boot', 10, 0 ); 54 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "buddy/deploy-buddy", 3 | "description": "Seamlessly trigger Buddy.works deploys from WordPress.", 4 | "type": "wordpress-plugin", 5 | "license": "MIT", 6 | "repositories": [ 7 | { 8 | "type": "vcs", 9 | "url": "https://github.com/fumikito/wp-readme" 10 | } 11 | ], 12 | "authors": [ 13 | { 14 | "name": "Maciej Palmowski", 15 | "email": "m.palmowski@freshpixels.pl" 16 | } 17 | ], 18 | "require": { 19 | "composer/installers": "^1.11", 20 | "cmb2/cmb2": "dev-master" 21 | }, 22 | "require-dev": { 23 | "fumikito/wp-readme": "dev-master" 24 | }, 25 | "autoload": { 26 | "psr-4": { 27 | "BuddyIntegration\\":"src/" 28 | }, 29 | "files": [ 30 | "vendor/cmb2/init.php", 31 | "src/functions.php" 32 | ] 33 | }, 34 | "extra": { 35 | "installer-paths": { 36 | "vendor/{$name}/": ["cmb2/cmb2"] 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_readme": [ 3 | "This file locks the dependencies of your project to a known state", 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", 5 | "This file is @generated automatically" 6 | ], 7 | "content-hash": "dbc7d77618ea19f4f0b0b3e5290c2023", 8 | "packages": [ 9 | { 10 | "name": "cmb2/cmb2", 11 | "version": "dev-master", 12 | "source": { 13 | "type": "git", 14 | "url": "https://github.com/CMB2/CMB2.git", 15 | "reference": "cacbc8cedbfdf8ffe0e840858e6860f9333c33f2" 16 | }, 17 | "dist": { 18 | "type": "zip", 19 | "url": "https://api.github.com/repos/CMB2/CMB2/zipball/cacbc8cedbfdf8ffe0e840858e6860f9333c33f2", 20 | "reference": "cacbc8cedbfdf8ffe0e840858e6860f9333c33f2", 21 | "shasum": "" 22 | }, 23 | "require": { 24 | "php": ">5.2.4" 25 | }, 26 | "require-dev": { 27 | "apigen/apigen": "4.1.2", 28 | "awesomemotive/am-cli-tools": ">=1.3.1", 29 | "nette/utils": "2.5.3", 30 | "phpunit/phpunit": "6.5.13" 31 | }, 32 | "suggest": { 33 | "composer/installers": "~1.0" 34 | }, 35 | "type": "wordpress-plugin", 36 | "notification-url": "https://packagist.org/downloads/", 37 | "license": [ 38 | "GPL-2.0-or-later" 39 | ], 40 | "authors": [ 41 | { 42 | "name": "Justin Sternberg", 43 | "email": "justin@dsgnwrks.pro", 44 | "homepage": "https://dsgnwrks.pro", 45 | "role": "Developer" 46 | }, 47 | { 48 | "name": "WebDevStudios", 49 | "email": "contact@webdevstudios.com", 50 | "homepage": "https://github.com/WebDevStudios", 51 | "role": "Developer" 52 | } 53 | ], 54 | "description": "CMB2 is a metabox, custom fields, and forms library for WordPress that will blow your mind.", 55 | "homepage": "https://github.com/CMB2/CMB2", 56 | "keywords": [ 57 | "metabox", 58 | "plugin", 59 | "wordpress" 60 | ], 61 | "support": { 62 | "issues": "https://github.com/CMB2/CMB2/issues", 63 | "source": "http://wordpress.org/support/plugin/cmb2" 64 | }, 65 | "time": "2021-03-04T02:18:53+00:00" 66 | }, 67 | { 68 | "name": "composer/installers", 69 | "version": "v1.11.0", 70 | "source": { 71 | "type": "git", 72 | "url": "https://github.com/composer/installers.git", 73 | "reference": "ae03311f45dfe194412081526be2e003960df74b" 74 | }, 75 | "dist": { 76 | "type": "zip", 77 | "url": "https://api.github.com/repos/composer/installers/zipball/ae03311f45dfe194412081526be2e003960df74b", 78 | "reference": "ae03311f45dfe194412081526be2e003960df74b", 79 | "shasum": "" 80 | }, 81 | "require": { 82 | "composer-plugin-api": "^1.0 || ^2.0" 83 | }, 84 | "replace": { 85 | "roundcube/plugin-installer": "*", 86 | "shama/baton": "*" 87 | }, 88 | "require-dev": { 89 | "composer/composer": "1.6.* || ^2.0", 90 | "composer/semver": "^1 || ^3", 91 | "phpstan/phpstan": "^0.12.55", 92 | "phpstan/phpstan-phpunit": "^0.12.16", 93 | "symfony/phpunit-bridge": "^4.2 || ^5", 94 | "symfony/process": "^2.3" 95 | }, 96 | "type": "composer-plugin", 97 | "extra": { 98 | "class": "Composer\\Installers\\Plugin", 99 | "branch-alias": { 100 | "dev-main": "1.x-dev" 101 | } 102 | }, 103 | "autoload": { 104 | "psr-4": { 105 | "Composer\\Installers\\": "src/Composer/Installers" 106 | } 107 | }, 108 | "notification-url": "https://packagist.org/downloads/", 109 | "license": [ 110 | "MIT" 111 | ], 112 | "authors": [ 113 | { 114 | "name": "Kyle Robinson Young", 115 | "email": "kyle@dontkry.com", 116 | "homepage": "https://github.com/shama" 117 | } 118 | ], 119 | "description": "A multi-framework Composer library installer", 120 | "homepage": "https://composer.github.io/installers/", 121 | "keywords": [ 122 | "Craft", 123 | "Dolibarr", 124 | "Eliasis", 125 | "Hurad", 126 | "ImageCMS", 127 | "Kanboard", 128 | "Lan Management System", 129 | "MODX Evo", 130 | "MantisBT", 131 | "Mautic", 132 | "Maya", 133 | "OXID", 134 | "Plentymarkets", 135 | "Porto", 136 | "RadPHP", 137 | "SMF", 138 | "Starbug", 139 | "Thelia", 140 | "Whmcs", 141 | "WolfCMS", 142 | "agl", 143 | "aimeos", 144 | "annotatecms", 145 | "attogram", 146 | "bitrix", 147 | "cakephp", 148 | "chef", 149 | "cockpit", 150 | "codeigniter", 151 | "concrete5", 152 | "croogo", 153 | "dokuwiki", 154 | "drupal", 155 | "eZ Platform", 156 | "elgg", 157 | "expressionengine", 158 | "fuelphp", 159 | "grav", 160 | "installer", 161 | "itop", 162 | "joomla", 163 | "known", 164 | "kohana", 165 | "laravel", 166 | "lavalite", 167 | "lithium", 168 | "magento", 169 | "majima", 170 | "mako", 171 | "mediawiki", 172 | "miaoxing", 173 | "modulework", 174 | "modx", 175 | "moodle", 176 | "osclass", 177 | "phpbb", 178 | "piwik", 179 | "ppi", 180 | "processwire", 181 | "puppet", 182 | "pxcms", 183 | "reindex", 184 | "roundcube", 185 | "shopware", 186 | "silverstripe", 187 | "sydes", 188 | "sylius", 189 | "symfony", 190 | "tastyigniter", 191 | "typo3", 192 | "wordpress", 193 | "yawik", 194 | "zend", 195 | "zikula" 196 | ], 197 | "support": { 198 | "issues": "https://github.com/composer/installers/issues", 199 | "source": "https://github.com/composer/installers/tree/v1.11.0" 200 | }, 201 | "funding": [ 202 | { 203 | "url": "https://packagist.com", 204 | "type": "custom" 205 | }, 206 | { 207 | "url": "https://github.com/composer", 208 | "type": "github" 209 | }, 210 | { 211 | "url": "https://tidelift.com/funding/github/packagist/composer/composer", 212 | "type": "tidelift" 213 | } 214 | ], 215 | "time": "2021-04-28T06:42:17+00:00" 216 | } 217 | ], 218 | "packages-dev": [ 219 | { 220 | "name": "fumikito/wp-readme", 221 | "version": "dev-master", 222 | "source": { 223 | "type": "git", 224 | "url": "https://github.com/fumikito/wp-readme.git", 225 | "reference": "686b2027e8a612444fdc275ae59aa659b198ff93" 226 | }, 227 | "dist": { 228 | "type": "zip", 229 | "url": "https://api.github.com/repos/fumikito/wp-readme/zipball/686b2027e8a612444fdc275ae59aa659b198ff93", 230 | "reference": "686b2027e8a612444fdc275ae59aa659b198ff93", 231 | "shasum": "" 232 | }, 233 | "require-dev": { 234 | "phpunit/phpunit": "^6.5" 235 | }, 236 | "default-branch": true, 237 | "type": "library", 238 | "scripts": { 239 | "test": [ 240 | "phpunit" 241 | ] 242 | }, 243 | "license": [ 244 | "MIT" 245 | ], 246 | "authors": [ 247 | { 248 | "name": "fumikito", 249 | "email": "guy@hametuha.com" 250 | } 251 | ], 252 | "description": "Generate readme.txt from Github's README.md", 253 | "support": { 254 | "source": "https://github.com/fumikito/wp-readme/tree/master", 255 | "issues": "https://github.com/fumikito/wp-readme/issues" 256 | }, 257 | "time": "2019-07-20T15:14:05+00:00" 258 | } 259 | ], 260 | "aliases": [], 261 | "minimum-stability": "stable", 262 | "stability-flags": { 263 | "cmb2/cmb2": 20, 264 | "fumikito/wp-readme": 20 265 | }, 266 | "prefer-stable": false, 267 | "prefer-lowest": false, 268 | "platform": [], 269 | "platform-dev": [], 270 | "plugin-api-version": "2.0.0" 271 | } 272 | -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/palmiak/deploy-buddy/0fb7e653de3d35c86afa42318ca8fed516450317/index.php -------------------------------------------------------------------------------- /languages/deploy-buddy-en_US.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/palmiak/deploy-buddy/0fb7e653de3d35c86afa42318ca8fed516450317/languages/deploy-buddy-en_US.mo -------------------------------------------------------------------------------- /languages/deploy-buddy-en_US.po: -------------------------------------------------------------------------------- 1 | msgid "" 2 | msgstr "" 3 | "Project-Id-Version: \n" 4 | "POT-Creation-Date: 2021-06-26 12:48+0200\n" 5 | "PO-Revision-Date: 2021-06-26 12:48+0200\n" 6 | "Last-Translator: \n" 7 | "Language-Team: \n" 8 | "Language: en_US\n" 9 | "MIME-Version: 1.0\n" 10 | "Content-Type: text/plain; charset=UTF-8\n" 11 | "Content-Transfer-Encoding: 8bit\n" 12 | "X-Generator: Poedit 3.0\n" 13 | "X-Poedit-Basepath: ..\n" 14 | "Plural-Forms: nplurals=2; plural=(n != 1);\n" 15 | "X-Poedit-KeywordsList: __;_e\n" 16 | "X-Poedit-SearchPath-0: .\n" 17 | "X-Poedit-SearchPathExcluded-0: .git\n" 18 | "X-Poedit-SearchPathExcluded-1: vendor\n" 19 | 20 | #: src/ManualDeploy.php:14 21 | msgid "Deploy Buddy" 22 | msgstr "" 23 | 24 | #: src/ManualDeploy.php:42 25 | msgid "Are you sure that you want to trigger a deployment?" 26 | msgstr "" 27 | 28 | #: src/ManualDeploy.php:47 29 | msgid "Deployment triggered succesfully." 30 | msgstr "" 31 | 32 | #: src/Settings.php:48 33 | msgid "Installation" 34 | msgstr "" 35 | 36 | #: src/Settings.php:54 37 | msgid "Manual Deploy" 38 | msgstr "" 39 | 40 | #: src/Settings.php:61 41 | msgid "Automatic Deploy" 42 | msgstr "" 43 | 44 | #: src/Settings.php:70 src/Settings.php:76 45 | msgid "You are not allowed to view this page" 46 | msgstr "" 47 | 48 | #: templates/automatic_deploy.php:7 49 | msgid "Automatic Deployments" 50 | msgstr "" 51 | 52 | #: templates/automatic_deploy.php:9 53 | #, php-format 54 | msgid "" 55 | "

Each time a member with at least %s capability will save " 56 | "or update a post from this post types:
%s
the " 57 | "auto deploy will run." 58 | msgstr "" 59 | 60 | #: templates/automatic_deploy.php:11 61 | msgid "" 62 | "

If you want to change the capability needed to trigger the auto deploy, " 63 | "add buddy_automatic_deploy_capabilities constant to wp-config." 64 | "php file." 65 | msgstr "" 66 | 67 | #: templates/automatic_deploy.php:13 68 | msgid "" 69 | "

If you want to change the post types, add " 70 | "buddy_automatic_deploy_post_types constant to wp-config.php " 71 | "file." 72 | msgstr "" 73 | 74 | #: templates/header.php:11 75 | msgid "Try Buddy" 76 | msgstr "" 77 | 78 | #: templates/header.php:12 79 | msgid "Report an issue" 80 | msgstr "" 81 | 82 | #: templates/installation.php:6 83 | msgid "Installation and usage" 84 | msgstr "" 85 | 86 | #: templates/installation.php:8 87 | msgid "Get your webhook url" 88 | msgstr "" 89 | 90 | #: templates/installation.php:12 91 | msgid "" 92 | "

    \n" 93 | "\t\t
  1. Login to your buddy.works account.
  2. \n" 94 | "\t\t
  3. Go to your project and than select the pipeline you want to execute." 95 | "
  4. \n" 96 | "\t\t
  5. Click Webhook URL in the sidebar and copy URL.\n" 98 | "\t
" 99 | msgstr "" 100 | 101 | #: templates/installation.php:21 102 | msgid "Configure the plugin" 103 | msgstr "" 104 | 105 | #: templates/installation.php:25 106 | msgid "" 107 | "

Currently the plugin is only configurable by constants that you can set " 108 | "in your wp-config.php file.

\n" 109 | "\n" 110 | "\t

The only required constant is the buddy_webhook, where you " 111 | "have to paste the webhook URL.

\n" 112 | "\n" 113 | "\t

define( 'buddy_webhook', PASTE_URL_HERE );

" 114 | msgstr "" 115 | 116 | #: templates/installation.php:34 117 | msgid "Other constants" 118 | msgstr "" 119 | 120 | #: templates/installation.php:37 121 | msgid "" 122 | "

buddy_topbar - default: true - adds the deploy button to the " 123 | "admin bar

\n" 124 | "\t\t

buddy_capabilities - default: manage_options - " 125 | "capability that is needed to see the deploy button

\n" 126 | "\t\t

buddy_automatic_deploy - default: false - turn on or off " 127 | "automatic deployments on post update.

\n" 128 | "\t\t

buddy_automatic_deploy_post_types - default: ['post', " 129 | "'page'] - sets on which post types does the update triggers the auto deploy." 130 | "

\n" 131 | "\t\t

buddy_automatic_deploy_capabilities - default: " 132 | "manage_options - capability that is need to run the auto deploy.

\n" 133 | "\t\t" 134 | msgstr "" 135 | 136 | #: templates/manual_deploy.php:7 137 | msgid "Execute manual deployment" 138 | msgstr "" 139 | 140 | #: templates/manual_deploy.php:9 141 | msgid "" 142 | "

By pressing the deploy button you will trigger the " 143 | "endpoint you selected.

" 144 | msgstr "" 145 | 146 | #: templates/manual_deploy.php:12 147 | msgid "Deploy" 148 | msgstr "" 149 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "buddy-deploy", 3 | "description": "", 4 | "license": "GPL-2.0-or-later", 5 | "main": "build/index.js", 6 | "scripts": { 7 | "build": "wp-scripts build", 8 | "format": "wp-scripts format", 9 | "lint:css": "wp-scripts lint-style", 10 | "lint:js": "wp-scripts lint-js", 11 | "start": "wp-scripts start", 12 | "packages-update": "wp-scripts packages-update" 13 | }, 14 | "dependencies": { 15 | "@wordpress/block-editor": "7.0.1", 16 | "@wordpress/blocks": "11.0.1", 17 | "@wordpress/i18n": "4.2.1", 18 | "react-tabs": "^3.2.2" 19 | }, 20 | "devDependencies": { 21 | "@wordpress/scripts": "18.0.0" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # Deploy Buddy 2 | 3 | Stable tag: 1.3.2 4 | Requires at least: 5.0 5 | Tested up to: 5.8 6 | Requires PHP: 7.2 7 | License: GPL v2 or later 8 | Tags: ci/cd, deployments, static, developer 9 | Contributors: palmiak 10 | 11 | ![](assets/images/cover.png) 12 | 13 | Seamlessly trigger [Buddy CI/CD](https://buddy.works/) deploys from WordPress. 14 | 15 | ## Description 16 | 17 | ### Plugin Installation 18 | 19 | 1. Download the latest [release](https://github.com/palmiak/buddy_deploy/releases/). 20 | 2. Upload the plugin in WordPress admin panel. 21 | 22 | ### Updates 23 | 24 | To keep this plugin up-to-date, install and configure the [Git Updater](https://github.com/afragen/git-updater). 25 | 26 | ### Get your webhook url 27 | 28 | 1. Sign in to your [Buddy](http://buddy.works) account. 29 | 2. Go to your project and select the pipeline you want to execute using the plugin. 30 | 3. Click **Webhook URL** in the right sidebar and copy the URL. 31 | 32 | ### Configuration 33 | 34 | You can configure the plugin using the UI or by using constants in the `wp-config.php` file. 35 | 36 | ### Available constants 37 | 38 | - `buddy_webhook` - default: `false` - bool - adds the webhook url 39 | - `buddy_manual_deploy` - default: `true` - bool - enables automatic deployments 40 | - `buddy_topbar` - default: `true` - bool - adds the deploy button to the admin bar 41 | - `buddy_manual_deploy_capabilities` - default: `manage_options` - string - capability required to see the deploy button 42 | - `buddy_capabilities_options` - default: `manage_options` - string - capability required to view options panel 43 | - `buddy_automatic_deploy` - default: `false` - bool - enables automatic deployments 44 | - `buddy_automatic_deploy_post_types` - default: `['post', 'page']` - array - post types which trigger automatic deployments 45 | - `buddy_automatic_deploy_capabilities` - default: `manage_options` - string - capability required to trigger automatic deployments 46 | 47 | ## Changelog 48 | 49 | ### 1.3.3 50 | 51 | - Changed the default value of `automatic deployments`. 52 | 53 | ### 1.3.2 54 | 55 | - More small fixes. 56 | 57 | ### 1.3.1 58 | 59 | - Removed development leftovers. 60 | 61 | ### 1.3.0 62 | 63 | - Settings screen rewrote to use Gutenberg. 64 | 65 | ### 1.2.4 66 | 67 | - Added some missing constatns in readme and in context help. 68 | 69 | ### 1.2.3 70 | 71 | - Lots of typos and descriptions fixed - all thanks to @tomekpapiernik. 72 | 73 | ### 1.2.2 74 | 75 | - Fixed the problem with Automatic Deployments running twice. 76 | 77 | ### 1.2.1 78 | 79 | - Minor coding fix. 80 | 81 | ### 1.2.0 82 | 83 | - Added **Gutenberg** Support - you can trigger the deployment even in Full Screen Mode in Gutenberg. 84 | - Fixed some typos. 85 | 86 | ### 1.1.1 87 | 88 | - Small fix with adding menu button. 89 | 90 | ### 1.1.0 91 | 92 | - Moved inline documentation into context help tab. 93 | - Fixed checkboxes not fully working in some cases. 94 | - Some other minor fixes. 95 | 96 | ### 1.0.0 97 | 98 | - Added a **configuration** tab. Since now using constants is not required. 99 | 100 | ### 0.2.1 101 | 102 | - Fixed a minor bug and a typo in readme. 103 | 104 | ### 0.2.0 105 | 106 | - Added automatic deployments. 107 | 108 | ### 0.1.5 109 | 110 | - Minor fix for empty webhook. 111 | 112 | ### 0.1.4 113 | 114 | - You can install and mange the plugin with composer. Just run `composer require buddy/deploy-buddy`. 115 | 116 | ### 0.1.3 117 | 118 | - Updates are made with [Git Updater](https://github.com/afragen/git-updater) 119 | 120 | ### 0.1.2 121 | 122 | - Made the admin panel a lot nicer 123 | - Fixed some minor bugs. 124 | 125 | ### 0.1.1 126 | 127 | - Fixed some minor bugs. 128 | - Plugin is fully translatable 129 | 130 | ### 0.1.0 131 | 132 | - Initial release 133 | -------------------------------------------------------------------------------- /readme.txt: -------------------------------------------------------------------------------- 1 | === Deploy Buddy === 2 | 3 | Stable tag: 1.2.2 4 | Requires at least: 5.0 5 | Tested up to: 5.8 6 | Requires PHP: 7.2 7 | License: GPL v2 or later 8 | Tags: ci/cd, deployments, static, developer 9 | Contributors: palmiak 10 | 11 | ![](assets/images/cover.png) 12 | 13 | Seamlessly trigger Buddy.works deploys from WordPress. 14 | == Description == 15 | 16 | = Plugin Installation = 17 | 18 | 1. Download the latest zip from [releases](https://github.com/palmiak/buddy_deploy/releases/) 19 | 2. Upload the plugin in WordPress admin panel 20 | 21 | = Updates = 22 | 23 | If you want to keep this plugin up-to-date install and configure . 24 | 25 | = Get your webhook url = 26 | 27 | 1. Login to your [buddy.works](http://buddy.works) account. 28 | 2. Go to your project and than select the pipeline you want to execute. 29 | 3. Click **Webhook URL** in the sidebar and copy URL. 30 | 31 | = Configuration = 32 | 33 | Currently the plugin is configurable by using the UI or by using constants in your `wp-config.php` file. 34 | 35 | = Available constants = 36 | 37 | `buddy_topbar` - default: true - adds the deploy button to the admin bar 38 | 39 | `buddy_manual_deploy_capabilities` - default: manage_options - capability that is needed to see the deploy button 40 | 41 | `buddy_capabilities_options` - default: manage_options - capability that is needed to view options panel. 42 | 43 | `buddy_automatic_deploy` - default: false - enables automatic deployments 44 | 45 | `buddy_automatic_deploy_post_types` - default: ['post', 'page'] - post types on which the auto deployment will run. 46 | 47 | `buddy_automatic_deploy_capabilities` - default: manage_options - capability needed to trigger the auto deploy. 48 | 49 | == Changelog == 50 | 51 | = 1.3.4 = 52 | 53 | - Fixed a critical bug. 54 | 55 | = 1.2.2 = 56 | 57 | - Fixed the problem with Automatic Deployments running twice. 58 | 59 | = 1.2.1 = 60 | 61 | - Minor coding fix. 62 | 63 | = 1.2.0 = 64 | 65 | - Added **Gutenberg** Support - you can trigger the deployment even in Full Screen Mode in Gutenberg. 66 | - Fixed some typos. 67 | 68 | = 1.1.1 = 69 | 70 | - Small fix with adding menu button. 71 | 72 | = 1.1.0 = 73 | 74 | - Moved inline documentation into context help tab. 75 | - Fixed checkboxes not fully working in some cases. 76 | - Some other minor fixes. 77 | 78 | = 1.0.0 = 79 | 80 | - Added a **configuration** tab. Since now using constants is not required. 81 | 82 | = 0.2.1 = 83 | 84 | - Fixed a minor bug and a typo in readme. 85 | 86 | = 0.2.0 = 87 | 88 | - Added automatic deployments. 89 | 90 | = 0.1.5 = 91 | 92 | - Minor fix for empty webhook. 93 | 94 | = 0.1.4 = 95 | 96 | - You can install and mange the plugin with composer. Just run `composer require buddy/deploy-buddy`. 97 | 98 | = 0.1.3 = 99 | 100 | - Updates are made with [Git Updater](https://github.com/afragen/git-updater) 101 | 102 | = 0.1.2 = 103 | 104 | - Made the admin panel a lot nicer 105 | - Fixed some minor bugs. 106 | 107 | = 0.1.1 = 108 | 109 | - Fixed some minor bugs. 110 | - Plugin is fully translatable 111 | 112 | = 0.1.0 = 113 | 114 | - Initial release 115 | -------------------------------------------------------------------------------- /src/AutomaticDeploy.php: -------------------------------------------------------------------------------- 1 | check_post_type( $post ) && $this->check_post_status( $new_status, $old_status, $post ) ) { 11 | $this->maybe_deploy( $post ); 12 | } 13 | } 14 | 15 | function check_post_type( $post ) { 16 | return in_array( $post->post_type, Config::get( 'automatic_deploy_post_types' ), true ) ? true : false; 17 | } 18 | 19 | function check_post_status( $new_status, $old_status, $post ) { 20 | if ( 'auto-draft' === $post->post_status || wp_is_post_revision( $post->ID ) ) { 21 | return false; 22 | } 23 | 24 | if ( 'publish' === $new_status || ( 'publish' !== $new_status && 'publish' === $old_status ) ) { 25 | return true; 26 | } 27 | 28 | return false; 29 | 30 | } 31 | 32 | function maybe_deploy( $post ) { 33 | if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) { 34 | $this->deploy( $post ); 35 | set_transient( 'buddy_updater_flag', 'done', 10 ); 36 | } else { 37 | if ( false === get_transient( 'buddy_updater_flag' ) ) { 38 | $this->deploy( $post ); 39 | } 40 | } 41 | } 42 | function deploy( $post ) { 43 | $response = wp_remote_post( Config::get( 'webhook' ) . '&comment=' . $post->post_title . ' was updated' ); 44 | if ( is_wp_error( $response ) ) { 45 | $error_message = $response->get_error_message(); 46 | \error_log( $error_message ); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/BuddyIntegration.php: -------------------------------------------------------------------------------- 1 | */ 11 | private static $container; 12 | 13 | /** 14 | * @param array $container 15 | * @return void 16 | */ 17 | public static function init( array $container ) { 18 | if ( isset( self::$container ) ) { 19 | return; 20 | } 21 | 22 | self::$container = $container; 23 | } 24 | 25 | /** 26 | * @return mixed 27 | */ 28 | public static function get( string $key ) { 29 | if ( ! isset( self::$container ) || ! array_key_exists( $key, self::$container ) ) { 30 | return null; 31 | } 32 | 33 | return self::$container[ $key ]; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/ContextHelp.php: -------------------------------------------------------------------------------- 1 | base ) { 15 | // content for help tab 16 | $webhook = __( 17 | '
    18 |
  1. Sign in to your Buddy account.
  2. 19 |
  3. Go to your project and select the pipeline you want to execute using the plugin.
  4. 20 |
  5. Click Webhook URL in the sidebar and copy the URL.
  6. 21 |
', 22 | Config::get( 'language_slug' ) 23 | ); 24 | 25 | $constants = __( 26 | ' 36 | ', 37 | Config::get( 'language_slug' ) 38 | ); 39 | // register primary help tab 40 | $current_screen->add_help_tab( 41 | array( 42 | 'id' => 'buddy_get_webhook', 43 | 'title' => __( 'Get your webhook', Config::get( 'language_slug' ) ), 44 | 'content' => $webhook, 45 | ) 46 | ); 47 | // register secondary help tab 48 | $current_screen->add_help_tab( 49 | array( 50 | 'id' => 'buddy_available_constants', 51 | 'title' => __( 'Available constants', Config::get( 'language_slug' ) ), 52 | 'content' => $constants, 53 | ) 54 | ); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/ManualDeploy.php: -------------------------------------------------------------------------------- 1 | 'buddy_manual_deploy_button', 14 | 'title' => '' . __( 'Trigger Deployment', Config::get( 'language_slug' ) ), 15 | 'href' => '#', 16 | 'meta' => array( 'class' => 'buddy_manual_deploy_button' ), 17 | ); 18 | $wp_admin_bar->add_node( $args ); 19 | } 20 | } 21 | 22 | 23 | function initialize() { 24 | if ( capabilities_helper( 'manual_deploy' ) ) { 25 | add_action( 'admin_enqueue_scripts', array( $this, 'trigger_script' ) ); 26 | add_action( 'wp_enqueue_scripts', array( $this, 'trigger_script' ) ); 27 | add_action( 'wp_head', array( $this, 'topbar_button_icon_styles' ) ); 28 | add_action( 'admin_head', array( $this, 'topbar_button_icon_styles' ) ); 29 | } 30 | } 31 | 32 | function trigger_script() { 33 | if ( ! is_admin() && ! wp_script_is( 'jquery', 'done' ) ) { 34 | wp_enqueue_script( 'jquery' ); 35 | } 36 | 37 | wp_add_inline_script( 38 | 'jquery', 39 | ' 40 | jQuery( document ).ready( function() { 41 | jQuery( document ).on( "click", ".buddy_manual_deploy_button a, input.buddy_manual_deploy_button", function( e ) { 42 | event.preventDefault(); 43 | if ( confirm( " '. __( 'Are you sure that you want to trigger a deployment?', Config::get( 'language_slug' ) ) . '" ) ) { 44 | jQuery.ajax( { 45 | type: "POST", 46 | url: "' . Config::get( 'webhook' ) . '&comment=Manually triggered deployment", 47 | success: function( d ) { 48 | window.alert( "' . __( 'Deployment triggered succesfully.', Config::get( 'language_slug' ) ) . '" ) 49 | } 50 | } ) 51 | } 52 | } ); 53 | 54 | var link_html = \'Trigger Deployment\'; 55 | 56 | var editorEl = document.getElementById( "editor" ); 57 | if( !editorEl ){ 58 | return; 59 | } 60 | 61 | var unsubscribe = wp.data.subscribe( function () { 62 | setTimeout( function () { 63 | if ( !document.getElementById( "buddy_manual_gutenberg_button" ) ) { 64 | var toolbalEl = editorEl.querySelector( ".edit-post-header__toolbar" ); 65 | if( toolbalEl instanceof HTMLElement ){ 66 | toolbalEl.insertAdjacentHTML( "beforeend", link_html ); 67 | } 68 | } 69 | }, 1 ) 70 | } ); 71 | } ) 72 | ' 73 | ); 74 | } 75 | 76 | function topbar_button_icon_styles() { 77 | ?> 78 | 108 | { 8 | const notices = useSelect( 9 | ( select ) => 10 | select( noticesStore ) 11 | .getNotices() 12 | .filter( ( notice ) => notice.type === 'snackbar' ), 13 | [] 14 | ); 15 | const { removeNotice } = useDispatch( noticesStore ); 16 | return ( 17 | 22 | ); 23 | }; 24 | 25 | export default Notices; 26 | -------------------------------------------------------------------------------- /src/SaveButton.js: -------------------------------------------------------------------------------- 1 | import { 2 | Button 3 | } from '@wordpress/components'; 4 | import { __ } from '@wordpress/i18n'; 5 | 6 | import { SnackbarList } from '@wordpress/components'; 7 | 8 | import { 9 | dispatch, 10 | useDispatch, 11 | useSelect, 12 | } from '@wordpress/data'; 13 | 14 | import { store as noticesStore } from '@wordpress/notices'; 15 | 16 | const Notices = () => { 17 | const notices = useSelect( 18 | ( select ) => 19 | select( noticesStore ) 20 | .getNotices() 21 | .filter( ( notice ) => notice.type === 'snackbar' ), 22 | [] 23 | ); 24 | const { removeNotice } = useDispatch( noticesStore ); 25 | return ( 26 | 31 | ); 32 | }; 33 | 34 | export default class SaveButton extends React.Component { 35 | render() { 36 | return ( 37 | 62 | ); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/Settings.php: -------------------------------------------------------------------------------- 1 | '', 23 | 'show_in_rest' => true, 24 | 'type' => 'string', 25 | ) 26 | ); 27 | 28 | register_setting( 29 | 'buddy_plugin_settings', 30 | 'buddy_manual_deploy', 31 | array( 32 | 'default' => true, 33 | 'show_in_rest' => true, 34 | 'type' => 'boolean', 35 | ) 36 | ); 37 | 38 | register_setting( 39 | 'buddy_plugin_settings', 40 | 'buddy_manual_deploy_capabilities', 41 | array( 42 | 'default' => 'manage_options', 43 | 'show_in_rest' => true, 44 | 'type' => 'string', 45 | ) 46 | ); 47 | 48 | register_setting( 49 | 'buddy_plugin_settings', 50 | 'buddy_topbar', 51 | array( 52 | 'default' => true, 53 | 'show_in_rest' => true, 54 | 'type' => 'boolean', 55 | ) 56 | ); 57 | 58 | register_setting( 59 | 'buddy_plugin_settings', 60 | 'buddy_automatic_deploy', 61 | array( 62 | 'default' => false, 63 | 'show_in_rest' => true, 64 | 'type' => 'boolean', 65 | ) 66 | ); 67 | 68 | register_setting( 69 | 'buddy_plugin_settings', 70 | 'buddy_automatic_deploy_post_types', 71 | array( 72 | 'default' => array( 'post', 'page' ), 73 | 'show_in_rest' => array( 74 | 'schema' => array( 75 | 'type' => 'array', 76 | 'items' => array( 77 | 'type' => 'string', 78 | ), 79 | ), 80 | ), 81 | ) 82 | ); 83 | 84 | register_setting( 85 | 'buddy_plugin_settings', 86 | 'buddy_automatic_deploy_capabilities', 87 | array( 88 | 'default' => 'manage_options', 89 | 'show_in_rest' => true, 90 | 'type' => 'string', 91 | ) 92 | ); 93 | 94 | } 95 | 96 | function plugin_admin_scripts() { 97 | $dir = Config::get( 'dir' ); 98 | 99 | $script_asset_path = "$dir/build/admin.asset.php"; 100 | 101 | $admin_js = 'build/admin.js'; 102 | $script_asset = require $script_asset_path; 103 | 104 | wp_register_script( 105 | 'buddy_deploy_admin_options', 106 | plugins_url( $admin_js, Config::get( 'file_path' ) ), 107 | $script_asset['dependencies'], 108 | $script_asset['version'] 109 | ); 110 | 111 | wp_localize_script( 112 | 'buddy_deploy_admin_options', 113 | 'buddy_vars', 114 | array( 115 | 'roles' => $this->roles_helper(), 116 | 'postTypes' => $this->post_type_helper(), 117 | 'definedWebhook' => defined( 'buddy_webhook' ), 118 | 'definedTopBar' => defined( 'buddy_topbar' ), 119 | 'definedManualDeployCapabilities' => defined( 'buddy_manual_deploy_capabilities' ), 120 | 'definedManualDeploy' => defined( 'buddy_manual_deploy' ), 121 | 'definedAutomaticDeploy' => defined( 'buddy_automatic_deploy' ), 122 | 'definedAutomaticDeployPostTypes' => defined( 'buddy_automatic_deploy_post_types' ), 123 | 'definedAutomaticDeployCapabilities' => defined( 'buddy_automatic_deploy_capabilities' ), 124 | 'languageSlug' => Config::get( 'language_slug' ), 125 | ), 126 | ); 127 | 128 | wp_enqueue_script( 'buddy_deploy_admin_options' ); 129 | 130 | $admin_css = 'build/admin.css'; 131 | wp_enqueue_style( 132 | 'buddy_deploy_admin_options', 133 | plugins_url( $admin_css, Config::get( 'file_path' ) ), 134 | array( 'wp-components' ), 135 | filemtime( "$dir/$admin_css" ) 136 | ); 137 | } 138 | 139 | /** 140 | * Add the top level menu page. 141 | */ 142 | function add_menu() { 143 | add_submenu_page( 144 | 'tools.php', 145 | Config::get( 'name' ) . ' - Options', 146 | Config::get( 'shortname' ), 147 | Config::get( 'capabilities_options' ), 148 | Config::get( 'slug' ), 149 | array( $this, 'options_page_html' ) 150 | ); 151 | } 152 | 153 | function include_styles() { 154 | wp_enqueue_style( 'buddy_admin', Config::get( 'plugin_url' ) . 'assets/css/admin.css', array(), Config::get( 'version' ) ); 155 | } 156 | 157 | function options_page_html() { 158 | $default_tab = null; 159 | $tab = isset( $_GET['tab'] ) ? $_GET['tab'] : $default_tab; 160 | 161 | ?> 162 | 165 |
166 | 183 | 184 |
185 |
'; 192 | break; 193 | default: 194 | include Config::get( 'dir' ) . '/templates/manual_deploy.php'; 195 | break; 196 | endswitch; 197 | ?> 198 |
199 | 200 | 203 | capabilities ) ) { 212 | $tmp = $this->capabilities; 213 | } else { 214 | $caps = array(); 215 | $editable_roles = \get_editable_roles(); 216 | foreach ( $editable_roles as $role => $details ) { 217 | $detail = get_role( $role )->capabilities; 218 | $caps = array_merge( $caps, $detail ); 219 | } 220 | 221 | $caps = array_unique( array_keys( $caps ) ); 222 | $caps = array_combine( $caps, $caps ); 223 | $tmp = $caps; 224 | } 225 | 226 | $ret = array(); 227 | foreach ( $caps as $cap ) { 228 | $ret[] = array( 229 | 'label' => $cap, 230 | 'value' => $cap, 231 | ); 232 | } 233 | 234 | return $ret; 235 | } 236 | 237 | function post_type_helper() { 238 | $post_types = \get_post_types(); 239 | $ret = array(); 240 | foreach ( $post_types as $type ) { 241 | $ret[] = array( 242 | 'label' => $type, 243 | 'value' => $type, 244 | ); 245 | } 246 | 247 | return $ret; 248 | } 249 | } 250 | -------------------------------------------------------------------------------- /src/admin.js: -------------------------------------------------------------------------------- 1 | import './admin.scss'; 2 | 3 | import api from '@wordpress/api'; 4 | 5 | import { 6 | Button, 7 | Panel, 8 | PanelBody, 9 | Placeholder, 10 | SelectControl, 11 | Spinner, 12 | TextControl, 13 | ToggleControl, 14 | CheckboxControl, 15 | } from '@wordpress/components'; 16 | 17 | import {Fragment, render, Component} from '@wordpress/element'; 18 | 19 | import {__} from '@wordpress/i18n'; 20 | import Notices from './Notice'; 21 | 22 | import {dispatch} from '@wordpress/data'; 23 | 24 | const posts_array = buddy_vars.postTypes; 25 | 26 | class App extends Component { 27 | constructor() { 28 | super(...arguments); 29 | 30 | this.state = { 31 | webhook: '', 32 | manualDeploy: true, 33 | topbar: true, 34 | manualDeployCapabilities: '', 35 | automaticDeploy: false, 36 | automaticDeployCapabilities: '', 37 | automaticDeployPostTypes: [''], 38 | isAPILoaded: false 39 | }; 40 | } 41 | 42 | componentDidMount() { 43 | 44 | api.loadPromise.then(() => { 45 | this.settings = new api.models.Settings(); 46 | 47 | const {isAPILoaded} = this.state; 48 | 49 | if (isAPILoaded === false) { 50 | this.settings.fetch().then((response) => { 51 | this.setState({ 52 | webhook: response['buddy_webhook'], 53 | manualDeploy: Boolean(response['buddy_manual_deploy']), 54 | topbar: Boolean(response['buddy_topbar']), 55 | manualDeployCapabilities: response['buddy_manual_deploy_capabilities'], 56 | automaticDeploy: Boolean(response['buddy_automatic_deploy']), 57 | automaticDeployCapabilities: response['buddy_automatic_deploy_capabilities'], 58 | automaticDeployPostTypes: response['buddy_automatic_deploy_post_types'], 59 | isAPILoaded: true 60 | }); 61 | }); 62 | } 63 | }); 64 | } 65 | 66 | render() { 67 | const { 68 | webhook, 69 | manualDeploy, 70 | topbar, 71 | manualDeployCapabilities, 72 | automaticDeploy, 73 | automaticDeployCapabilities, 74 | automaticDeployPostTypes, 75 | isAPILoaded 76 | } = this.state; 77 | 78 | if (!isAPILoaded) { 79 | return ( 80 | 81 | 82 | 83 | ); 84 | } 85 | 86 | return ( 87 | 88 |
89 | 90 | { !buddy_vars.definedWebhook 91 | ? 95 | this.setState({webhook}) 103 | } 104 | value={webhook}/> 105 | 106 | : 110 |

Webhook is already defined in wp-config.php file.

111 |
112 | } 113 | 114 | 118 | 119 | { !buddy_vars.definedManualDeploy 120 | ? this.setState({manualDeploy}) 129 | }/> 130 | :
131 | } 132 | 133 | { !buddy_vars.definedTopBar 134 | ? this.setState({topbar}) 143 | }/> 144 | :
145 | } 146 | 147 | { !buddy_vars.definedManualDeployCapabilities 148 | ? this.setState( { manualDeployCapabilities } ) } 152 | options={ buddy_vars.roles } 153 | value={ manualDeployCapabilities } 154 | /> 155 | :
156 | } 157 | 158 | 159 | 163 | { !buddy_vars.definedAutomaticDeploy 164 | ? this.setState({automaticDeploy}) 173 | }/> 174 | :
175 | } 176 | 177 | { !buddy_vars.definedAutomaticDeployPostTypes 178 | ?
    179 | { 180 | posts_array.map(( item ) => ( 181 |
  • -1 } 185 | onChange={ ( check ) => { 186 | const index = automaticDeployPostTypes.indexOf( item.label ); 187 | check ? automaticDeployPostTypes.push( item.label ) : ( index !== -1 ? automaticDeployPostTypes.splice( index, 1 ) : automaticDeployPostTypes ); 188 | this.setState({ automaticDeployPostTypes } ) 189 | } } 190 | />
  • 191 | ) ) 192 | } 193 |
194 | :
195 | } 196 | 197 | { !buddy_vars.definedAutomaticDeployPostTypes 198 | ? this.setState( { automaticDeployCapabilities } ) } 202 | options={ buddy_vars.roles } 203 | value={ automaticDeployCapabilities } 204 | /> 205 | :
206 | } 207 | 208 | 241 | 242 |
243 |
244 | 245 |
246 | 247 | ) 248 | } 249 | } 250 | 251 | document.addEventListener('DOMContentLoaded', () => { 252 | const htmlOutput = document.getElementById('buddy-options-wrapper'); 253 | 254 | if (htmlOutput) { 255 | render ( 256 | , 257 | htmlOutput 258 | ); 259 | } 260 | }); 261 | -------------------------------------------------------------------------------- /src/admin.scss: -------------------------------------------------------------------------------- 1 | #buddy-options-wrapper { 2 | 3 | .components-placeholder { 4 | background: #f1f1f1; 5 | } 6 | 7 | .buddy-plugin__main { 8 | margin-left: auto; 9 | margin-right: auto; 10 | 11 | .components-panel { 12 | background: none; 13 | border: none; 14 | } 15 | 16 | .components-panel__body { 17 | background: #ffffff; 18 | border: 1px solid #e2e4e7; 19 | margin: 1rem 0; 20 | } 21 | } 22 | 23 | .components-panel__row { 24 | > div { 25 | flex-grow: 1; 26 | margin-right: 1rem; 27 | 28 | &:last-of-type { 29 | margin-right: 0; 30 | } 31 | } 32 | } 33 | 34 | .buddy-plugin__notices { 35 | .components-snackbar-list { 36 | bottom: .5rem; 37 | position: fixed; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/functions.php: -------------------------------------------------------------------------------- 1 |

%1$s %3$s %4$s

', 41 | esc_html__( 'Webhook not set! Please set it in', Config::get( 'language_slug' ) ), 42 | esc_url( 'tools.php?page=deploy-buddy&tab=settings' ), 43 | esc_html__( 'the Settings Tab', Config::get( 'language_slug' ) ), 44 | esc_html__( '.', Config::get( 'language_slug' ) ) 45 | ); 46 | } 47 | 48 | /** 49 | * Start! 50 | * 51 | * @return void 52 | */ 53 | function boot() { 54 | new BuddyIntegration(); 55 | } 56 | 57 | function requirements_met() { 58 | return ( options_helper( 'buddy_webhook', false ) !== false ) ? true : false; 59 | } 60 | 61 | function capabilities_helper( $type ) { 62 | if ( function_exists( 'BuddyIntegration\\' . $type ) ) { 63 | return call_user_func( 'BuddyIntegration\\' . $type ); 64 | } 65 | 66 | return false; 67 | } 68 | 69 | function top_bar() { 70 | return is_admin_bar_showing() && ! empty( Config::get( 'webhook' ) ) && Config::get( 'manual_deploy' ) && Config::get( 'add_to_topbar' ) && current_user_can( Config::get( 'manual_deploy_capabilities' ) ); 71 | } 72 | 73 | function manual_deploy() { 74 | return ! empty( Config::get( 'webhook' ) ) && Config::get( 'manual_deploy' ) && current_user_can( Config::get( 'manual_deploy_capabilities' ) ); 75 | } 76 | 77 | function automatic_deploy() { 78 | return ! empty( Config::get( 'webhook' ) ) && Config::get( 'automatic_deploy' ) && ! empty( Config::get( 'automatic_deploy_post_types' ) ) && current_user_can( Config::get( 'automatic_deploy_capabilities' ) ); 79 | } 80 | 81 | function edit_options() { 82 | return current_user_can( Config::get( 'capabilities_options' ) ); 83 | } 84 | 85 | function options_helper( $key_name, $default ) { 86 | if ( defined( $key_name ) ) { 87 | return constant( $key_name ); 88 | } else { 89 | return get_option( $key_name, $default ); 90 | } 91 | } 92 | function update_settings() { 93 | $option_keys = array( 94 | 'buddy_webhook', 95 | 'buddy_topbar', 96 | 'buddy_manual_deploy_capabilities', 97 | 'buddy_manual_deploy', 98 | 'buddy_automatic_deploy', 99 | 'buddy_automatic_deploy_post_types', 100 | 'buddy_automatic_deploy_capabilities', 101 | 'buddy_capabilities_options', 102 | ); 103 | 104 | $old_options = get_option( 'options-page' ); 105 | 106 | if ( $old_options && count( $old_options ) > 0 ) { 107 | foreach( $option_keys as $option ) { 108 | if ( isset( $old_options[ $option ] ) ) { 109 | // CMB had this weird thing about storing false, so they were store as on or off. 110 | if ( in_array( $option, array( 'buddy_manual_deploy', 'buddy_topbar', 'buddy_automatic_deploy' ) ) ) { 111 | $value = $old_options[ $option ] === 'on' ? true : false; 112 | update_option( $option, $value ); 113 | } else { 114 | update_option( $option, $old_options[ $option ] ); 115 | } 116 | } 117 | } 118 | } 119 | 120 | update_option( 'buddy_options_version', 2 ); 121 | } 122 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /templates/automatic_deploy.php: -------------------------------------------------------------------------------- 1 | - ' . $value . ''; 7 | }, 8 | Config::get( 'automatic_deploy_post_types' ) 9 | ); 10 | ?> 11 | 12 |
13 |

14 | 15 | 16 | The automatic deployment runs every time a user with at least %1$s saves or updates post of these post types:
    %2$s
', Config::get( 'language_slug' ) ), Config::get( 'automatic_deploy_capabilities' ), implode( '', $post_types ) ); ?> 17 | 18 | To change the capability required to trigger tha automatic deployment, go to the plugin\'s settings tab or add buddy_automatic_deploy_capabilities constant to wp-config.php file.', Config::get( 'language_slug' ) ); ?> 19 | 20 | To change the post types, go to the plugin\'s settings tab or add buddy_automatic_deploy_post_types constant to wp-config.php file.', Config::get( 'language_slug' ) ); ?> 21 | 22 | Automatic deployments are disabled.

', Config::get( 'language_slug' ) ); ?> 23 | 24 |
25 | 26 | -------------------------------------------------------------------------------- /templates/configuration.php: -------------------------------------------------------------------------------- 1 | 4 | 5 |
6 |

7 | 8 | 9 |
10 |

If options are missing from the Settings tab, it means they are declared in the wp-config.php. Remove the declarations from the wp-config.php file to adjust the corresponding options here.

11 |
12 | 13 | cmb_form; 15 | ?> 16 | 17 | Automatic deployments are disabled.

', Config::get( 'language_slug' ) ); ?> 18 | 19 |
20 | 21 | -------------------------------------------------------------------------------- /templates/footer.php: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/palmiak/deploy-buddy/0fb7e653de3d35c86afa42318ca8fed516450317/templates/footer.php -------------------------------------------------------------------------------- /templates/header.php: -------------------------------------------------------------------------------- 1 | 5 |
6 |
7 | 8 |
9 | 15 |
16 | -------------------------------------------------------------------------------- /templates/installation.php: -------------------------------------------------------------------------------- 1 | 5 |
6 |

7 |
8 |

9 | 10 | 13 |
  • Login to your buddy.works account.
  • 14 |
  • Go to your project and than select the pipeline you want to execute.
  • 15 |
  • Click Webhook URL in the sidebar and copy URL.
  • 16 | ', 17 | Config::get( 'language_slug' ) 18 | ); 19 | ?> 20 |
    21 |

    22 | 23 | You can configure all the options in the settings tab or you set constants in your wp-config.php file.

    ', 26 | Config::get( 'language_slug' ) 27 | ); 28 | ?> 29 |
    30 |

    31 | 32 | buddy_webhook - default: \'\' - sets the webhook

    34 |

    buddy_topbar - default: true - adds the deploy button to the admin bar

    35 |

    buddy_manual_deploy_capabilities - default: manage_options - capability that is needed to see the deploy button

    36 |

    buddy_automatic_deploy - default: false - turn on or off automatic deployments on post update.

    37 |

    buddy_automatic_deploy_post_types - default: [\'post\', \'page\'] - sets on which post types does the update triggers the auto deploy.

    38 |

    buddy_automatic_deploy_capabilities - default: manage_options - capability that is need to run the auto deploy.

    39 | ', 40 | Config::get( 'language_slug' ) 41 | ); ?> 42 |
    43 | -------------------------------------------------------------------------------- /templates/manual_deploy.php: -------------------------------------------------------------------------------- 1 | 5 | 6 |
    7 |

    8 | 9 | 10 | Press the Deploy button to trigger the selected webhook.

    ', Config::get( 'language_slug' ) ); ?> 11 |
    12 |
    13 | 14 |
    15 | 16 | Manual deployments are disabled.

    ', Config::get( 'language_slug' ) ); ?> 17 | 18 |
    19 | -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | const defaultConfig = require( '@wordpress/scripts/config/webpack.config' ); 2 | const path = require( 'path' ); 3 | 4 | module.exports = { 5 | ...defaultConfig, 6 | entry: { 7 | ...defaultConfig.entry, 8 | admin: path.resolve( process.cwd(), 'src', 'admin.js' ), 9 | } 10 | }; 11 | --------------------------------------------------------------------------------