Guest User

Untitled

a guest
Aug 29th, 2019
91
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. if (!defined('ABSPATH'))
  4.  
  5. exit;
  6.  
  7. class DfdHeaderBuilder_Logo extends DfdHeaderBuilderElementAbstract {
  8.  
  9.  
  10.  
  11. public function render() {
  12.  
  13. $view = DfdHeader_ViewCollection::instance()->getView();
  14.  
  15. echo '<div class="dfd-header-logos">';
  16.  
  17. echo '<div class="dfd-logo-wrap">';
  18.  
  19. echo '<a href="' . esc_url(home_url()) . '" title="' . esc_attr__('Site logo', 'dfd-native') . '">';
  20.  
  21. if ($view == "desktop") {
  22.  
  23. $this->getLogoImg();
  24.  
  25. } else {
  26.  
  27. $this->mobile_logo_html();
  28.  
  29. }
  30.  
  31. echo '</a>';
  32.  
  33. $this->sticky_logo_html();
  34.  
  35. echo '</div>';
  36.  
  37. echo '</div>';
  38.  
  39. }
  40.  
  41.  
  42.  
  43. protected function getLogoImg($class = 'main-logo') {
  44.  
  45. global $dfd_native;
  46.  
  47. $logo_sett = DfdHeader_ViewCollection::instance()->getPreset()->getGlobalSettingByName("logo_header_builder");
  48.  
  49. $logo_retina_sett = DfdHeader_ViewCollection::instance()->getPreset()->getGlobalSettingByName("retina_logo_header_builder");
  50.  
  51. $retina_img = $img = $logos_data_atts="";
  52.  
  53. if (is_object($logo_retina_sett)) {
  54.  
  55. $logo_retina_val_set="";
  56.  
  57. if(is_string($logo_retina_sett->value)){
  58.  
  59. $logo_retina_val_set = json_decode($logo_retina_sett->value);
  60.  
  61. }
  62.  
  63. if (is_object($logo_retina_val_set)) {
  64.  
  65. $img_retina_id = $logo_retina_val_set->id;
  66.  
  67. $retina_img = wp_get_attachment_image_src($img_retina_id, "full");
  68.  
  69. }
  70.  
  71. }
  72.  
  73. if (is_object($logo_sett)) {
  74.  
  75. $logo_val_sett="";
  76.  
  77. if(is_string($logo_sett->value)){
  78.  
  79. $logo_val_sett = json_decode($logo_sett->value);
  80.  
  81. }
  82.  
  83. if (is_object($logo_val_sett)) {
  84.  
  85. $img_id = $logo_val_sett->id;
  86.  
  87. $img = wp_get_attachment_image_src($img_id, "full");
  88.  
  89. }
  90.  
  91. }
  92.  
  93. if ($retina_img && is_array($retina_img)) {
  94.  
  95. $retina_img = $retina_img[0];
  96.  
  97. }
  98.  
  99. if ($img && is_array($img)) {
  100.  
  101. $img = $img[0];
  102.  
  103. }
  104.  
  105.  
  106.  
  107.  
  108.  
  109. $header_logo = $img;
  110.  
  111.  
  112.  
  113. $header_logo_retina = $retina_img;
  114.  
  115.  
  116.  
  117. if (empty($header_logo) && isset($dfd_native['custom_logo_image']['url']) && !empty($dfd_native['custom_logo_image']['url'])) {
  118.  
  119. $header_logo = $dfd_native['custom_logo_image']['url'];
  120.  
  121. }
  122.  
  123.  
  124.  
  125. if (empty($header_logo_retina) && isset($dfd_native['custom_retina_logo_image']['url']) && !empty($dfd_native['custom_retina_logo_image']['url'])) {
  126.  
  127. $header_logo_retina = $dfd_native['custom_retina_logo_image']['url'];
  128.  
  129. }
  130.  
  131.  
  132.  
  133. if (!empty($header_logo)) {
  134.  
  135. if (!empty($header_logo_retina)) {
  136.  
  137. $logos_data_atts .= ' data-retina="' . esc_url($header_logo_retina) . '"';
  138.  
  139. }
  140.  
  141.  
  142.  
  143. echo '<img src="' . esc_url($header_logo) . '" class="' . esc_attr($class) . '" alt="' . esc_attr__('Site logo', 'dfd-native') . '" ' . $logos_data_atts . ' />';
  144.  
  145. }
  146.  
  147.  
  148.  
  149.  
  150.  
  151. return "";
  152.  
  153. }
  154.  
  155.  
  156.  
  157. private function main_logo_img($class = 'main-logo') {
  158.  
  159. global $dfd_native;
  160.  
  161.  
  162.  
  163. $logos_data_atts = '';
  164.  
  165.  
  166.  
  167. $header_logo = $this->get_value('logo_header');
  168.  
  169.  
  170.  
  171. $header_logo_retina = $this->get_value('retina_logo_header');
  172.  
  173.  
  174.  
  175. if (empty($header_logo['url']) && isset($dfd_native['custom_logo_image']['url']) && !empty($dfd_native['custom_logo_image']['url'])) {
  176.  
  177. $header_logo = $dfd_native['custom_logo_image'];
  178.  
  179. }
  180.  
  181.  
  182.  
  183. if (empty($header_logo_retina) && isset($dfd_native['custom_retina_logo_image']['url']) && !empty($dfd_native['custom_retina_logo_image']['url'])) {
  184.  
  185. $header_logo_retina = $dfd_native['custom_retina_logo_image'];
  186.  
  187. }
  188.  
  189.  
  190.  
  191. if (isset($header_logo['url']) && !empty($header_logo['url'])) {
  192.  
  193. if (isset($header_logo_retina['url']) && !empty($header_logo_retina['url'])) {
  194.  
  195. $logos_data_atts .= ' data-retina="' . esc_url($header_logo_retina['url']) . '"';
  196.  
  197. }
  198.  
  199.  
  200.  
  201. echo '<img src="' . esc_url($header_logo['url']) . '" class="' . esc_attr($class) . '" alt="' . esc_attr__('Site logo', 'dfd-native') . '" ' . $logos_data_atts . ' />';
  202.  
  203. }
  204.  
  205. }
  206.  
  207.  
  208.  
  209. private function sticky_logo_html() {
  210.  
  211. global $dfd_native;
  212.  
  213.  
  214.  
  215. $sticky_header_logo = $mobile_header_logo = '';
  216.  
  217.  
  218.  
  219. if (isset($dfd_native['custom_logo_fixed_header']['url']) && !empty($dfd_native['custom_logo_fixed_header']['url'])) {
  220.  
  221. $retina_logo_data = '';
  222.  
  223. if (isset($dfd_native['custom_retina_logo_fixed_header']['url']) && !empty($dfd_native['custom_retina_logo_fixed_header']['url'])) {
  224.  
  225. $retina_logo_data = 'data-retina="' . esc_url($dfd_native['custom_retina_logo_fixed_header']['url']) . '"';
  226.  
  227. }
  228.  
  229. $sticky_header_logo .= '<img src="' . esc_url($dfd_native['custom_logo_fixed_header']['url']) . '" class="sticky-logo" ' . $retina_logo_data . ' alt="' . esc_attr__('Sticky header logo', 'dfd-native') . '" />';
  230.  
  231. }
  232.  
  233.  
  234.  
  235. echo '<div class="dfd-logo-wrap mobile-sticky-logos sticky-logo-wrap">'
  236.  
  237. . '<a href="' . esc_url(home_url()) . '" title="' . esc_attr__('Site logo', 'dfd-native') . '">';
  238.  
  239. if ($sticky_header_logo != '') {
  240.  
  241. echo $sticky_header_logo;
  242.  
  243. } else {
  244.  
  245. $this->main_logo_img('sticky-logo');
  246.  
  247. }
  248.  
  249. echo '</a>';
  250.  
  251. echo '</div>';
  252.  
  253. }
  254.  
  255.  
  256.  
  257. private function mobile_logo_html($simple = false) {
  258.  
  259. global $dfd_native;
  260.  
  261.  
  262.  
  263. $mobile_header_logo = '';
  264.  
  265.  
  266.  
  267. if (isset($dfd_native['mobile_logo_image']['url']) && !empty($dfd_native['mobile_logo_image']['url'])) {
  268.  
  269. $retina_logo_data = '';
  270.  
  271. if (isset($dfd_native['mobile_retina_logo_image']['url']) && !empty($dfd_native['mobile_retina_logo_image']['url'])) {
  272.  
  273. $retina_logo_data = 'data-retina="' . esc_url($dfd_native['mobile_retina_logo_image']['url']) . '"';
  274.  
  275. }
  276.  
  277. $mobile_header_logo .= '<img src="' . esc_url($dfd_native['mobile_logo_image']['url']) . '" class="main-logo" ' . $retina_logo_data . ' alt="' . esc_attr__('Mobile logo', 'dfd-native') . '" />';
  278.  
  279. }
  280.  
  281. if ($mobile_header_logo != '') {
  282.  
  283. echo $mobile_header_logo;
  284.  
  285. } else {
  286.  
  287. $this->getLogoImg();
  288.  
  289. }
  290.  
  291.  
  292.  
  293. }
  294.  
  295.  
  296.  
  297. private function small_logo_img($class = 'main-logo') {
  298.  
  299. global $dfd_native;
  300.  
  301.  
  302.  
  303. $logos_data_atts = '';
  304.  
  305.  
  306.  
  307. $header_logo = $this->get_value('small_logo_header');
  308.  
  309.  
  310.  
  311. $header_logo_retina = $this->get_value('small_retina_logo_header');
  312.  
  313.  
  314.  
  315. if (empty($header_logo['url']) && isset($dfd_native['custom_logo_image']['url']) && !empty($dfd_native['custom_logo_image']['url'])) {
  316.  
  317. $header_logo = $dfd_native['custom_logo_image'];
  318.  
  319. }
  320.  
  321.  
  322.  
  323. if (empty($header_logo_retina) && isset($dfd_native['custom_retina_logo_image']['url']) && !empty($dfd_native['custom_retina_logo_image']['url'])) {
  324.  
  325. $header_logo_retina = $dfd_native['custom_retina_logo_image'];
  326.  
  327. }
  328.  
  329.  
  330.  
  331. if (isset($header_logo['url']) && !empty($header_logo['url'])) {
  332.  
  333. if (isset($header_logo_retina['url']) && !empty($header_logo_retina['url'])) {
  334.  
  335. $logos_data_atts .= ' data-retina="' . esc_url($header_logo_retina['url']) . '"';
  336.  
  337. }
  338.  
  339.  
  340.  
  341. echo '<img src="' . esc_url($header_logo['url']) . '" class="' . esc_attr($class) . '" alt="' . esc_attr__('Site logo', 'dfd-native') . '" ' . $logos_data_atts . ' />';
  342.  
  343. }
  344.  
  345. }
  346.  
  347.  
  348.  
  349. }
RAW Paste Data