PluginProbe
Borderless – Addons and Templates for Elementor / 1.2.3
Borderless – Addons and Templates for Elementor v1.2.3
trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.2.2 1.2.3 All 78 releases
borderless / includes / widgets / divider.php

divider.php in Borderless – Addons and Templates for Elementor 1.2.3, at includes/widgets/divider.php

153 lines 7.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Adds Borderless_Widget_Divider widget.
4 */
5 class Borderless_Widget_Divider extends WP_Widget {
6
7 /**
8 * Register widget with WordPress.
9 */
10 function __construct() {
11 parent::__construct(
12 'borderless_divider', // Base ID
13 __( 'Borderless - Divider', 'borderless' ), // Name
14 array( 'description' => __( 'Divider allows add horizontal or vertical line between elements.', 'borderless' ), ) // Args
15 );
16 }
17
18 /**
19 * Front-end display of widget.
20 *
21 * @see WP_Widget::widget()
22 *
23 * @param array $args Widget arguments.
24 * @param array $instance Saved values from database.
25 */
26 public function widget( $args, $instance ) {
27 extract( $args );
28 $axis = apply_filters('widget_axis', $instance['axis']);
29 $color = apply_filters('widget_color', $instance['color']);
30 $size = apply_filters('widget_size', $instance['size']);
31 $space = apply_filters('widget_space', $instance['space']);
32
33 // Retrieve data from the database.
34 $options = get_option( 'borderless' );
35 $borderless_primary_color = isset( $options['primary_color'] ) ? $options['primary_color'] : '#0000FF'; //Primary Color
36 $borderless_secondary_color = isset( $options['secondary_color'] ) ? $options['secondary_color'] : '#FF6819'; //Secondary Color
37 $borderless_tertiary_color = isset( $options['tertiary_color'] ) ? $options['tertiary_color'] : '#3FCC14'; //Accent Color
38 $borderless_text_color = isset( $options['text_color'] ) ? $options['text_color'] : '#333333'; //Text Color
39
40 ?>
41 <style type="text/css">
42 :root {
43 --borderless-color-primary-lighter: <?php echo luminanceLight ( $borderless_primary_color, 0.4 ); ?>;
44 --borderless-color-primary-light: <?php echo luminanceLight ( $borderless_primary_color, 0.2 ); ?>;
45 --borderless-color-primary: <?php echo $borderless_primary_color; ?>;
46 --borderless-color-primary-dark: <?php echo luminanceDark ( $borderless_primary_color, 0.2 ); ?>;
47 --borderless-color-primary-darker: <?php echo luminanceDark ( $borderless_primary_color, 0.4 ); ?>;
48
49 --borderless-color-secondary-lighter: <?php echo luminanceLight ( $borderless_secondary_color, 0.4 ); ?>;
50 --borderless-color-secondary-light: <?php echo luminanceLight ( $borderless_secondary_color, 0.2 ); ?>;
51 --borderless-color-secondary: <?php echo $borderless_secondary_color; ?>;
52 --borderless-color-secondary-dark: <?php echo luminanceDark ( $borderless_secondary_color, 0.2 ); ?>;
53 --borderless-color-secondary-darker: <?php echo luminanceDark ( $borderless_secondary_color, 0.4 ); ?>;
54
55 --borderless-color-tertiary-lighter: <?php echo luminanceLight ( $borderless_tertiary_color, 0.4 ); ?>;
56 --borderless-color-tertiary-light: <?php echo luminanceLight ( $borderless_tertiary_color, 0.2 ); ?>;
57 --borderless-color-tertiary: <?php echo $borderless_tertiary_color; ?>;
58 --borderless-color-tertiary-dark: <?php echo luminanceDark ( $borderless_tertiary_color, 0.2 ); ?>;
59 --borderless-color-tertiary-darker: <?php echo luminanceDark ( $borderless_tertiary_color, 0.4 ); ?>;
60
61 --borderless-text-color: <?php echo $borderless_text_color; ?>;
62 }
63 </style>
64 <?php
65
66 echo $before_widget;
67
68 if ( $axis == 'borderless-divider--horizontal' ) {
69 $size = 'width:'.$size.';';
70 $space = 'margin:'.$space.' 0;';
71 } else if ( $axis == 'borderless-divider--vertical' ) {
72 $size = 'height:'.$size.';';
73 $space = 'margin:0 '.$space.';';
74 } ?>
75
76 <div class="borderless-divider <?php echo $axis.' '.$color; ?>" style="<?php echo $size.' '.$space; ?>"></div>
77
78 <?php echo $after_widget;
79 }
80
81
82 /**
83 * Back-end widget form.
84 *
85 * @see WP_Widget::form()
86 *
87 * @param array $instance Previously saved values from database.
88 */
89 public function form( $instance ) {
90 $axis = isset( $instance['axis'] ) ? $instance['axis'] : 'divider--horizontal';
91 $color = isset( $instance['color'] ) ? $instance['color'] : 'borderless-divider--primary';
92 $size = isset( $instance['size'] ) ? $instance['size'] : '2rem';
93 $space = isset( $instance['space'] ) ? $instance['space'] : '1rem';
94 ?>
95
96 <p>
97 <label for="<?php echo $this->get_field_id( 'size' ); ?>"><?php _e( 'Size - CSS measurement units allowed', 'borderless' ); ?></label>
98 <input class="widefat" id="<?php echo $this->get_field_id( 'size' ); ?>" name="<?php echo $this->get_field_name( 'size' ); ?>" type="text" value="<?php echo esc_attr( $size ); ?>" />
99 </p>
100 <p>
101 <label for="<?php echo $this->get_field_id( 'space' ); ?>"><?php _e( 'Space - CSS measurement units allowed', 'borderless' ); ?></label>
102 <input class="widefat" id="<?php echo $this->get_field_id( 'space' ); ?>" name="<?php echo $this->get_field_name( 'space' ); ?>" type="text" value="<?php echo esc_attr( $space ); ?>" />
103 </p>
104 <p>
105 <label for="<?php echo $this->get_field_id('axis'); ?>"><?php _e('Axis:', 'borderless') ?></label>
106 <select id="<?php echo $this->get_field_id('axis'); ?>" name="<?php echo $this->get_field_name('axis'); ?>" class="widefat">
107 <option value='borderless-divider--horizontal'<?php selected( $axis, 'divider--horizontal'); ?>><?php _e( 'Horizontal', 'borderless' ); ?></option>
108 <option value='borderless-divider--vertical'<?php selected( $axis, 'divider--vertical'); ?>><?php _e( 'Vertical', 'borderless' ); ?></option>
109 </select>
110 </p>
111 <p>
112 <label for="<?php echo $this->get_field_id('color'); ?>"><?php _e('Color:', 'borderless') ?></label>
113 <select id="<?php echo $this->get_field_id('color'); ?>" name="<?php echo $this->get_field_name('color'); ?>" class="widefat">
114 <option value='borderless-divider--primary'<?php selected( $color, 'borderless-divider--primary'); ?>><?php _e( 'Primary Color', 'borderless' ); ?></option>
115 <option value='borderless-divider--secondary'<?php selected( $color, 'borderless-divider--secondary'); ?>><?php _e( 'Secondary Color', 'borderless' ); ?></option>
116 <option value='borderless-divider--tertiary'<?php selected( $color, 'borderless-divider--tertiary'); ?>><?php _e( 'Tertiary Color', 'borderless' ); ?></option>
117 <option value='borderless-divider--light'<?php selected( $color, 'borderless-divider--light'); ?>><?php _e( 'Light Color', 'borderless' ); ?></option>
118 <option value='borderless-divider--dark'<?php selected( $color, 'borderless-divider--dark'); ?>><?php _e( 'Dark Color', 'borderless' ); ?></option>
119 </select>
120 </p>
121
122 <?php }
123
124
125 /**
126 * Sanitize widget form values as they are saved.
127 *
128 * @see WP_Widget::update()
129 *
130 * @param array $new_instance Values just sent to be saved.
131 * @param array $old_instance Previously saved values from database.
132 *
133 * @return array Updated safe values to be saved.
134 */
135 public function update( $new_instance, $old_instance ) {
136 $instance = array();
137 $instance['axis'] = ( !empty( $new_instance['axis'] ) ) ? strip_tags( $new_instance['axis'] ) : '';
138 $instance['color'] = ( !empty( $new_instance['color'] ) ) ? strip_tags( $new_instance['color'] ) : '';
139 $instance['size'] = ( !empty( $new_instance['size'] ) ) ? strip_tags( $new_instance['size'] ) : '';
140 $instance['space'] = ( !empty( $new_instance['space'] ) ) ? strip_tags( $new_instance['space'] ) : '';
141
142 return $instance;
143 }
144
145 } // class Borderless_Widget_Divider ends
146
147
148
149 // register Borderless_Widget_Divider widget
150 function register_borderless_divider() {
151 register_widget( 'Borderless_Widget_Divider' );
152 }
153 add_action( 'widgets_init', 'register_borderless_divider' );