Guest User

Untitled

a guest
Feb 16th, 2022
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 38.88 KB | None | 0 0
  1. <?php
  2. /**
  3. * Fullwidth Easy Slider
  4. *
  5. * Shortcode dDisplay a simple fullwidth slideshow element
  6. */
  7. if( ! defined( 'ABSPATH' ) ) { exit; } // Exit if accessed directly
  8.  
  9.  
  10. if( ! class_exists( 'avia_sc_slider_full' ) )
  11. {
  12. class avia_sc_slider_full extends aviaShortcodeTemplate
  13. {
  14. /**
  15. *
  16. * @var int
  17. */
  18. static public $slide_count = 0;
  19.  
  20. /**
  21. * Save avia_slideshow objects for reuse. As we need to access the same object when creating the post css file in header,
  22. * create the styles and HTML creation. Makes sure to get the same id.
  23. *
  24. * $element_id => avia_slideshow
  25. *
  26. * @since 4.8.9
  27. * @var array
  28. */
  29. protected $obj_slideshow = array();
  30.  
  31. /**
  32. * @since 4.8.9
  33. * @param AviaBuilder $builder
  34. */
  35. public function __construct( AviaBuilder $builder )
  36. {
  37. parent::__construct( $builder );
  38.  
  39. $this->obj_slideshow = array();
  40. }
  41.  
  42. /**
  43. * @since 4.8.9
  44. */
  45. public function __destruct()
  46. {
  47. unset( $this->obj_slideshow );
  48.  
  49. parent::__destruct();
  50. }
  51.  
  52. /**
  53. * Create the config array for the shortcode button
  54. */
  55. function shortcode_insert_button()
  56. {
  57. $this->config['version'] = '1.0';
  58. $this->config['is_fullwidth'] = 'yes';
  59. $this->config['self_closing'] = 'no';
  60. $this->config['base_element'] = 'yes';
  61.  
  62. $this->config['name'] = __( 'Fullwidth Easy Slider', 'avia_framework' );
  63. $this->config['tab'] = __( 'Media Elements', 'avia_framework' );
  64. $this->config['icon'] = AviaBuilder::$path['imagesURL'] . 'sc-slideshow-full.png';
  65. $this->config['order'] = 80;
  66. $this->config['target'] = 'avia-target-insert';
  67. $this->config['shortcode'] = 'av_slideshow_full';
  68. $this->config['shortcode_nested'] = array( 'av_slide_full' );
  69. $this->config['tooltip'] = __( 'Display a simple fullwidth slideshow element', 'avia_framework' );
  70. $this->config['tinyMCE'] = array( 'disable' => 'true' );
  71. $this->config['drag-level'] = 1;
  72. $this->config['disabling_allowed'] = true;
  73. $this->config['id_name'] = 'id';
  74. $this->config['id_show'] = 'yes';
  75. $this->config['name_item'] = __( 'Fullwidth Easy Slider Item', 'avia_framework' );
  76. $this->config['tooltip_item'] = __( 'A Fullwidth Easy Slider image or video item', 'avia_framework' );
  77. }
  78.  
  79. function extra_assets()
  80. {
  81. //load css
  82. wp_enqueue_style( 'avia-module-slideshow', AviaBuilder::$path['pluginUrlRoot'] . 'avia-shortcodes/slideshow/slideshow.css', array( 'avia-layout' ), false );
  83. wp_enqueue_style( 'avia-module-slideshow-fullsize', AviaBuilder::$path['pluginUrlRoot'] . 'avia-shortcodes/slideshow_fullsize/slideshow_fullsize.css' , array( 'avia-module-slideshow' ), false );
  84.  
  85. //load js
  86. wp_enqueue_script( 'avia-module-slideshow', AviaBuilder::$path['pluginUrlRoot'] . 'avia-shortcodes/slideshow/slideshow.js', array( 'avia-shortcodes' ), false, true );
  87. wp_enqueue_script( 'avia-module-slideshow-video', AviaBuilder::$path['pluginUrlRoot'] . 'avia-shortcodes/slideshow/slideshow-video.js', array( 'avia-shortcodes' ), false, true );
  88. }
  89.  
  90. /**
  91. * Popup Elements
  92. *
  93. * If this function is defined in a child class the element automatically gets an edit button, that, when pressed
  94. * opens a modal window that allows to edit the element properties
  95. *
  96. * @return void
  97. */
  98. function popup_elements()
  99. {
  100. $this->elements = array(
  101.  
  102. array(
  103. 'type' => 'tab_container',
  104. 'nodescription' => true
  105. ),
  106.  
  107. array(
  108. 'type' => 'tab',
  109. 'name' => __( 'Content', 'avia_framework' ),
  110. 'nodescription' => true
  111. ),
  112.  
  113. array(
  114. 'type' => 'template',
  115. 'template_id' => $this->popup_key( 'content_entries' )
  116. ),
  117.  
  118. array(
  119. 'type' => 'tab_close',
  120. 'nodescription' => true
  121. ),
  122.  
  123. array(
  124. 'type' => 'tab',
  125. 'name' => __( 'Styling', 'avia_framework' ),
  126. 'nodescription' => true
  127. ),
  128.  
  129. array(
  130. 'type' => 'template',
  131. 'template_id' => 'toggle_container',
  132. 'templates_include' => array(
  133. $this->popup_key( 'styling_slideshow' ),
  134. $this->popup_key( 'styling_background' )
  135. ),
  136. 'nodescription' => true
  137. ),
  138.  
  139. array(
  140. 'type' => 'tab_close',
  141. 'nodescription' => true
  142. ),
  143.  
  144. array(
  145. 'type' => 'tab',
  146. 'name' => __( 'Advanced', 'avia_framework' ),
  147. 'nodescription' => true
  148. ),
  149.  
  150. array(
  151. 'type' => 'toggle_container',
  152. 'nodescription' => true
  153. ),
  154.  
  155. array(
  156. 'type' => 'template',
  157. 'template_id' => $this->popup_key( 'advanced_privacy' )
  158. ),
  159.  
  160. array(
  161. 'type' => 'template',
  162. 'template_id' => $this->popup_key( 'advanced_animation_slider' )
  163. ),
  164.  
  165. array(
  166. 'type' => 'template',
  167. 'template_id' => 'lazy_loading_toggle',
  168. 'lockable' => true
  169. ),
  170.  
  171. array(
  172. 'type' => 'template',
  173. 'template_id' => 'screen_options_toggle',
  174. 'lockable' => true
  175. ),
  176.  
  177. array(
  178. 'type' => 'template',
  179. 'template_id' => 'developer_options_toggle',
  180. 'args' => array( 'sc' => $this )
  181. ),
  182.  
  183. array(
  184. 'type' => 'toggle_container_close',
  185. 'nodescription' => true
  186. ),
  187.  
  188. array(
  189. 'type' => 'tab_close',
  190. 'nodescription' => true
  191. ),
  192.  
  193. array(
  194. 'type' => 'template',
  195. 'template_id' => 'element_template_selection_tab',
  196. 'args' => array( 'sc' => $this )
  197. ),
  198.  
  199. array(
  200. 'type' => 'tab_container_close',
  201. 'nodescription' => true
  202. )
  203.  
  204. );
  205.  
  206. }
  207.  
  208. /**
  209. * Create and register templates for easier maintainance
  210. *
  211. * @since 4.6.4
  212. */
  213. protected function register_dynamic_templates()
  214. {
  215.  
  216. $this->register_modal_group_templates();
  217.  
  218. /**
  219. * Content Tab
  220. * ===========
  221. */
  222.  
  223. $c = array(
  224. array(
  225. 'type' => 'modal_group',
  226. 'id' => 'content',
  227. 'modal_title' => __( 'Edit Form Element', 'avia_framework' ),
  228. 'add_label' => __( 'Add single image or video', 'avia_framework' ),
  229. 'container_class' => 'avia-element-fullwidth avia-multi-img',
  230. 'std' => array(),
  231. 'editable_item' => true,
  232. 'lockable' => true,
  233. 'tmpl_set_default' => false,
  234. 'creator' => array(
  235. 'name' => __( 'Add Images', 'avia_framework' ),
  236. 'desc' => __( 'Here you can add new Images to the slideshow.', 'avia_framework' ),
  237. 'id' => 'id',
  238. 'type' => 'multi_image',
  239. 'title' => __( 'Add multiple Images', 'avia_framework' ),
  240. 'button' => __( 'Insert Images', 'avia_framework' ),
  241. 'std' => ''
  242. ),
  243. 'subelements' => $this->create_modal()
  244. ),
  245.  
  246. array(
  247. 'name' => __( 'Use first slides caption as permanent caption', 'avia_framework' ),
  248. 'desc' => __( 'If checked the caption will be placed on top of the slider. Please be aware that all slideshow link settings and other captions will be ignored then', 'avia_framework' ) ,
  249. 'id' => 'perma_caption',
  250. 'type' => 'checkbox',
  251. 'std' => '',
  252. 'lockable' => true
  253. )
  254. );
  255.  
  256. AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'content_entries' ), $c );
  257.  
  258.  
  259. /**
  260. * Styling Tab
  261. * ===========
  262. */
  263.  
  264. $c = array(
  265. array(
  266. 'name' => __( 'Slideshow Image and Video Size', 'avia_framework' ),
  267. 'desc' => __( 'Choose image and Video size for your slideshow.', 'avia_framework' ),
  268. 'id' => 'size',
  269. 'type' => 'select',
  270. 'std' => 'featured',
  271. 'container_class' => 'av_half av_half_first',
  272. 'lockable' => true,
  273. 'subtype' => AviaHelper::get_registered_image_sizes( 1000 )
  274. ),
  275.  
  276. array(
  277. 'name' => __( 'Slider minimum height in pixel', 'avia_framework' ),
  278. 'desc' => __( 'This is helpful on smaller screens if you got a lot of text in your slider', 'avia_framework' ),
  279. 'id' => 'min_height',
  280. 'type' => 'input',
  281. 'container_class' => 'av_half',
  282. 'std' => '0px',
  283. 'lockable' => true,
  284. ),
  285.  
  286. array(
  287. 'name' => __( 'Stretch image to fit the slideshow size?', 'avia_framework' ),
  288. 'desc' => __( 'By default the image stretches across the full width of the screen. You can deactivate this behavior and simply align it in the center of the slider', 'avia_framework' ),
  289. 'id' => 'stretch',
  290. 'type' => 'select',
  291. 'std' => '',
  292. 'lockable' => true,
  293. 'subtype' => array(
  294. __( 'Yes, stretch the image', 'avia_framework' ) => '',
  295. __( 'No, dont stretch the image. If the browser window is bigger than the image simply align it centered', 'avia_framework' ) => 'image_no_stretch'
  296. )
  297. ),
  298.  
  299. array(
  300. 'name' => __( 'Slideshow control styling?', 'avia_framework' ),
  301. 'desc' => __( 'Here you can select if and how to display the slideshow controls', 'avia_framework' ),
  302. 'id' => 'control_layout',
  303. 'type' => 'select',
  304. 'std' => 'av-control-default',
  305. 'lockable' => true,
  306. 'subtype' => array(
  307. __( 'Default', 'avia_framework' ) => 'av-control-default',
  308. __( 'Minimal White', 'avia_framework' ) => 'av-control-minimal',
  309. __( 'Minimal Black', 'avia_framework' ) => 'av-control-minimal av-control-minimal-dark',
  310. __( 'Hidden', 'avia_framework' ) => 'av-control-hidden'
  311. )
  312. )
  313. );
  314.  
  315. $template = array(
  316. array(
  317. 'type' => 'template',
  318. 'template_id' => 'toggle',
  319. 'title' => __( 'Slideshow Settings', 'avia_framework' ),
  320. 'content' => $c
  321. ),
  322. );
  323.  
  324. AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'styling_slideshow' ), $template );
  325.  
  326. $c = array(
  327. array(
  328. 'name' => __( 'Slideshow Background Image', 'avia_framework' ),
  329. 'desc' => __( 'If you are displaying transparent images like pngs you can set a static background image or pattern that will appear behind those pngs.', 'avia_framework' ),
  330. 'id' => 'src',
  331. 'type' => 'image',
  332. 'title' => __( 'Insert Image', 'avia_framework' ),
  333. 'button' => __( 'Insert', 'avia_framework' ),
  334. 'std' => '',
  335. 'lockable' => true,
  336. 'locked' => array( 'src', 'attachment', 'attachment_size' )
  337. ),
  338.  
  339. array(
  340. 'type' => 'template',
  341. 'template_id' => 'background_image_position',
  342. 'args' => array(
  343. 'id_pos' => 'position',
  344. 'id_repeat' => 'repeat',
  345. 'repeat_remove' => array( 'contain' )
  346. ),
  347. 'lockable' => true
  348. ),
  349.  
  350. array(
  351. 'name' => __( 'Background Attachment', 'avia_framework' ),
  352. 'id' => 'attach',
  353. 'type' => 'select',
  354. 'std' => 'scroll',
  355. 'lockable' => true,
  356. 'required' => array( 'src', 'not', '' ),
  357. 'subtype' => array(
  358. __( 'Scroll', 'avia_framework' ) => 'scroll',
  359. __( 'Fixed', 'avia_framework' ) => 'fixed'
  360. )
  361. )
  362.  
  363. );
  364.  
  365. $template = array(
  366. array(
  367. 'type' => 'template',
  368. 'template_id' => 'toggle',
  369. 'title' => __( 'Slideshow Background', 'avia_framework' ),
  370. 'content' => $c
  371. ),
  372. );
  373.  
  374. AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'styling_background' ), $template );
  375.  
  376. /**
  377. * Advanced Tab
  378. * ============
  379. */
  380.  
  381. $c = array(
  382. array(
  383. 'name' => __( 'Slideshow Transition', 'avia_framework' ),
  384. 'desc' => __( 'Choose the transition for your Slideshow.', 'avia_framework' ),
  385. 'id' => 'animation',
  386. 'type' => 'select',
  387. 'std' => 'slide',
  388. 'lockable' => true,
  389. 'subtype' => array(
  390. __( 'Slide sidewards', 'avia_framework' ) => 'slide',
  391. __( 'Slide up/down', 'avia_framework' ) => 'slide_up',
  392. __( 'Fade', 'avia_framework' ) => 'fade'
  393. ),
  394. ),
  395.  
  396. array(
  397. 'name' => __( 'Transition Speed', 'avia_framework' ),
  398. 'desc' => __( 'Selected speed in milliseconds for transition effect.', 'avia_framework' ),
  399. 'id' => 'transition_speed',
  400. 'type' => 'select',
  401. 'std' => '',
  402. 'lockable' => true,
  403. 'subtype' => AviaHtmlHelper::number_array( 100, 10000, 100, array( __( 'Use Default', 'avia_framework' ) => '' ) )
  404. ),
  405.  
  406. array(
  407. 'name' => __( 'Autorotation active?', 'avia_framework' ),
  408. 'desc' => __( 'Check if the slideshow should rotate by default', 'avia_framework' ),
  409. 'id' => 'autoplay',
  410. 'type' => 'select',
  411. 'std' => 'false',
  412. 'lockable' => true,
  413. 'subtype' => array(
  414. __( 'Yes', 'avia_framework' ) => 'true',
  415. __( 'No', 'avia_framework' ) => 'false'
  416. )
  417. ),
  418.  
  419. array(
  420. 'name' => __( 'Stop Autorotation with the last slide', 'avia_framework' ),
  421. 'desc' => __( 'Check if you want to disable autorotation when this last slide is displayed', 'avia_framework' ),
  422. 'id' => 'autoplay_stopper',
  423. 'type' => 'checkbox',
  424. 'std' => '',
  425. 'lockable' => true,
  426. 'required' => array( 'autoplay', 'equals', 'true' )
  427. ),
  428.  
  429. array(
  430. 'name' => __( 'Slideshow autorotation duration', 'avia_framework' ),
  431. 'desc' => __( 'Images will be shown the selected amount of seconds.', 'avia_framework' ),
  432. 'id' => 'interval',
  433. 'type' => 'select',
  434. 'std' => '5',
  435. 'lockable' => true,
  436. 'required' => array( 'autoplay', 'equals', 'true' ),
  437. 'subtype' => array( '1'=>'1', '2'=>'2', '3'=>'3', '4'=>'4', '5'=>'5', '6'=>'6', '7'=>'7', '8'=>'8', '9'=>'9', '10'=>'10', '15'=>'15', '20'=>'20', '30'=>'30', '40'=>'40', '60'=>'60', '100'=>'100' )
  438. )
  439. );
  440.  
  441. $template = array(
  442. array(
  443. 'type' => 'template',
  444. 'template_id' => 'toggle',
  445. 'title' => __( 'Slider Animation', 'avia_framework' ),
  446. 'content' => $c
  447. ),
  448. );
  449.  
  450. AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'advanced_animation_slider' ), $template );
  451.  
  452. $c = array(
  453. array(
  454. 'name' => __( 'Lazy Load videos', 'avia_framework' ),
  455. 'desc' => __( 'Option to only load the preview image of a video slide. The actual videos will only be fetched once the user clicks on the image (Waiting for user interaction speeds up the inital pageload)', 'avia_framework' ),
  456. 'id' => 'conditional_play',
  457. 'type' => 'select',
  458. 'std' => '',
  459. 'lockable' => true,
  460. 'subtype' => array(
  461. __( 'Always load videos', 'avia_framework' ) => '',
  462. __( 'Wait for user interaction or for a slide with active autoplay to load the video', 'avia_framework' ) => 'confirm_all'
  463. )
  464. )
  465. );
  466.  
  467. $template = array(
  468. array(
  469. 'type' => 'template',
  470. 'template_id' => 'toggle',
  471. 'title' => __( 'Privacy', 'avia_framework' ),
  472. 'content' => $c
  473. ),
  474. );
  475.  
  476. AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'advanced_privacy' ), $template );
  477. }
  478.  
  479. /**
  480. * Creates the modal popup for a single entry
  481. *
  482. * @since 4.6.4
  483. * @return array
  484. */
  485. protected function create_modal()
  486. {
  487. $elements = array(
  488.  
  489. array(
  490. 'type' => 'tab_container',
  491. 'nodescription' => true
  492. ),
  493.  
  494. array(
  495. 'type' => 'tab',
  496. 'name' => __( 'Content', 'avia_framework' ),
  497. 'nodescription' => true
  498. ),
  499.  
  500. array(
  501. 'type' => 'template',
  502. 'template_id' => 'toggle_container',
  503. 'templates_include' => array(
  504. $this->popup_key( 'modal_content_slidecontent' ),
  505. $this->popup_key( 'modal_content_fallback' ),
  506. $this->popup_key( 'modal_content_caption' )
  507. ),
  508. 'nodescription' => true
  509. ),
  510.  
  511. array(
  512. 'type' => 'tab_close',
  513. 'nodescription' => true
  514. ),
  515.  
  516. array(
  517. 'type' => 'tab',
  518. 'name' => __( 'Styling', 'avia_framework' ),
  519. 'nodescription' => true
  520. ),
  521.  
  522. array(
  523. 'type' => 'template',
  524. 'template_id' => 'toggle_container',
  525. 'templates_include' => array(
  526. $this->popup_key( 'modal_styling_video' ),
  527. $this->popup_key( 'modal_styling_caption' ),
  528. $this->popup_key( 'modal_styling_fonts' ),
  529. $this->popup_key( 'modal_styling_colors' ),
  530. ),
  531. 'nodescription' => true
  532. ),
  533.  
  534. array(
  535. 'type' => 'tab_close',
  536. 'nodescription' => true
  537. ),
  538.  
  539. array(
  540. 'type' => 'tab',
  541. 'name' => __( 'Advanced', 'avia_framework' ),
  542. 'nodescription' => true
  543. ),
  544.  
  545. array(
  546. 'type' => 'template',
  547. 'template_id' => 'toggle_container',
  548. 'templates_include' => array(
  549. $this->popup_key( 'modal_advanced_heading' ),
  550. $this->popup_key( 'modal_advanced_link' ),
  551. $this->popup_key( 'modal_advanced_overlay' )
  552. ),
  553. 'nodescription' => true
  554. ),
  555.  
  556. array(
  557. 'type' => 'tab_close',
  558. 'nodescription' => true
  559. ),
  560.  
  561. array(
  562. 'type' => 'template',
  563. 'template_id' => 'element_template_selection_tab',
  564. 'args' => array(
  565. 'sc' => $this,
  566. 'modal_group' => true
  567. )
  568. ),
  569.  
  570. array(
  571. 'type' => 'tab_container_close',
  572. 'nodescription' => true
  573. )
  574. );
  575.  
  576. return $elements;
  577. }
  578.  
  579. /**
  580. * Register all templates for the modal group popup
  581. *
  582. * @since 4.6.4
  583. */
  584. protected function register_modal_group_templates()
  585. {
  586. /**
  587. * Content Tab
  588. * ===========
  589. */
  590.  
  591. $c = array(
  592. array(
  593. 'name' => __( 'Which type of slide is this?', 'avia_framework' ),
  594. 'id' => 'slide_type',
  595. 'type' => 'select',
  596. 'std' => '',
  597. 'lockable' => true,
  598. 'subtype' => array(
  599. __( 'Image Slide', 'avia_framework' ) => 'image',
  600. __( 'Video Slide', 'avia_framework' ) => 'video',
  601. )
  602. ),
  603.  
  604. array(
  605. 'name' => __( 'Choose another Image', 'avia_framework' ),
  606. 'desc' => __( 'Either upload a new, or choose an existing image from your media library', 'avia_framework' ),
  607. 'id' => 'id',
  608. 'type' => 'image',
  609. 'fetch' => 'id',
  610. 'title' => __( 'Change Image', 'avia_framework' ),
  611. 'button' => __( 'Change Image', 'avia_framework' ),
  612. 'std' => '',
  613. 'lockable' => true,
  614. 'required' => array( 'slide_type', 'is_empty_or', 'image' ),
  615. ),
  616.  
  617. array(
  618. 'type' => 'template',
  619. 'template_id' => 'video',
  620. 'required' => array( 'slide_type', 'equals', 'video' ),
  621. 'id' => 'video',
  622. 'args' => array(
  623. 'sc' => $this
  624. ),
  625. 'lockable' => true,
  626. )
  627.  
  628. );
  629.  
  630. $template = array(
  631. array(
  632. 'type' => 'template',
  633. 'template_id' => 'toggle',
  634. 'title' => __( 'Select Slide Content', 'avia_framework' ),
  635. 'content' => $c
  636. ),
  637. );
  638.  
  639. AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'modal_content_slidecontent' ), $template );
  640.  
  641. $c = array(
  642. array(
  643. 'type' => 'template',
  644. 'template_id' => 'slideshow_fallback_image',
  645. 'lockable' => true
  646. )
  647.  
  648. );
  649.  
  650. $template = array(
  651. array(
  652. 'type' => 'template',
  653. 'template_id' => 'toggle',
  654. 'title' => __( 'Fallback images', 'avia_framework' ),
  655. 'content' => $c
  656. ),
  657. );
  658.  
  659. AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'modal_content_fallback' ), $template );
  660.  
  661. $c = array(
  662. array(
  663. 'name' => __( 'Caption Title', 'avia_framework' ),
  664. 'desc' => __( 'Enter a caption title for the slide here', 'avia_framework' ) ,
  665. 'id' => 'title',
  666. 'type' => 'input',
  667. 'std' => '',
  668. 'lockable' => true
  669. ),
  670.  
  671. array(
  672. 'name' => __( 'Caption Text', 'avia_framework' ),
  673. 'desc' => __( 'Enter some additional caption text', 'avia_framework' ) ,
  674. 'id' => 'content',
  675. 'type' => 'textarea',
  676. 'std' => '',
  677. 'lockable' => true
  678. )
  679. );
  680.  
  681. $template = array(
  682. array(
  683. 'type' => 'template',
  684. 'template_id' => 'toggle',
  685. 'title' => __( 'Caption', 'avia_framework' ),
  686. 'content' => $c
  687. ),
  688. );
  689.  
  690. AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'modal_content_caption' ), $template );
  691.  
  692. /**
  693. * Styling Tab
  694. * ===========
  695. */
  696.  
  697. $c = array(
  698. array(
  699. 'name' => __( 'Video Size', 'avia_framework' ),
  700. 'desc' => __( "By default the video will try to match the default slideshow size that was selected in the slider settings at 'Slideshow Image and Video Size'", 'avia_framework' ),
  701. 'id' => 'video_format',
  702. 'type' => 'select',
  703. 'std' => '',
  704. 'lockable' => true,
  705. 'required' => array( 'slide_type', 'equals', 'video' ),
  706. 'subtype' => array(
  707. __( 'Try to match the default slideshow size (Video will not be cropped, but black borders will be visible at each side)', 'avia_framework' ) => '',
  708. __( 'Try to match the default slideshow size but stretch the video to fill the whole slider (video will be cropped at top and bottom)', 'avia_framework' ) => 'stretch',
  709. __( 'Show the full Video without cropping', 'avia_framework' ) =>'full',
  710. )
  711. ),
  712.  
  713. array(
  714. 'name' => __( 'Video Aspect Ratio', 'avia_framework' ),
  715. 'desc' => __( 'In order to calculate the correct height and width for the video slide you need to enter a aspect ratio (width:height). usually: 16:9 or 4:3.', 'avia_framework' ) . '<br/>' . __( 'If left empty 16:9 will be used', 'avia_framework' ),
  716. 'id' => 'video_ratio',
  717. 'type' => 'input',
  718. 'std' => '16:9',
  719. 'lockable' => true,
  720. 'required' => array( 'video_format', 'not', '' )
  721. ),
  722.  
  723.  
  724. array(
  725. 'type' => 'template',
  726. 'template_id' => 'slideshow_player',
  727. 'required' => array( 'slide_type', 'equals', 'video' ),
  728. 'lockable' => true
  729. ),
  730.  
  731. );
  732.  
  733. $template = array(
  734. array(
  735. 'type' => 'template',
  736. 'template_id' => 'toggle',
  737. 'title' => __( 'Video Settings', 'avia_framework' ),
  738. 'content' => $c
  739. )
  740. );
  741.  
  742. AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'modal_styling_video' ), $template );
  743.  
  744. $c = array(
  745. array(
  746. 'name' => __( 'Caption Positioning', 'avia_framework' ),
  747. 'id' => 'caption_pos',
  748. 'type' => 'select',
  749. 'std' => 'caption_bottom',
  750. 'lockable' => true,
  751. 'subtype' => array(
  752. __( 'Right Framed', 'avia_framework' ) => 'caption_right caption_right_framed caption_framed',
  753. __( 'Left Framed', 'avia_framework' ) => 'caption_left caption_left_framed caption_framed',
  754. __( 'Bottom Framed', 'avia_framework' ) => 'caption_bottom caption_bottom_framed caption_framed',
  755. __( 'Center Framed', 'avia_framework' ) => 'caption_center caption_center_framed caption_framed',
  756. __( 'Right without Frame', 'avia_framework' ) => 'caption_right',
  757. __( 'Left without Frame', 'avia_framework' ) => 'caption_left',
  758. __( 'Bottom without Frame', 'avia_framework' ) => 'caption_bottom',
  759. __( 'Center without Frame', 'avia_framework' ) => 'caption_center'
  760. ),
  761. )
  762.  
  763. );
  764.  
  765. $template = array(
  766. array(
  767. 'type' => 'template',
  768. 'template_id' => 'toggle',
  769. 'title' => __( 'Caption', 'avia_framework' ),
  770. 'content' => $c
  771. ),
  772. );
  773.  
  774. AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'modal_styling_caption' ), $template );
  775.  
  776. $c = array(
  777. array(
  778. 'name' => __( 'Caption Title Font Size', 'avia_framework' ),
  779. 'desc' => __( 'Select a custom font size for the titles.', 'avia_framework' ),
  780. 'type' => 'template',
  781. 'template_id' => 'font_sizes_icon_switcher',
  782. 'lockable' => true,
  783. 'subtype' => array(
  784. 'default' => AviaHtmlHelper::number_array( 10, 120, 1, array( __( 'Use Default', 'avia_framework' ) => '' ), 'px' ),
  785. 'medium' => AviaHtmlHelper::number_array( 10, 120, 1, array( __( 'Use Default', 'avia_framework' ) => '', __( 'Hidden', 'avia_framework' ) => 'hidden' ), 'px' ),
  786. 'small' => AviaHtmlHelper::number_array( 10, 120, 1, array( __( 'Use Default', 'avia_framework' ) => '', __( 'Hidden', 'avia_framework' ) => 'hidden' ), 'px' ),
  787. 'mini' => AviaHtmlHelper::number_array( 10, 120, 1, array( __( 'Use Default', 'avia_framework' ) => '', __( 'Hidden', 'avia_framework' ) => 'hidden' ), 'px' )
  788. ),
  789. 'id_sizes' => array(
  790. 'default' => 'custom_title_size',
  791. 'medium' => 'av-medium-font-size-title',
  792. 'small' => 'av-small-font-size-title',
  793. 'mini' => 'av-mini-font-size-title'
  794. )
  795. ),
  796.  
  797. array(
  798. 'name' => __( 'Caption Content Font Size', 'avia_framework' ),
  799. 'desc' => __( 'Select a custom font size for the titles.', 'avia_framework' ),
  800. 'type' => 'template',
  801. 'template_id' => 'font_sizes_icon_switcher',
  802. 'lockable' => true,
  803. 'subtype' => array(
  804. 'default' => AviaHtmlHelper::number_array( 10, 90, 1, array( __( 'Use Default', 'avia_framework' ) => '' ), 'px' ),
  805. 'medium' => AviaHtmlHelper::number_array( 10, 90, 1, array( __( 'Use Default', 'avia_framework' ) => '', __( 'Hidden', 'avia_framework' ) => 'hidden' ), 'px' ),
  806. 'small' => AviaHtmlHelper::number_array( 10, 90, 1, array( __( 'Use Default', 'avia_framework' ) => '', __( 'Hidden', 'avia_framework' ) => 'hidden' ), 'px' ),
  807. 'mini' => AviaHtmlHelper::number_array( 10, 90, 1, array( __( 'Use Default', 'avia_framework' ) => '', __( 'Hidden', 'avia_framework' ) => 'hidden' ), 'px' )
  808. ),
  809. 'id_sizes' => array(
  810. 'default' => 'custom_content_size',
  811. 'medium' => 'av-medium-font-size',
  812. 'small' => 'av-small-font-size',
  813. 'mini' => 'av-mini-font-size'
  814. )
  815. )
  816. );
  817.  
  818. $template = array(
  819. array(
  820. 'type' => 'template',
  821. 'template_id' => 'toggle',
  822. 'title' => __( 'Font Sizes', 'avia_framework' ),
  823. 'content' => $c
  824. ),
  825. );
  826.  
  827. AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'modal_styling_fonts' ), $template );
  828.  
  829. $c = array(
  830. array(
  831. 'name' => __( 'Font Colors', 'avia_framework' ),
  832. 'desc' => __( 'Either use the themes default colors or apply some custom ones', 'avia_framework' ),
  833. 'id' => 'font_color',
  834. 'type' => 'select',
  835. 'std' => '',
  836. 'lockable' => true,
  837. 'subtype' => array(
  838. __( 'Default', 'avia_framework' ) => '',
  839. __( 'Define Custom Colors', 'avia_framework' ) => 'custom'
  840. ),
  841. ),
  842.  
  843. array(
  844. 'name' => __( 'Custom Caption Title Font Color', 'avia_framework' ),
  845. 'desc' => __( 'Select a custom font color. Leave empty to use the default', 'avia_framework' ),
  846. 'id' => 'custom_title',
  847. 'type' => 'colorpicker',
  848. 'std' => '',
  849. 'container_class' => 'av_half av_half_first',
  850. 'lockable' => true,
  851. 'required' => array( 'font_color', 'equals', 'custom' )
  852. ),
  853.  
  854. array(
  855. 'name' => __( 'Custom Caption Content Font Color', 'avia_framework' ),
  856. 'desc' => __( 'Select a custom font color. Leave empty to use the default', 'avia_framework' ),
  857. 'id' => 'custom_content',
  858. 'type' => 'colorpicker',
  859. 'std' => '',
  860. 'container_class' => 'av_half',
  861. 'lockable' => true,
  862. 'required' => array( 'font_color', 'equals', 'custom' )
  863. ),
  864.  
  865. );
  866.  
  867. $template = array(
  868. array(
  869. 'type' => 'template',
  870. 'template_id' => 'toggle',
  871. 'title' => __( 'Colors', 'avia_framework' ),
  872. 'content' => $c
  873. ),
  874. );
  875.  
  876. AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'modal_styling_colors' ), $template );
  877.  
  878. /**
  879. * Advanced Tab
  880. * ===========
  881. */
  882.  
  883. $c = array(
  884. array(
  885. 'type' => 'template',
  886. 'template_id' => 'heading_tag',
  887. 'theme_default' => 'h2',
  888. 'context' => __CLASS__,
  889. 'lockable' => true
  890. ),
  891.  
  892. );
  893.  
  894. $template = array(
  895. array(
  896. 'type' => 'template',
  897. 'template_id' => 'toggle',
  898. 'title' => __( 'Heading Tag', 'avia_framework' ),
  899. 'content' => $c
  900. ),
  901. );
  902.  
  903. AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'modal_advanced_heading' ), $template );
  904.  
  905. $c = array(
  906.  
  907. array(
  908. 'type' => 'template',
  909. 'template_id' => 'slideshow_button_links',
  910. 'lockable' => true
  911. )
  912. );
  913.  
  914. $template = array(
  915. array(
  916. 'type' => 'template',
  917. 'template_id' => 'toggle',
  918. 'title' => __( 'Link Settings', 'avia_framework' ),
  919. 'content' => $c
  920. ),
  921. );
  922.  
  923. AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'modal_advanced_link' ), $template );
  924.  
  925. $c = array(
  926. array(
  927. 'type' => 'template',
  928. 'template_id' => 'slideshow_overlay',
  929. 'lockable' => true
  930. ),
  931. );
  932.  
  933. $template = array(
  934. array(
  935. 'type' => 'template',
  936. 'template_id' => 'toggle',
  937. 'title' => __( 'Overlay', 'avia_framework' ),
  938. 'content' => $c
  939. ),
  940. );
  941.  
  942. AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'modal_advanced_overlay' ), $template );
  943.  
  944. }
  945.  
  946. /**
  947. * Editor Element - this function defines the visual appearance of an element on the AviaBuilder Canvas
  948. * Most common usage is to define some markup in the $params['innerHtml'] which is then inserted into the drag and drop container
  949. * Less often used: $params['data'] to add data attributes, $params['class'] to modify the className
  950. *
  951. *
  952. * @param array $params this array holds the default values for $content and $args.
  953. * @return $params the return array usually holds an innerHtml key that holds item specific markup.
  954. */
  955. function editor_element( $params )
  956. {
  957.  
  958. $params = parent::editor_element( $params );
  959. return $params;
  960. }
  961.  
  962. /**
  963. * Editor Sub Element - this function defines the visual appearance of an element that is displayed within a modal window and on click opens its own modal window
  964. * Works in the same way as Editor Element
  965. * @param array $params this array holds the default values for $content and $args.
  966. * @return $params the return array usually holds an innerHtml key that holds item specific markup.
  967. */
  968. function editor_sub_element( $params )
  969. {
  970. $default = array();
  971. $locked = array();
  972. $attr = $params['args'];
  973. $content = $params['content'];
  974. Avia_Element_Templates()->set_locked_attributes( $attr, $this, $this->config['shortcode_nested'][0], $default, $locked, $content );
  975.  
  976. $img_template = $this->update_option_lockable( array( 'id', 'img_fakeArg' ), $locked );
  977. $title_templ = $this->update_option_lockable( 'title', $locked );
  978. $content_tmpl = $this->update_option_lockable( 'content', $locked );
  979. $video_tmpl = $this->update_option_lockable( 'video', $locked );
  980.  
  981. $thumbnail = isset( $attr['id'] ) ? wp_get_attachment_image( $attr['id'] ) : '';
  982.  
  983. $params['innerHtml'] = '';
  984. $params['innerHtml'] .= '<div class="avia_title_container" data-update_element_template="yes">';
  985. $params['innerHtml'] .= '<div ' . $this->class_by_arguments_lockable( 'slide_type', $attr, $locked ) . '>';
  986. $params['innerHtml'] .= "<span class='avia_slideshow_image' {$img_template} >{$thumbnail}</span>";
  987. $params['innerHtml'] .= '<div class="avia_slideshow_content">';
  988. $params['innerHtml'] .= "<h4 class='avia_title_container_inner' {$title_templ} >{$attr['title']}</h4>";
  989. $params['innerHtml'] .= "<p class='avia_content_container' {$content_tmpl}>" . stripslashes( $content ) . '</p>';
  990. $params['innerHtml'] .= "<small class='avia_video_url' {$video_tmpl}>" . stripslashes( $attr['video'] ) . '</small>';
  991. $params['innerHtml'] .= '</div>';
  992. $params['innerHtml'] .= '</div>';
  993. $params['innerHtml'] .= '</div>';
  994.  
  995. return $params;
  996. }
  997.  
  998. /**
  999. *
  1000. * @since 4.8.9
  1001. * @param array $args
  1002. * @return array
  1003. */
  1004. protected function get_element_styles( array $args )
  1005. {
  1006. $result = parent::get_element_styles( $args );
  1007.  
  1008. // @since 4.9 - bugfix for cloned element where av_uid was not changed
  1009. if( current_theme_supports( 'avia_post_css_slideshow_fix' ) )
  1010. {
  1011. $result['element_id'] = 'av-' . md5( $result['element_id'] . $result['content'] );
  1012. }
  1013.  
  1014. extract( $result );
  1015.  
  1016. $default = array(
  1017. 'size' => 'featured',
  1018. 'animation' => 'slide',
  1019. 'transition_speed' => '',
  1020. 'ids' => '',
  1021. 'autoplay' => 'false',
  1022. 'interval' => 5,
  1023. 'src' => '',
  1024. 'position' => 'top left',
  1025. 'repeat' => 'no-repeat',
  1026. 'attach' => 'scroll',
  1027. //'easing' => 'easeInOutQuint',
  1028. 'stretch' => '',
  1029. 'control_layout' => 'av-control-default',
  1030. 'perma_caption' => '',
  1031. 'autoplay_stopper' => '',
  1032. 'min_height' => '0px',
  1033. 'lazy_loading' => 'disabled',
  1034. 'img_scrset' => ''
  1035. );
  1036.  
  1037. // Backwards comp. - make sure to provide "old" defaults for options not set and override with default options provided
  1038. $default = array_merge( avia_slideshow::default_args(), $this->sync_sc_defaults_array( $default, 'no_modal_item', 'no_content' ) );
  1039.  
  1040.  
  1041. $locked = array();
  1042. Avia_Element_Templates()->set_locked_attributes( $atts, $this, $shortcodename, $default, $locked, $content );
  1043. Avia_Element_Templates()->add_template_class( $meta, $atts, $default );
  1044.  
  1045. $add = array(
  1046. 'handle' => $shortcodename,
  1047. 'content' => ShortcodeHelper::shortcode2array( $content, 1 ),
  1048. 'class' => '',
  1049. 'custom_markup' => '',
  1050. 'el_id' => '',
  1051. 'heading_tag' => '',
  1052. 'heading_class' => ''
  1053. );
  1054.  
  1055. $defaults = array_merge( $default, $add );
  1056.  
  1057. $atts = shortcode_atts( $defaults, $atts, $this->config['shortcode'] );
  1058.  
  1059. foreach( $atts['content'] as $key => &$item )
  1060. {
  1061. $item_def = $this->get_default_modal_group_args();
  1062. Avia_Element_Templates()->set_locked_attributes( $item['attr'], $this, $this->config['shortcode_nested'][0], $item_def, $locked, $item['content'] );
  1063. }
  1064.  
  1065. unset( $item );
  1066.  
  1067. if( ! isset( $this->obj_slideshow[ $element_id ] ) )
  1068. {
  1069. $this->obj_slideshow[ $element_id ] = new avia_slideshow( $atts, $this );
  1070. }
  1071.  
  1072. $slideshow = $this->obj_slideshow[ $element_id ];
  1073.  
  1074. $update = array(
  1075. 'class' => ! empty( $meta['custom_class'] ) ? $meta['custom_class'] : '',
  1076. 'custom_markup' => ! empty( $meta['custom_markup'] ) ? $meta['custom_markup'] : '',
  1077. // 'el_id' => ! empty( $meta['custom_el_id'] ) ? $meta['custom_el_id'] : '',
  1078. // 'heading_tag' => ! empty( $meta['heading_tag'] ) ? $meta['heading_tag'] : '',
  1079. // 'heading_class' => ! empty( $meta['heading_class'] ) ? $meta['heading_class'] : '',
  1080. );
  1081.  
  1082. $atts = $slideshow->update_config( $update );
  1083.  
  1084.  
  1085. $result['default'] = $default;
  1086. $result['atts'] = $atts;
  1087. $result['content'] = $content;
  1088. $result['element_styling'] = $element_styling;
  1089. $result['meta'] = $meta;
  1090.  
  1091. $result = $slideshow->get_element_styles( $result );
  1092.  
  1093. return $result;
  1094. }
  1095.  
  1096. /**
  1097. * Frontend Shortcode Handler
  1098. *
  1099. * @param array $atts array of attributes
  1100. * @param string $content text within enclosing form of shortcode element
  1101. * @param string $shortcodename the shortcode found, when == callback name
  1102. * @return string $output returns the modified html string
  1103. */
  1104. function shortcode_handler( $atts, $content = '', $shortcodename = '', $meta = '' )
  1105. {
  1106. $result = $this->get_element_styles( compact( array( 'atts', 'content', 'shortcodename', 'meta' ) ) );
  1107.  
  1108. extract( $result );
  1109. extract( $atts );
  1110.  
  1111. if( 'disabled' == $atts['img_scrset'] )
  1112. {
  1113. Av_Responsive_Images()->force_disable( 'disabled' );
  1114. }
  1115.  
  1116. $background = '';
  1117. $class = '';
  1118.  
  1119. if( $src != '' )
  1120. {
  1121. if( $repeat == 'stretch' )
  1122. {
  1123. $background .= 'background-repeat: no-repeat; ';
  1124. $class .= ' avia-full-stretch';
  1125. }
  1126. else
  1127. {
  1128. $background .= "background-repeat: {$repeat}; ";
  1129. }
  1130.  
  1131. $background .= "background-image: url({$src}); ";
  1132. $background .= "background-attachment: {$attach}; ";
  1133. $background .= "background-position: {$position}; ";
  1134. }
  1135.  
  1136. if( $background )
  1137. {
  1138. $params['bg'] = $background;
  1139. }
  1140.  
  1141. $skipSecond = false;
  1142. avia_sc_slider_full::$slide_count ++;
  1143. $av_display_classes = $element_styling->responsive_classes_string( 'hide_element', $atts );
  1144.  
  1145. $params['class'] = "avia-fullwidth-slider main_color avia-shadow {$av_display_classes} {$meta['el_class']} {$class}";
  1146. $params['open_structure'] = false;
  1147.  
  1148. //we dont need a closing structure if the element is the first one or if a previous fullwidth element was displayed before
  1149. if( isset( $meta['index'] ) && $meta['index'] == 0 )
  1150. {
  1151. $params['close'] = false;
  1152. }
  1153.  
  1154. if( ! empty( $meta['siblings']['prev']['tag'] ) && in_array( $meta['siblings']['prev']['tag'], AviaBuilder::$full_el_no_section ) )
  1155. {
  1156. $params['close'] = false;
  1157. }
  1158.  
  1159. if( isset( $meta['index'] ) && $meta['index'] > 0 )
  1160. {
  1161. $params['class'] .= ' slider-not-first';
  1162. }
  1163.  
  1164. $params['id'] = AviaHelper::save_string( $meta['custom_id_val'], '-', 'full_slider_' . avia_sc_slider_full::$slide_count );
  1165.  
  1166. $slideshow = $this->obj_slideshow[ $element_id ];
  1167. $slideshow->set_extra_class( $atts['stretch'] );
  1168.  
  1169.  
  1170. $output = '';
  1171. $output .= avia_new_section( $params );
  1172. $output .= $slideshow->html();
  1173. $output .= '</div>'; //close section
  1174.  
  1175. Av_Responsive_Images()->force_disable( 'reset' );
  1176.  
  1177. //if the next tag is a section dont create a new section from this shortcode
  1178. if( ! empty( $meta['siblings']['next']['tag'] ) && in_array( $meta['siblings']['next']['tag'], AviaBuilder::$full_el ) )
  1179. {
  1180. $skipSecond = true;
  1181. }
  1182.  
  1183. //if there is no next element dont create a new section.
  1184. if( empty( $meta['siblings']['next']['tag'] ) )
  1185. {
  1186. $skipSecond = true;
  1187. }
  1188.  
  1189. if( empty( $skipSecond ) )
  1190. {
  1191. $output .= avia_new_section( array( 'close' => false, 'id' => 'after_full_slider_' . avia_sc_slider_full::$slide_count ) );
  1192. }
  1193.  
  1194. return $output;
  1195. }
  1196. }
  1197. }
  1198.  
  1199.  
  1200.  
Advertisement
Add Comment
Please, Sign In to add comment