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

Scrollsequence – Cinematic Scroll Image Animation Plugin, version 0.9.94. 320 lines.

- Page: https://pluginprobe.com/plugins/scrollsequence/0.9.94/code/admin/class-scrollsequence-admin.php
- Raw: https://pluginprobe.com/plugins/scrollsequence/0.9.94/raw/admin/class-scrollsequence-admin.php
- Modified: 2020-10-27T12:40:54+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.94/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 ;
        global  $pagenow ;
        if ( 'scrollsequence' == $post_type && ('post-new.php' === $pagenow || 'post.php' === $pagenow) ) {
            // 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*/
            'edit_posts',
            /*roles and capability needed*/
            // Update 0.9.93
            '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 = '<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. ';
        $scrollsequence_left_center_right = '
<div style="float: left">Left</div>
<div style="float: right">Right</div>
<div style="margin: 0 auto; width: 100px;"></div>
';
        $scrollsequence_bottom_center_top = '
<div style="float: left">Top</div>
<div style="float: right">Bottom</div>
<div style="margin: 0 auto; width: 100px;"></div>
';
        $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>';
        // 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.' ),
            // PANORAMA (MOBILE)
            Field::make( 'html', 'scrollsequence_info_html_panorama' )->set_html( '<h3>Image Scale and Alignment</h3><p>Panorama (Mobile)</p>' ),
            Field::make( 'select', 'scrollsequence_p_scaleto_mobile', __( 'Panorama (Mobile)' ) )->set_width( 30 )->set_options( array(
                'fill' => ' Scale to fill',
                'fit'  => 'Scale to fit 100%',
                '0.5'  => 'Scale to fit 50%',
            ) ),
            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' ),
            // ROADM
            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' ),
            // ROADM
            // LANDSCAPE (DEKSTOP)
            Field::make( 'html', 'scrollsequence_info_html_landscape' )->set_html( '<p>Landscape (Desktop)</p>' ),
            Field::make( 'select', 'scrollsequence_p_scaleto_desktop', __( 'Scale' ) )->set_width( 30 )->set_options( array(
                'fill' => ' Scale to fill',
                'fit'  => 'Scale to fit 100%',
                '0.5'  => 'Scale to fit 50%',
            ) ),
            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' ),
            // ROADM
            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' ),
            // ROADM
            Field::make( 'html', 'scrollsequence_info_html_freealignadv' )->set_html( $scrollsequence_aglignmentadv ),
        ) )->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( 'select', 'scrollsequence_content_spacer', 'Classic Content Position' )->add_options( array(
            'after100' => 'End of Document (default)',
            'after'    => 'End of Document (with overlap) ',
            'during'   => 'Start of Document',
        ) ),
            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. Only active when there is content after the image sequence. ' ),
            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 Alert Too Many Pages and Images
     * 
     * @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 in your Scrollsequence.</p></div>' ;
        }
        
        // Ak: end
    }
    
    /**
     * Classic Content Editor Heading
     * 
     * @since    0.7.4
     */
    public function scrollsequence_classic_content_html()
    {
        // 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  '<h1>Classic Content Editor </h1>' ;
        }
        if ( $pagenow == 'post-new.php' && 'scrollsequence' == $post_type ) {
            echo  '<h1>Classic Content Editor </h1>' ;
        }
        // Ak: end
    }

}
// end of class Scrollsequence_Admin
```
