Skip to content

Instantly share code, notes, and snippets.

@seanwash
Last active November 17, 2015 15:02
Show Gist options
  • Save seanwash/92b63e3882eef4d85e95 to your computer and use it in GitHub Desktop.
Save seanwash/92b63e3882eef4d85e95 to your computer and use it in GitHub Desktop.
<?php
class Hooks_kollide_password_protect extends Hooks
{
public $meta = array(
'name' => 'Kollide - Password Protect',
'version' => '1.0.0',
'author' => 'Sean Washington',
'author_url' => 'http://octopuscreative.com'
);
public function control_panel__publish($publish_data)
{
$should_be_password_protected = !!array_get($publish_data, 'yaml:should_be_password_protected', false);
if (isset($should_be_password_protected) && $should_be_password_protected == true) {
// _protect:
// password:
// allowed: [ "my-password", "another-password"]
$publish_data["yaml"]["_protect"]["password"]["allowed"] = $publish_data["yaml"]["password"];
} else {
unset($publish_data["yaml"]["_protect"]);
unset($publish_data["yaml"]["password"]);
}
return $publish_data;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment