PluginProbe
Cool Timeline (Horizontal & Vertical Timeline) / trunk
Cool Timeline (Horizontal & Vertical Timeline) vtrunk
3.4.0 3.3.6 3.3.5 3.3.4 3.3.3 3.3.2 2.2.3 2.3.3 2.4 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.6.1 2.7.1 2.8.3 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 2.9.8 2.9.9 3.0.0 All 79 releases
cool-timeline / admin / ctl-shortcode-generator.php

ctl-shortcode-generator.php in Cool Timeline (Horizontal & Vertical Timeline) trunk, at admin/ctl-shortcode-generator.php

316 lines 9.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 *
4 * This file is responsible for creating all admin settings in Timeline Builder (post)
5 */
6 if ( ! defined( 'ABSPATH' ) ) {
7 exit;
8 }
9
10 if ( ! class_exists( 'CSF_free_shortcode_generator' ) ) {
11 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound
12 class CSF_free_shortcode_generator {
13
14
15 /**
16 * The Constructor
17 */
18 public function __construct() {
19 // register actions
20
21 $this->init_shortcode_generator();
22 add_action( 'admin_print_styles', array( $this, 'ctl_custom_shortcode_style' ) );
23 add_action( 'admin_enqueue_scripts', array( $this, 'ctl_preview_script' ) );
24 }
25
26 public function ctl_custom_shortcode_style() {
27 echo '<style>
28 span.dashicon.dashicons.dashicons-ctl-custom-icon:before {
29 content:"";
30 background: url(' . esc_url( CTL_PLUGIN_URL ) . 'assets/images/timeline-icon2-32x32.png);
31 background-size: contain;
32 background-repeat: no-repeat;
33 height: 20px;
34 display: block;
35
36 }
37 #wp-content-wrap a[data-modal-id="ctl_timeline_shortcode"]:before {
38 content: "";
39 background: url(' . esc_url( CTL_PLUGIN_URL ) . 'assets/images/cool-timeline-icon.svg);
40 background-size: contain;
41 background-repeat: no-repeat;
42 height: 17px;
43 display: inline-block;
44 margin: 0px 1px -3px 0;
45 width: 20px;
46 }
47 .csf-shortcode-single .csf-modal-content {
48 height: 655px !important;
49
50 }
51
52 #csf-modal-ctl_timeline_shortcode .csf-modal-inner {
53 height: 500px !important;
54 }
55 #csf-modal-ctl_timeline_shortcode .csf-modal-content {
56 height:400px !important;
57 }
58
59 #ctl_preview{
60 width: 200%;
61 height: 200%;
62 transform: translate(-25%, -25%) scale(0.5);
63 }
64 </style>';
65 }
66
67 // Preview Scripts Loaded
68 public function ctl_preview_script() {
69 wp_enqueue_script( 'ctl_preview_scripts', esc_url( CTL_PLUGIN_URL . 'includes/shortcodes/assets/js/ctl-preview.min.js' ), array( 'jquery' ), CTL_V, false );
70 wp_localize_script(
71 'ctl_preview_scripts',
72 'myAjax',
73 array(
74 'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ),
75 'nonce' => wp_create_nonce( 'ctl_preview' ),
76 )
77 );
78 }
79
80 public function init_shortcode_generator() {
81
82
83 // Sanitize input data (read-only admin screen detection).
84 // phpcs:ignore WordPress.Security.NonceVerification.Recommended
85 $id = isset( $_GET['post'] ) ? intval( wp_unslash( $_GET['post'] ) ) : 0;
86 // phpcs:ignore WordPress.Security.NonceVerification.Recommended
87 $post_type = isset( $_GET['post_type'] ) ? sanitize_key( wp_unslash( $_GET['post_type'] ) ) : get_post_type( $id );
88
89 // change block name if older block exists in current page condition start
90 $block_name = 'ctl-gutenberg-block';
91 if ( $id > 0 ) {
92 $ctl_post_id = (int) $id;
93 $all_blocks = array();
94 $post_content = get_post( $ctl_post_id );
95 if ( null !== $post_content ) {
96 $parse_data = parse_blocks( $post_content->post_content );
97 foreach ( $parse_data as $parse ) {
98 if ( isset( $parse['blockName'] ) && null !== $parse['blockName'] ) {
99 array_push( $all_blocks, $parse['blockName'] );
100 }
101 };
102 };
103
104 if ( ! in_array( 'csf/ctl-timeline-shortcode', $all_blocks ) ) {
105 $block_name = 'ctl-gutenberg-block';
106 } else {
107 $block_name = 'ctl_timeline_shortcode';
108 };
109 }
110 // change block name if older block exists in current page condition end
111
112 if ( $post_type !== 'page' && $post_type !== 'post' && $post_type != '' ) {
113 return;
114 }
115 if ( class_exists( 'CSF' ) ) {
116
117 //
118 // Set a unique slug-like ID
119 $prefix = 'ctl_timeline_shortcode';
120
121 //
122 // Create a shortcoder
123 CSF::createShortcoder(
124 $prefix,
125 array(
126 'button_title' => 'Add Shortcode',
127 'insert_title' => 'Insert shortcode',
128 'gutenberg' => array(
129 'block_name' => $block_name,
130 'title' => 'Cool Timeline Shortcode Generator',
131 'icon' => 'ctl-custom-icon',
132 'description' => 'Cool Timeline Shortcode Generator Block.',
133 'category' => 'widgets',
134 'keywords' => array( 'shortcode', 'ctl', 'cooltimeline', 'timeline' ),
135 'previewImage' => CTL_PLUGIN_URL . 'includes/cool-timeline-block/images/timeline.27d3f3c7.png',
136 ),
137 )
138 );
139
140 //
141 // A basic shortcode
142
143 CSF::createSection(
144 $prefix,
145 array(
146 'title' => 'Cool Timeline Shortcode',
147 'view' => 'normal', // View model of the shortcode. `normal` `contents` `group` `repeater`
148 'shortcode' => 'cool-timeline', // Set a unique slug-like name of shortcode.
149 'fields' => array(
150 array(
151 'id' => 'ctl-story-tab',
152 'type' => 'tabbed',
153 'tabs' => array(
154 // Timeline General Tabs Start
155 array(
156 'title' => 'General',
157 'fields' => array(
158 array(
159 'id' => 'layout',
160 'type' => 'select',
161 'title' => 'Select Layout',
162 'default' => 'default',
163 'desc' => 'Select your timeline Layout',
164 'options' => array(
165 'default' => 'Vertical',
166 'horizontal' => 'Horizontal',
167 'one-side' => 'One Side Layout',
168 'simple' => 'Simple Layout',
169 'compact' => 'Compact Layout',
170 ),
171 'attributes' => array(
172 'style' => 'width: 50%;',
173 ),
174 ),
175 array(
176 'id' => 'skin',
177 'type' => 'select',
178 'title' => 'Select Skin',
179 'default' => 'default',
180 'dependency' => array( 'layout', '!=', 'horizontal' ),
181 'options' => array(
182 'default' => 'Default',
183 'clean' => 'Clean',
184 ),
185 'desc' => 'Create Light, Dark or Colorful Timeline',
186 'attributes' => array(
187 'style' => 'width: 50%;',
188 ),
189 ),
190 array(
191 'id' => 'date-format',
192 'type' => 'select',
193 'title' => 'Select Date Formats',
194 'default' => 'F j',
195 'options' => array(
196 'F j' => 'F j',
197 'F j Y' => 'F j Y',
198 'Y-m-d' => 'Y-m-d',
199 'm/d/Y' => 'm/d/Y',
200 'd/m/Y' => 'd/m/Y',
201 'F j Y g:i A' => 'F j Y g:i A',
202 'Y' => 'Y',
203 ),
204 'desc' => 'Timeline Stories dates formats',
205 'attributes' => array(
206 'style' => 'width: 50%;',
207 ),
208 ),
209 array(
210 'id' => 'show-posts',
211 'type' => 'text',
212 'title' => 'Display Pers Page?',
213 'default' => '10',
214 'desc' => 'You Can Show Pagination After These Posts In Vertical Timeline.',
215 'attributes' => array(
216 'style' => 'width: 50%;',
217 ),
218 ),
219 array(
220 'id' => 'items',
221 'type' => 'text',
222 'title' => 'Slide To Show',
223 'default' => '4',
224 'desc' => 'You can set the number of items in Horizontal Layout.',
225 'attributes' => array(
226 'style' => 'width: 50%;',
227 ),
228 'dependency' => array( 'layout', '==', 'horizontal' ),
229 ),
230 array(
231 'id' => 'animation',
232 'type' => 'select',
233 'title' => 'Animation',
234 'default' => 'none',
235 'dependency' => array( 'layout', '!=', 'horizontal' ),
236 'options' => array(
237 'none' => 'none',
238 'fade-up' => 'fadeInUp',
239 ),
240 'attributes' => array(
241 'style' => 'width: 50%;',
242 ),
243 ),
244 array(
245 'id' => 'icons',
246 'type' => 'select',
247 'title' => 'Icons',
248 'default' => 'NO',
249 'options' => array(
250 'NO' => 'NO',
251 'YES' => 'YES',
252 ),
253 'desc' => 'Display Icons In Timeline Stories. By default Is Dot',
254 'attributes' => array(
255 'style' => 'width: 50%;',
256 ),
257 ),
258
259 array(
260 'id' => 'order',
261 'type' => 'select',
262 'title' => 'Stories Order?',
263 'default' => 'DESC',
264 'options' => array(
265 'DESC' => 'DESC',
266 'ASC' => 'ASC',
267 ),
268 'attributes' => array(
269 'style' => 'width: 50%;',
270 ),
271 'desc' => '<span>Timeline Stories order like:- DESC(2017-1900) , ASC(1900-2017)</span>',
272 ),
273 array(
274 'id' => 'story-content',
275 'type' => 'select',
276 'title' => 'Stories Description?',
277 'default' => 'short',
278 'options' => array(
279 'short' => 'Summary',
280 'full' => 'Full Text',
281 ),
282 'desc' => '<span>Summary:- Short description<br>Full:- All content with formated text.</span>',
283 'attributes' => array(
284 'style' => 'width: 50%;',
285 ),
286
287 ),
288 ),
289 ),
290 // Timeline Preview Tabs Start
291 array(
292 'title' => 'Preview',
293 'fields' => array(
294 array(
295 'id' => 'preview',
296 'type' => 'content',
297 'content' => '<iframe id="ctl_preview" name="my_iframe" src="' . esc_url( CTL_PLUGIN_URL . 'includes/shortcodes/class-ctl-shortcode-preview.php' ) . '" title="preview iframe" scrolling="auto" frameborder="0" data-preloader="' . esc_url( CTL_PLUGIN_URL . 'assets/images/clt-preloader.gif' ) . '"></iframe>',
298 ),
299 ),
300 ),
301 ),
302 ),
303 ),
304 )
305 );
306
307 }
308
309 }
310
311 }
312
313 }
314
315 new CSF_free_shortcode_generator();
316