EduardET

Blog module with Excerpt length option

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