EduardET

Blog Module :: No Ajax Pagination

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