$maxbutton_gradient_end_opacity_hover_display = strlen($maxbutton_gradient_end_opacity_hover_display) == 1 ? '0' . $maxbutton_gradient_end_opacity_hover_display : $maxbutton_gradient_end_opacity_hover_display;
$maxbutton_container_enabled_value = isset($button) ? $button->container_enabled : 'on';
$maxbutton_container_width_value = isset($button) ? $button->container_width : '';
$maxbutton_container_margin_top_value = isset($button) ? $button->container_margin_top : '';
$maxbutton_container_margin_right_value = isset($button) ? $button->container_margin_right : '';
$maxbutton_container_margin_bottom_value = isset($button) ? $button->container_margin_bottom : '';
$maxbutton_container_margin_left_value = isset($button) ? $button->container_margin_left : '';
$maxbutton_container_alignment_value = isset($button) ? $button->container_alignment : '';
$maxbutton_container_center_div_wrap_enabled_value = isset($button) ? $button->container_center_div_wrap_enabled : 'on';
$maxbutton_external_css_value = isset($button) ? $button->external_css : '';
$maxbutton_important_css_value = isset($button) ? $button->important_css : '';
// Convert hex to rgba
$gradient_start_rgba = maxbuttons_hex2rgba($maxbutton_gradient_start_color_value, $maxbutton_gradient_start_opacity_value);
$gradient_end_rgba = maxbuttons_hex2rgba($maxbutton_gradient_end_color_value, $maxbutton_gradient_end_opacity_value);
$gradient_start_rgba_hover = maxbuttons_hex2rgba($maxbutton_gradient_start_color_hover_value, $maxbutton_gradient_start_opacity_hover_value);
$gradient_end_rgba_hover = maxbuttons_hex2rgba($maxbutton_gradient_end_color_hover_value, $maxbutton_gradient_end_opacity_hover_value);
$redirect = false;
$button_id = isset($_GET['id']) ? $_GET['id'] : 0;
if ($_POST) {
    global $wpdb;
    $data = array('name' => $_POST[$maxbutton_name_key] != '' ? stripslashes($_POST[$maxbutton_name_key]) : __('Unnamed Button', 'maxbuttons'), 'description' => stripslashes($_POST[$maxbutton_description_key]), 'url' => stripslashes($_POST[$maxbutton_url_key]), 'text' => stripslashes($_POST[$maxbutton_text_key]), 'new_window' => $wpdb->escape($_POST[$maxbutton_new_window_key]), 'nofollow' => $wpdb->escape($_POST[$maxbutton_nofollow_key]), 'text_font_family' => $_POST[$maxbutton_text_font_family_key] != '' ? $wpdb->escape($_POST[$maxbutton_text_font_family_key]) : $maxbutton_text_font_family_default, 'text_font_size' => $_POST[$maxbutton_text_font_size_key] != '' ? $wpdb->escape($_POST[$maxbutton_text_font_size_key]) : $maxbutton_text_font_size_default, 'text_font_style' => $_POST[$maxbutton_text_font_style_key] != '' ? $wpdb->escape($_POST[$maxbutton_text_font_style_key]) : $maxbutton_text_font_style_default, 'text_font_weight' => $_POST[$maxbutton_text_font_weight_key] != '' ? $wpdb->escape($_POST[$maxbutton_text_font_weight_key]) : $maxbutton_text_font_weight_default, 'text_color' => $_POST[$maxbutton_text_color_key] != '' ? $wpdb->escape($_POST[$maxbutton_text_color_key]) : $maxbutton_text_color_default, 'text_color_hover' => $_POST[$maxbutton_text_color_hover_key] != '' ? $wpdb->escape($_POST[$maxbutton_text_color_hover_key]) : $maxbutton_text_color_hover_default, 'text_shadow_offset_left' => $_POST[$maxbutton_text_shadow_offset_left_key] != '' ? $wpdb->escape($_POST[$maxbutton_text_shadow_offset_left_key]) . 'px' : $maxbutton_text_shadow_offset_left_default, 'text_shadow_offset_top' => $_POST[$maxbutton_text_shadow_offset_top_key] != '' ? $wpdb->escape($_POST[$maxbutton_text_shadow_offset_top_key]) . 'px' : $maxbutton_text_shadow_offset_top_default, 'text_shadow_width' => $_POST[$maxbutton_text_shadow_width_key] != '' ? $wpdb->escape($_POST[$maxbutton_text_shadow_width_key]) . 'px' : $maxbutton_text_shadow_width_default, 'text_shadow_color' => $_POST[$maxbutton_text_shadow_color_key] != '' ? $wpdb->escape($_POST[$maxbutton_text_shadow_color_key]) : $maxbutton_text_shadow_color_default, 'text_shadow_color_hover' => $_POST[$maxbutton_text_shadow_color_hover_key] != '' ? $wpdb->escape($_POST[$maxbutton_text_shadow_color_hover_key]) : $maxbutton_text_shadow_color_hover_default, 'text_padding_top' => $_POST[$maxbutton_text_padding_top_key] != '' ? $wpdb->escape($_POST[$maxbutton_text_padding_top_key]) . 'px' : $maxbutton_text_padding_top_default, 'text_padding_bottom' => $_POST[$maxbutton_text_padding_bottom_key] != '' ? $wpdb->escape($_POST[$maxbutton_text_padding_bottom_key]) . 'px' : $maxbutton_text_padding_bottom_default, 'text_padding_left' => $_POST[$maxbutton_text_padding_left_key] != '' ? $wpdb->escape($_POST[$maxbutton_text_padding_left_key]) . 'px' : $maxbutton_text_padding_left_default, 'text_padding_right' => $_POST[$maxbutton_text_padding_right_key] != '' ? $wpdb->escape($_POST[$maxbutton_text_padding_right_key]) . 'px' : $maxbutton_text_padding_right_default, 'border_radius_top_left' => $_POST[$maxbutton_border_radius_top_left_key] != '' ? $wpdb->escape($_POST[$maxbutton_border_radius_top_left_key]) . 'px' : $maxbutton_border_radius_top_left_default, 'border_radius_top_right' => $_POST[$maxbutton_border_radius_top_right_key] != '' ? $wpdb->escape($_POST[$maxbutton_border_radius_top_right_key]) . 'px' : $maxbutton_border_radius_top_right_default, 'border_radius_bottom_left' => $_POST[$maxbutton_border_radius_bottom_left_key] != '' ? $wpdb->escape($_POST[$maxbutton_border_radius_bottom_left_key]) . 'px' : $maxbutton_border_radius_bottom_left_default, 'border_radius_bottom_right' => $_POST[$maxbutton_border_radius_bottom_right_key] != '' ? $wpdb->escape($_POST[$maxbutton_border_radius_bottom_right_key]) . 'px' : $maxbutton_border_radius_bottom_right_default, 'border_style' => $_POST[$maxbutton_border_style_key] != '' ? $wpdb->escape($_POST[$maxbutton_border_style_key]) : $maxbutton_border_style_default, 'border_width' => $_POST[$maxbutton_border_width_key] != '' ? $wpdb->escape($_POST[$maxbutton_border_width_key]) . 'px' : $maxbutton_border_width_default, 'border_color' => $_POST[$maxbutton_border_color_key] != '' ? $wpdb->escape($_POST[$maxbutton_border_color_key]) : $maxbutton_border_color_default, 'border_color_hover' => $_POST[$maxbutton_border_color_hover_key] != '' ? $wpdb->escape($_POST[$maxbutton_border_color_hover_key]) : $maxbutton_border_color_hover_default, 'box_shadow_offset_left' => $_POST[$maxbutton_box_shadow_offset_left_key] != '' ? $wpdb->escape($_POST[$maxbutton_box_shadow_offset_left_key]) . 'px' : $maxbutton_box_shadow_offset_left_default, 'box_shadow_offset_top' => $_POST[$maxbutton_box_shadow_offset_top_key] != '' ? $wpdb->escape($_POST[$maxbutton_box_shadow_offset_top_key]) . 'px' : $maxbutton_box_shadow_offset_top_default, 'box_shadow_width' => $_POST[$maxbutton_box_shadow_width_key] != '' ? $wpdb->escape($_POST[$maxbutton_box_shadow_width_key]) . 'px' : $maxbutton_box_shadow_width_default, 'box_shadow_color' => $_POST[$maxbutton_box_shadow_color_key] != '' ? $wpdb->escape($_POST[$maxbutton_box_shadow_color_key]) : $maxbutton_box_shadow_color_default, 'box_shadow_color_hover' => $_POST[$maxbutton_box_shadow_color_hover_key] != '' ? $wpdb->escape($_POST[$maxbutton_box_shadow_color_hover_key]) : $maxbutton_box_shadow_color_hover_default, 'gradient_start_color' => $_POST[$maxbutton_gradient_start_color_key] != '' ? $wpdb->escape($_POST[$maxbutton_gradient_start_color_key]) : $maxbutton_gradient_start_color_default, 'gradient_start_color_hover' => $_POST[$maxbutton_gradient_start_color_hover_key] != '' ? $wpdb->escape($_POST[$maxbutton_gradient_start_color_hover_key]) : $maxbutton_gradient_start_color_hover_default, 'gradient_end_color' => $_POST[$maxbutton_gradient_end_color_key] != '' ? $wpdb->escape($_POST[$maxbutton_gradient_end_color_key]) : $maxbutton_gradient_end_color_default, 'gradient_end_color_hover' => $_POST[$maxbutton_gradient_end_color_hover_key] != '' ? $wpdb->escape($_POST[$maxbutton_gradient_end_color_hover_key]) : $maxbutton_gradient_end_color_hover_default, 'gradient_stop' => $_POST[$maxbutton_gradient_stop_key] != '' ? $wpdb->escape($_POST[$maxbutton_gradient_stop_key]) : $maxbutton_gradient_stop_default, 'gradient_start_opacity' => $_POST[$maxbutton_gradient_start_opacity_key] != '' ? $wpdb->escape($_POST[$maxbutton_gradient_start_opacity_key]) : $maxbutton_gradient_start_opacity_default, 'gradient_end_opacity' => $_POST[$maxbutton_gradient_end_opacity_key] != '' ? $wpdb->escape($_POST[$maxbutton_gradient_end_opacity_key]) : $maxbutton_gradient_end_opacity_default, 'gradient_start_opacity_hover' => $_POST[$maxbutton_gradient_start_opacity_hover_key] != '' ? $wpdb->escape($_POST[$maxbutton_gradient_start_opacity_hover_key]) : $maxbutton_gradient_start_opacity_hover_default, 'gradient_end_opacity_hover' => $_POST[$maxbutton_gradient_end_opacity_hover_key] != '' ? $wpdb->escape($_POST[$maxbutton_gradient_end_opacity_hover_key]) : $maxbutton_gradient_end_opacity_hover_default, 'container_enabled' => $wpdb->escape($_POST[$maxbutton_container_enabled_key]), 'container_width' => $_POST[$maxbutton_container_width_key] != '' ? $wpdb->escape($_POST[$maxbutton_container_width_key]) . 'px' : '', 'container_margin_top' => $_POST[$maxbutton_container_margin_top_key] != '' ? $wpdb->escape($_POST[$maxbutton_container_margin_top_key]) . 'px' : '', 'container_margin_right' => $_POST[$maxbutton_container_margin_right_key] != '' ? $wpdb->escape($_POST[$maxbutton_container_margin_right_key]) . 'px' : '', 'container_margin_bottom' => $_POST[$maxbutton_container_margin_bottom_key] != '' ? $wpdb->escape($_POST[$maxbutton_container_margin_bottom_key]) . 'px' : '', 'container_margin_left' => $_POST[$maxbutton_container_margin_left_key] != '' ? $wpdb->escape($_POST[$maxbutton_container_margin_left_key]) . 'px' : '', 'container_alignment' => $_POST[$maxbutton_container_alignment_key] != '' ? $wpdb->escape($_POST[$maxbutton_container_alignment_key]) : '', 'container_center_div_wrap_enabled' => $wpdb->escape($_POST[$maxbutton_container_center_div_wrap_enabled_key]), 'external_css' => $wpdb->escape($_POST[$maxbutton_external_css_key]), 'important_css' => $wpdb->escape($_POST[$maxbutton_important_css_key]));
    if ($_GET['id'] == '') {
        // This is a new button
        $wpdb->insert(maxbuttons_get_buttons_table_name(), $data);
        $button_id = $wpdb->insert_id;
    } else {
        // Updating an existing button
        $where = array('id' => $_GET['id']);
        $data_format = array('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s');
        $where_format = array('%d');
        $wpdb->update(maxbuttons_get_buttons_table_name(), $data, $where, $data_format, $where_format);
Esempio n. 2
0
function maxbuttons_button_shortcode($atts)
{
    extract(shortcode_atts(array('id' => '', 'name' => '', 'text' => '', 'url' => '', 'window' => '', 'nofollow' => '', 'externalcss' => '', 'externalcsspreview' => '', 'ignorecontainer' => '', 'exclude' => ''), $atts));
    $button_name = "{$name}";
    $button_id = "{$id}";
    if ($button_id != '' || $button_name != '') {
        if ($button_name != '') {
            $button = maxbuttons_get_button($button_name);
        } else {
            $button = maxbuttons_get_button($button_id);
        }
        if (isset($button)) {
            // If we're not in the admin and the button is in the trash, just return nothing
            if (!is_admin() && $button->status == 'trash') {
                return '';
            }
            // Check to handle excludes
            if ("{$exclude}" != '') {
                global $post;
                // Don't render the button if excluded from the current post/page
                $exclude = explode(',', "{$exclude}");
                if (in_array($post->ID, $exclude)) {
                    return '';
                }
            }
            if ($button->gradient_stop != '') {
                $gradient_stop = strlen($button->gradient_stop) == 1 ? '0' . $button->gradient_stop : $button->gradient_stop;
            } else {
                $gradient_stop = '45';
                // Default
            }
            $external_css = false;
            if ("{$externalcss}" != '') {
                if ("{$externalcss}" == 'true') {
                    $external_css = true;
                }
            } else {
                if ($button->external_css == 'on') {
                    $external_css = true;
                }
            }
            // Check to exit early with external css preview
            $external_css_preview = false;
            if ("{$externalcsspreview}" != '') {
                if ("{$externalcsspreview}" == 'true') {
                    $external_css_preview = true;
                }
            }
            // Check to ignore container
            $ignore_container = false;
            if ("{$ignorecontainer}" != '') {
                if ("{$ignorecontainer}" == 'true') {
                    $ignore_container = true;
                }
            }
            // Check to set !important
            $important = '';
            if ($button->important_css == 'on') {
                $important = ' !important';
            }
            // Initialize the css
            $css = '';
            // The container style
            if ($button->container_enabled == 'on') {
                $css .= 'div.maxbutton-' . $button->id . '-container { ';
                if ($button->container_alignment != '') {
                    $css .= $button->container_alignment . $important . '; ';
                }
                if ($button->container_width != '') {
                    $css .= 'width: ' . $button->container_width . $important . '; ';
                }
                if ($button->container_margin_top != '') {
                    $css .= 'margin-top: ' . $button->container_margin_top . $important . '; ';
                }
                if ($button->container_margin_right != '') {
                    $css .= 'margin-right: ' . $button->container_margin_right . $important . '; ';
                }
                if ($button->container_margin_bottom != '') {
                    $css .= 'margin-bottom: ' . $button->container_margin_bottom . $important . '; ';
                }
                if ($button->container_margin_left != '') {
                    $css .= 'margin-left: ' . $button->container_margin_left . $important . '; ';
                }
                $css .= '} ';
            }
            $button_url = "{$url}" != '' ? "{$url}" : $button->url;
            // Gradients
            $gradient_start_color = maxbuttons_hex2rgba($button->gradient_start_color, $button->gradient_start_opacity);
            $gradient_end_color = maxbuttons_hex2rgba($button->gradient_end_color, $button->gradient_end_opacity);
            // The button style
            $css .= 'a.maxbutton-' . $button->id . ' { ';
            $css .= 'text-decoration: none' . $important . '; ';
            $css .= 'color: ' . $button->text_color . $important . '; ';
            $css .= 'font-family: ' . $button->text_font_family . $important . '; ';
            $css .= 'font-size: ' . $button->text_font_size . $important . '; ';
            $css .= 'font-style: ' . $button->text_font_style . $important . '; ';
            $css .= 'font-weight: ' . $button->text_font_weight . $important . '; ';
            $css .= 'padding-top: ' . $button->text_padding_top . $important . '; ';
            $css .= 'padding-right: ' . $button->text_padding_right . $important . '; ';
            $css .= 'padding-bottom: ' . $button->text_padding_bottom . $important . '; ';
            $css .= 'padding-left: ' . $button->text_padding_left . $important . '; ';
            $css .= 'background-color: ' . $button->gradient_start_color . $important . '; ';
            $css .= 'background: linear-gradient(' . $gradient_start_color . ' ' . $gradient_stop . '%, ' . $gradient_end_color . '); ';
            $css .= 'background: -moz-linear-gradient(' . $gradient_start_color . ' ' . $gradient_stop . '%, ' . $gradient_end_color . '); ';
            $css .= 'background: -o-linear-gradient(' . $gradient_start_color . ' ' . $gradient_stop . '%, ' . $gradient_end_color . '); ';
            $css .= 'background: -webkit-gradient(linear, left top, left bottom, color-stop(.' . $gradient_stop . ', ' . $gradient_start_color . '), color-stop(1, ' . $gradient_end_color . ')); ';
            $css .= 'border-style: ' . $button->border_style . $important . '; ';
            $css .= 'border-width: ' . $button->border_width . $important . '; ';
            $css .= 'border-color: ' . $button->border_color . $important . '; ';
            $css .= 'box-sizing: border-box' . $important . '; ';
            $css .= 'white-space: nowrap;';
            if (maxbuttons_border_radius_values_are_equal($button->border_radius_top_left, $button->border_radius_top_right, $button->border_radius_bottom_left, $button->border_radius_bottom_right)) {
                $css .= 'border-radius: ' . $button->border_radius_top_left . $important . '; ';
                $css .= '-moz-border-radius: ' . $button->border_radius_top_left . $important . '; ';
                $css .= '-webkit-border-radius: ' . $button->border_radius_top_left . $important . '; ';
            } else {
                $css .= 'border-top-left-radius: ' . $button->border_radius_top_left . $important . '; ';
                $css .= 'border-top-right-radius: ' . $button->border_radius_top_right . $important . '; ';
                $css .= 'border-bottom-left-radius: ' . $button->border_radius_bottom_left . $important . '; ';
                $css .= 'border-bottom-right-radius: ' . $button->border_radius_bottom_right . $important . '; ';
                $css .= '-moz-border-radius-topleft: ' . $button->border_radius_top_left . $important . '; ';
                $css .= '-moz-border-radius-topright: ' . $button->border_radius_top_right . $important . '; ';
                $css .= '-moz-border-radius-bottomleft: ' . $button->border_radius_bottom_left . $important . '; ';
                $css .= '-moz-border-radius-bottomright: ' . $button->border_radius_bottom_right . $important . '; ';
                $css .= '-webkit-border-top-left-radius: ' . $button->border_radius_top_left . $important . '; ';
                $css .= '-webkit-border-top-right-radius: ' . $button->border_radius_top_right . $important . '; ';
                $css .= '-webkit-border-bottom-left-radius: ' . $button->border_radius_bottom_left . $important . '; ';
                $css .= '-webkit-border-bottom-right-radius: ' . $button->border_radius_bottom_right . $important . '; ';
            }
            $css .= 'text-shadow: ' . $button->text_shadow_offset_left . ' ' . $button->text_shadow_offset_top . ' ' . $button->text_shadow_width . ' ' . $button->text_shadow_color . $important . '; ';
            $css .= 'box-shadow: ' . $button->box_shadow_offset_left . ' ' . $button->box_shadow_offset_top . ' ' . $button->box_shadow_width . ' ' . $button->box_shadow_color . $important . '; ';
            // PIE
            $css .= '-pie-background: linear-gradient(' . $gradient_start_color . ' ' . $gradient_stop . '%, ' . $gradient_end_color . '); ';
            $css .= 'position: relative' . $important . '; ';
            $css .= 'behavior: url("' . MAXBUTTONS_PLUGIN_URL . '/pie/PIE.htc"); ';
            $css .= '} ';
            // The button style - visited
            $css .= 'a.maxbutton-' . $button->id . ':visited { ';
            $css .= 'text-decoration: none' . $important . '; ';
            $css .= 'color: ' . $button->text_color . $important . '; ';
            $css .= '} ';
            if ($button_url != '') {
                // Hover gradients
                $gradient_start_color_hover = maxbuttons_hex2rgba($button->gradient_start_color_hover, $button->gradient_start_opacity_hover);
                $gradient_end_color_hover = maxbuttons_hex2rgba($button->gradient_end_color_hover, $button->gradient_end_opacity_hover);
                // The button style - hover
                $css .= 'a.maxbutton-' . $button->id . ':hover { ';
                $css .= 'text-decoration: none' . $important . '; ';
                $css .= 'color: ' . $button->text_color_hover . $important . '; ';
                $css .= 'background-color: ' . $button->gradient_start_color_hover . $important . '; ';
                $css .= 'background: linear-gradient(' . $gradient_start_color_hover . ' ' . $gradient_stop . '%, ' . $gradient_end_color_hover . '); ';
                $css .= 'background: -moz-linear-gradient(' . $gradient_start_color_hover . ' ' . $gradient_stop . '%, ' . $gradient_end_color_hover . '); ';
                $css .= 'background: -o-linear-gradient(' . $gradient_start_color_hover . ' ' . $gradient_stop . '%, ' . $gradient_end_color_hover . '); ';
                $css .= 'background: -webkit-gradient(linear, left top, left bottom, color-stop(.' . $gradient_stop . ', ' . $gradient_start_color_hover . '), color-stop(1, ' . $gradient_end_color_hover . ')); ';
                $css .= 'border-color: ' . $button->border_color_hover . $important . '; ';
                $css .= 'text-shadow: ' . $button->text_shadow_offset_left . ' ' . $button->text_shadow_offset_top . ' ' . $button->text_shadow_width . ' ' . $button->text_shadow_color_hover . $important . '; ';
                $css .= 'box-shadow: ' . $button->box_shadow_offset_left . ' ' . $button->box_shadow_offset_top . ' ' . $button->box_shadow_width . ' ' . $button->box_shadow_color_hover . $important . '; ';
                // PIE
                $css .= '-pie-background: linear-gradient(' . $gradient_start_color_hover . ' ' . $gradient_stop . '%, ' . $gradient_end_color_hover . '); ';
                $css .= 'position: relative' . $important . '; ';
                $css .= 'behavior: url("' . MAXBUTTONS_PLUGIN_URL . '/pie/PIE.htc"); ';
                $css .= '}';
            }
            if ($external_css_preview) {
                return $css;
            }
            $button_text = "{$text}" != '' ? "{$text}" : $button->text;
            $button_window = '';
            $button_nofollow = '';
            // Check to open the link in a new window
            if ("{$window}" != '') {
                if ("{$window}" == 'new') {
                    $button_window = 'target="_blank"';
                }
            } else {
                if ($button->new_window == 'on') {
                    $button_window = 'target="_blank"';
                }
            }
            // Check to add rel="nofollow" to the link
            if ("{$nofollow}" != '') {
                if ("{$nofollow}" == 'true') {
                    $button_nofollow = 'rel="nofollow"';
                }
            } else {
                if ($button->nofollow == 'on') {
                    $button_nofollow = 'rel="nofollow"';
                }
            }
            // Initialize the output
            $output = '';
            // Check to add the css
            if (!$external_css) {
                //$output .= $css;
                global $maxbuttons_css;
                $maxbuttons_css[$button->id] = $css;
            }
            if (!$ignore_container) {
                // Check to add the center div wrapper
                if ($button->container_center_div_wrap_enabled == 'on') {
                    $output .= '<div align="center">';
                }
                // Check to add the container
                if ($button->container_enabled == 'on') {
                    $output .= '<div class="maxbutton-' . $button->id . '-container">';
                }
            }
            // If no button url then don't output the href
            if ($button_url == '') {
                $output .= '<a class="maxbutton-' . $button->id . '">' . do_shortcode($button_text) . '</a>';
            } else {
                $output .= '<a class="maxbutton-' . $button->id . '" href="' . do_shortcode($button_url) . '" ' . $button_window . ' ' . $button_nofollow . '>' . do_shortcode($button_text) . '</a>';
            }
            if (!$ignore_container) {
                // Check to close the container
                if ($button->container_enabled == 'on') {
                    $output .= '</div>';
                    // Might need to clear the float
                    if ($button->container_alignment == 'float: right' || $button->container_alignment == 'float: left') {
                        $output .= '<div style="clear: both;"></div>';
                    }
                }
                // Check to close the center div wrapper
                if ($button->container_center_div_wrap_enabled == 'on') {
                    $output .= '</div>';
                }
            }
            return $output;
        }
    }
}
Esempio n. 3
0
 function post_process_css($css, $mode)
 {
     $raw_css = $css;
     return $css;
     foreach ($css as $part => $styles) {
         /* Hover part doesn't boost all settings - these are set from normal part */
         if (strpos($part, ':hover') !== false) {
             if (!isset($styles["gradient-start-opacity"])) {
                 $styles["gradient-start-opacity"] = $raw_css["normal"]["gradient-start-opacity"];
             }
             if (!isset($styles["gradient-end-opacity"])) {
                 $styles["gradient-end-opacity"] = $raw_css["normal"]["gradient-end-opacity"];
             }
             if (!isset($styles["gradient-stop"])) {
                 $styles["gradient-stop"] = $raw_css["normal"]["gradient-stop"];
             }
             if (!isset($styles["box-shadow-width"])) {
                 $styles["box-shadow-width"] = $raw_css["normal"]["box-shadow-width"];
             }
             if (!isset($styles["box-shadow-offset-left"])) {
                 $styles["box-shadow-offset-left"] = $raw_css["normal"]["box-shadow-offset-left"];
             }
             if (!isset($styles["box-shadow-offset-top"])) {
                 $styles["box-shadow-offset-top"] = $raw_css["normal"]["box-shadow-offset-top"];
             }
             if (!isset($styles["text-shadow-width"])) {
                 $styles["text-shadow-width"] = $raw_css["-mb-text"]["text-shadow-width"];
             }
             if (!isset($styles["text-shadow-left"])) {
                 $styles["text-shadow-left"] = $raw_css["-mb-text"]["text-shadow-left"];
             }
             if (!isset($styles["text-shadow-top"])) {
                 $styles["text-shadow-top"] = $raw_css["-mb-text"]["text-shadow-top"];
             }
         }
         /* End Hover fix */
         if (isset($styles["gradient-start-color"])) {
             $start = isset($styles["gradient-start-color"]) ? $styles["gradient-start-color"] : '';
             $end = isset($styles["gradient-end-color"]) ? $styles["gradient-end-color"] : '';
             $start_opacity = isset($styles["gradient-start-opacity"]) ? $styles["gradient-start-opacity"] : '';
             $end_opacity = isset($styles["gradient-end-opacity"]) ? $styles["gradient-end-opacity"] : '';
             $start = maxbuttons_hex2rgba($start, $start_opacity);
             $end = maxbuttons_hex2rgba($end, $end_opacity);
             $stop = isset($styles["gradient-stop"]) ? $styles["gradient-stop"] : '';
             $css[$part]["background-color"] = $start;
             if ($start != '' && $end != '' && $stop != '') {
                 $css[$part]["background"] = "linear-gradient( {$start} {$stop}%, {$end});";
                 $css[$part]["background"] .= "background: -moz-linear-gradient({$start} {$stop}%, {$end});";
                 $css[$part]["background"] .= "background: -webkit-gradient(linear, left top, left bottom, color-stop({$stop}%, {$start}), \n\t\t\t\t \t\t\t\t\t\t\t\tcolor-stop(1, {$end}));";
                 $css[$part]["background"] .= "background: -o-linear-gradient({$start} {$stop}%, {$end});";
                 $css[$part]["-pie-background"] = "linear-gradient({$start} {$stop}%, {$end})";
             }
             unset($css[$part]["gradient-start-color"]);
             unset($css[$part]["gradient-end-color"]);
             unset($css[$part]["gradient-stop"]);
             unset($css[$part]["gradient-start-opacity"]);
             unset($css[$part]["gradient-end-opacity"]);
         }
         if (isset($styles["box-shadow-width"])) {
             $width = $styles["box-shadow-width"];
             $left = $styles["box-shadow-offset-left"];
             $top = $styles["box-shadow-offset-top"];
             $color = isset($styles["box-shadow-color"]) ? $styles["box-shadow-color"] : '';
             if ($color != '') {
                 $css[$part]["box-shadow"] = "{$left} {$top} {$width} {$color}";
             }
             unset($css[$part]["box-shadow-width"]);
             unset($css[$part]["box-shadow-offset-left"]);
             unset($css[$part]["box-shadow-offset-top"]);
             unset($css[$part]["box-shadow-color"]);
         }
         if (isset($styles["text-shadow-width"])) {
             $width = $styles["text-shadow-width"];
             $left = $styles["text-shadow-left"];
             $top = $styles["text-shadow-top"];
             $color = isset($styles["text-shadow-color"]) ? $styles["text-shadow-color"] : '';
             if ($color != '') {
                 $css[$part]["text-shadow"] = "{$left} {$top} {$width} {$color}";
             }
             unset($css[$part]["text-shadow-width"]);
             unset($css[$part]["text-shadow-left"]);
             unset($css[$part]["text-shadow-top"]);
             unset($css[$part]["text-shadow-color"]);
         }
     }
     return $css;
 }