EduardET

ET custom blog module

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