# scrollsequence/0.9.92/admin/class-scrollsequence-admin.php

Scrollsequence – Cinematic Scroll Image Animation Plugin, version 0.9.92. 291 lines.

- Page: https://pluginprobe.com/plugins/scrollsequence/0.9.92/code/admin/class-scrollsequence-admin.php
- Raw: https://pluginprobe.com/plugins/scrollsequence/0.9.92/raw/admin/class-scrollsequence-admin.php
- Modified: 2020-08-29T19:02:14+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/scrollsequence/0.9.92/code/admin/class-scrollsequence-admin.php#L10-L20`.

```php
<?php

use  Carbon_Fields\Container ;
use  Carbon_Fields\Field ;
/**
 * The admin-specific functionality of the plugin.
 *
 * @link       www.scrollsequence.com
 * @since      0.7.0
 *
 * @package    Scrollsequence
 * @subpackage Scrollsequence/admin
 */
/**
 * The admin-specific functionality of the plugin.
 *
 * Defines the plugin name, version, and two examples hooks for how to
 * enqueue the admin-specific stylesheet and JavaScript.
 *
 * @package    Scrollsequence
 * @subpackage Scrollsequence/admin
 * @author     Scrollsequence <info@scrollsequence.com>
 */
class Scrollsequence_Admin
{
    /**
     * The ID of this plugin.
     *
     * @since    0.7.0
     * @access   private
     * @var      string    $plugin_name    The ID of this plugin.
     */
    private  $plugin_name ;
    /**
     * The version of this plugin.
     *
     * @since    0.7.0
     * @access   private
     * @var      string    $version    The current version of this plugin.
     */
    private  $version ;
    /**
     * Initialize the class and set its properties.
     *
     * @since    0.7.0
     * @param      string    $plugin_name       The name of this plugin.
     * @param      string    $version    The version of this plugin.
     */
    public function __construct( $plugin_name, $version )
    {
        $this->plugin_name = $plugin_name;
        $this->version = $version;
    }
    
    /**
     * Register the stylesheets for the admin area.
     *
     * @since    0.7.0
     */
    public function enqueue_styles()
    {
        /**
         * This function is provided for demonstration purposes only.
         *
         * An instance of this class should be passed to the run() function
         * defined in Scrollsequence_Loader as all of the hooks are defined
         * in that particular class.
         *
         * The Scrollsequence_Loader will then create the relationship
         * between the defined hooks and the functions defined in this
         * class.
         */
        // Ak: I want to add an IF statement to enqueue scripts only to my CPT
        global  $post_type ;
        if ( 'scrollsequence' == $post_type ) {
            wp_enqueue_style(
                $this->plugin_name,
                plugin_dir_url( __FILE__ ) . 'css/scrollsequence-admin.css',
                array(),
                $this->version,
                'all'
            );
        }
        // Ak: end
    }
    
    /**
     * Register the JavaScript for the admin area.
     *
     * @since    0.7.0
     */
    public function enqueue_scripts()
    {
        /**
         * This function is provided for demonstration purposes only.
         *
         * An instance of this class should be passed to the run() function
         * defined in Scrollsequence_Loader as all of the hooks are defined
         * in that particular class.
         *
         * The Scrollsequence_Loader will then create the relationship
         * between the defined hooks and the functions defined in this
         * class.
         */
        // Ak: I want to add an IF statement to enqueue scripts only to my CPT
        global  $post_type ;
        if ( 'scrollsequence' == $post_type ) {
            // Free
            wp_enqueue_script(
                $this->plugin_name,
                plugin_dir_url( __FILE__ ) . 'js/scrollsequence-admin.js',
                array( 'jquery' ),
                $this->version,
                true
            );
        }
        // Ak: end
    }
    
    /**
     * Register Scrollsequence CPT .
     *
     * @since    0.7.0
     */
    public function scrollsequence_cpt()
    {
        require_once "create-cpt.php";
    }
    
    /**
     * Register Scrollsequence CPT .
     *
     * @since    0.7.3
     */
    public function scrollsequence_cpt_submenu()
    {
        add_submenu_page(
            'edit.php?post_type=scrollsequence',
            /*parent_slug*/
            'Dashboard Scrollsequence',
            /*page title*/
            'Dashboard',
            /*menu title*/
            'manage_options',
            /*roles and capability needed*/
            'dashboard',
            /*menu slug*/
            'scrollsequence_cpt_dashboard_callback'
        );
        function scrollsequence_cpt_dashboard_callback()
        {
            //include_once 'dashboard.php';  - results on parse error
            require_once "partials/scrollsequence-admin-display.php";
        }
    
    }
    
    /**
     * Single file custom template for scrollsequence. I am following this: 
     *  https://code.tutsplus.com/tutorials/a-guide-to-wordpress-custom-post-types-creation-display-and-meta-boxes--wp-27645
     * ref "tutsplus" in class-scrollsequence add action thing
     * @since 0.7.0
     * @uses i dont know
     * Step 1 https://blog.wplauncher.com/add-meta-box-wordpress-custom-post-type/
     */
    public function scrollsequence_template( $template_path )
    {
        if ( get_post_type() == 'scrollsequence' ) {
            if ( is_single() ) {
                // checks if the file exists in the theme first,
                // otherwise serve the file from the plugin
                
                if ( $theme_file = locate_template( array( 'single-scrollsequence.php' ) ) ) {
                    $template_path = $theme_file;
                } else {
                    $template_path = plugin_dir_path( __DIR__ ) . 'public/partials/single-scrollsequence.php';
                }
            
            }
        }
        return $template_path;
    }
    
    /**
     * Carbon Fields Boot function. This function boots up carbon fields.
     * 
     * @since    0.9.8
     */
    public function scrollsequence_carbon_fields_load()
    {
        require_once __DIR__ . '/../includes/carbonfields/autoload.php';
        \Carbon_Fields\Carbon_Fields::boot();
    }
    
    public function scrollsequence_carbon_fields()
    {
        $scrollsequence_advert_html = 'To be able to animate elements <a href=' . admin_url( "admin.php?page=scrollsequence-pricing" ) . '"> Get Scrollsequence PRO </a>. ';
        // FREE VERSION
        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(
            'plural_name'   => 'Pages',
            'singular_name' => 'Page',
        ) )->set_layout( 'tabbed-horizontal' )->set_required( true )->set_max( 3 )->add_fields( array(
            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>
						' ),
            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' ),
            Field::make( 'complex', 'ssqnce_anim', 'Animation' )->set_layout( 'tabbed-vertical' )->setup_labels( array(
                'plural_name'   => 'Animations',
                'singular_name' => 'Animation',
            ) )->add_fields( 'ssqnce_anim_io', 'Animate From/To', array(
                Field::make( 'text', 'ssqnce_anim_io_id', 'Selector' )->set_width( 20 )->set_required( true )->set_help_text( 'Enter #id or .class selector' ),
                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' ),
                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' ),
                // Free advert
                Field::make( 'separator', 'scrollsequence_advert', 'Animation Settings Not Available in Free Version' )->set_help_text( $scrollsequence_advert_html ),
            ) )->set_header_template( ' Animate
						    <% if (ssqnce_anim_io_id) { %>
						         - <%- ssqnce_anim_io_id %>  
						    <% } %> 
						' ),
            // PRO ONLY END1
            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.' ),
            Field::make( 'separator', 'scrollsequence_separator1', __( 'Image Scale and Alignment' ) ),
            Field::make( 'select', 'scrollsequence_p_scaleto_mobile', __( 'Mobile' ) )->set_width( 50 )->set_options( array(
                'fill' => ' Scale to fill',
                'fit'  => 'Scale to fit',
            ) ),
            Field::make( 'select', 'scrollsequence_p_scaleto_desktop', __( 'Desktop' ) )->set_width( 50 )->set_options( array(
                'fill' => ' Scale to fill',
                'fit'  => 'Scale to fit',
            ) ),
            Field::make( 'separator', 'scrollsequence_separator2', __( 'Horizontal Align' ) ),
            Field::make( 'select', 'scrollsequence_p_alignx_mobile', 'Mobile' )->set_width( 50 )->set_options( array(
                'center' => ' Center',
                'left'   => ' Left',
                'right'  => 'Right',
            ) ),
            Field::make( 'select', 'scrollsequence_p_alignx_desktop', 'Desktop' )->set_width( 50 )->set_options( array(
                'center' => ' Center',
                'left'   => ' Left',
                'right'  => 'Right',
            ) ),
            Field::make( 'separator', 'scrollsequence_separator3', __( 'Vertical Align' ) ),
            Field::make( 'select', 'scrollsequence_p_aligny_mobile', 'Mobile' )->set_width( 50 )->set_options( array(
                'center' => ' Center',
                'top'    => ' Top',
                'bottom' => 'Bottom',
            ) ),
            Field::make( 'select', 'scrollsequence_p_aligny_desktop', 'Desktop' )->set_width( 50 )->set_options( array(
                'center' => ' Center',
                'top'    => ' Top',
                'bottom' => 'Bottom',
            ) ),
        ) )->set_header_template( '<%- $_index %>' ) ) );
        // End of ELSE (FREE)
        /*
         * SIDE CONTEXT - SETTINGS 
         */
        Container::make( 'post_meta', 'Settings' )->where( 'post_type', '=', 'scrollsequence' )->set_context( 'side' )->set_priority( 'low' )->add_fields( array(
            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' ),
            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.' ),
            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. ' ),
            Field::make( 'textarea', 'scrollsequence_custom_css', __( 'Custom CSS' ) )->help_text( 'Enter custom CSS here.' )
        ) );
        /*
         * SIDE CONTEXT - ADVANCED SETTINGS 
         */
        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.' ) ) );
    }
    
    // END OF CARBON FIELD FUNCTION
    /**
     * ROADM CMB Alert Too Many
     * 
     * @since    0.7.4
     */
    public function scrollsequence_admin_notice()
    {
        // Ak: I want to add an IF statement to add admin notice only to scrollsequence post php
        global  $post_type ;
        global  $pagenow ;
        
        if ( $pagenow == 'post.php' && 'scrollsequence' == $post_type ) {
            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>' ;
            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>' ;
        }
        
        // Ak: end
    }

}
// end of class Scrollsequence_Admin
```
