PluginProbe
Scrollsequence – Cinematic Scroll Image Animation Plugin / 0.9.92
Scrollsequence – Cinematic Scroll Image Animation Plugin v0.9.92
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.92, at admin/class-scrollsequence-admin.php

291 lines 13.6 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 if ( 'scrollsequence' == $post_type ) {
108 // Free
109 wp_enqueue_script(
110 $this->plugin_name,
111 plugin_dir_url( __FILE__ ) . 'js/scrollsequence-admin.js',
112 array( 'jquery' ),
113 $this->version,
114 true
115 );
116 }
117 // Ak: end
118 }
119
120 /**
121 * Register Scrollsequence CPT .
122 *
123 * @since 0.7.0
124 */
125 public function scrollsequence_cpt()
126 {
127 require_once "create-cpt.php";
128 }
129
130 /**
131 * Register Scrollsequence CPT .
132 *
133 * @since 0.7.3
134 */
135 public function scrollsequence_cpt_submenu()
136 {
137 add_submenu_page(
138 'edit.php?post_type=scrollsequence',
139 /*parent_slug*/
140 'Dashboard Scrollsequence',
141 /*page title*/
142 'Dashboard',
143 /*menu title*/
144 'manage_options',
145 /*roles and capability needed*/
146 'dashboard',
147 /*menu slug*/
148 'scrollsequence_cpt_dashboard_callback'
149 );
150 function scrollsequence_cpt_dashboard_callback()
151 {
152 //include_once 'dashboard.php'; - results on parse error
153 require_once "partials/scrollsequence-admin-display.php";
154 }
155
156 }
157
158 /**
159 * Single file custom template for scrollsequence. I am following this:
160 * https://code.tutsplus.com/tutorials/a-guide-to-wordpress-custom-post-types-creation-display-and-meta-boxes--wp-27645
161 * ref "tutsplus" in class-scrollsequence add action thing
162 * @since 0.7.0
163 * @uses i dont know
164 * Step 1 https://blog.wplauncher.com/add-meta-box-wordpress-custom-post-type/
165 */
166 public function scrollsequence_template( $template_path )
167 {
168 if ( get_post_type() == 'scrollsequence' ) {
169 if ( is_single() ) {
170 // checks if the file exists in the theme first,
171 // otherwise serve the file from the plugin
172
173 if ( $theme_file = locate_template( array( 'single-scrollsequence.php' ) ) ) {
174 $template_path = $theme_file;
175 } else {
176 $template_path = plugin_dir_path( __DIR__ ) . 'public/partials/single-scrollsequence.php';
177 }
178
179 }
180 }
181 return $template_path;
182 }
183
184 /**
185 * Carbon Fields Boot function. This function boots up carbon fields.
186 *
187 * @since 0.9.8
188 */
189 public function scrollsequence_carbon_fields_load()
190 {
191 require_once __DIR__ . '/../includes/carbonfields/autoload.php';
192 \Carbon_Fields\Carbon_Fields::boot();
193 }
194
195 public function scrollsequence_carbon_fields()
196 {
197 $scrollsequence_advert_html = 'To be able to animate elements <a href=' . admin_url( "admin.php?page=scrollsequence-pricing" ) . '"> Get Scrollsequence PRO </a>. ';
198 // FREE VERSION
199 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(
200 'plural_name' => 'Pages',
201 'singular_name' => 'Page',
202 ) )->set_layout( 'tabbed-horizontal' )->set_required( true )->set_max( 3 )->add_fields( array(
203 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>
204 ' ),
205 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' ),
206 Field::make( 'complex', 'ssqnce_anim', 'Animation' )->set_layout( 'tabbed-vertical' )->setup_labels( array(
207 'plural_name' => 'Animations',
208 'singular_name' => 'Animation',
209 ) )->add_fields( 'ssqnce_anim_io', 'Animate From/To', array(
210 Field::make( 'text', 'ssqnce_anim_io_id', 'Selector' )->set_width( 20 )->set_required( true )->set_help_text( 'Enter #id or .class selector' ),
211 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' ),
212 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' ),
213 // Free advert
214 Field::make( 'separator', 'scrollsequence_advert', 'Animation Settings Not Available in Free Version' )->set_help_text( $scrollsequence_advert_html ),
215 ) )->set_header_template( ' Animate
216 <% if (ssqnce_anim_io_id) { %>
217 - <%- ssqnce_anim_io_id %>
218 <% } %>
219 ' ),
220 // PRO ONLY END1
221 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.' ),
222 Field::make( 'separator', 'scrollsequence_separator1', __( 'Image Scale and Alignment' ) ),
223 Field::make( 'select', 'scrollsequence_p_scaleto_mobile', __( 'Mobile' ) )->set_width( 50 )->set_options( array(
224 'fill' => ' Scale to fill',
225 'fit' => 'Scale to fit',
226 ) ),
227 Field::make( 'select', 'scrollsequence_p_scaleto_desktop', __( 'Desktop' ) )->set_width( 50 )->set_options( array(
228 'fill' => ' Scale to fill',
229 'fit' => 'Scale to fit',
230 ) ),
231 Field::make( 'separator', 'scrollsequence_separator2', __( 'Horizontal Align' ) ),
232 Field::make( 'select', 'scrollsequence_p_alignx_mobile', 'Mobile' )->set_width( 50 )->set_options( array(
233 'center' => ' Center',
234 'left' => ' Left',
235 'right' => 'Right',
236 ) ),
237 Field::make( 'select', 'scrollsequence_p_alignx_desktop', 'Desktop' )->set_width( 50 )->set_options( array(
238 'center' => ' Center',
239 'left' => ' Left',
240 'right' => 'Right',
241 ) ),
242 Field::make( 'separator', 'scrollsequence_separator3', __( 'Vertical Align' ) ),
243 Field::make( 'select', 'scrollsequence_p_aligny_mobile', 'Mobile' )->set_width( 50 )->set_options( array(
244 'center' => ' Center',
245 'top' => ' Top',
246 'bottom' => 'Bottom',
247 ) ),
248 Field::make( 'select', 'scrollsequence_p_aligny_desktop', 'Desktop' )->set_width( 50 )->set_options( array(
249 'center' => ' Center',
250 'top' => ' Top',
251 'bottom' => 'Bottom',
252 ) ),
253 ) )->set_header_template( '<%- $_index %>' ) ) );
254 // End of ELSE (FREE)
255 /*
256 * SIDE CONTEXT - SETTINGS
257 */
258 Container::make( 'post_meta', 'Settings' )->where( 'post_type', '=', 'scrollsequence' )->set_context( 'side' )->set_priority( 'low' )->add_fields( array(
259 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' ),
260 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.' ),
261 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. ' ),
262 Field::make( 'textarea', 'scrollsequence_custom_css', __( 'Custom CSS' ) )->help_text( 'Enter custom CSS here.' )
263 ) );
264 /*
265 * SIDE CONTEXT - ADVANCED SETTINGS
266 */
267 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.' ) ) );
268 }
269
270 // END OF CARBON FIELD FUNCTION
271 /**
272 * ROADM CMB Alert Too Many
273 *
274 * @since 0.7.4
275 */
276 public function scrollsequence_admin_notice()
277 {
278 // Ak: I want to add an IF statement to add admin notice only to scrollsequence post php
279 global $post_type ;
280 global $pagenow ;
281
282 if ( $pagenow == 'post.php' && 'scrollsequence' == $post_type ) {
283 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>' ;
284 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 on your Scrollsequence.</p></div>' ;
285 }
286
287 // Ak: end
288 }
289
290 }
291 // end of class Scrollsequence_Admin