';
// build compatibility test result
$html .= '' . apply_filters( 'aiwp_unsupported_browser_message', 'It appears your browser is not capable of displaying this content. Try connecting with Chrome, Firefox, or Opera.' ) . '';
// include appearin iframe populated by API
$html .= '';
if ( AIWP_SHOW_INVITE ) {
$html .= '
';
return $html;
} // end display_shortcode
/**
* Change the brightness of the passed in color
*
* $diff should be negative to go darker, positive to go lighter and
* is subtracted from the decimal (0-255) value of the color
*
* @param string $hex color to be modified
* @param string $diff amount to change the color
* @return string hex color
*/
public function hex_color_mod($hex, $diff) {
$rgb = str_split(trim($hex, '# '), 2);
foreach ($rgb as &$hex) {
$dec = hexdec($hex);
if ($diff >= 0) {
$dec += $diff;
}
else {
$dec -= abs($diff);
}
$dec = max(0, min(255, $dec));
$hex = str_pad(dechex($dec), 2, '0', STR_PAD_LEFT);
}
return '#'.implode($rgb);
}
/**
* Returns whether or not given color is considered "light"
* @param string|Boolean $color
* @return boolean
* @link https://github.com/mexitek/phpColors
*/
public function is_color_light( $color = FALSE ) {
// Get our color
$color = ($color) ? $color : $this->_hex;
// Calculate straight from rbg
$r = hexdec($color[0].$color[1]);
$g = hexdec($color[2].$color[3]);
$b = hexdec($color[4].$color[5]);
return (( $r*299 + $g*587 + $b*114 )/1000 > 130);
}
} // end class
/**
* Call to include room form
*/
function aiwp_include( $args ) {
$aiwp_defaults = array(
'room' => '',
'type' => 'public',
);
$args = wp_parse_args( $args, $aiwp_defaults );
$shortcode = '[appear_in ';
foreach ( $args as $parameter => $value ) {
if ( ! empty( $value ) && ! is_null( $value ) ) {
$shortcode .= $parameter . '="' . $value . '" ';
}
}
$shortcode .= ']';
Appear_In_WP::add_stylesheets_and_javascript();
echo do_shortcode( $shortcode );
}
/**
* Create a random room code
*/
function aiwp_random_room() {
// predefine the alphabet used
$aiwp_alphabet = 'qwertyuiopasdfghjklzxcvbnm1234567890';
// set the length of the string
$aiwp_stringLength = 30;
// initialize the room name as an empty string
$aiwp_randomString = '';
// select and add 30 random character to the string
for ( $i=0; $i<$aiwp_stringLength; $i++) {
$aiwp_character = $aiwp_alphabet[ round( ( rand(0,100)/100 )*(strlen($aiwp_alphabet)-1) ) ];
$aiwp_randomString .= $aiwp_character;
} // end for
// return the result
return $aiwp_randomString;
}
/**
* Creates a new room code and saves to db
*/
function aiwp_expire_room() {
$aiwp_room = aiwp_random_room();
update_option( 'aiwp_public_room', $aiwp_room );
}
// Hook function to expireroom cron event (found in admin class)
add_action( 'expireroom', 'aiwp_expire_room' );
?>