Forked from seanwash/hooks.kollide_password_protect.php
Created
November 17, 2015 15:02
-
-
Save mwesten/88d94decb2f60a080cc0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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