PluginProbe
Scrollsequence – Cinematic Scroll Image Animation Plugin / 0.9.94
Scrollsequence – Cinematic Scroll Image Animation Plugin v0.9.94
1.4.3 1.4.4 1.4.5 1.4.6 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.2 1.6.3 trunk 0.9.92 0.9.93 0.9.94 0.9.96 1.0.072 1.0.073 All 61 releases
scrollsequence / admin / class-scrollsequence-admin.php

class-scrollsequence-admin.php in Scrollsequence – Cinematic Scroll Image Animation Plugin 0.9.94, at admin/class-scrollsequence-admin.php

320 lines 16.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 use Carbon_Fields\Container ;
4 use Carbon_Fields\Field ;
5 /**
6 * The admin-specific functionality of the plugin.
7 *
8 * @link www.scrollsequence.com
9 * @since 0.7.0
10 *
11 * @package Scrollsequence
12 * @subpackage Scrollsequence/admin
13 */
14 /**
15 * The admin-specific functionality of the plugin.
16 *
17 * Defines the plugin name, version, and two examples hooks for how to
18 * enqueue the admin-specific stylesheet and JavaScript.
19 *
20 * @package Scrollsequence
21 * @subpackage Scrollsequence/admin
22 * @author Scrollsequence <info@scrollsequence.com>
23 */
24 class Scrollsequence_Admin
25 {
26 /**
27 * The ID of this plugin.
28 *
29 * @since 0.7.0
30 * @access private
31 * @var string $plugin_name The ID of this plugin.
32 */
33 private $plugin_name ;
34 /**
35 * The version of this plugin.
36 *
37 * @since 0.7.0
38 * @access private
39 * @var string $version The current version of this plugin.
40 */
41 private $version ;
42 /**
43 * Initialize the class and set its properties.
44 *
45 * @since 0.7.0
46 * @param string $plugin_name The name of this plugin.
47 * @param string $version The version of this plugin.
48 */
49 public function __construct( $plugin_name, $version )
50 {
51 $this->plugin_name = $plugin_name;
52 $this->version = $version;
53 }
54
55 /**
56 * Register the stylesheets for the admin area.
57 *
58 * @since 0.7.0
59 */
60 public function enqueue_styles()
61 {
62 /**
63 * This function is provided for demonstration purposes only.
64 *
65 * An instance of this class should be passed to the run() function
66 * defined in Scrollsequence_Loader as all of the hooks are defined
67 * in that particular class.
68 *
69 * The Scrollsequence_Loader will then create the relationship
70 * between the defined hooks and the functions defined in this
71 * class.
72 */
73 // Ak: I want to add an IF statement to enqueue scripts only to my CPT
74 global $post_type ;
75 if ( 'scrollsequence' == $post_type ) {
76 wp_enqueue_style(
77 $this->plugin_name,
78 plugin_dir_url( __FILE__ ) . 'css/scrollsequence-admin.css',
79 array(),
80 $this->version,
81 'all'
82 );
83 }
84 // Ak: end
85 }
86
87 /**
88 * Register the JavaScript for the admin area.
89 *
90 * @since 0.7.0
91 */
92 public function enqueue_scripts()
93 {
94 /**
95 * This function is provided for demonstration purposes only.
96 *
97 * An instance of this class should be passed to the run() function
98 * defined in Scrollsequence_Loader as all of the hooks are defined
99 * in that particular class.
100 *
101 * The Scrollsequence_Loader will then create the relationship
102 * between the defined hooks and the functions defined in this
103 * class.
104 */
105 // Ak: I want to add an IF statement to enqueue scripts only to my CPT
106 global $post_type ;
107 global $pagenow ;
108 if ( 'scrollsequence' == $post_type && ('post-new.php' === $pagenow || 'post.php' === $pagenow) ) {
109 // Free
110 wp_enqueue_script(
111 $this->plugin_name,
112 plugin_dir_url( __FILE__ ) . 'js/scrollsequence-admin.js',
113 array( 'jquery' ),
114 $this->version,
115 true
116 );
117 }
118 // Ak: end
119 }
120
121 /**
122 * Register Scrollsequence CPT .
123 *
124 * @since 0.7.0
125 */
126 public function scrollsequence_cpt()
127 {
128 require_once "create-cpt.php";
129 }
130
131 /**
132 * Register Scrollsequence CPT .
133 *
134 * @since 0.7.3
135 */
136 public function scrollsequence_cpt_submenu()
137 {
138 add_submenu_page(
139 'edit.php?post_type=scrollsequence',
140 /*parent_slug*/
141 'Dashboard Scrollsequence',
142 /*page title*/
143 'Dashboard',
144 /*menu title*/
145 'edit_posts',
146 /*roles and capability needed*/
147 // Update 0.9.93
148 'dashboard',
149 /*menu slug*/
150 'scrollsequence_cpt_dashboard_callback'
151 );
152 function scrollsequence_cpt_dashboard_callback()
153 {
154 //include_once 'dashboard.php'; - results on parse error
155 require_once "partials/scrollsequence-admin-display.php";
156 }
157
158 }
159
160 /**
161 * Single file custom template for scrollsequence. I am following this:
162 * https://code.tutsplus.com/tutorials/a-guide-to-wordpress-custom-post-types-creation-display-and-meta-boxes--wp-27645
163 * ref "tutsplus" in class-scrollsequence add action thing
164 * @since 0.7.0
165 * @uses i dont know
166 * Step 1 https://blog.wplauncher.com/add-meta-box-wordpress-custom-post-type/
167 */
168 public function scrollsequence_template( $template_path )
169 {
170 if ( get_post_type() == 'scrollsequence' ) {
171 if ( is_single() ) {
172 // checks if the file exists in the theme first,
173 // otherwise serve the file from the plugin
174
175 if ( $theme_file = locate_template( array( 'single-scrollsequence.php' ) ) ) {
176 $template_path = $theme_file;
177 } else {
178 $template_path = plugin_dir_path( __DIR__ ) . 'public/partials/single-scrollsequence.php';
179 }
180
181 }
182 }
183 return $template_path;
184 }
185
186 /**
187 * Carbon Fields Boot function. This function boots up carbon fields.
188 *
189 * @since 0.9.8
190 */
191 public function scrollsequence_carbon_fields_load()
192 {
193 require_once __DIR__ . '/../includes/carbonfields/autoload.php';
194 \Carbon_Fields\Carbon_Fields::boot();
195 }
196
197 public function scrollsequence_carbon_fields()
198 {
199 $scrollsequence_advert_html = '<h4>Full animation settings are available in <a href=' . admin_url( "admin.php?page=scrollsequence-pricing" ) . '>Scrollsequence PRO</a>.</h4><strong>NEW: </strong>We offer <a href=' . admin_url( "admin.php?page=scrollsequence-pricing&trial=true" ) . '>14 days FREE trial</a> - no card required, no risk. ';
200 $scrollsequence_left_center_right = '
201 <div style="float: left">Left</div>
202 <div style="float: right">Right</div>
203 <div style="margin: 0 auto; width: 100px;"></div>
204 ';
205 $scrollsequence_bottom_center_top = '
206 <div style="float: left">Top</div>
207 <div style="float: right">Bottom</div>
208 <div style="margin: 0 auto; width: 100px;"></div>
209 ';
210 $scrollsequence_aglignmentadv = '<p>More Scale and Alignment settings are available in <a href=' . admin_url( "admin.php?page=scrollsequence-pricing" ) . '>Scrollsequence PRO</a>. </p><p><strong>NEW: </strong>We offer <a href=' . admin_url( "admin.php?page=scrollsequence-pricing&trial=true" ) . '>14 days FREE trial</a> - no card required, no risk.</p>';
211 // FREE VERSION
212 Container::make( 'post_meta', 'Scrollsequence' )->where( 'post_type', '=', 'scrollsequence' )->set_context( 'carbon_fields_after_title' )->add_fields( array( Field::make( 'complex', 'scrollsequence_page', 'Page' )->setup_labels( array(
213 'plural_name' => 'Pages',
214 'singular_name' => 'Page',
215 ) )->set_layout( 'tabbed-horizontal' )->set_required( true )->set_max( 3 )->add_fields( array(
216 Field::make( 'rich_text', 'scrollsequence_p_wysiwyg', __( 'Page Content' ) )->set_default_value( '<h1 style="text-align: center;" id="on-earth">Another day on earth. </h1>
217 ' ),
218 Field::make( 'media_gallery', 'scrollsequence_p_images', __( 'Image Sequence' ) )->set_type( array( 'image' ) )->set_required( true )->set_duplicates_allowed( true )->set_classes( 'scrollsequence-custom-class' ),
219 Field::make( 'complex', 'ssqnce_anim', 'Animation' )->set_layout( 'tabbed-vertical' )->setup_labels( array(
220 'plural_name' => 'Animations',
221 'singular_name' => 'Animation',
222 ) )->add_fields( 'ssqnce_anim_io', 'Animate From/To', array(
223 Field::make( 'text', 'ssqnce_anim_io_id', 'Selector' )->set_width( 20 )->set_required( true )->set_help_text( 'Enter #id or .class selector' ),
224 Field::make( 'text', 'ssqnce_anim_io_start', 'Start' )->set_width( 20 )->set_required( true )->set_help_text( 'Enter image number where element becomes visible' )->set_attribute( 'type', 'number' )->set_attribute( 'min', '0' )->set_attribute( 'step', '1' ),
225 Field::make( 'text', 'ssqnce_anim_io_end', 'End' )->set_width( 20 )->set_required( true )->set_help_text( 'Enter image number where element is hidden' )->set_attribute( 'type', 'number' )->set_attribute( 'min', '0' )->set_attribute( 'step', '1' ),
226 // Free advert
227 Field::make( 'separator', 'scrollsequence_advert', 'Animation Settings Not Available in Free Version' )->set_help_text( $scrollsequence_advert_html ),
228 ) )->set_header_template( ' Animate
229 <% if (ssqnce_anim_io_id) { %>
230 - <%- ssqnce_anim_io_id %>
231 <% } %>
232 ' ),
233 // PRO ONLY END1
234 Field::make( 'text', 'scrollsequence_p_duration', __( 'Page Duration' ) )->set_attribute( 'type', 'number' )->set_required( true )->set_default_value( '200' )->set_attribute( 'min', '20' )->set_attribute( 'max', '2000' )->set_attribute( 'step', '1' )->help_text( 'This sets the amount of scroll needed to get past this page.' ),
235 // PANORAMA (MOBILE)
236 Field::make( 'html', 'scrollsequence_info_html_panorama' )->set_html( '<h3>Image Scale and Alignment</h3><p>Panorama (Mobile)</p>' ),
237 Field::make( 'select', 'scrollsequence_p_scaleto_mobile', __( 'Panorama (Mobile)' ) )->set_width( 30 )->set_options( array(
238 'fill' => ' Scale to fill',
239 'fit' => 'Scale to fit 100%',
240 '0.5' => 'Scale to fit 50%',
241 ) ),
242 Field::make( 'text', 'scrollsequence_p_alignx_mobile', 'Horizontal Align' )->set_help_text( $scrollsequence_left_center_right )->set_width( 35 )->set_attribute( 'type', 'range' )->set_classes( 'ssq-range-slider' )->set_default_value( '0.5' )->set_attribute( 'min', '0' )->set_attribute( 'max', '1' )->set_attribute( 'step', '0.5' ),
243 // ROADM
244 Field::make( 'text', 'scrollsequence_p_aligny_mobile', 'Vertical Align' )->set_help_text( $scrollsequence_bottom_center_top )->set_width( 35 )->set_attribute( 'type', 'range' )->set_classes( 'ssq-range-slider' )->set_default_value( '0.5' )->set_attribute( 'min', '0' )->set_attribute( 'max', '1' )->set_attribute( 'step', '0.5' ),
245 // ROADM
246 // LANDSCAPE (DEKSTOP)
247 Field::make( 'html', 'scrollsequence_info_html_landscape' )->set_html( '<p>Landscape (Desktop)</p>' ),
248 Field::make( 'select', 'scrollsequence_p_scaleto_desktop', __( 'Scale' ) )->set_width( 30 )->set_options( array(
249 'fill' => ' Scale to fill',
250 'fit' => 'Scale to fit 100%',
251 '0.5' => 'Scale to fit 50%',
252 ) ),
253 Field::make( 'text', 'scrollsequence_p_alignx_desktop', 'Horizontal Align' )->set_help_text( $scrollsequence_left_center_right )->set_width( 35 )->set_attribute( 'type', 'range' )->set_classes( 'ssq-range-slider' )->set_default_value( '0.5' )->set_attribute( 'min', '0' )->set_attribute( 'max', '1' )->set_attribute( 'step', '0.5' ),
254 // ROADM
255 Field::make( 'text', 'scrollsequence_p_aligny_desktop', 'Vertical Align' )->set_help_text( $scrollsequence_bottom_center_top )->set_width( 35 )->set_attribute( 'type', 'range' )->set_classes( 'ssq-range-slider' )->set_default_value( '0.5' )->set_attribute( 'min', '0' )->set_attribute( 'max', '1' )->set_attribute( 'step', '0.5' ),
256 // ROADM
257 Field::make( 'html', 'scrollsequence_info_html_freealignadv' )->set_html( $scrollsequence_aglignmentadv ),
258 ) )->set_header_template( '<%- $_index %>' ) ) );
259 // End of ELSE (FREE)
260 /*
261 * SIDE CONTEXT - SETTINGS
262 */
263 Container::make( 'post_meta', 'Settings' )->where( 'post_type', '=', 'scrollsequence' )->set_context( 'side' )->set_priority( 'low' )->add_fields( array(
264 Field::make( 'text', 'scrollsequence_image_opacity', __( 'Image Opacity' ) )->set_attribute( 'type', 'number' )->set_required( true )->set_default_value( '1' )->set_attribute( 'min', '0' )->set_attribute( 'max', '1' )->set_attribute( 'step', '0.01' ),
265 Field::make( 'select', 'scrollsequence_content_spacer', 'Classic Content Position' )->add_options( array(
266 'after100' => 'End of Document (default)',
267 'after' => 'End of Document (with overlap) ',
268 'during' => 'Start of Document',
269 ) ),
270 Field::make( 'color', 'scrollsequence_bodybgcolor', __( 'Body Background Color' ) )->help_text( 'Set CSS attribute <i><strong>background-color</strong></i> of <i><strong>body.single-scrollsequence</strong></i> class.' ),
271 Field::make( 'color', 'scrollsequence_classic_content_after_bgcolor', __( 'Background Color - After Scrollsequence' ) )->help_text( 'Use in case you want to have different background color after the scrollsequence is finished. Only active when there is content after the image sequence. ' ),
272 Field::make( 'textarea', 'scrollsequence_custom_css', __( 'Custom CSS' ) )->help_text( 'Enter custom CSS here.' )
273 ) );
274 /*
275 * SIDE CONTEXT - ADVANCED SETTINGS
276 */
277 Container::make( 'post_meta', 'Advanced Settings' )->where( 'post_type', '=', 'scrollsequence' )->set_context( 'side' )->set_priority( 'low' )->add_fields( array( Field::make( 'checkbox', 'scrollsequence_show_sidebar', __( 'Show Sidebar' ) )->set_option_value( 'yes' )->help_text( 'Experimental, take care' ), Field::make( 'checkbox', 'scrollsequence_show_footer', __( 'Show Footer' ) )->set_option_value( 'yes' )->help_text( 'Experimental, take care. <br>(This setting displays footer element and changes z-index to 9999)' ), Field::make( 'checkbox', 'scrollsequence_debug_ssq', __( 'Debug Mode' ) )->set_option_value( 'yes' )->help_text( 'Show debug information in developers console.' ) ) );
278 }
279
280 // END OF CARBON FIELD FUNCTION
281 /**
282 * ROADM Alert Too Many Pages and Images
283 *
284 * @since 0.7.4
285 */
286 public function scrollsequence_admin_notice()
287 {
288 // Ak: I want to add an IF statement to add admin notice only to scrollsequence post php
289 global $post_type ;
290 global $pagenow ;
291
292 if ( $pagenow == 'post.php' && 'scrollsequence' == $post_type ) {
293 echo '<div class="notice notice-warning" id="scrollsequence_notice_toomanyimg" style="display:none" ><p>Warning: Image limit reached. For performance reasons, free version allows maximum of 100 images on a single page. Images marked with "X" will not be displayed. <a href="' . admin_url( 'admin.php?page=scrollsequence-pricing' ) . '">Upgrade</a> to display unlimited images in your Scrollsequence.</p></div>' ;
294 echo '<div class="notice notice-warning" id="scrollsequence_notice_toomanypages" style="display:none" ><p>Warning: Page limit reached. For performance reasons, free version allows maximum of 3 pages. <a href="' . admin_url( 'admin.php?page=scrollsequence-pricing' ) . '">Upgrade</a> to display unlimited pages in your Scrollsequence.</p></div>' ;
295 }
296
297 // Ak: end
298 }
299
300 /**
301 * Classic Content Editor Heading
302 *
303 * @since 0.7.4
304 */
305 public function scrollsequence_classic_content_html()
306 {
307 // Ak: I want to add an IF statement to add admin notice only to scrollsequence post php
308 global $post_type ;
309 global $pagenow ;
310 if ( $pagenow == 'post.php' && 'scrollsequence' == $post_type ) {
311 echo '<h1>Classic Content Editor </h1>' ;
312 }
313 if ( $pagenow == 'post-new.php' && 'scrollsequence' == $post_type ) {
314 echo '<h1>Classic Content Editor </h1>' ;
315 }
316 // Ak: end
317 }
318
319 }
320 // end of class Scrollsequence_Admin