本文整理汇总了PHP中FusionCore_Plugin::calc_color_brightness方法的典型用法代码示例。如果您正苦于以下问题:PHP FusionCore_Plugin::calc_color_brightness方法的具体用法?PHP FusionCore_Plugin::calc_color_brightness怎么用?PHP FusionCore_Plugin::calc_color_brightness使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FusionCore_Plugin
的用法示例。
在下文中一共展示了FusionCore_Plugin::calc_color_brightness方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: attr
function attr()
{
$attr = array();
$attr['class'] = 'fusion-highlight';
$brightness_level = FusionCore_Plugin::calc_color_brightness(self::$args['color']);
if ($brightness_level > 140) {
$attr['class'] .= ' light';
} else {
$attr['class'] .= ' dark';
}
if (self::$args['class']) {
$attr['class'] .= ' ' . self::$args['class'];
}
if (self::$args['rounded'] == 'yes') {
$attr['class'] .= ' rounded';
}
if (self::$args['id']) {
$attr['id'] = self::$args['id'];
}
if (self::$args['color'] == 'black') {
$attr['class'] .= ' highlight2';
} else {
$attr['class'] .= ' highlight1';
}
$attr['style'] = sprintf('background-color:%s;', self::$args['color']);
return $attr;
}
示例2: render
/**
* Render the shortcode
* @param array $args Shortcode paramters
* @param string $content Content between shortcode
* @return string HTML output
*/
function render($args, $content = '')
{
global $smof_data;
$defaults = FusionCore_Plugin::set_shortcode_defaults(array('class' => '', 'id' => '', 'animation' => 'no', 'address' => '', 'height' => '300px', 'icon' => '', 'infobox' => '', 'infobox_background_color' => '', 'infobox_content' => '', 'infobox_text_color' => '', 'map_style' => '', 'overlay_color' => '', 'popup' => 'yes', 'scale' => 'yes', 'scrollwheel' => 'yes', 'type' => 'roadmap', 'width' => '100%', 'zoom' => '14', 'zoom_pancontrol' => 'yes'), $args);
extract($defaults);
self::$args = $defaults;
$html = '';
if ($address) {
$addresses = explode('|', $address);
if ($addresses) {
self::$args['address'] = $addresses;
}
$num_of_addresses = count($addresses);
if ($infobox_content) {
$infobox_content_array = explode('|', $infobox_content);
} else {
$infobox_content_array = '';
}
if ($icon) {
$icon_array = explode('|', $icon);
} else {
$icon_array = '';
}
if ($map_style == 'theme') {
$map_style = 'custom';
$icon = 'theme';
$animation = 'yes';
$infobox = 'custom';
$infobox_background_color = FusionCore_Plugin::hex2rgb($smof_data['primary_color']);
$infobox_background_color = 'rgba(' . $infobox_background_color[0] . ', ' . $infobox_background_color[1] . ', ' . $infobox_background_color[2] . ', 0.8)';
$overlay_color = $smof_data['primary_color'];
$brightness_level = FusionCore_Plugin::calc_color_brightness($smof_data['primary_color']);
if ($brightness_level > 140) {
$infobox_text_color = '#fff';
} else {
$infobox_text_color = '#747474';
}
}
// If only one custom icon is set, use it for all markers
if ($map_style == 'custom' && $icon && $icon != 'theme' && $icon_array && count($icon_array) == 1) {
$icon_url = $icon_array[0];
for ($i = 0; $i < $num_of_addresses; $i++) {
$icon_array[$i] = $icon_url;
}
}
if ($icon == 'theme' && $map_style == 'custom') {
for ($i = 0; $i < $num_of_addresses; $i++) {
$icon_array[$i] = plugins_url('images/avada_map_marker.png', dirname(__FILE__));
}
}
if (wp_script_is('google-maps-api', 'registered')) {
wp_print_scripts('google-maps-api');
}
if (wp_script_is('google-maps-infobox', 'registered')) {
wp_print_scripts('google-maps-infobox');
}
foreach (self::$args['address'] as $add) {
$add = trim($add);
$add_arr = explode("\n", $add);
$add_arr = array_filter($add_arr, 'trim');
$add = implode('<br/>', $add_arr);
$add = str_replace("\r", '', $add);
$add = str_replace("\n", '', $add);
$coordinates[]['address'] = $add;
}
if (!is_array($coordinates)) {
return;
}
for ($i = 0; $i < $num_of_addresses; $i++) {
if (strpos(self::$args['address'][$i], 'latlng=') === 0) {
self::$args['address'][$i] = $coordinates[$i]['address'];
}
}
if (is_array($infobox_content_array) && !empty($infobox_content_array)) {
for ($i = 0; $i < $num_of_addresses; $i++) {
if (!array_key_exists($i, $infobox_content_array)) {
$infobox_content_array[$i] = self::$args['address'][$i];
}
}
self::$args['infobox_content'] = $infobox_content_array;
} else {
self::$args['infobox_content'] = self::$args['address'];
}
$cached_addresses = get_option('fusion_map_addresses');
foreach (self::$args['address'] as $key => $address) {
$json_addresses[] = array('address' => $address, 'infobox_content' => html_entity_decode(self::$args['infobox_content'][$key]));
if (isset($icon_array) && is_array($icon_array) && array_key_exists($key, $icon_array)) {
$json_addresses[$key]['marker'] = $icon_array[$key];
}
if (strpos($address, strtolower('latlng=')) !== false) {
$json_addresses[$key]['address'] = str_replace('latlng=', '', $address);
$latLng = explode(',', $json_addresses[$key]['address']);
$json_addresses[$key]['coordinates'] = true;
$json_addresses[$key]['latitude'] = $latLng[0];
//.........这里部分代码省略.........
示例3: render
/**
* Render the shortcode
* @param array $args Shortcode paramters
* @param string $content Content between shortcode
* @return string HTML output
*/
function render($args, $content = '')
{
global $smof_data;
$defaults = FusionCore_Plugin::set_shortcode_defaults(array('class' => '', 'id' => '', 'animation' => 'no', 'address' => '', 'height' => '300px', 'icon' => '', 'infobox' => '', 'infobox_background_color' => '', 'infobox_content' => '', 'infobox_text_color' => '', 'map_style' => '', 'overlay_color' => '', 'popup' => 'yes', 'scale' => 'yes', 'scrollwheel' => 'yes', 'type' => 'roadmap', 'width' => '100%', 'zoom' => '14', 'zoom_pancontrol' => 'yes'), $args);
extract($defaults);
self::$args = $defaults;
$html = '';
if ($address) {
$addresses = explode('|', $address);
if ($infobox_content) {
$infobox_content_array = explode('|', $infobox_content);
} else {
$infobox_content_array = '';
}
if ($icon) {
$icon_array = explode('|', $icon);
} else {
$icon_array = '';
}
if ($addresses) {
self::$args['address'] = $addresses;
}
$num_of_addresses = count($addresses);
if ($map_style == 'theme') {
$map_style = 'custom';
$icon = 'theme';
$animation = 'yes';
$infobox = 'custom';
$infobox_background_color = FusionCore_Plugin::hex2rgb($smof_data['primary_color']);
$infobox_background_color = 'rgba(' . $infobox_background_color[0] . ', ' . $infobox_background_color[1] . ', ' . $infobox_background_color[2] . ', 0.8)';
$overlay_color = $smof_data['primary_color'];
$brightness_level = FusionCore_Plugin::calc_color_brightness($smof_data['primary_color']);
if ($brightness_level > 140) {
$infobox_text_color = '#fff';
} else {
$infobox_text_color = '#747474';
}
}
if ($map_style == 'custom') {
$animation = 'yes';
}
if ($icon == 'theme' && $map_style == 'custom') {
for ($i = 0; $i < $num_of_addresses; $i++) {
$icon_array[$i] = plugins_url('images/avada_map_marker.png', dirname(__FILE__));
}
}
wp_print_scripts('google-maps-api');
wp_print_scripts('google-maps-infobox');
foreach (self::$args['address'] as $add) {
$coordinates[] = $this->get_coordinates($add);
}
if (!is_array($coordinates)) {
return;
}
for ($i = 0; $i < $num_of_addresses; $i++) {
if (strpos(self::$args['address'][$i], 'latlng=') === 0) {
self::$args['address'][$i] = $coordinates[$i]['address'];
}
}
if (is_array($infobox_content_array) && !empty($infobox_content_array)) {
for ($i = 0; $i < $num_of_addresses; $i++) {
if (!array_key_exists($i, $infobox_content_array)) {
$infobox_content_array[$i] = self::$args['address'][$i];
}
}
self::$args['infobox_content'] = $infobox_content_array;
} else {
self::$args['infobox_content'] = self::$args['address'];
}
$map_id = uniqid('fusion_map_');
// generate a unique ID for this map
$this->map_id = $map_id;
ob_start();
?>
<script type="text/javascript">
var map_<?php
echo $map_id;
?>
;
var markers = [];
var counter = 0;
function fusion_run_map_<?php
echo $map_id;
?>
() {
var location = new google.maps.LatLng(<?php
echo $coordinates[0]['lat'];
?>
, <?php
echo $coordinates[0]['lng'];
?>
);
var map_options = {
zoom: <?php
//.........这里部分代码省略.........