Exemplo n.º 1
0
function et_fb_enqueue_assets_head()
{
    if (et_fb_is_enabled()) {
        // Setup WP media.
        wp_enqueue_media();
    }
}
Exemplo n.º 2
0
 /**
  * Get attachment data for gallery module
  *
  * @param string comma separated gallery ID
  * @param string on|off to determine grid / slider layout
  *
  * @return string JSON encoded array of attachments data
  */
 static function get_gallery($args = array(), $conditional_tags = array(), $current_page = array())
 {
     $attachments = array();
     $defaults = array('gallery_ids' => array(), 'gallery_orderby' => '', 'fullwidth' => 'on');
     $args = wp_parse_args($args, $defaults);
     $attachments_args = array('include' => $args['gallery_ids'], 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'post__in');
     if ('rand' === $args['gallery_orderby']) {
         $attachments_args['orderby'] = 'rand';
     }
     $width = 'on' === $args['fullwidth'] ? 1080 : 400;
     $width = (int) apply_filters('et_pb_gallery_image_width', $width);
     $height = 'on' === $args['fullwidth'] ? 9999 : 284;
     $height = (int) apply_filters('et_pb_gallery_image_height', $height);
     $_attachments = get_posts($attachments_args);
     foreach ($_attachments as $key => $val) {
         $attachments[$key] = $_attachments[$key];
         $attachments[$key]->image_src_full = wp_get_attachment_image_src($val->ID, 'full');
         $attachments[$key]->image_src_thumb = wp_get_attachment_image_src($val->ID, array($width, $height));
         if (et_fb_is_enabled()) {
             $attachments[$key]->image_src_thumb_fullwidth = wp_get_attachment_image_src($val->ID, array(1080, 9999));
             $attachments[$key]->image_src_thumb_grid = wp_get_attachment_image_src($val->ID, array(400, 284));
         }
     }
     return $attachments;
 }
 static function set_style($function_name, $style)
 {
     // do not process all the styles if FB enabled. Only those for modules without fb support
     if (et_fb_is_enabled() && !in_array($function_name, self::get_fb_unsupported_modules())) {
         return;
     }
     $order_class_name = self::get_module_order_class($function_name);
     // Prepend .et_divi_builder class before all CSS rules in the Divi Builder plugin
     if (et_is_builder_plugin_active()) {
         $order_class_name = "et_divi_builder #et_builder_outer_content .{$order_class_name}";
     }
     $selector = str_replace('%%order_class%%', ".{$order_class_name}", $style['selector']);
     $selector = str_replace('%order_class%', ".{$order_class_name}", $selector);
     $selector = apply_filters('et_pb_set_style_selector', $selector, $function_name);
     $declaration = $style['declaration'];
     // New lines are saved as || in CSS Custom settings, remove them
     $declaration = preg_replace('/(\\|\\|)/i', '', $declaration);
     $media_query = isset($style['media_query']) ? $style['media_query'] : 'general';
     if (isset(self::$styles[$media_query][$selector]['declaration'])) {
         self::$styles[$media_query][$selector]['declaration'] = sprintf('%1$s %2$s', self::$styles[$media_query][$selector]['declaration'], $declaration);
     } else {
         self::$styles[$media_query][$selector]['declaration'] = $declaration;
     }
     if (isset($style['priority'])) {
         self::$styles[$media_query][$selector]['priority'] = (int) $style['priority'];
     }
 }
Exemplo n.º 4
0
/**
 * Add "Use Visual Builder" link to WP-Admin bar
 *
 * @return void
 */
function et_fb_add_admin_bar_link()
{
    if (!is_singular(et_builder_get_builder_post_types()) || !et_pb_is_allowed('use_visual_builder')) {
        return;
    }
    global $wp_admin_bar, $wp_the_query;
    $page_url = get_permalink(get_the_ID());
    // Don't add the link, if Frontend Builder has been loaded already
    if (et_fb_is_enabled()) {
        $wp_admin_bar->add_menu(array('id' => 'et-disable-visual-builder', 'title' => esc_html__('Exit Visual Builder', 'et_builder'), 'href' => esc_url($page_url)));
        return;
    }
    $current_object = $wp_the_query->get_queried_object();
    if (!current_user_can('edit_post', $current_object->ID)) {
        return;
    }
    $use_visual_builder_url = et_pb_is_pagebuilder_used(get_the_ID()) ? add_query_arg('et_fb', '1', et_fb_prepare_ssl_link($page_url)) : add_query_arg(array('et_fb_activation_nonce' => wp_create_nonce('et_fb_activation_nonce_' . get_the_ID())), $page_url);
    $wp_admin_bar->add_menu(array('id' => 'et-use-visual-builder', 'title' => esc_html__('Enable Visual Builder', 'et_builder'), 'href' => esc_url($use_visual_builder_url)));
}