EduardET

Untitled

Mar 6th, 2018
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 49.02 KB | None | 0 0
  1. <?php
  2.  
  3. class ET_Builder_Module_Blog extends ET_Builder_Module_Type_PostBased {
  4.     function init() {
  5.         $this->name       = esc_html__( 'Blog', 'et_builder' );
  6.         $this->slug       = 'et_pb_blog';
  7.         $this->fb_support = true;
  8.  
  9.         $this->whitelisted_fields = array(
  10.             'fullwidth',
  11.             'posts_number',
  12.             'include_categories',
  13.             'meta_date',
  14.             'show_thumbnail',
  15.             'show_content',
  16.             'show_more',
  17.             'show_author',
  18.             'show_date',
  19.             'show_categories',
  20.             'show_comments',
  21.             'show_pagination',
  22.             'offset_number',
  23.             'background_layout',
  24.             'admin_label',
  25.             'module_id',
  26.             'module_class',
  27.             'masonry_tile_background_color',
  28.             'use_overlay',
  29.             'overlay_icon_color',
  30.             'hover_overlay_color',
  31.             'hover_icon',
  32.         );
  33.  
  34.         $this->fields_defaults = array(
  35.             'fullwidth'         => array( 'on' ),
  36.             'posts_number'      => array( 10, 'add_default_setting' ),
  37.             'meta_date'         => array( 'M j, Y', 'add_default_setting' ),
  38.             'show_thumbnail'    => array( 'on' ),
  39.             'show_content'      => array( 'off' ),
  40.             'show_more'         => array( 'off' ),
  41.             'show_author'       => array( 'on' ),
  42.             'show_date'         => array( 'on' ),
  43.             'show_categories'   => array( 'on' ),
  44.             'show_comments'     => array( 'off' ),
  45.             'show_pagination'   => array( 'on' ),
  46.             'offset_number'     => array( 0, 'only_default_setting' ),
  47.             'background_layout' => array( 'light' ),
  48.             'use_overlay'       => array( 'off' ),
  49.         );
  50.  
  51.         $this->main_css_element = '%%order_class%% .et_pb_post';
  52.  
  53.         $this->options_toggles = array(
  54.             'general'  => array(
  55.                 'toggles' => array(
  56.                     'main_content' => esc_html__( 'Content', 'et_builder' ),
  57.                     'elements'     => esc_html__( 'Elements', 'et_builder' ),
  58.                     'background'   => esc_html__( 'Background', 'et_builder' ),
  59.                 ),
  60.             ),
  61.             'advanced' => array(
  62.                 'toggles' => array(
  63.                     'layout'  => esc_html__( 'Layout', 'et_builder' ),
  64.                     'overlay' => esc_html__( 'Overlay', 'et_builder' ),
  65.                     'image' => array(
  66.                         'title' => esc_html__( 'Image', 'et_builder' ),
  67.                         'priority' => 51,
  68.                     ),
  69.                     'text'    => array(
  70.                         'title'    => esc_html__( 'Text', 'et_builder' ),
  71.                         'priority' => 49,
  72.                     ),
  73.                 ),
  74.             ),
  75.         );
  76.  
  77.         $this->advanced_options = array(
  78.             'border' => array(
  79.                 'css' => array(
  80.                     'main' => array(
  81.                         'border_radii'  => "%%order_class%% .et_pb_blog_grid .et_pb_post",
  82.                         'border_styles' => "%%order_class%% .et_pb_blog_grid .et_pb_post",
  83.                     ),
  84.                 ),
  85.                 'depends_to'      => array( 'fullwidth' ),
  86.                 'depends_show_if' => 'off',
  87.                 'defaults' => array(
  88.                     'border_radii'  => 'on|0px|0px|0px|0px',
  89.                     'border_styles' => array(
  90.                         'width' => '1px',
  91.                         'color' => '#d8d8d8',
  92.                         'style' => 'solid',
  93.                     ),
  94.                 ),
  95.             ),
  96.             'fonts' => array(
  97.                 'header' => array(
  98.                     'label'    => esc_html__( 'Title', 'et_builder' ),
  99.                     'css'      => array(
  100.                         'main' => "{$this->main_css_element} .entry-title",
  101.                         'color' => "{$this->main_css_element} .entry-title a",
  102.                         'plugin_main' => "{$this->main_css_element} .entry-title, {$this->main_css_element} .entry-title a",
  103.                         'important' => 'all',
  104.                     ),
  105.                     'header_level' => array(
  106.                         'default' => 'h2',
  107.                         'computed_affects' => array(
  108.                             '__posts',
  109.                         ),
  110.                     ),
  111.                 ),
  112.                 'body'   => array(
  113.                     'label'    => esc_html__( 'Body', 'et_builder' ),
  114.                     'css'      => array(
  115.                         'main'        => "{$this->main_css_element} .post-content, %%order_class%%.et_pb_bg_layout_light .et_pb_post .post-content p, %%order_class%%.et_pb_bg_layout_dark .et_pb_post .post-content p",
  116.                         'color'       => "{$this->main_css_element}, {$this->main_css_element} .post-content *",
  117.                         'line_height' => "{$this->main_css_element} p",
  118.                         'plugin_main' => "{$this->main_css_element}, %%order_class%%.et_pb_bg_layout_light .et_pb_post .post-content p, %%order_class%%.et_pb_bg_layout_dark .et_pb_post .post-content p, %%order_class%%.et_pb_bg_layout_light .et_pb_post a.more-link, %%order_class%%.et_pb_bg_layout_dark .et_pb_post a.more-link",
  119.                     ),
  120.                 ),
  121.                 'meta' => array(
  122.                     'label'    => esc_html__( 'Meta', 'et_builder' ),
  123.                     'css'      => array(
  124.                         'main'        => "{$this->main_css_element} .post-meta, {$this->main_css_element} .post-meta a",
  125.                         'plugin_main' => "{$this->main_css_element} .post-meta, {$this->main_css_element} .post-meta a, {$this->main_css_element} .post-meta span",
  126.                     ),
  127.                 ),
  128.                 'pagination' => array(
  129.                     'label'    => esc_html__( 'Pagination', 'et_builder' ),
  130.                     'css'      => array(
  131.                         'main' => function_exists( 'wp_pagenavi' ) ? '%%order_class%% .wp-pagenavi a, %%order_class%% .wp-pagenavi span' : '%%order_class%% .pagination a',
  132.                         'important'  => function_exists( 'wp_pagenavi' ) ? 'all' : array(),
  133.                         'text_align' => '%%order_class%% .wp-pagenavi',
  134.                     ),
  135.                     'hide_text_align' => ! function_exists( 'wp_pagenavi' ),
  136.                     'text_align' => array(
  137.                         'options' => et_builder_get_text_orientation_options( array( 'justified' ), array() ),
  138.                     ),
  139.                 ),
  140.             ),
  141.             'background' => array(
  142.                 'css' => array(
  143.                     'main' => '%%order_class%%',
  144.                 ),
  145.             ),
  146.             'custom_margin_padding' => array(
  147.                 'css'           => array(
  148.                     'main' => '%%order_class%%',
  149.                 ),
  150.             ),
  151.             'max_width' => array(),
  152.             'text'      => array(
  153.                 'css' => array(
  154.                     'text_shadow' => '%%order_class%%',
  155.                 ),
  156.             ),
  157.             'filters' => array(
  158.                 'child_filters_target' => array(
  159.                     'tab_slug' => 'advanced',
  160.                     'toggle_slug' => 'image',
  161.                 ),
  162.             ),
  163.             'image' => array(
  164.                 'css' => array(
  165.                     'main' => array(
  166.                         '%%order_class%% img',
  167.                         '%%order_class%% .et_pb_slides',
  168.                         '%%order_class%% .et_pb_video_overlay',
  169.                     ),
  170.                 ),
  171.             ),
  172.         );
  173.  
  174.         $this->custom_css_options = array(
  175.             'title' => array(
  176.                 'label'    => esc_html__( 'Title', 'et_builder' ),
  177.                 'selector' => '.entry-title',
  178.             ),
  179.             'content' => array(
  180.                 'label'    => esc_html__( 'Content', 'et_builder' ),
  181.                 'selector' => '.post-content',
  182.             ),
  183.             'post_meta' => array(
  184.                 'label'    => esc_html__( 'Post Meta', 'et_builder' ),
  185.                 'selector' => '.post-meta',
  186.             ),
  187.             'pagenavi' => array(
  188.                 'label'    => esc_html__( 'Pagenavi', 'et_builder' ),
  189.                 'selector' => '.wp_pagenavi',
  190.             ),
  191.             'featured_image' => array(
  192.                 'label'    => esc_html__( 'Featured Image', 'et_builder' ),
  193.                 'selector' => '.et_pb_image_container',
  194.             ),
  195.             'read_more' => array(
  196.                 'label'    => esc_html__( 'Read More Button', 'et_builder' ),
  197.                 'selector' => '.more-link',
  198.             ),
  199.         );
  200.     }
  201.  
  202.     function get_fields() {
  203.         $fields = array(
  204.             'fullwidth' => array(
  205.                 'label'             => esc_html__( 'Layout', 'et_builder' ),
  206.                 'type'              => 'select',
  207.                 'option_category'   => 'layout',
  208.                 'options'           => array(
  209.                     'on'  => esc_html__( 'Fullwidth', 'et_builder' ),
  210.                     'off' => esc_html__( 'Grid', 'et_builder' ),
  211.                 ),
  212.                 'affects'           => array(
  213.                     'background_layout',
  214.                     'masonry_tile_background_color',
  215.                     'border_radii_fullwidth',
  216.                     'border_styles_fullwidth',
  217.                     'border_radii',
  218.                     'border_styles',
  219.                 ),
  220.                 'description'        => esc_html__( 'Toggle between the various blog layout types.', 'et_builder' ),
  221.                 'computed_affects'   => array(
  222.                     '__posts',
  223.                 ),
  224.                 'tab_slug'           => 'advanced',
  225.                 'toggle_slug'        => 'layout',
  226.             ),
  227.             'posts_number' => array(
  228.                 'label'             => esc_html__( 'Posts Number', 'et_builder' ),
  229.                 'type'              => 'text',
  230.                 'option_category'   => 'configuration',
  231.                 'description'       => esc_html__( 'Choose how much posts you would like to display per page.', 'et_builder' ),
  232.                 'computed_affects'   => array(
  233.                     '__posts',
  234.                 ),
  235.                 'toggle_slug'       => 'main_content',
  236.             ),
  237.             'include_categories' => array(
  238.                 'label'            => esc_html__( 'Include Categories', 'et_builder' ),
  239.                 'renderer'         => 'et_builder_include_categories_option',
  240.                 'option_category'  => 'basic_option',
  241.                 'renderer_options' => array(
  242.                     'use_terms' => false,
  243.                 ),
  244.                 'description'      => esc_html__( 'Choose which categories you would like to include in the feed.', 'et_builder' ),
  245.                 'toggle_slug'      => 'main_content',
  246.                 'computed_affects' => array(
  247.                     '__posts',
  248.                 ),
  249.             ),
  250.             'meta_date' => array(
  251.                 'label'             => esc_html__( 'Meta Date Format', 'et_builder' ),
  252.                 'type'              => 'text',
  253.                 'option_category'   => 'configuration',
  254.                 'description'       => esc_html__( 'If you would like to adjust the date format, input the appropriate PHP date format here.', 'et_builder' ),
  255.                 'toggle_slug'       => 'main_content',
  256.                 'computed_affects'  => array(
  257.                     '__posts',
  258.                 ),
  259.             ),
  260.             'show_thumbnail' => array(
  261.                 'label'             => esc_html__( 'Show Featured Image', 'et_builder' ),
  262.                 'type'              => 'yes_no_button',
  263.                 'option_category'   => 'configuration',
  264.                 'options'           => array(
  265.                     'on'  => esc_html__( 'Yes', 'et_builder' ),
  266.                     'off' => esc_html__( 'No', 'et_builder' ),
  267.                 ),
  268.                 'description'       => esc_html__( 'This will turn thumbnails on and off.', 'et_builder' ),
  269.                 'computed_affects'  => array(
  270.                     '__posts',
  271.                 ),
  272.                 'toggle_slug'       => 'elements',
  273.             ),
  274.             'show_content' => array(
  275.                 'label'             => esc_html__( 'Content', 'et_builder' ),
  276.                 'type'              => 'select',
  277.                 'option_category'   => 'configuration',
  278.                 'options'           => array(
  279.                     'off' => esc_html__( 'Show Excerpt', 'et_builder' ),
  280.                     'on'  => esc_html__( 'Show Content', 'et_builder' ),
  281.                 ),
  282.                 'affects'           => array(
  283.                     'show_more',
  284.                 ),
  285.                 'description'       => esc_html__( 'Showing the full content will not truncate your posts on the index page. Showing the excerpt will only display your excerpt text.', 'et_builder' ),
  286.                 'toggle_slug'       => 'main_content',
  287.                 'computed_affects'  => array(
  288.                     '__posts',
  289.                 ),
  290.             ),
  291.             'show_more' => array(
  292.                 'label'             => esc_html__( 'Show Read More Button', 'et_builder' ),
  293.                 'type'              => 'yes_no_button',
  294.                 'option_category'   => 'configuration',
  295.                 'options'           => array(
  296.                     'off' => esc_html__( 'No', 'et_builder' ),
  297.                     'on'  => esc_html__( 'Yes', 'et_builder' ),
  298.                 ),
  299.                 'depends_show_if'   => 'off',
  300.                 'description'       => esc_html__( 'Here you can define whether to show "read more" link after the excerpts or not.', 'et_builder' ),
  301.                 'computed_affects'   => array(
  302.                     '__posts',
  303.                 ),
  304.                 'toggle_slug'       => 'elements',
  305.             ),
  306.             'show_author' => array(
  307.                 'label'             => esc_html__( 'Show Author', 'et_builder' ),
  308.                 'type'              => 'yes_no_button',
  309.                 'option_category'   => 'configuration',
  310.                 'options'           => array(
  311.                     'on'  => esc_html__( 'Yes', 'et_builder' ),
  312.                     'off' => esc_html__( 'No', 'et_builder' ),
  313.                 ),
  314.                 'description'        => esc_html__( 'Turn on or off the author link.', 'et_builder' ),
  315.                 'computed_affects'   => array(
  316.                     '__posts',
  317.                 ),
  318.                 'toggle_slug'        => 'elements',
  319.             ),
  320.             'show_date' => array(
  321.                 'label'             => esc_html__( 'Show Date', 'et_builder' ),
  322.                 'type'              => 'yes_no_button',
  323.                 'option_category'   => 'configuration',
  324.                 'options'           => array(
  325.                     'on'  => esc_html__( 'Yes', 'et_builder' ),
  326.                     'off' => esc_html__( 'No', 'et_builder' ),
  327.                 ),
  328.                 'description'        => esc_html__( 'Turn the date on or off.', 'et_builder' ),
  329.                 'computed_affects'   => array(
  330.                     '__posts',
  331.                 ),
  332.                 'toggle_slug'        => 'elements',
  333.             ),
  334.             'show_categories' => array(
  335.                 'label'             => esc_html__( 'Show Categories', 'et_builder' ),
  336.                 'type'              => 'yes_no_button',
  337.                 'option_category'   => 'configuration',
  338.                 'options'           => array(
  339.                     'on'  => esc_html__( 'Yes', 'et_builder' ),
  340.                     'off' => esc_html__( 'No', 'et_builder' ),
  341.                 ),
  342.                 'description'        => esc_html__( 'Turn the category links on or off.', 'et_builder' ),
  343.                 'computed_affects'   => array(
  344.                     '__posts',
  345.                 ),
  346.                 'toggle_slug'        => 'elements',
  347.             ),
  348.             'show_comments' => array(
  349.                 'label'             => esc_html__( 'Show Comment Count', 'et_builder' ),
  350.                 'type'              => 'yes_no_button',
  351.                 'option_category'   => 'configuration',
  352.                 'options'           => array(
  353.                     'on'  => esc_html__( 'Yes', 'et_builder' ),
  354.                     'off' => esc_html__( 'No', 'et_builder' ),
  355.                 ),
  356.                 'description'        => esc_html__( 'Turn comment count on and off.', 'et_builder' ),
  357.                 'computed_affects'   => array(
  358.                     '__posts',
  359.                 ),
  360.                 'toggle_slug'        => 'elements',
  361.             ),
  362.             'show_pagination' => array(
  363.                 'label'             => esc_html__( 'Show Pagination', 'et_builder' ),
  364.                 'type'              => 'yes_no_button',
  365.                 'option_category'   => 'configuration',
  366.                 'options'           => array(
  367.                     'on'  => esc_html__( 'Yes', 'et_builder' ),
  368.                     'off' => esc_html__( 'No', 'et_builder' ),
  369.                 ),
  370.                 'description'        => esc_html__( 'Turn pagination on and off.', 'et_builder' ),
  371.                 'computed_affects'   => array(
  372.                     '__posts',
  373.                 ),
  374.                 'toggle_slug'        => 'elements',
  375.             ),
  376.             'offset_number' => array(
  377.                 'label'            => esc_html__( 'Offset Number', 'et_builder' ),
  378.                 'type'             => 'text',
  379.                 'option_category'  => 'configuration',
  380.                 'description'      => esc_html__( 'Choose how many posts you would like to offset by', 'et_builder' ),
  381.                 'toggle_slug'      => 'main_content',
  382.                 'computed_affects' => array(
  383.                     '__posts',
  384.                 ),
  385.             ),
  386.             'use_overlay' => array(
  387.                 'label'             => esc_html__( 'Featured Image Overlay', 'et_builder' ),
  388.                 'type'              => 'yes_no_button',
  389.                 'option_category'   => 'layout',
  390.                 'options'           => array(
  391.                     'off' => esc_html__( 'Off', 'et_builder' ),
  392.                     'on'  => esc_html__( 'On', 'et_builder' ),
  393.                 ),
  394.                 'affects'           => array(
  395.                     'overlay_icon_color',
  396.                     'hover_overlay_color',
  397.                     'hover_icon',
  398.                 ),
  399.                 'description'       => esc_html__( 'If enabled, an overlay color and icon will be displayed when a visitors hovers over the featured image of a post.', 'et_builder' ),
  400.                 'computed_affects'   => array(
  401.                     '__posts',
  402.                 ),
  403.                 'tab_slug'          => 'advanced',
  404.                 'toggle_slug'       => 'overlay',
  405.             ),
  406.             'overlay_icon_color' => array(
  407.                 'label'             => esc_html__( 'Overlay Icon Color', 'et_builder' ),
  408.                 'type'              => 'color-alpha',
  409.                 'custom_color'      => true,
  410.                 'depends_show_if'   => 'on',
  411.                 'tab_slug'          => 'advanced',
  412.                 'toggle_slug'       => 'overlay',
  413.                 'description'       => esc_html__( 'Here you can define a custom color for the overlay icon', 'et_builder' ),
  414.             ),
  415.             'hover_overlay_color' => array(
  416.                 'label'             => esc_html__( 'Hover Overlay Color', 'et_builder' ),
  417.                 'type'              => 'color-alpha',
  418.                 'custom_color'      => true,
  419.                 'depends_show_if'   => 'on',
  420.                 'tab_slug'          => 'advanced',
  421.                 'toggle_slug'       => 'overlay',
  422.                 'description'       => esc_html__( 'Here you can define a custom color for the overlay', 'et_builder' ),
  423.             ),
  424.             'hover_icon' => array(
  425.                 'label'               => esc_html__( 'Hover Icon Picker', 'et_builder' ),
  426.                 'type'                => 'text',
  427.                 'option_category'     => 'configuration',
  428.                 'class'               => array( 'et-pb-font-icon' ),
  429.                 'renderer'            => 'et_pb_get_font_icon_list',
  430.                 'renderer_with_field' => true,
  431.                 'depends_show_if'     => 'on',
  432.                 'description'         => esc_html__( 'Here you can define a custom icon for the overlay', 'et_builder' ),
  433.                 'tab_slug'            => 'advanced',
  434.                 'toggle_slug'         => 'overlay',
  435.                 'computed_affects'    => array(
  436.                     '__posts',
  437.                 ),
  438.             ),
  439.             'background_layout' => array(
  440.                 'label'       => esc_html__( 'Text Color', 'et_builder' ),
  441.                 'type'        => 'select',
  442.                 'option_category' => 'color_option',
  443.                 'options'           => array(
  444.                     'light' => esc_html__( 'Dark', 'et_builder' ),
  445.                     'dark'  => esc_html__( 'Light', 'et_builder' ),
  446.                 ),
  447.                 'depends_default' => true,
  448.                 'tab_slug'        => 'advanced',
  449.                 'toggle_slug'     => 'text',
  450.                 'description'     => esc_html__( 'Here you can choose whether your text should be light or dark. If you are working with a dark background, then your text should be light. If your background is light, then your text should be set to dark.', 'et_builder' ),
  451.             ),
  452.             'masonry_tile_background_color' => array(
  453.                 'label'             => esc_html__( 'Grid Tile Background Color', 'et_builder' ),
  454.                 'type'              => 'color-alpha',
  455.                 'custom_color'      => true,
  456.                 'toggle_slug'       => 'background',
  457.                 'depends_show_if'   => 'off',
  458.                 'depends_to'        => array(
  459.                     'fullwidth',
  460.                 ),
  461.             ),
  462.             'disabled_on' => array(
  463.                 'label'           => esc_html__( 'Disable on', 'et_builder' ),
  464.                 'type'            => 'multiple_checkboxes',
  465.                 'options'         => array(
  466.                     'phone'   => esc_html__( 'Phone', 'et_builder' ),
  467.                     'tablet'  => esc_html__( 'Tablet', 'et_builder' ),
  468.                     'desktop' => esc_html__( 'Desktop', 'et_builder' ),
  469.                 ),
  470.                 'additional_att'  => 'disable_on',
  471.                 'option_category' => 'configuration',
  472.                 'description'     => esc_html__( 'This will disable the module on selected devices', 'et_builder' ),
  473.                 'tab_slug'        => 'custom_css',
  474.                 'toggle_slug'     => 'visibility',
  475.             ),
  476.             'admin_label' => array(
  477.                 'label'       => esc_html__( 'Admin Label', 'et_builder' ),
  478.                 'type'        => 'text',
  479.                 'description' => esc_html__( 'This will change the label of the module in the builder for easy identification.', 'et_builder' ),
  480.                 'toggle_slug' => 'admin_label',
  481.             ),
  482.             'module_id' => array(
  483.                 'label'           => esc_html__( 'CSS ID', 'et_builder' ),
  484.                 'type'            => 'text',
  485.                 'option_category' => 'configuration',
  486.                 'tab_slug'        => 'custom_css',
  487.                 'toggle_slug'     => 'classes',
  488.                 'option_class'    => 'et_pb_custom_css_regular',
  489.             ),
  490.             'module_class' => array(
  491.                 'label'           => esc_html__( 'CSS Class', 'et_builder' ),
  492.                 'type'            => 'text',
  493.                 'option_category' => 'configuration',
  494.                 'tab_slug'        => 'custom_css',
  495.                 'toggle_slug'     => 'classes',
  496.                 'option_class'    => 'et_pb_custom_css_regular',
  497.             ),
  498.             '__posts' => array(
  499.                 'type' => 'computed',
  500.                 'computed_callback' => array( 'ET_Builder_Module_Blog', 'get_blog_posts' ),
  501.                 'computed_depends_on' => array(
  502.                     'fullwidth',
  503.                     'posts_number',
  504.                     'include_categories',
  505.                     'meta_date',
  506.                     'show_thumbnail',
  507.                     'show_content',
  508.                     'show_more',
  509.                     'show_author',
  510.                     'show_date',
  511.                     'show_categories',
  512.                     'show_comments',
  513.                     'show_pagination',
  514.                     'offset_number',
  515.                     'use_overlay',
  516.                     'hover_icon',
  517.                     'header_level',
  518.                     '__page',
  519.                 ),
  520.                 'computed_minimum' => array(
  521.                     'posts_number',
  522.                 ),
  523.             ),
  524.             '__page'          => array(
  525.                 'type'              => 'computed',
  526.                 'computed_callback' => array( 'ET_Builder_Module_Blog', 'get_blog_posts' ),
  527.                 'computed_affects'  => array(
  528.                     '__posts',
  529.                 ),
  530.             ),
  531.         );
  532.         return $fields;
  533.     }
  534.  
  535.     /**
  536.      * Get blog posts for blog module
  537.      *
  538.      * @param array   arguments that is being used by et_pb_blog
  539.      * @return string blog post markup
  540.      */
  541.     static function get_blog_posts( $args = array(), $conditional_tags = array(), $current_page = array() ) {
  542.         global $paged, $post, $wp_query, $et_fb_processing_shortcode_object, $et_pb_rendering_column_content;
  543.  
  544.         $global_processing_original_value = $et_fb_processing_shortcode_object;
  545.  
  546.         // Default params are combination of attributes that is used by et_pb_blog and
  547.         // conditional tags that need to be simulated (due to AJAX nature) by passing args
  548.         $defaults = array(
  549.             'fullwidth'                     => '',
  550.             'posts_number'                  => '',
  551.             'include_categories'            => '',
  552.             'meta_date'                     => '',
  553.             'show_thumbnail'                => '',
  554.             'show_content'                  => '',
  555.             'show_author'                   => '',
  556.             'show_date'                     => '',
  557.             'show_categories'               => '',
  558.             'show_comments'                 => '',
  559.             'show_pagination'               => '',
  560.             'background_layout'             => '',
  561.             'show_more'                     => '',
  562.             'offset_number'                 => '',
  563.             'masonry_tile_background_color' => '',
  564.             'overlay_icon_color'            => '',
  565.             'hover_overlay_color'           => '',
  566.             'hover_icon'                    => '',
  567.             'use_overlay'                   => '',
  568.             'header_level'                  => 'h2',
  569.         );
  570.  
  571.         // WordPress' native conditional tag is only available during page load. It'll fail during component update because
  572.         // et_pb_process_computed_property() is loaded in admin-ajax.php. Thus, use WordPress' conditional tags on page load and
  573.         // rely to passed $conditional_tags for AJAX call
  574.         $is_front_page               = et_fb_conditional_tag( 'is_front_page', $conditional_tags );
  575.         $is_search                   = et_fb_conditional_tag( 'is_search', $conditional_tags );
  576.         $is_single                   = et_fb_conditional_tag( 'is_single', $conditional_tags );
  577.         $et_is_builder_plugin_active = et_fb_conditional_tag( 'et_is_builder_plugin_active', $conditional_tags );
  578.  
  579.         $container_is_closed = false;
  580.  
  581.         // remove all filters from WP audio shortcode to make sure current theme doesn't add any elements into audio module
  582.         remove_all_filters( 'wp_audio_shortcode_library' );
  583.         remove_all_filters( 'wp_audio_shortcode' );
  584.         remove_all_filters( 'wp_audio_shortcode_class' );
  585.  
  586.         $args = wp_parse_args( $args, $defaults );
  587.  
  588.         $processed_header_level = et_pb_process_header_level( $args['header_level'], 'h2' );
  589.  
  590.         $overlay_output = '';
  591.         $hover_icon = '';
  592.  
  593.         if ( 'on' === $args['use_overlay'] ) {
  594.             $data_icon = '' !== $args['hover_icon']
  595.                 ? sprintf(
  596.                     ' data-icon="%1$s"',
  597.                     esc_attr( et_pb_process_font_icon( $args['hover_icon'] ) )
  598.                 )
  599.                 : '';
  600.  
  601.             $overlay_output = sprintf(
  602.                 '<span class="et_overlay%1$s"%2$s></span>',
  603.                 ( '' !== $args['hover_icon'] ? ' et_pb_inline_icon' : '' ),
  604.                 $data_icon
  605.             );
  606.         }
  607.  
  608.         $overlay_class = 'on' === $args['use_overlay'] ? ' et_pb_has_overlay' : '';
  609.  
  610.         $query_args = array(
  611.             'posts_per_page' => intval( $args['posts_number'] ),
  612.             'post_status'    => 'publish',
  613.         );
  614.  
  615.         if ( defined( 'DOING_AJAX' ) && isset( $current_page['paged'] ) ) {
  616.             $paged = intval( $current_page['paged'] );
  617.         } else {
  618.             $paged = $is_front_page ? get_query_var( 'page' ) : get_query_var( 'paged' );
  619.         }
  620.  
  621.         // support pagination in VB
  622.         if ( isset( $args['__page'] ) ) {
  623.             $paged = $args['__page'];
  624.         }
  625.  
  626.         if ( '' !== $args['include_categories'] ) {
  627.             $query_args['cat'] = $args['include_categories'];
  628.         }
  629.  
  630.         if ( ! $is_search ) {
  631.             $query_args['paged'] = $paged;
  632.         }
  633.  
  634.         if ( '' !== $args['offset_number'] && ! empty( $args['offset_number'] ) ) {
  635.             /**
  636.              * Offset + pagination don't play well. Manual offset calculation required
  637.              * @see: https://codex.wordpress.org/Making_Custom_Queries_using_Offset_and_Pagination
  638.              */
  639.             if ( $paged > 1 ) {
  640.                 $query_args['offset'] = ( ( $paged - 1 ) * intval( $args['posts_number'] ) ) + intval( $args['offset_number'] );
  641.             } else {
  642.                 $query_args['offset'] = intval( $args['offset_number'] );
  643.             }
  644.         }
  645.  
  646.         if ( $is_single ) {
  647.             $query_args['post__not_in'][] = get_the_ID();
  648.         }
  649.  
  650.         // Get query
  651.         $query = new WP_Query( $query_args );
  652.  
  653.         // Keep page's $wp_query global
  654.         $wp_query_page = $wp_query;
  655.  
  656.         // Turn page's $wp_query into this module's query
  657.         $wp_query = $query;
  658.  
  659.         ob_start();
  660.  
  661.         if ( $query->have_posts() ) {
  662.             if ( 'on' !== $args['fullwidth'] ) {
  663.                 echo '<div class="et_pb_salvattore_content" data-columns>';
  664.             }
  665.  
  666.             while( $query->have_posts() ) {
  667.                 $query->the_post();
  668.                 global $et_fb_processing_shortcode_object;
  669.  
  670.                 $global_processing_original_value = $et_fb_processing_shortcode_object;
  671.  
  672.                 // reset the fb processing flag
  673.                 $et_fb_processing_shortcode_object = false;
  674.  
  675.                 $thumb          = '';
  676.                 $width          = 'on' === $args['fullwidth'] ? 1080 : 400;
  677.                 $width          = (int) apply_filters( 'et_pb_blog_image_width', $width );
  678.                 $height         = 'on' === $args['fullwidth'] ? 675 : 250;
  679.                 $height         = (int) apply_filters( 'et_pb_blog_image_height', $height );
  680.                 $classtext      = 'on' === $args['fullwidth'] ? 'et_pb_post_main_image' : '';
  681.                 $titletext      = get_the_title();
  682.                 $thumbnail      = get_thumbnail( $width, $height, $classtext, $titletext, $titletext, false, 'Blogimage' );
  683.                 $thumb          = $thumbnail["thumb"];
  684.                 $no_thumb_class = '' === $thumb || 'off' === $args['show_thumbnail'] ? ' et_pb_no_thumb' : '';
  685.  
  686.                 $post_format = et_pb_post_format();
  687.                 if ( in_array( $post_format, array( 'video', 'gallery' ) ) ) {
  688.                     $no_thumb_class = '';
  689.                 }
  690.  
  691.                 // Print output
  692.                 ?>
  693.                     <article id="" <?php post_class( 'et_pb_post clearfix' . $no_thumb_class . $overlay_class ) ?>>
  694.                         <?php
  695.                             et_divi_post_format_content();
  696.  
  697.                             if ( ! in_array( $post_format, array( 'link', 'audio', 'quote' ) ) ) {
  698.                                 if ( 'video' === $post_format && false !== ( $first_video = et_get_first_video() ) ) :
  699.                                     $video_overlay = has_post_thumbnail() ? sprintf(
  700.                                         '<div class="et_pb_video_overlay" style="background-image: url(%1$s); background-size: cover;">
  701.                                             <div class="et_pb_video_overlay_hover">
  702.                                                 <a href="#" class="et_pb_video_play"></a>
  703.                                             </div>
  704.                                         </div>',
  705.                                         $thumb
  706.                                     ) : '';
  707.  
  708.                                     printf(
  709.                                         '<div class="et_main_video_container">
  710.                                             %1$s
  711.                                             %2$s
  712.                                         </div>',
  713.                                         $video_overlay,
  714.                                         $first_video
  715.                                     );
  716.                                 elseif ( 'gallery' === $post_format ) :
  717.                                     et_pb_gallery_images( 'slider' );
  718.                                 elseif ( '' !== $thumb && 'on' === $args['show_thumbnail'] ) :
  719.                                     if ( 'on' !== $args['fullwidth'] ) echo '<div class="et_pb_image_container">'; ?>
  720.                                         <a href="<?php esc_url( the_permalink() ); ?>" class="entry-featured-image-url">
  721.                                             <?php print_thumbnail( $thumb, $thumbnail["use_timthumb"], $titletext, $width, $height ); ?>
  722.                                             <?php if ( 'on' === $args['use_overlay'] ) {
  723.                                                 echo $overlay_output;
  724.                                             } ?>
  725.                                         </a>
  726.                                 <?php
  727.                                     if ( 'on' !== $args['fullwidth'] ) echo '</div> <!-- .et_pb_image_container -->';
  728.                                 endif;
  729.                             }
  730.                         ?>
  731.  
  732.                         <?php if ( 'off' === $args['fullwidth'] || ! in_array( $post_format, array( 'link', 'audio', 'quote' ) ) ) { ?>
  733.                             <?php if ( ! in_array( $post_format, array( 'link', 'audio' ) ) ) { ?>
  734.                                 <<?php echo $processed_header_level; ?> class="entry-title"><a href="<?php esc_url( the_permalink() ); ?>"><?php the_title(); ?></a></<?php echo $processed_header_level; ?>>
  735.                             <?php } ?>
  736.  
  737.                             <?php
  738.                                 if ( 'on' === $args['show_author'] || 'on' === $args['show_date'] || 'on' === $args['show_categories'] || 'on' === $args['show_comments'] ) {
  739.                                     printf( '<p class="post-meta">%1$s %2$s %3$s %4$s %5$s %6$s %7$s</p>',
  740.                                         (
  741.                                             'on' === $args['show_author']
  742.                                                 ? et_get_safe_localization( sprintf( __( 'by %s', 'et_builder' ), '<span class="author vcard">' .  et_pb_get_the_author_posts_link() . '</span>' ) )
  743.                                                 : ''
  744.                                         ),
  745.                                         (
  746.                                             ( 'on' === $args['show_author'] && 'on' === $args['show_date'] )
  747.                                                 ? ' | '
  748.                                                 : ''
  749.                                         ),
  750.                                         (
  751.                                             'on' === $args['show_date']
  752.                                                 ? et_get_safe_localization( sprintf( __( '%s', 'et_builder' ), '<span class="published">' . esc_html( get_the_date( $args['meta_date'] ) ) . '</span>' ) )
  753.                                                 : ''
  754.                                         ),
  755.                                         (
  756.                                             (( 'on' === $args['show_author'] || 'on' === $args['show_date'] ) && 'on' === $args['show_categories'] )
  757.                                                 ? ' | '
  758.                                                 : ''
  759.                                         ),
  760.                                         (
  761.                                             'on' === $args['show_categories']
  762.                                                 ? get_the_category_list(', ')
  763.                                                 : ''
  764.                                         ),
  765.                                         (
  766.                                             (( 'on' === $args['show_author'] || 'on' === $args['show_date'] || 'on' === $args['show_categories'] ) && 'on' === $args['show_comments'])
  767.                                                 ? ' | '
  768.                                                 : ''
  769.                                         ),
  770.                                         (
  771.                                             'on' === $args['show_comments']
  772.                                                 ? sprintf( esc_html( _nx( '%s Comment', '%s Comments', get_comments_number(), 'number of comments', 'et_builder' ) ), number_format_i18n( get_comments_number() ) )
  773.                                                 : ''
  774.                                         )
  775.                                     );
  776.                                 }
  777.  
  778.                                 $post_content = et_strip_shortcodes( et_delete_post_first_video( get_the_content() ), true );
  779.  
  780.                                 // reset the fb processing flag
  781.                                 $et_fb_processing_shortcode_object = false;
  782.                                 // set the flag to indicate that we're processing internal content
  783.                                 $et_pb_rendering_column_content = true;
  784.                                 // reset all the attributes required to properly generate the internal styles
  785.                                 ET_Builder_Element::clean_internal_modules_styles();
  786.  
  787.                                 echo '<div class="post-content">';
  788.  
  789.                                 if ( 'on' === $args['show_content'] ) {
  790.                                     global $more;
  791.  
  792.                                     // page builder doesn't support more tag, so display the_content() in case of post made with page builder
  793.                                     if ( et_pb_is_pagebuilder_used( get_the_ID() ) ) {
  794.                                         $more = 1;
  795.  
  796.                                         echo apply_filters( 'the_content', $post_content );
  797.  
  798.                                     } else {
  799.                                         $more = null;
  800.                                         echo apply_filters( 'the_content', et_delete_post_first_video( get_the_content( esc_html__( 'read more...', 'et_builder' ) ) ) );
  801.                                     }
  802.                                 } else {
  803.                                     if ( has_excerpt() ) {
  804.                                         the_excerpt();
  805.                                     } else {
  806.                                         if ( '' !== $post_content ) {
  807.                                             // set the $et_fb_processing_shortcode_object to false, to retrieve the content inside truncate_post() correctly
  808.                                             $et_fb_processing_shortcode_object = false;
  809.                                             echo wpautop( et_delete_post_first_video( strip_shortcodes( truncate_post( 270, false, '', true ) ) ) );
  810.                                             // reset the $et_fb_processing_shortcode_object to its original value
  811.                                             $et_fb_processing_shortcode_object = $global_processing_original_value;
  812.                                         } else {
  813.                                             echo '';
  814.                                         }
  815.                                     }
  816.                                 }
  817.  
  818.                                 $et_fb_processing_shortcode_object = $global_processing_original_value;
  819.                                 // retrieve the styles for the modules inside Blog content
  820.                                 $internal_style = ET_Builder_Element::get_style( true );
  821.                                 // reset all the attributes after we retrieved styles
  822.                                 ET_Builder_Element::clean_internal_modules_styles( false );
  823.                                 $et_pb_rendering_column_content = false;
  824.                                 // append styles to the blog content
  825.                                 if ( $internal_style ) {
  826.                                     printf(
  827.                                         '<style type="text/css" class="et_fb_blog_inner_content_styles">
  828.                                             %1$s
  829.                                         </style>',
  830.                                         $internal_style
  831.                                     );
  832.                                 }
  833.  
  834.                                 echo '</div>';
  835.  
  836.                                 if ( 'on' !== $args['show_content'] ) {
  837.                                     $more = 'on' == $args['show_more'] ? sprintf( ' <a href="%1$s" class="more-link" >%2$s</a>' , esc_url( get_permalink() ), esc_html__( 'read more', 'et_builder' ) )  : '';
  838.                                     echo $more;
  839.                                 }
  840.                                 ?>
  841.                         <?php } // 'off' === $fullwidth || ! in_array( $post_format, array( 'link', 'audio', 'quote', 'gallery' ?>
  842.                     </article>
  843.                 <?php
  844.  
  845.                 $et_fb_processing_shortcode_object = $global_processing_original_value;
  846.             } // endwhile
  847.  
  848.             if ( 'on' !== $args['fullwidth'] ) {
  849.                 echo '</div>';
  850.             }
  851.  
  852.             if ( 'on' === $args['show_pagination'] && ! $is_search ) {
  853.                 // echo '</div> <!-- .et_pb_posts -->'; // @todo this causes closing tag issue
  854.  
  855.                 $container_is_closed = true;
  856.  
  857.                 if ( function_exists( 'wp_pagenavi' ) ) {
  858.                     wp_pagenavi( array(
  859.                         'query' => $query
  860.                     ) );
  861.                 } else {
  862.                     if ( $et_is_builder_plugin_active ) {
  863.                         include( ET_BUILDER_PLUGIN_DIR . 'includes/navigation.php' );
  864.                     } else {
  865.                         get_template_part( 'includes/navigation', 'index' );
  866.                     }
  867.                 }
  868.             }
  869.  
  870.             wp_reset_query();
  871.         }
  872.  
  873.         wp_reset_postdata();
  874.  
  875.         // Reset $wp_query to its origin
  876.         $wp_query = $wp_query_page;
  877.  
  878.         if ( ! $posts = ob_get_clean() ) {
  879.             $posts = self::get_no_results_template();
  880.         }
  881.  
  882.         return $posts;
  883.     }
  884.  
  885.     function shortcode_callback( $atts, $content = null, $function_name ) {
  886.         global $post;
  887.  
  888.         // Stored current global post as variable so global $post variable can be restored
  889.         // to its original state when et_pb_blog shortcode ends to avoid incorrect global $post
  890.         // being used on the page (i.e. blog + shop module in backend builder)
  891.         $post_cache = $post;
  892.  
  893.         /**
  894.          * Cached $wp_filter so it can be restored at the end of the callback.
  895.          * This is needed because this callback uses the_content filter / calls a function
  896.          * which uses the_content filter. WordPress doesn't support nested filter
  897.          */
  898.         global $wp_filter;
  899.         $wp_filter_cache = $wp_filter;
  900.  
  901.         $module_id           = $this->shortcode_atts['module_id'];
  902.         $module_class        = $this->shortcode_atts['module_class'];
  903.         $fullwidth           = $this->shortcode_atts['fullwidth'];
  904.         $posts_number        = $this->shortcode_atts['posts_number'];
  905.         $include_categories  = $this->shortcode_atts['include_categories'];
  906.         $meta_date           = $this->shortcode_atts['meta_date'];
  907.         $show_thumbnail      = $this->shortcode_atts['show_thumbnail'];
  908.         $show_content        = $this->shortcode_atts['show_content'];
  909.         $show_author         = $this->shortcode_atts['show_author'];
  910.         $show_date           = $this->shortcode_atts['show_date'];
  911.         $show_categories     = $this->shortcode_atts['show_categories'];
  912.         $show_comments       = $this->shortcode_atts['show_comments'];
  913.         $show_pagination     = $this->shortcode_atts['show_pagination'];
  914.         $background_layout   = $this->shortcode_atts['background_layout'];
  915.         $show_more           = $this->shortcode_atts['show_more'];
  916.         $offset_number       = $this->shortcode_atts['offset_number'];
  917.         $masonry_tile_background_color = $this->shortcode_atts['masonry_tile_background_color'];
  918.         $overlay_icon_color  = $this->shortcode_atts['overlay_icon_color'];
  919.         $hover_overlay_color = $this->shortcode_atts['hover_overlay_color'];
  920.         $hover_icon          = $this->shortcode_atts['hover_icon'];
  921.         $use_overlay         = $this->shortcode_atts['use_overlay'];
  922.         $header_level        = $this->shortcode_atts['header_level'];
  923.  
  924.         global $paged;
  925.  
  926.         $module_class              = ET_Builder_Element::add_module_order_class( $module_class, $function_name );
  927.         $video_background          = $this->video_background();
  928.         $parallax_image_background = $this->get_parallax_image_background();
  929.  
  930.         $container_is_closed = false;
  931.  
  932.         $processed_header_level = et_pb_process_header_level( $header_level, 'h2' );
  933.  
  934.         // some themes do not include these styles/scripts so we need to enqueue them in this module to support audio post format
  935.         wp_enqueue_style( 'wp-mediaelement' );
  936.         wp_enqueue_script( 'wp-mediaelement' );
  937.  
  938.         // include easyPieChart which is required for loading Blog module content via ajax correctly
  939.         wp_enqueue_script( 'easypiechart' );
  940.  
  941.         // include ET Shortcode scripts
  942.         wp_enqueue_script( 'et-shortcodes-js' );
  943.  
  944.         // remove all filters from WP audio shortcode to make sure current theme doesn't add any elements into audio module
  945.         remove_all_filters( 'wp_audio_shortcode_library' );
  946.         remove_all_filters( 'wp_audio_shortcode' );
  947.         remove_all_filters( 'wp_audio_shortcode_class' );
  948.  
  949.         if ( '' !== $masonry_tile_background_color ) {
  950.             ET_Builder_Element::set_style( $function_name, array(
  951.                 'selector'    => '%%order_class%% .et_pb_blog_grid .et_pb_post',
  952.                 'declaration' => sprintf(
  953.                     'background-color: %1$s;',
  954.                     esc_html( $masonry_tile_background_color )
  955.                 ),
  956.             ) );
  957.         }
  958.  
  959.         if ( '' !== $overlay_icon_color ) {
  960.             ET_Builder_Element::set_style( $function_name, array(
  961.                 'selector'    => '%%order_class%% .et_overlay:before',
  962.                 'declaration' => sprintf(
  963.                     'color: %1$s !important;',
  964.                     esc_html( $overlay_icon_color )
  965.                 ),
  966.             ) );
  967.         }
  968.  
  969.         if ( '' !== $hover_overlay_color ) {
  970.             ET_Builder_Element::set_style( $function_name, array(
  971.                 'selector'    => '%%order_class%% .et_overlay',
  972.                 'declaration' => sprintf(
  973.                     'background-color: %1$s;',
  974.                     esc_html( $hover_overlay_color )
  975.                 ),
  976.             ) );
  977.         }
  978.  
  979.         if ( 'on' === $use_overlay ) {
  980.             $data_icon = '' !== $hover_icon
  981.                 ? sprintf(
  982.                     ' data-icon="%1$s"',
  983.                     esc_attr( et_pb_process_font_icon( $hover_icon ) )
  984.                 )
  985.                 : '';
  986.  
  987.             $overlay_output = sprintf(
  988.                 '<span class="et_overlay%1$s"%2$s></span>',
  989.                 ( '' !== $hover_icon ? ' et_pb_inline_icon' : '' ),
  990.                 $data_icon
  991.             );
  992.         }
  993.  
  994.         $overlay_class = 'on' === $use_overlay ? ' et_pb_has_overlay' : '';
  995.  
  996.         if ( 'on' !== $fullwidth ){
  997.             wp_enqueue_script( 'salvattore' );
  998.  
  999.             $background_layout = 'light';
  1000.         }
  1001.  
  1002.         $args = array( 'posts_per_page' => (int) $posts_number );
  1003.  
  1004.         $et_paged = is_front_page() ? get_query_var( 'page' ) : get_query_var( 'paged' );
  1005.  
  1006.         if ( is_front_page() ) {
  1007.             $paged = $et_paged;
  1008.         }
  1009.  
  1010.         if ( '' !== $include_categories ) {
  1011.             $args['cat'] = $include_categories;
  1012.         }
  1013.  
  1014.         if ( ! is_search() ) {
  1015.             $args['paged'] = $et_paged;
  1016.         }
  1017.  
  1018.         if ( '' !== $offset_number && ! empty( $offset_number ) ) {
  1019.             /**
  1020.              * Offset + pagination don't play well. Manual offset calculation required
  1021.              * @see: https://codex.wordpress.org/Making_Custom_Queries_using_Offset_and_Pagination
  1022.              */
  1023.             if ( $paged > 1 ) {
  1024.                 $args['offset'] = ( ( $et_paged - 1 ) * intval( $posts_number ) ) + intval( $offset_number );
  1025.             } else {
  1026.                 $args['offset'] = intval( $offset_number );
  1027.             }
  1028.         }
  1029.  
  1030.         if ( is_single() && ! isset( $args['post__not_in'] ) ) {
  1031.             $args['post__not_in'] = array( get_the_ID() );
  1032.         }
  1033.  
  1034.         // Images: Add CSS Filters and Mix Blend Mode rules (if set)
  1035.         if ( array_key_exists( 'image', $this->advanced_options ) && array_key_exists( 'css', $this->advanced_options['image'] ) ) {
  1036.             $module_class .= $this->generate_css_filters(
  1037.                 $function_name,
  1038.                 'child_',
  1039.                 self::$data_utils->array_get( $this->advanced_options['image']['css'], 'main', '%%order_class%%' )
  1040.             );
  1041.         }
  1042.  
  1043.         ob_start();
  1044.  
  1045.         query_posts( $args );
  1046.  
  1047.         if ( have_posts() ) {
  1048.             if ( 'off' === $fullwidth ) {
  1049.                 echo '<div class="et_pb_salvattore_content" data-columns>';
  1050.             }
  1051.  
  1052.             while ( have_posts() ) {
  1053.                 the_post();
  1054.  
  1055.                 global $post;
  1056.  
  1057.                 $post_format = et_pb_post_format();
  1058.  
  1059.                 $thumb = '';
  1060.  
  1061.                 $width = 'on' === $fullwidth ? 1080 : 400;
  1062.                 $width = (int) apply_filters( 'et_pb_blog_image_width', $width );
  1063.  
  1064.                 $height = 'on' === $fullwidth ? 675 : 250;
  1065.                 $height = (int) apply_filters( 'et_pb_blog_image_height', $height );
  1066.                 $classtext = 'on' === $fullwidth ? 'et_pb_post_main_image' : '';
  1067.                 $titletext = get_the_title();
  1068.                 $thumbnail = get_thumbnail( $width, $height, $classtext, $titletext, $titletext, false, 'Blogimage' );
  1069.                 $thumb = $thumbnail['thumb'];
  1070.  
  1071.                 $no_thumb_class = '' === $thumb || 'off' === $show_thumbnail ? ' et_pb_no_thumb' : '';
  1072.  
  1073.                 if ( in_array( $post_format, array( 'video', 'gallery' ) ) ) {
  1074.                     $no_thumb_class = '';
  1075.                 }
  1076.                 $video_urls = get_post_meta( get_the_ID(), '_video_format_urls', true );
  1077.                 ?>
  1078.  
  1079.             <article id="post-<?php the_ID(); ?>" <?php post_class( 'et_pb_post clearfix' . $no_thumb_class . $overlay_class  ); ?>>
  1080.             <?php
  1081.                 et_divi_post_format_content();
  1082.  
  1083.                 if ( ! in_array( $post_format, array( 'link', 'audio', 'quote' ) ) || post_password_required( $post ) ) {
  1084.                         $video_overlay = has_post_thumbnail() ? sprintf(
  1085.                             '<div class="et_pb_video_overlay" style="background-image: url(%1$s); background-size: cover;">
  1086.                                 <div class="et_pb_video_overlay_hover">
  1087.                                     <a href="#" class="et_pb_video_play"></a>
  1088.                                 </div>
  1089.                             </div>',
  1090.                             $thumb
  1091.                         ) : '';
  1092.  
  1093.                         printf(
  1094.                             '<div class="et_main_video_container">
  1095.                                 %1$s
  1096.                                 %2$s
  1097.                                 %3$s
  1098.                             </div>',
  1099.                             $video_overlay,
  1100.                             $first_video,
  1101.                             $video_embed = extra_get_video_embed( $video_urls )
  1102.                         );
  1103.                     if ( 'gallery' === $post_format ) :
  1104.                         et_pb_gallery_images( 'slider' );
  1105.                     elseif ( '' !== $thumb && 'on' === $show_thumbnail ) :
  1106.                         if ( 'on' !== $fullwidth ) {
  1107.                             echo '<div class="et_pb_image_container">';
  1108.                         }
  1109.                         ?>
  1110.                             <a href="<?php esc_url( the_permalink() ); ?>" class="entry-featured-image-url">
  1111.                                 <?php print_thumbnail( $thumb, $thumbnail["use_timthumb"], $titletext, $width, $height ); ?>
  1112.                                 <?php if ( 'on' === $use_overlay ) {
  1113.                                     echo $overlay_output;
  1114.                                 } ?>
  1115.                             </a>
  1116.                     <?php
  1117.                         if ( 'on' !== $fullwidth ) echo '</div> <!-- .et_pb_image_container -->';
  1118.                     endif;
  1119.                 } ?>
  1120.  
  1121.             <?php if ( 'off' === $fullwidth || ! in_array( $post_format, array( 'link', 'audio', 'quote' ) ) || post_password_required( $post ) ) { ?>
  1122.                 <?php if ( ! in_array( $post_format, array( 'link', 'audio' ) ) || post_password_required( $post ) ) { ?>
  1123.                     <<?php echo $processed_header_level; ?> class="entry-title"><a href="<?php esc_url( the_permalink() ); ?>"><?php the_title(); ?></a></<?php echo $processed_header_level; ?>>
  1124.                 <?php } ?>
  1125.  
  1126.                 <?php
  1127.                     if ( 'on' === $show_author || 'on' === $show_date || 'on' === $show_categories || 'on' === $show_comments ) {
  1128.                         printf( '<p class="post-meta">%1$s %2$s %3$s %4$s %5$s %6$s %7$s</p>',
  1129.                             (
  1130.                                 'on' === $show_author
  1131.                                     ? et_get_safe_localization( sprintf( __( 'by %s', 'et_builder' ), '<span class="author vcard">' .  et_pb_get_the_author_posts_link() . '</span>' ) )
  1132.                                     : ''
  1133.                             ),
  1134.                             (
  1135.                                 ( 'on' === $show_author && 'on' === $show_date )
  1136.                                     ? ' | '
  1137.                                     : ''
  1138.                             ),
  1139.                             (
  1140.                                 'on' === $show_date
  1141.                                     ? et_get_safe_localization( sprintf( __( '%s', 'et_builder' ), '<span class="published">' . esc_html( get_the_date( $meta_date ) ) . '</span>' ) )
  1142.                                     : ''
  1143.                             ),
  1144.                             (
  1145.                                 (( 'on' === $show_author || 'on' === $show_date ) && 'on' === $show_categories)
  1146.                                     ? ' | '
  1147.                                     : ''
  1148.                             ),
  1149.                             (
  1150.                                 'on' === $show_categories
  1151.                                     ? get_the_category_list(', ')
  1152.                                     : ''
  1153.                             ),
  1154.                             (
  1155.                                 (( 'on' === $show_author || 'on' === $show_date || 'on' === $show_categories ) && 'on' === $show_comments)
  1156.                                     ? ' | '
  1157.                                     : ''
  1158.                             ),
  1159.                             (
  1160.                                 'on' === $show_comments
  1161.                                     ? sprintf( esc_html( _nx( '%s Comment', '%s Comments', get_comments_number(), 'number of comments', 'et_builder' ) ), number_format_i18n( get_comments_number() ) )
  1162.                                     : ''
  1163.                             )
  1164.                         );
  1165.                     }
  1166.  
  1167.                     echo '<div class="post-content">';
  1168.                     global $et_pb_rendering_column_content;
  1169.  
  1170.                     $post_content = et_strip_shortcodes( et_delete_post_first_video( get_the_content() ), true );
  1171.  
  1172.                     $et_pb_rendering_column_content = true;
  1173.  
  1174.                     if ( 'on' === $show_content ) {
  1175.                         global $more;
  1176.  
  1177.                         // page builder doesn't support more tag, so display the_content() in case of post made with page builder
  1178.                         if ( et_pb_is_pagebuilder_used( get_the_ID() ) ) {
  1179.                             $more = 1;
  1180.                             echo apply_filters( 'the_content', $post_content );
  1181.                         } else {
  1182.                             $more = null;
  1183.                             echo apply_filters( 'the_content', et_delete_post_first_video( get_the_content( esc_html__( 'read more...', 'et_builder' ) ) ) );
  1184.                         }
  1185.                     } else {
  1186.                         if ( has_excerpt() ) {
  1187.                             the_excerpt();
  1188.                         } else {
  1189.                             echo wpautop( et_delete_post_first_video( strip_shortcodes( truncate_post( 270, false, '', true ) ) ) );
  1190.                         }
  1191.                     }
  1192.  
  1193.                     $et_pb_rendering_column_content = false;
  1194.  
  1195.                     if ( 'on' !== $show_content ) {
  1196.                         $more = 'on' == $show_more ? sprintf( ' <a href="%1$s" class="more-link" >%2$s</a>' , esc_url( get_permalink() ), esc_html__( 'read more', 'et_builder' ) )  : '';
  1197.                         echo $more;
  1198.                     }
  1199.  
  1200.                     echo '</div>';
  1201.                     ?>
  1202.             <?php } // 'off' === $fullwidth || ! in_array( $post_format, array( 'link', 'audio', 'quote', 'gallery' ?>
  1203.  
  1204.             </article> <!-- .et_pb_post -->
  1205.     <?php
  1206.             } // endwhile
  1207.  
  1208.             if ( 'off' === $fullwidth ) {
  1209.                 echo '</div><!-- .et_pb_salvattore_content -->';
  1210.             }
  1211.  
  1212.             if ( 'on' === $show_pagination && ! is_search() ) {
  1213.                 if ( function_exists( 'wp_pagenavi' ) ) {
  1214.                     wp_pagenavi();
  1215.                 } else {
  1216.                     if ( et_is_builder_plugin_active() ) {
  1217.                         include( ET_BUILDER_PLUGIN_DIR . 'includes/navigation.php' );
  1218.                     } else {
  1219.                         get_template_part( 'includes/navigation', 'index' );
  1220.                     }
  1221.                 }
  1222.  
  1223.                 echo '</div> <!-- .et_pb_posts -->';
  1224.  
  1225.                 $container_is_closed = true;
  1226.             }
  1227.         } else {
  1228.             if ( et_is_builder_plugin_active() ) {
  1229.                 include( ET_BUILDER_PLUGIN_DIR . 'includes/no-results.php' );
  1230.             } else {
  1231.                 get_template_part( 'includes/no-results', 'index' );
  1232.             }
  1233.         }
  1234.  
  1235.         wp_reset_query();
  1236.  
  1237.         $posts = ob_get_contents();
  1238.  
  1239.         ob_end_clean();
  1240.  
  1241.         $class = " et_pb_bg_layout_{$background_layout}";
  1242.  
  1243.         if ( 'on' !== $fullwidth ) {
  1244.             $output = sprintf(
  1245.                 '<div%5$s class="et_pb_module et_pb_blog_grid_wrapper%6$s">
  1246.                     <div class="%1$s%3$s%7$s%9$s%11$s">
  1247.                     %10$s
  1248.                     %8$s
  1249.                     <div class="et_pb_ajax_pagination_container">
  1250.                         %2$s
  1251.                     </div>
  1252.                     %4$s %12$s
  1253.                 </div>',
  1254.                 ( 'on' === $fullwidth ? 'et_pb_posts' : 'et_pb_blog_grid clearfix' ),
  1255.                 $posts,
  1256.                 esc_attr( $class ),
  1257.                 ( ! $container_is_closed ? '</div> <!-- .et_pb_posts -->' : '' ),
  1258.                 ( '' !== $module_id ? sprintf( ' id="%1$s"', esc_attr( $module_id ) ) : '' ),
  1259.                 ( '' !== $module_class ? sprintf( ' %1$s', esc_attr( $module_class ) ) : '' ),
  1260.                 '' !== $video_background ? ' et_pb_section_video et_pb_preload' : '',
  1261.                 $video_background,
  1262.                 '' !== $parallax_image_background ? ' et_pb_section_parallax' : '',
  1263.                 $parallax_image_background,
  1264.                 $this->get_text_orientation_classname(),
  1265.                 $this->drop_shadow_back_compatibility( $function_name )
  1266.             );
  1267.         } else {
  1268.             $output = sprintf(
  1269.                 '<div%5$s class="et_pb_module %1$s%3$s%6$s%7$s%9$s%11$s">
  1270.                 %10$s
  1271.                 %8$s
  1272.                 <div class="et_pb_ajax_pagination_container">
  1273.                     %2$s
  1274.                 </div>
  1275.                 %4$s %12$s',
  1276.                 ( 'on' === $fullwidth ? 'et_pb_posts' : 'et_pb_blog_grid clearfix' ),
  1277.                 $posts,
  1278.                 esc_attr( $class ),
  1279.                 ( ! $container_is_closed ? '</div> <!-- .et_pb_posts -->' : '' ),
  1280.                 ( '' !== $module_id ? sprintf( ' id="%1$s"', esc_attr( $module_id ) ) : '' ),
  1281.                 ( '' !== $module_class ? sprintf( ' %1$s', esc_attr( $module_class ) ) : '' ),
  1282.                 '' !== $video_background ? ' et_pb_section_video et_pb_preload' : '',
  1283.                 $video_background,
  1284.                 '' !== $parallax_image_background ? ' et_pb_section_parallax' : '',
  1285.                 $parallax_image_background,
  1286.                 $this->get_text_orientation_classname(),
  1287.                 $this->drop_shadow_back_compatibility( $function_name )
  1288.             );
  1289.         }
  1290.  
  1291.         // Restore $wp_filter
  1292.         $wp_filter = $wp_filter_cache;
  1293.         unset($wp_filter_cache);
  1294.  
  1295.         // Restore global $post into its original state when et_pb_blog shortcode ends to avoid
  1296.         // the rest of the page uses incorrect global $post variable
  1297.         $post = $post_cache;
  1298.  
  1299.         return $output;
  1300.     }
  1301.  
  1302.     public function process_box_shadow( $function_name ) {
  1303.         /**
  1304.          * @var ET_Builder_Module_Field_BoxShadow $boxShadow
  1305.          */
  1306.         $boxShadow = ET_Builder_Module_Fields_Factory::get( 'BoxShadow' );
  1307.         $selector = '.' . self::get_module_order_class( $function_name );
  1308.  
  1309.         if ( isset( $this->shortcode_atts['fullwidth'] ) && $this->shortcode_atts['fullwidth'] === 'off' ) {
  1310.             $selector .= ' article.et_pb_post';
  1311.         }
  1312.  
  1313.         self::set_style( $function_name, $boxShadow->get_style( $selector, $this->shortcode_atts ) );
  1314.     }
  1315.  
  1316.     protected function _add_additional_border_fields() {
  1317.         parent::_add_additional_border_fields();
  1318.  
  1319.         $suffix = 'fullwidth';
  1320.  
  1321.         $this->_additional_fields_options = array_merge(
  1322.             $this->_additional_fields_options,
  1323.             ET_Builder_Module_Fields_Factory::get( 'Border' )->get_fields( array(
  1324.                 'suffix'          => "_{$suffix}",
  1325.                 'depends_to'      => array( 'fullwidth' ),
  1326.                 'depends_show_if' => 'on',
  1327.                 'defaults'        => array(
  1328.                     'border_radii'  => 'on||||',
  1329.                     'border_styles' => array(
  1330.                         'width' => '0px',
  1331.                         'color' => '#333333',
  1332.                         'style' => 'solid',
  1333.                     ),
  1334.                 ),
  1335.             ) )
  1336.         );
  1337.  
  1338.         $this->advanced_options["border_{$suffix}"]["border_styles_{$suffix}"] = $this->_additional_fields_options["border_styles_{$suffix}"];
  1339.         $this->advanced_options["border_{$suffix}"]["border_radii_{$suffix}"] = $this->_additional_fields_options["border_radii_{$suffix}"];
  1340.  
  1341.         $this->advanced_options["border_{$suffix}"]['css'] = array(
  1342.             'main' => array(
  1343.                 'border_radii'  => "%%order_class%%:not(.et_pb_blog_grid) .et_pb_post",
  1344.                 'border_styles' => "%%order_class%%:not(.et_pb_blog_grid) .et_pb_post",
  1345.             ),
  1346.         );
  1347.     }
  1348.  
  1349.     function process_advanced_border_options( $function_name ) {
  1350.         parent::process_advanced_border_options( $function_name );
  1351.  
  1352.         $suffix = 'fullwidth';
  1353.         /**
  1354.          * @var ET_Builder_Module_Field_Border $border_field
  1355.          */
  1356.         $border_field = ET_Builder_Module_Fields_Factory::get( 'Border' );
  1357.  
  1358.         $css_selector = ! empty( $this->advanced_options["border_{$suffix}"]['css']['main']['border_radii'] ) ? $this->advanced_options["border_{$suffix}"]['css']['main']['border_radii'] : $this->main_css_element;
  1359.         self::set_style( $function_name, array(
  1360.             'selector'    => $css_selector,
  1361.             'declaration' => $border_field->get_radii_style( $this->shortcode_atts, $this->advanced_options, "_{$suffix}" ),
  1362.             'priority'    => $this->_style_priority,
  1363.         ) );
  1364.  
  1365.         $css_selector = ! empty( $this->advanced_options["border_{$suffix}"]['css']['main']['border_styles'] ) ? $this->advanced_options["border_{$suffix}"]['css']['main']['border_styles'] : $this->main_css_element;
  1366.         self::set_style( $function_name, array(
  1367.             'selector'    => $css_selector,
  1368.             'declaration' => $border_field->get_borders_style( $this->shortcode_atts, $this->advanced_options, "_{$suffix}" ),
  1369.             'priority'    => $this->_style_priority,
  1370.         ) );
  1371.     }
  1372.  
  1373.     /**
  1374.      * Since the styling file is not updated until the author updates the page/post,
  1375.      * we should keep the drop shadow visible.
  1376.      *
  1377.      * @param string $functions_name
  1378.      *
  1379.      * @return string
  1380.      */
  1381.     private function drop_shadow_back_compatibility( $functions_name ) {
  1382.         $utils = ET_Core_Data_Utils::instance();
  1383.         $atts  = $this->shortcode_atts;
  1384.  
  1385.         if (
  1386.             version_compare( $utils->array_get( $atts, '_builder_version', '3.0.93' ), '3.0.94', 'lt' )
  1387.             &&
  1388.             'on' !== $utils->array_get( $atts, 'fullwidth' )
  1389.             &&
  1390.             'on' === $utils->array_get( $atts, 'use_dropshadow' )
  1391.         ) {
  1392.             $class = self::get_module_order_class( $functions_name );
  1393.  
  1394.             return sprintf(
  1395.                 '<style>%1$s</style>',
  1396.                 sprintf( '.%1$s  article.et_pb_post { box-shadow: 0 1px 5px rgba(0,0,0,.1) }', esc_html( $class ) )
  1397.             );
  1398.         }
  1399.  
  1400.         return '';
  1401.     }
  1402. }
  1403.  
  1404. new ET_Builder_Module_Blog;
Advertisement
Add Comment
Please, Sign In to add comment