vc-gitem-post-data.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. if ( ! defined( 'ABSPATH' ) ) {
  3. die( '-1' );
  4. }
  5. require_once vc_path_dir( 'SHORTCODES_DIR', 'vc-custom-heading.php' );
  6. /**
  7. * Class WPBakeryShortCode_Vc_Gitem_Post_Data
  8. */
  9. class WPBakeryShortCode_Vc_Gitem_Post_Data extends WPBakeryShortCode_Vc_Custom_heading {
  10. /**
  11. * Get data_source attribute value
  12. *
  13. * @param array $atts - list of shortcode attributes
  14. *
  15. * @return string
  16. */
  17. public function getDataSource( array $atts ) {
  18. return isset( $atts['data_source'] ) ? $atts['data_source'] : 'post_title';
  19. }
  20. /**
  21. * @param $atts
  22. * @return array
  23. * @throws \Exception
  24. */
  25. public function getAttributes( $atts ) {
  26. $atts = vc_map_get_attributes( $this->getShortcode(), $atts );
  27. if ( isset( $atts['block_container'] ) && strlen( $atts['block_container'] ) > 0 ) {
  28. if ( ! isset( $atts['font_container'] ) ) {
  29. $atts['font_container'] = $atts['block_container'];
  30. } else {
  31. // merging two params into font_container
  32. $atts['font_container'] .= '|' . $atts['block_container'];
  33. }
  34. }
  35. $atts = parent::getAttributes( $atts );
  36. if ( ! isset( $this->atts['use_custom_fonts'] ) || 'yes' !== $this->atts['use_custom_fonts'] ) {
  37. $atts['google_fonts_data'] = array();
  38. }
  39. return $atts;
  40. }
  41. }