PluginProbe
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News / 4.0.2
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News v4.0.2
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 4.0.2 4.0.1 2.3.5 2.3.6 2.4.0 2.4.1 2.4.10 2.4.11 2.4.12 2.4.13 2.4.14 2.4.15 2.4.16 2.4.17 2.4.18 2.4.19 2.4.2 2.4.20 2.4.21 All 88 releases
post-carousel / includes / updates / update-2.2.0.php

update-2.2.0.php in Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News 4.0.2, at includes/updates/update-2.2.0.php

319 lines 12.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * This file is used to update the database version of the plugin.
4 *
5 * @link https://wpsmartpost.com/
6 * @since 2.2.0
7 *
8 * @package Smart_Post_Show
9 * @subpackage Smart_Post_Show/includes
10 */
11
12 if ( ! defined( 'ABSPATH' ) ) {
13 exit; // Exit if accessed directly.
14 }
15
16 update_option( 'smart_post_show_version', '2.2.0' );
17 update_option( 'smart_post_show_db_version', '2.2.0' );
18
19 /**
20 * Update settings.
21 */
22 $setting_options = array(
23 'pcp_delete_all_data' => false,
24 'pcp_swiper_js' => true,
25 'pcp_swiper_css' => true,
26 'pcp_fontawesome_css' => true,
27 'accessibility' => false,
28 'pcp_custom_css' => '',
29 'pcp_custom_js' => '',
30 );
31 update_option( 'sp_post_carousel_settings', $setting_options );
32
33 /**
34 * Shortcode query for id.
35 */
36 $args = new WP_Query(
37 array(
38 'post_type' => 'sp_pc_shortcodes',
39 'post_status' => 'any',
40 'posts_per_page' => '300',
41 )
42 );
43 $shortcode_ids = wp_list_pluck( $args->posts, 'ID' );
44
45 if ( count( $shortcode_ids ) > 0 ) {
46 foreach ( $shortcode_ids as $shortcode_key => $shortcode_id ) {
47
48 $number_of_total_posts = intval( get_post_meta( $shortcode_id, 'pc_number_of_total_posts', true ) );
49 $number_of_column = intval( get_post_meta( $shortcode_id, 'pc_number_of_column', true ) );
50 $number_of_column_desktop = intval( get_post_meta( $shortcode_id, 'pc_number_of_column_desktop', true ) );
51 $number_of_column_tablet = intval( get_post_meta( $shortcode_id, 'pc_number_of_column_tablet', true ) );
52 $number_of_column_mobile = intval( get_post_meta( $shortcode_id, 'pc_number_of_column_mobile', true ) );
53 $auto_play_speed = get_post_meta( $shortcode_id, 'pc_auto_play_speed', true );
54 $nav_arrow_color = get_post_meta( $shortcode_id, 'pc_nav_arrow_color', true );
55 $nav_arrow_bg = get_post_meta( $shortcode_id, 'pc_nav_arrow_bg', true );
56 $pagination_color = get_post_meta( $shortcode_id, 'pc_pagination_color', true );
57 $pagination_active_color = get_post_meta( $shortcode_id, 'pc_pagination_active_color', true );
58 $scroll_speed = get_post_meta( $shortcode_id, 'pc_scroll_speed', true );
59 $post_title_color = get_post_meta( $shortcode_id, 'pc_post_title_color', true );
60 $post_title_hover_color = get_post_meta( $shortcode_id, 'pc_post_title_hover_color', true );
61 $post_content_color = get_post_meta( $shortcode_id, 'pc_post_content_color', true );
62 $post_meta_color = get_post_meta( $shortcode_id, 'pc_post_meta_color', true );
63 $post_meta_hover_color = get_post_meta( $shortcode_id, 'pc_post_meta_hover_color', true );
64 $carousel_title_color = get_post_meta( $shortcode_id, 'pc_carousel_title_color', true );
65 $themes = get_post_meta( $shortcode_id, 'pc_themes', true );
66 $post_title = get_post_meta( $shortcode_id, 'pc_post_title', 'true' );
67 $post_content = get_post_meta( $shortcode_id, 'pc_post_content', 'true' );
68 // $post_author = get_post_meta( $shortcode_id, 'pc_post_author', 'true' );
69 // $post_date = get_post_meta( $shortcode_id, 'pc_post_date', 'true' );
70 $section_title_data = get_post_meta( $shortcode_id, 'pc_carousel_title', true );
71 $section_title = ( 'on' == $section_title_data ) ? true : false;
72
73 $view_options['pcp_select_post_type'] = 'post';
74 $view_options['pcp_include_only_posts'] = '';
75 $view_options['pcp_exclude_post_set'] = '';
76 $view_options['pcp_post_limit'] = $number_of_total_posts;
77 $view_options['pcp_advanced_filter'] = '';
78 $view_options['section_title'] = $section_title;
79 $view_options['section_title_margin'] = array(
80 'top' => '0',
81 'right' => '0',
82 'bottom' => '30',
83 'top' => '0',
84 );
85 $view_options['pcp_number_of_columns'] = array(
86 'lg_desktop' => $number_of_column,
87 'desktop' => $number_of_column_desktop,
88 'tablet' => $number_of_column_tablet,
89 'mobile_landscape' => $number_of_column_tablet,
90 'mobile' => $number_of_column_mobile,
91 );
92 $view_options['margin_between_post'] = array(
93 'all' => '20',
94 );
95 $view_options['post_content_orientation'] = 'default';
96 $border_size = ( 'carousel_two' == $themes ) ? '1' : '0';
97 $border_color = ( 'carousel_two' == $themes ) ? '#ddd' : '#e2e2e2';
98 $view_options['post_border'] = array(
99 'all' => $border_size,
100 'style' => 'solid',
101 'color' => $border_color,
102 );
103 $view_options['post_border_radius_property'] = array(
104 'all' => '0',
105 );
106 $view_options['post_background_property'] = 'transparent';
107 $inner_padding = ( 'carousel_two' == $themes ) ? '15' : '0';
108 $view_options['post_inner_padding_property'] = array(
109 'top' => $inner_padding,
110 'right' => $inner_padding,
111 'bottom' => $inner_padding,
112 'left' => $inner_padding,
113 'unit' => 'px',
114 );
115 $view_options['post_content_sorter'] = array(
116 'pcp_post_thumb' => array(
117 'post_thumb_show' => true,
118 'pcp_thumb_sizes' => 'full',
119 ),
120 'pcp_post_title' => array(
121 'show_post_title' => ( 'on' == $post_title ) ? true : false,
122 'post_title_tag' => 'h2',
123 ),
124 'pcp_post_meta' => array(
125 'show_post_meta' => true,
126 'pcp_post_meta_group' => array(
127 array(
128 'select_post_meta' => 'author',
129 'select_meta_icon' => 'fa fa-user',
130 ),
131 array(
132 'select_post_meta' => 'date',
133 'select_meta_icon' => 'fa fa-calendar',
134 ),
135 ),
136 ),
137 'pcp_post_content' => array(
138 'show_post_content' => ( 'hide' == $post_content ) ? false : true,
139 'post_content_type' => ( 'content_with_limit' == $post_content ) ? 'excerpt' : 'full_content',
140 'show_read_more' => false,
141 'pcp_read_label' => 'Read More',
142 'readmore_color_button' => array(
143 'standard' => '#111',
144 'hover' => '#fff',
145 'bg' => 'transparent',
146 'hover_bg' => '#e1624b',
147 'border' => '#888',
148 'hover_border' => '#e1624b',
149 ),
150 ),
151 );
152 $view_options['show_post_pagination'] = false;
153 $view_options['post_pagination_type'] = 'no_ajax';
154 $view_options['pcp_pagination_btn_color'] = array(
155 'text_color' => '#5e5e5e',
156 'text_acolor' => '#ffffff',
157 'border_color' => '#bbbbbb',
158 'border_acolor' => '#e1624b',
159 'background' => '#ffffff',
160 'active_background' => '#e1624b',
161 );
162 $view_options['post_per_page'] = 12;
163 $view_options['show_preloader'] = false;
164
165 $view_options['pcp_carousel_speed'] = $scroll_speed;
166 $auto_play = get_post_meta( $shortcode_id, 'pc_auto_play', 'true' );
167 $view_options['pcp_autoplay'] = ( 'on' == $auto_play ) ? true : false;
168 $view_options['pcp_autoplay_speed'] = $auto_play_speed;
169 $pause_on_hover = get_post_meta( $shortcode_id, 'pc_pause_on_hover', 'true' );
170 $view_options['pcp_pause_hover'] = ( 'on' == $pause_on_hover ) ? true : false;
171 $view_options['pcp_infinite_loop'] = true;
172 $view_options['pcp_lazy_load'] = false;
173 $rtl = get_post_meta( $shortcode_id, 'pc_rtl', 'true' );
174 $view_options['pcp_carousel_direction'] = $rtl;
175 $show_navigation = get_post_meta( $shortcode_id, 'pc_show_navigation', 'true' );
176 $view_options['pcp_navigation'] = ( 'on' == $show_navigation ) ? 'show' : 'hide';
177 $view_options['pcp_nav_colors'] = array(
178 'color' => $nav_arrow_color,
179 'hover-color' => $nav_arrow_color,
180 'bg' => $nav_arrow_bg,
181 'hover-bg' => $nav_arrow_bg,
182 'border-color' => $nav_arrow_bg,
183 'hover-border-color' => $nav_arrow_bg,
184 );
185 $show_pagination_dots = get_post_meta( $shortcode_id, 'pc_show_pagination_dots', 'true' );
186 $view_options['pcp_pagination'] = ( 'on' == $show_pagination_dots ) ? 'show' : 'hide';
187 $view_options['pcp_pagination_color_set'] = array(
188 'pcp_pagination_color' => array(
189 'color' => $pagination_color,
190 'active-color' => $pagination_active_color,
191 ),
192 );
193 $view_options['pcp_adaptive_height'] = '';
194 $view_options['pcp_accessibility'] = false;
195 $touch_swipe = get_post_meta( $shortcode_id, 'pc_touch_swipe', 'true' );
196 $view_options['touch_swipe'] = ( 'on' == $touch_swipe ) ? true : false;
197 $mouse_draggable = get_post_meta( $shortcode_id, 'pc_mouse_draggable', 'true' );
198 $view_options['slider_draggable'] = ( 'on' == $mouse_draggable ) ? true : false;
199
200 $view_options['pcp_page_link_type'] = 'single_page';
201 $view_options['pcp_link_target'] = '_self';
202 $view_options['pcp_link_rel'] = 'false';
203
204 $view_options['post_title_typography'] = array(
205 'color' => $post_title_color,
206 'hover_color' => $post_title_hover_color,
207 'font-family' => '',
208 'font-weight' => '',
209 'subset' => '',
210 'font-size' => '20',
211 'tablet-font-size' => '18',
212 'mobile-font-size' => '16',
213 'line-height' => '24',
214 'tablet-line-height' => '22',
215 'mobile-line-height' => '20',
216 'letter-spacing' => '0',
217 'text-align' => 'left',
218 'text-transform' => 'none',
219 'type' => '',
220 'unit' => 'px',
221 );
222 $view_options['post_content_typography'] = array(
223 'color' => $post_content_color,
224 'font-family' => '',
225 'font-weight' => '',
226 'subset' => '',
227 'font-size' => '16',
228 'tablet-font-size' => '14',
229 'mobile-font-size' => '12',
230 'line-height' => '20',
231 'tablet-line-height' => '18',
232 'mobile-line-height' => '18',
233 'letter-spacing' => '0',
234 'text-align' => 'left',
235 'text-transform' => 'none',
236 'type' => '',
237 'unit' => 'px',
238 );
239 $view_options['post_meta_typography'] = array(
240 'color' => $post_meta_color,
241 'hover_color' => $post_meta_hover_color,
242 'font-family' => '',
243 'font-weight' => '',
244 'subset' => '',
245 'font-size' => '14',
246 'tablet-font-size' => '14',
247 'mobile-font-size' => '12',
248 'line-height' => '16',
249 'tablet-line-height' => '16',
250 'mobile-line-height' => '16',
251 'letter-spacing' => '0',
252 'text-align' => 'left',
253 'text-transform' => 'none',
254 'type' => '',
255 'unit' => 'px',
256 );
257 $view_options['section_title_typography'] = array(
258 'color' => $carousel_title_color,
259 'font-family' => '',
260 'font-weight' => '',
261 'subset' => '',
262 'font-size' => '24',
263 'tablet-font-size' => '20',
264 'mobile-font-size' => '18',
265 'line-height' => '28',
266 'tablet-line-height' => '24',
267 'mobile-line-height' => '20',
268 'letter-spacing' => '0',
269 'text-align' => 'left',
270 'text-transform' => 'none',
271 'type' => '',
272 'unit' => 'px',
273 );
274
275 /**
276 * Layouts.
277 */
278 $layouts['pcp_layout_preset'] = 'carousel_layout';
279
280 update_post_meta( $shortcode_id, 'sp_pcp_view_options', $view_options );
281 update_post_meta( $shortcode_id, 'sp_pcp_layouts', $layouts );
282 }
283
284 /**
285 * Old post type to new for shortcode.
286 */
287 global $wpdb;
288 $old_post_types = array( 'sp_pc_shortcodes' => 'sp_post_carousel' );
289 foreach ( $old_post_types as $old_type => $type ) {
290 $wpdb->query( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
291 $wpdb->prepare(
292 "UPDATE {$wpdb->posts} SET post_type = REPLACE(post_type, %s, %s)
293 WHERE post_type LIKE %s",
294 $old_type,
295 $type,
296 $old_type
297 )
298 );
299 $wpdb->query( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
300 $wpdb->prepare(
301 "UPDATE {$wpdb->posts} SET guid = REPLACE(guid, %s, %s)
302 WHERE guid LIKE %s",
303 "post_type={$old_type}",
304 "post_type={$type}",
305 "%post_type={$type}%"
306 )
307 );
308 $wpdb->query( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
309 $wpdb->prepare(
310 "UPDATE {$wpdb->posts} SET guid = REPLACE(guid, %s, %s)
311 WHERE guid LIKE %s",
312 "/{$old_type}/",
313 "/{$type}/",
314 "%/{$old_type}/%"
315 )
316 );
317 }
318 }
319