Example #1
0
function popmake_get_popup_theme_google_fonts($popup_theme_id)
{
    $fonts_found = array();
    $theme = popmake_get_popup_theme_data_attr($popup_theme_id);
    $google_fonts = popmake_get_google_webfonts_list();
    if (!empty($theme['title']['font_family']) && is_string($theme['title']['font_family']) && array_key_exists($theme['title']['font_family'], $google_fonts)) {
        $variant = $theme['title']['font_weight'] != 'normal' ? $theme['title']['font_weight'] : '';
        if ($theme['title']['font_style'] == 'italic') {
            $variant .= 'italic';
        }
        $fonts_found[$theme['title']['font_family']][$variant] = $variant;
    }
    if (!empty($theme['content']['font_family']) && is_string($theme['content']['font_family']) && array_key_exists($theme['content']['font_family'], $google_fonts)) {
        $variant = $theme['content']['font_weight'] != 'normal' ? $theme['content']['font_weight'] : '';
        if ($theme['content']['font_style'] == 'italic') {
            $variant .= 'italic';
        }
        $fonts_found[$theme['content']['font_family']][$variant] = $variant;
    }
    if (!empty($theme['close']['font_family']) && is_string($theme['close']['font_family']) && array_key_exists($theme['close']['font_family'], $google_fonts)) {
        $variant = $theme['close']['font_weight'] != 'normal' ? $theme['close']['font_weight'] : '';
        if ($theme['close']['font_style'] == 'italic') {
            $variant .= 'italic';
        }
        $fonts_found[$theme['close']['font_family']][$variant] = $variant;
    }
    return $fonts_found;
}
function popmake_generate_theme_styles($popup_theme_id)
{
    $styles = array('overlay' => array(), 'container' => array(), 'title' => array(), 'content' => array(), 'close' => array());
    $theme = popmake_get_popup_theme_data_attr($popup_theme_id);
    extract($theme);
    if (empty($overlay) || empty($container) || empty($title) || empty($content) || empty($close)) {
        return array();
    }
    /*
     * Overlay Styles
     */
    if (!empty($overlay['background_color'])) {
        $styles['overlay']['background-color'] = popmake_get_rgba_value($overlay['background_color'], $overlay['background_opacity']);
    }
    /*
     * Container Styles
     */
    $styles['container'] = array('padding' => "{$container['padding']}px", 'border-radius' => "{$container['border_radius']}px", 'border' => popmake_get_border_style($container['border_width'], $container['border_style'], $container['border_color']), 'box-shadow' => popmake_get_box_shadow_style($container['boxshadow_horizontal'], $container['boxshadow_vertical'], $container['boxshadow_blur'], $container['boxshadow_spread'], $container['boxshadow_color'], $container['boxshadow_opacity'], $container['boxshadow_inset']));
    if (!empty($container['background_color'])) {
        $styles['container']['background-color'] = popmake_get_rgba_value($container['background_color'], $container['background_opacity']);
    }
    /*
     * Title Styles
     */
    $styles['title'] = array('color' => $title['font_color'], 'text-align' => $title['text_align'], 'text-shadow' => popmake_get_text_shadow_style($title['textshadow_horizontal'], $title['textshadow_vertical'], $title['textshadow_blur'], $title['textshadow_color'], $title['textshadow_opacity']), 'font-family' => $title['font_family'], 'font-weight' => $title['font_weight'], 'font-size' => "{$title['font_size']}px", 'font-style' => $title['font_style'], 'line-height' => "{$title['line_height']}px");
    /*
     * Content Styles
     */
    $styles['content'] = array('color' => $content['font_color'], 'font-family' => $content['font_family'], 'font-weight' => $content['font_weight'], 'font-style' => $content['font_style']);
    /*
     * Close Styles
     */
    $styles['close'] = array('height' => empty($close['height']) || $close['height'] <= 0 ? 'auto' : "{$close['height']}px", 'width' => empty($close['width']) || $close['width'] <= 0 ? 'auto' : "{$close['width']}px", 'left' => 'auto', 'right' => 'auto', 'bottom' => 'auto', 'top' => 'auto', 'padding' => "{$close['padding']}px", 'color' => $close['font_color'], 'font-family' => $close['font_family'], 'font-weight' => $close['font_weight'], 'font-size' => "{$close['font_size']}px", 'font-style' => $close['font_style'], 'line-height' => "{$close['line_height']}px", 'border' => popmake_get_border_style($close['border_width'], $close['border_style'], $close['border_color']), 'border-radius' => "{$close['border_radius']}px", 'box-shadow' => popmake_get_box_shadow_style($close['boxshadow_horizontal'], $close['boxshadow_vertical'], $close['boxshadow_blur'], $close['boxshadow_spread'], $close['boxshadow_color'], $close['boxshadow_opacity'], $close['boxshadow_inset']), 'text-shadow' => popmake_get_text_shadow_style($close['textshadow_horizontal'], $close['textshadow_vertical'], $close['textshadow_blur'], $close['textshadow_color'], $close['textshadow_opacity']));
    if (!empty($close['background_color'])) {
        $styles['close']['background-color'] = popmake_get_rgba_value($close['background_color'], $close['background_opacity']);
    }
    switch ($close['location']) {
        case "topleft":
            $styles['close']['top'] = "{$close['position_top']}px";
            $styles['close']['left'] = "{$close['position_left']}px";
            break;
        case "topright":
            $styles['close']['top'] = "{$close['position_top']}px";
            $styles['close']['right'] = "{$close['position_right']}px";
            break;
        case "bottomleft":
            $styles['close']['bottom'] = "{$close['position_bottom']}px";
            $styles['close']['left'] = "{$close['position_left']}px";
            break;
        case "bottomright":
            $styles['close']['bottom'] = "{$close['position_bottom']}px";
            $styles['close']['right'] = "{$close['position_right']}px";
            break;
    }
    return apply_filters('popmake_generate_theme_styles', $styles, $popup_theme_id, $theme);
}
function popmake_get_popup_themes_data()
{
    $themes = popmake_get_all_popup_themes();
    $popmake_themes = array();
    foreach ($themes as $theme) {
        $popmake_themes[$theme->ID] = popmake_get_popup_theme_data_attr($theme->ID);
    }
    wp_reset_postdata();
    return apply_filters('popmake_get_popup_themes_data', $popmake_themes);
}
function popmake_get_popup_themes_data()
{
    $query = get_posts(array('post_type' => 'popup_theme', 'posts_per_page' => -1));
    $popmake_themes = array();
    foreach ($query as $theme) {
        $popmake_themes[$theme->ID] = popmake_get_popup_theme_data_attr($theme->ID);
    }
    wp_reset_postdata();
    return apply_filters('popmake_get_popup_themes_data', $popmake_themes);
}