PluginProbe ʕ •ᴥ•ʔ
Slider Ultimate / 2.2.10
Slider Ultimate v2.2.10
2.2.10 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 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 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 2.1.1 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9
ultimate-slider / includes / template-functions.php
ultimate-slider / includes Last commit date
AboutUs.class.php 3 years ago BackwardsCompatibility.class.php 4 years ago Blocks.class.php 4 years ago CustomPostTypes.class.php 2 years ago Dashboard.class.php 3 years ago DeactivationSurvey.class.php 1 month ago Helper.class.php 4 years ago InstallationWalkthrough.class.php 4 years ago Permissions.class.php 4 years ago ReviewAsk.class.php 4 years ago Settings.class.php 2 years ago Widgets.class.php 4 years ago WooCommerceIntegration.class.php 4 years ago template-functions.php 2 years ago
template-functions.php
163 lines
1 <?php
2
3 /**
4 * Create a shortcode to display a slider
5 * @since 2.0.0
6 */
7 function ewd_us_slider_shortcode( $atts ) {
8
9 // Define shortcode attributes
10 $slider_atts = array(
11 'slider_type' => null,
12 'post__in_string' => '',
13 'posts' => -1,
14 'category' => false,
15 'carousel' => false,
16 'slide_indicators' => null,
17 'timer_bar' => null
18 );
19
20 // Create filter so addons can modify the accepted attributes
21 $slider_atts = apply_filters( 'ewd_us_slider_shortcode_atts', $slider_atts );
22
23 // Extract the shortcode attributes
24 $args = shortcode_atts( $slider_atts, $atts );
25
26 // Render menu
27 ewd_us_load_view_files();
28 $slider = new ewdusViewSlider( $args );
29
30 return $slider->render();
31 }
32 add_shortcode( 'ultimate-slider', 'ewd_us_slider_shortcode' );
33
34 function ewd_us_load_view_files() {
35
36 $files = array(
37 EWD_US_PLUGIN_DIR . '/views/Base.class.php' // This will load all default classes
38 );
39
40 $files = apply_filters( 'ewd_us_load_view_files', $files );
41
42 foreach( $files as $file ) {
43 require_once( $file );
44 }
45
46 }
47
48 function ewd_us_create_watermarked_image( $image_url ) {
49
50 $upload_dir = wp_upload_dir();
51 $plugin_upload_path = $upload_dir['basedir'] . "/ultimate-slider/";
52
53 wp_mkdir_p( $plugin_upload_path );
54
55 $path_parts = pathinfo( $image_url );
56
57 $image_file_path = $plugin_upload_path . $path_parts['filename'] . '_watermarked.png';
58
59 $aspect_ratio_fraction = ewd_us_get_aspect_ratio_fraction();
60
61 $image_string = file_get_contents( $image_url );
62
63 $stamp = imagecreatefrompng( EWD_US_PLUGIN_URL . '/assets/img/star-watermark.png' );
64 $image = imagecreatefromstring( $image_string );
65
66 $height = intval( imagesy( $image ) );
67 $width = intval( imagesx( $image ) );
68
69 if ( $width < 2500 ) {
70 $stamp_width = round( $width / 10 );
71 $stamp_height = $stamp_width;
72 $scaled_stamp = imagescale( $stamp, $stamp_width, $stamp_height );
73 }
74 else {
75 $scaled_stamp = $stamp;
76 }
77
78 $margin_right = 10;
79 $margin_bottom = intval( $height - ( $width * $aspect_ratio_fraction ) + 10 );
80 $sx = intval( imagesx( $scaled_stamp ) );
81 $sy = intval( imagesy( $scaled_stamp ) );
82 $posx = $width -$sx - $margin_right;
83 $posy = $height - $sy - $margin_bottom;
84
85 imagecopy( $image, $scaled_stamp, $posx, $posy, 0, 0, $sx, $sy );
86
87 imagepng( $image, $image_file_path );
88
89 imagedestroy( $image );
90 }
91
92 function ewd_us_get_aspect_ratio_fraction() {
93 global $ewd_us_controller;
94
95 $aspect_ratio = $ewd_us_controller->settings->get_setting( 'aspect-ratio' );
96
97 if ($aspect_ratio == "3_1") {$aspect_ratio_fraction = .333333333;}
98 elseif ($aspect_ratio == "2_1") {$aspect_ratio_fraction = .5;}
99 elseif ($aspect_ratio == "16_9") {$aspect_ratio_fraction = .5625;}
100 elseif ($aspect_ratio == "3_2") {$aspect_ratio_fraction = .666666666;}
101 elseif ($aspect_ratio == "4_3") {$aspect_ratio_fraction = .75;}
102 elseif ($aspect_ratio == "1_1") {$aspect_ratio_fraction = 1;}
103 else {$aspect_ratio_fraction = .444444444;}
104
105 return $aspect_ratio_fraction;
106 }
107
108 if ( ! function_exists( 'ewd_us_get_aspect_fraction' ) ) {
109 function ewd_us_get_aspect_fraction( $aspect_ratio ) {
110
111 if ($aspect_ratio == "3_1") {$aspect_fraction = .333333333;}
112 if ($aspect_ratio == "16_7") {$aspect_fraction = .4375;}
113 if ($aspect_ratio == "2_1") {$aspect_fraction = .5;}
114 if ($aspect_ratio == "16_9") {$aspect_fraction = .5625;}
115 if ($aspect_ratio == "3_2") {$aspect_fraction = .666666667;}
116 if ($aspect_ratio == "4_3") {$aspect_fraction = .75;}
117 if ($aspect_ratio == "1_1") {$aspect_fraction = 1;}
118
119 return $aspect_fraction;
120 }
121 }
122
123 if ( ! function_exists( 'ewd_hex_to_rgb' ) ) {
124 function ewd_hex_to_rgb( $hex ) {
125
126 $hex = str_replace("#", "", $hex);
127
128 // return if the string isn't a color code
129 if ( strlen( $hex ) !== 3 and strlen( $hex ) !== 6 ) { return '0,0,0'; }
130
131 if(strlen($hex) == 3) {
132 $r = hexdec( substr( $hex, 0, 1 ) . substr( $hex, 0, 1 ) );
133 $g = hexdec( substr( $hex, 1, 1 ) . substr( $hex, 1, 1 ) );
134 $b = hexdec( substr( $hex, 2, 1 ) . substr( $hex, 2, 1 ) );
135 } else {
136 $r = hexdec( substr( $hex, 0, 2 ) );
137 $g = hexdec( substr( $hex, 2, 2 ) );
138 $b = hexdec( substr( $hex, 4, 2 ) );
139 }
140
141 $rgb = $r . ", " . $g . ", " . $b;
142
143 return $rgb;
144 }
145 }
146
147 if ( ! function_exists( 'ewd_format_classes' ) ) {
148 function ewd_format_classes( $classes ) {
149
150 if ( count( $classes ) ) {
151 return ' class="' . join( ' ', $classes ) . '"';
152 }
153 }
154 }
155
156 if ( ! function_exists( 'ewd_add_frontend_ajax_url' ) ) {
157 function ewd_add_frontend_ajax_url() { ?>
158
159 <script type="text/javascript">
160 var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>';
161 </script>
162 <?php }
163 }